Discussions related to Visual Prolog
hadiranji
Posts: 11
Joined: 7 Dec 2013 15:16

error c504

Unread post 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'
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

The problem is in the declaration of findPath2, see if you can spot it ;-).
Regards Thomas Linder Puls
PDC
User avatar
George
Active Member
Posts: 47
Joined: 19 Sep 2011 8:54

Unread post 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..
Kind Regards,
George Ananth. S | Prolog Developer
georgeananth.prolog@gmail.com
+91 9791499282
Post Reply