What is the difference between a strongly statically typed language and a weakly statically typed language?
Given the definition
f([]) = [] f(h::t) = (h*h)::f(t) when h > 10 f(h::t) = f(t) when h <= 10show an inside-out evaluation of expression f([4,12,15,6,11]). 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 a function called smallest so that smallest(n,x) is the smallest member of list n::x. For example, smallest(3, [6,4,7]) = 3 and smallest(8, [2,5]) = 2. You may presume that you have a function called min that takes the minimum of two numbers. For example, min(7,4) = 4.
Show an inside-out evaluation of smallest(4, [2,6,1]), using your definition from the preceding question.
Write an equational definition of a function suffix so that suffix(x,y) is true just when list x is a suffix of list y. (List x is a suffix of list y if there exists a list z such that z ++ x = y.) For example, suffix([4,6], [1,2,4,6]) is true, but suffix([5,6], [1,5,2,6]) is false. The empty list is a suffix of every list, and every list is a suffix of itself.
In a purely functional language, is it ever possible to compute the same expression twice in the same context and get different values? For example, if E is an expression, and you compute E two times, one right after another, could the first computation yield a different result from the second computation? Why or why not?
Answer the preceding question, but for an imperative language such as C++ or Java rather than for a purely functional language.