% library(win_menu) compiled into win_menu 0.02 sec, 33 clauses Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 6.4.0) Copyright (c) 1990-2013 University of Amsterdam, VU Amsterdam SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Please visit http://www.swi-prolog.org for details. For help, use ?- help(Topic). or ?- apropos(Word). 1 ?- consult('lp.pro'). ERROR: c:/users/joshu/documents/csc366/assignments/assignment12/lp.pro:12: No permission to modify static procedure `length/2' Defined at c:/program files/swipl/boot/init.pl:2865 ERROR: c:/users/joshu/documents/csc366/assignments/assignment12/lp.pro:13: No permission to modify static procedure `length/2' Defined at c:/program files/swipl/boot/init.pl:2865 % lp.pro compiled 0.00 sec, 48 clauses true. 2 ?- writelist([1,2,3]). 1 2 3 true. 3 ?- member(2,[1,2,3]). true . 4 ?- member(4,[1,2,3]). false. 5 ?- length([1,2,3],L). L = 3. 6 ?- item(0,[1,2,3],Element). Element = 1 . 7 ?- item(2,[1,2,3],Element). Element = 3 . 8 ?- append([1,2,3],[4,5,6],NewList). NewList = [1, 2, 3, 4, 5, 6]. 9 ?- append([],[1,2,3],NewList). NewList = [1, 2, 3]. 10 ?- last([1,2,3],Last). Last = 3 . 11 ?- last([1],Last). Last = 1 . 12 ?- remove(2,[1,2,3],NewList). NewList = [1, 3] . 13 ?- remove(2,[],NewList). NewList = [] . 14 ?- remove(4,[1,2,3],NewList). NewList = [1, 2, 3] . 15 ?- replace(1,one,[1,2,3],NewList). NewList = [1, one, 3] . 16 ?- replace(0,one,[1,2,3],NewList). NewList = [one, 2, 3] . 17 ?- makelist(3,7,NewList). NewList = [7, 7, 7] . 18 ?- makelist(0,nothing,NewList). NewList = [] . 19 ?- reverse([3,2,1],NewList). NewList = [1, 2, 3] . 20 ?- reverse([3],NewList). NewList = [3] . 21 ?- lastput(2,[],NewList). NewList = [2] . 22 ?- lastput(4,[1,2,3],NewList). NewList = [1, 2, 3, 4] . 23 ?- pick([1,2,3],Item). Item = 3 . 24 ?- pick([1,2,3],Item). Item = 3 . 25 ?- pick([1,2,3],Item). Item = 2 . 26 ?- pick([1,2,3],Item). Item = 2 . 27 ?- pick([1,2,3,4,5,6],Item). Item = 5 . 28 ?- pick([1,2,3,4,5,6],Item). Item = 5 . 29 ?- pick([1,2,3,4,5,6],Item). Item = 3 . 30 ?- pick([1,2,3,4,5,6],Item). Item = 3 . 31 ?- pick([1,2,3,4,5,6],Item). Item = 5 . 32 ?- take([1,2,3,4,5,6],5,NewList). false. 33 ?- take([1,2,3,4,5,6],Item,NewList). Item = 2, NewList = [1, 3, 4, 5, 6] . 34 ?- take([1,2,3,4,5,6],Item,NewList). Item = 3, NewList = [1, 2, 4, 5, 6] . 35 ?- iota(5,List). List = [1, 2, 3, 4, 5] . 36 ?- iota(3, List). List = [1, 2, 3] . 37 ?- sum([1,2,3],Sum). Sum = 6. 38 ?- sum([1,1,1],Sum). Sum = 3. 39 ?- min([4,3,5,8,1,2],Min). Min = 1 . 40 ?- max([4,3,5,8,1,2],Max). Max = 8 . 41 ?- sort_inc([4,3,5,8,1,2],List). List = [1, 2, 3, 4, 5, 8] . 42 ?- sort_dec([4,3,5,8,1,2],List). List = [8, 5, 4, 3, 2, 1] . 43 ?- alist([2,3,4],[two,three,four],Alist). Alist = [pair(2, two), pair(3, three), pair(4, four)]. 44 ?- assoc([pair(2,two),pair(3,three),pair(4,four)],K,V). K = 2, V = two ; K = 3, V = three ; K = 4, V = four ; false. 45 ?- flatten([a, [b,c], [[d],[],[e]]], R). R = [a, b, c, d, e] .