tips.pl 551 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
%defines some interesting pairs of numbers
interestingPair(42, 0).
interestingPair(42, 23).
interestingPair(42, 42).
interestingPair(42, 1337).

%shows how findall works
findAllInteresting(Number, ResultList):-
	findall(X,interestingPair(Number,X),ResultList).


%helper, adds 1 to Number
addOne(Number,Newnumber):-
	Newnumber is 1 + Number.

%shows how maplist executes addOne on List and stores the Result
addOneToList(List,ResultList):-
	maplist(addOne,List, ResultList).

%demonstrates min_list
showMinList(List,Minimum):-
	min_list(List,Minimum).