What is shadowing, and how can it occur? Give an example.
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]). Assume that arithmetic is done as soon as possible.
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.
Write an equational definition of a function stutter where stutter([a,b,c,d]) = [a,a,b,b,c,c,d,d]. In general, stutter includes two copies of each item.
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, could
Let x = E + E.ever yield a different result from
Let y = E. Let x = y + y.Why or why not?