menu:- write('how much data to input : '),read(N1),
N2 is 0,loop(N2,N1).
loop(N2,N1):-N1>0, N3 is N2+1,
write('Input data '),write(N3),write(' : '),read(M1),
N is N2+1, X is N1-1, loop(N,X).
guys i new at prolog there i have loop input, how to add from loop input (M1) to list, then find Max and Min on the list? my data is integer.
If you just start Prolog from command line you get this:
And then the cursor is waiting for you to input things. You can then write a list of integers between brackets and put it in a variable and it looks like this:
Now if you want to see if all elements are integer you can write:
Now if you want to find min and max you can use library predicates like this:
If you really want to do all at once you can do like this maybe:
But really is this any better than using library predicates? Maybe, or maybe not.