What is an important advantage of the linked representation of sequences over the sequential representation?
What is an important advantage of the sequential representation of sequences over the linked representation?
What is a solution to pattern match equation [x,y+1] = [7,99]?
What is the head of list [3,5,4,8]?
What is the tail of list [3,5,4,8]?
What is the head of list [4,2]?
What is the tail of list [4,2]?
What is 3::[5,4]?
Given the definition
f([]) = [] f(h::t) = (h*h)::f(t) when h > 10 f(h::t) = f(t) when h ≤ 10show an evaluation of expression f([4,12,15,6,11]) by substitution. Show the entire expression at each step. Assume that arithmetic is done as soon as possible.
Write an equational definition of a function prefix so that prefix(x,y) is true just when list x is a prefix of list y. For example, prefix([1,2], [1,2,4,6]) is true, but prefix([1,2], [1,5,2,6]) is false. It is not required that x be a proper prefix of y. So prefix([2,3], [2,3]) is true. The empty list is a prefix of every list.
Show an inside-out evaluation of prefix([1,2], [1,2,3,4]) using your definition of prefix from the preceding question. Show the entire expression at each step.
Write an equational definition of function numEven(L), which returns the number of even numbers in list-of-integers L. For example, numEven([2,3,4,5,6]) = 3. Assume that isEven(n) is true if n is even, false if n is odd.