abe:~/cs313/prolog% rlwrap swipl Welcome to SWI-Prolog (threaded, 64 bits, version 7.4.0-rc1) 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). 1 ?- [pete1]. true. 4 ?- solve(1, 2, 1, 1). 1*2=1+1 true ; false. 5 ?- solve(4, 3, 3, 0). false. 6 ?- solve(2, 4, 3, 8). false. 7 ?- solve(5, 9, 6, 7). false. 8 ?- solve(2, 3, 3, 3). 2*3=3+3 true . 9 ?- solve(1, 3, 9, 3). 1*3=9/3 true ; false. 10 ?- 2+3 = 3+1. false. 11 ?- 2+2 = 3+1. false. 12 ?- X is 2+2, Y is 3+1, X=Y. X = Y, Y = 4. 13 ?- member(3, [1, 2, 3]). Correct to: "lists:member(3,[1,2,3])"? yes true. 14 ?- use_module(library(lists)). true. 15 ?- member(3, [1, 2, 3]). true. 16 ?- member(X, [1, 2, 3]). X = 1 ; X = 2 ; X = 3. 17 ?- member(4, [1, X, 3]). X = 4 . 18 ?- append([1, 2], [3, 4], R). R = [1, 2, 3, 4]. 19 ?- member(X, [1, 2, 3]), writeln(X), fail. 1 2 3 false. 20 ?- append([1, 2], [3, 4], [1, 2, 3, 4]). true. 21 ?- append([1, 2], X, [1, 2, 3, 4]). X = [3, 4]. 22 ?- append(X, [3, 4], [1, 2, 3, 4]). X = [1, 2] . 23 ?- append(X, Y, [1, 2, 3, 4]). X = [], Y = [1, 2, 3, 4] ; X = [1], Y = [2, 3, 4] ; X = [1, 2], Y = [3, 4] ; X = [1, 2, 3], Y = [4] ; X = [1, 2, 3, 4], Y = [] ; false. 24 ?- append(X, X, [1, 2, 3, 4]). false. 25 ?- append(X, X, [1, 2, 1, 2]). X = [1, 2] . 26 ?- X = 1+1, X = 2. false. 27 ?- X is 1+1, X = 2. X = 2. 28 ?- append(X, X, [1, 2, 1]). false. 29 ?- member(3, [X]), member(4, [X]). false. 30 ?- member(3, [X]), member(3, [X]). X = 3. 31 ?- member(h([2, 3]), [X]), member(h([2, 3]), [X]). X = h([2, 3]). 32 ?- member(3, [X]), member(Z, [X]). X = Z, Z = 3. 33 ?- 3=4. false. 34 ?- member(3, X), member(4, X). X = [3, 4|_1688] ; X = [3, _1686, 4|_1694] . 35 ?- reverse([1, 2, 3], X). X = [3, 2, 1]. 36 ?- reverse(X, [1, 2, 3]). X = [3, 2, 1] . 37 ?- reverse(X, X). X = [] ; X = [_3658] ; X = [_3658, _3658] ; X = [_3658, _3670, _3658] ; X = [_3658, _3670, _3670, _3658] ; X = [_3658, _3670, _3682, _3670, _3658] ; X = [_3658, _3670, _3682, _3682, _3670, _3658] . 38 ?- [loop]. true. 39 ?- loop(10,X). X = 10 . 40 ?- [bst]. true. 41 ?- mytree1(T). T = node(5, node(3, nil, nil), node(8, node(7, nil, nil), node(9, nil, nil))). 42 ?- mytree1(T), find(3, T). T = node(5, node(3, nil, nil), node(8, node(7, nil, nil), node(9, nil, nil))) . 43 ?- mytree1(T), find(33, T). false. 44 ?- mytree1(T), find(2, T). false. 45 ?- mytree2(T), find(2, T). T = node(2, node(1, nil, nil), node(5, node(3, nil, nil), node(8, node(7, nil, nil), node(9, nil, nil)))) . 48 ?- mytree1(T), show(T). 9 8 7 5 3 T = node(5, node(3, nil, nil), node(8, node(7, nil, nil), node(9, nil, nil))). 49 ?- mytree2(T), show(T). 9 8 7 5 3 2 1 T = node(2, node(1, nil, nil), node(5, node(3, nil, nil), node(8, node(7, nil, nil), node(9, nil, nil)))).