List Processing Demo - CSC 366 Home Page - Code

...@...:~/Desktop/COG366$ swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 7.6.0-rc2)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit http://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- consult('a11/lp.pro').
true.

?- writelist([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p]).
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
true.

?- member(d,[a,b,c,d,e]).
true .

?- size([a,b,c,d,e,f,g,h,i,j,k,l],Size).
Size = 12.

?- item(3,[1,2,3,4,5,6],X).
X = 4 .

?- append([we,hello,tooth],[will,goodbye,123],[3.4,woah,ok],Result).
Result = [we, hello, tooth, will, goodbye, 123, 3.4, woah, ok].

?- last([1,2,3,4,6,5],Last).
Last = 5 .

?- remove(s,[a,r,b,s,t,e,s,g],Result).
Result = [a, r, b, t, e, s, g] .

?- replace(0,here,[nothere,here,here,here],Result).
Result = [here, here, here, here] .

?- makelist(4,nyr,List).
List = [nyr, nyr, nyr, nyr] .

?- reverse([this,is,not,today,but,tomorrow],RevList).
RevList = [tomorrow, but, today, not, is, this] .

?- lastput(last,[first,second,third,fourth,fifth],List).
List = [first, second, third, fourth, fifth, last] .

?- pick([a,b,c,d,e,f],Result).
Result = c .

?- pick([a,b,c,d,e,f],Result).
Result = d .

?- pick([a,b,c,d,e,f],Result).
Result = e .

?- take([a,b,c,d,e,f],a,List).
List = [b, c, d, e, f] .

?- iota(8,List).
List = [1, 2, 3, 4, 5, 6, 7, 8] .

?- sum([1,4,3,5,6,3],Sum).
Sum = 22.

?- min([12,34,23,5,23,55,6,123,3,7],Min).
Min = 3.

?- max([12,34,23,5,23,55,6,123,3,7],Min).
Min = 123.

?- max([12,34,23,5,23,55,6,123,3,7],Max).
Max = 123.

?- sort_inc([5,3,7,2,5,4,6,1,3,2,5],Result).
Result = [1, 2, 3, 4, 5, 6, 7] .

?- sort_dec([4,6,2,3,1,7,9],Result).
Result = [9, 7, 6, 4, 3, 2, 1] .

?- alist([1,2,3],[z,y,x],Result).
Result = [pair(1, z), pair(2, y), pair(3, x)].

?- assoc([pair(not,today),pair(hello,goodbye),pair(well,ok)],K,V).
K = not,
V = today ;
K = hello,
V = goodbye ;
K = well,
V = ok ;
false.

?- assoc([pair(not,today),pair(hello,goodbye),pair(well,ok)],not,V).
V = today .

?- assoc([pair(not,today),pair(hello,goodbye),pair(well,ok)],not,today).
true .

?-