Page 1 of 1

error c504

Posted: 23 Feb 2014 18:16
by hadiranji
hi
i write a program for finding path but received error message please help me ?

Code: Select all

predicates     findPath : (string Start, string End) -> string* Path determ. clauses     findPath(Start, End) = list::reverse(findPath2(Start, End, [Start])).<<<<<error   predicates     findPath2 : (string Start, string End, string* PathSoFar) -> string Path determ. clauses     findPath2(C, C, PathSoFar) = [C|PathSoFar] :-<<<<<error         !.       findPath2(A, C, PathSoFar) = Path :-         edge(A, B),         not(list::isMember(B, PathSoFar)),         Path = findPath2(A, B, [B|PathSoFar]),         !.
error :

Code: Select all

Network.pro(47,38) error c504: The expression has type '::string', which is incompatible with the type '::string*'   Network.pro(49,34) error c504: The expression has type 'a$*', which is incompatible with the type '::string'

Posted: 23 Feb 2014 19:00
by Thomas Linder Puls
The problem is in the declaration of findPath2, see if you can spot it ;-).

Posted: 27 Feb 2014 15:18
by George

Code: Select all

predicates     findPath : (string Start, string End) -> string* Path determ. clauses     findPath(Start, End) = list::reverse(findPath2(Start, End, [Start])).  %Input to this predicate is string list - so you must return string list from the findPath2/..  predicate   predicates     findPath2 : (string Start, string End, string* PathSoFar) -> string* Path determ.  %return type must be stirng list clauses     findPath2(C, C, PathSoFar) = [C|PathSoFar] :-         !.     findPath2(A, C, PathSoFar) = Path :-         edge(A, B),         not(list::isMember(B, PathSoFar)),         !,         Path = findPath2(A, B, [B|PathSoFar]).         predicates     edge : (string, string[out]). clauses     edge("A", "B"):-!.     edge(_, "").

If you need any help for solving your project - send a email to "georgeananth.prolog@gmail.com" -I'll assist you..