I have this block of numbers:
num(1).
num(-2).
num(5).
num(50).
num(-3).
num(87).
I'm supposed to make a function that given a number it is supposed to check if that number is the smallest of that "list" of numbers given above.
ex:
not_smallest(5).
true.
not_smallest(X).
X = 1 ;
X = -2 ;
X = 5 ;
X = 50 ;
X = 87.
What i thought was making a list with the above block of numbers , and comparing a given number to all elements of the list. But whenever i try to load the .pl doc i get this error:
Syntax error: Operator expected
what i have done so far is this:
%increments the index of a List
incr(X, X1) :-
X1 is X + 1.
%L-list containing "list" of numbers, N - elements of that "list",
I-index , C-number X is going to be compared to, X- number to compare.
nao_menor(X) :-
findall(N, num(N), L),
num(X),
I is 0,
nth0(I, L, C),
X =< C,
incr(I,I).
%character specifies a comment line (cannot have newlines), so you should add % at the start of the line'I-index....'or put those two lines in a single one - gusbronao_menor/1procedure won't work as you expect. (e.g.incr(I,I)will always fail) - gusbroincr(I,I)? - repeat