1

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.

false
  • 10,264
  • 13
  • 101
  • 209
Zohaib
  • 363
  • 2
  • 4
  • 15
  • 1
    For ISO Prolog, please look at [this answer][1]. [1]: http://stackoverflow.com/questions/8264699/what-is-the-difference-between-and-in-prolog/8269897#8269897 – false Nov 28 '11 at 08:19
  • 3
    In Prolog there is not such thing as pointers or typed variables, so there is nothing like "char *" in prolog. But, if you tell us what you want to do at a higher level we will be able to show you how to do it in Prolog. – salva Nov 28 '11 at 08:50

2 Answers2

0

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".

joel76
  • 5,565
  • 1
  • 18
  • 22
  • OP is using Turbo Prolog. You can tell because he defines a ´list=integer*´ which is Turbo Prolog specific – gusbro Dec 02 '11 at 12:43
0

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
gusbro
  • 22,357
  • 35
  • 46