Give a string in the language of L1 but not in the language of L2
Give a string in the language of L2 but not in the language of L1
Briefly explain the difference between the two
Give a code fragment that declares, allocates, and initializes a two dimensional array using row-major allocation
Give a code fragment that declares, allocates, and initializes a two dimensional array using row-pointers allocation
val x = 5; fun f1 y = x+y; fun f2 z = z * f1 2; val a1 = f1 5; val b1 = f2 5; val x = 10; val a2 = f1 5; val b2 = f2 5; fun f1 y = x-y; val a3 = f1 5; val b3 = f2 5;
e(1,2). e(3,1). e(2,1). e(1,1). e(2,3). e(1,3). triangle(A,B,C) :- e(A,B),e(B,C),e(C,A).
(1) Draw the search tree (as we did in class) for running the query triangle(X,Y,Z) until the third output is produced. Make sure to annotate the tree with binding for variables. In addition, mark potential backtracking points in the tree.
(2) To clarify your answer from above, list the first 3 answers produced by the system on the query triangle(X,Y,Z). For each answer give the binding for X, Y, Z.
fun foldl f e  = e | foldl f e (h::t) = foldl f (f(h,e)) t; fun f L = foldl (fn(x,y) => 10*y+x) 0 L; val a = f [1,2,3];
val merge = fn : int list * int list -> int listand when running the function with:
val a = merge([1,3,5],[2,3,6]); val b = merge(,[1,3,9]);we get
val a = [1,2,3,3,5,6] : int list val b = [1,3,9,10] : int list
You may not assume or use any list library functions. If you need such a function you should give the code for it as well.
?- length2sub([a,b,c,a],Out). Out = [a, b] ; Out = [a, c] ; Out = [a, a] ; Out = [b, c] ; Out = [b, a] ; Out = [c, a] ; No ?- length2sub([1,2],Out). Out = [1, 2] ; No ?- length2sub(,Out). No
This document was generated using the LaTeX2HTML translator Version 2002-2-1 (1.70)
Copyright © 1993, 1994, 1995, 1996,
Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999, Ross Moore, Mathematics Department, Macquarie University, Sydney.
The command line arguments were:
latex2html -split 0 -no_navigation -no_images -dir TEMPHTML fsample.tex
The translation was initiated by Roni Khardon on 2008-04-29