type reverse (list A) -> (list A) -> o. reverse [] []. reverse [H|T] Y :- reverse T Z, append Z [H] Y.In Haskell:
reverse [] = [] reverse (h:t) = (reverse t) ++ [h]
magic_number_plus_one X
gives X : 4
foo X
gives X : 3
min 2 5 5
incorrectly answers true
. A
simple way to fix it is
min X Y Z :- X <= Y, !, X = Z. min X Y Y.In Haskell, this corresponds to
min x y z | (x < y) = (x == z). min x y z | (y == z) = True.
read_all :- repeat, read X, eof X, !.