?- noah([a,b,c,d], [[a,b],[c,d]]). yes. ?- noah([1,B,3,4,5,6,seven,eight], [[A,2]|X]). A=1 B=2 X=[[3,4],[5,6][seven,eight]] ?- noah(X,[]). X=[] ?- noah([a,b,c], X). no. ?- noah(X, [a,b]). no.
?- noah_n(2, [a,b,C,D], [E,[sea,dee]]). C=sea D=dee E=[a,b] ?- noah_n(1, [a,b,c], X). X=[[a],[b],[c]] ?- noah_n(3, [a,b,c,d,e,f,g,h,i,j,k,l], X). X=[[a,b,c],[d,e,f],[g,h,i],[j,k,l]] ?- noah_n(4, [a,b,c], X). noYou can assume that the number is actually given, although you'll get extra style points if it works even when the number is not specified.
?- subst_list([a,b,c,[a,c,d,c]], X, c, sea). X=[a,b,sea,[a,sea,d,sea]] ?- subst_list(X, [a,b,sea,[a,sea,d,sea]], c, sea). X=[a,b,c,[a,c,d,c]]
?- ev(3,N). N=3 ?- ev([+,3,4], N). N=7 ?- ev([+,3,[*,8,0.25]], N). N=5Expressions in the ``little language'' are defined as
E ::= number | [+, E, E] | [*, E, E] | [exp, E] | [sin, E] | [cos, E]These have the obvious numeric meanings when evaluated.
E ::= xie the symbol x is now also a valid expression, and (2) it takes a new argument (in the second position) which must be a number, and which gives the value of x. Eg
?- ev(3,100,N). N=3 ?- ev([+,x,4],100,N). N=104 ?- ev([+,3,[*,x,0.25]], 100, Y). Y=28 ?- ev([+,3,[sin,x]], 1, N). N=3.84147
Any of the following solutions would be okay, although the last would get style points.
?- diff([*,3,[cos,x]], E). E=[+,0,[*,3,[*,-1,[sin,x]]]] ?- diff([*,3,[cos,x]], E). E=[+,[*,3,[*,1,[*,-1,[sin,x]]]],[*,0,[cos,x]]] ?- diff([*,3,[cos,x]], E). E=[*,-3,[sin,x]]
~bap/bin/handin hw3.plon a regular UNM CS machine.
Due: noon, Fri Sep 28.