I'm new to prolog .. i tried this code but got error and don't know why ?!
de(F,L,R):-
R=[F|L].
is that because rule must have a recursion ? the error is
ERROR: Syntax error: Operator expected
In your comment , you specify what you did wrong:
i tested it as
de[a,[a,1,2,3],Z].
When you call a predicate, you use parenthesis ( (…)
), square brackets ( […]
) are used to construct lists. You thus should call the predicate with parenthesis:
?- defa,[a,1,2,3],Z.
Z = [a, a, 1, 2, 3].
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.