Prolog List instantiation -
i want create predifined list. doing wrong because when pass argument doesnt work. here code have:
list([5, 1, 2, 8, 10, 4, 3, 6, 9, 7]). print( [ ] ). print( [ x | y ] ):- write(x), write(' '), print( y ). test:- print(list).
console output:
1 ?- a. true .
it doesnt work. here when pass list myself:
2 ?- print([5, 1, 2, 8, 10, 4, 3, 6, 9, 7]). 5 1 2 8 10 4 3 6 9 7 true.
you should use variables communicate information between predicates. list
predicate doesn't "return" value, instantiates variable.
test :- list(l), print(l).
Comments
Post a Comment