1. Quiz! Was: Re: New functions: input() and reverse()
On Sun, 18 Oct 1998, Matt Z Nunyabidness wrote:
Nice to see you're making a coding effort Matt. Even if we have to mail
you for the code! :)
> Here's the syntax for input():
>
> var=input()
There's tonnes of versions of input(). I've coded at least three. :)
Most people prefer "input_sequence = input(prompt_sequence)", so you can
use things like:
age = input("How old are you?\n>")
HTH
> And here's the syntax for reverse():
> var2=reverse(var1)
Just how far do you go in terms of reversal...?:
Quiz Time (for everyone not just Matt :) )
---------
* Use EX.EXE *after* you've got answers. No cheating!
i) Give the semantic difference between the following two subroutines.
ii) Give the contents of X and Y at the end of the program.
iii) Which function is more correct? (In your opinion) Discuss.
[I hate "Discuss" questions >:^> ]
iv) BONUS question. Where have I got the "Start" numbers from? :)
function reverse(sequence in)
sequence out
for i = 1 to length(in) do
out = in[i] & out
end for
return out
end function
function r_reverse(sequence in)
sequence out
for i = 1 to length(in) do
if atom(in[i]) then
out = in[i] & out
else
out = r_reverse(in[i]) & out
end if
end for
return out
end function
constant Start = {3,1,4,{1,5,9,2,{6,5},3,5,8},9,7,9,{3,2,{3,8},4},6,2,6,4}
sequence X, Y
X = reverse(Start)
Y = r_reverse(Start)
"Answers on a postcard to" this mailing list. Check to see if someone has
already posted the same solution as yourself. We don't want 220 messages
all saying the same thing... <g>
Happy Interpreting!
Carl
--
Carl R White -- Final Year Computer Science at the University of Bradford
E-mail...: cyrek- at -bigfoot.com -- Remove the hyphens before mailing. Ta :)
URL......: http://www.bigfoot.com/~cyrek/
Ykk rnyllaqur rgiokc cea nyemdok ymc giququezka caysgr -- B.Q.Vgesa