what is the syntax for char* in prolog

1k Views Asked by At

I want to know the syntax for char* in prolog which i want to use for a list of a characters. I have used list=integer* for a list of integers but i dont know sysntax for characters list in prolog.

2

There are 2 best solutions below

1
On

In SWI-Prolog, you must use _string_to_list /2 to create strings :

?- A = "ABCD".
A = [65,66,67,68].

?- string_to_list(A, "ABCD").
A = "ABCD".

0
On

I guess you are using Turbo Prolog. In that case, there is already a predefined domain string used for strings.

Here goes a usage example:

predicates
  test(string, string).

clauses
test(X, Z):- concat("Hello ", X, Z).

Sample output:

Goal: test("World",Z).
Z=Hello World
1 Solution