1. Re: subscripts (Long Post)
On Wed, 17 May 2000 14:59:55 +1200, Jiri Babor <J.Babor at GNS.CRI.NZ> wrote:
>function fetch(object a, sequence b)
> integer i,len
> i = 1
> len = length(b)
> while i <= len do
> a = a[b[i]]
> i += 1
> end while
> return a
>end function
Carl returns as today's cheeky pedant:
function fetch(sequence a, object b)
if atom(b) then return a[b] end if
for i = 1 to length(b) do
a = a[b[i]] -- can't pick holes in this line
end for
return a
end function
Note that an 'if not length(b)' line isn't required, since the for loop
will skip, and a will be returned as a whole.
>Or, if you prefer a recursive variant:
[snipped]
Shudder!
There's a time and a place for recursion, Jiri. This wasn't
it...
))
</pedant>,
Carl -- ducking and waiting for Jiri's flames...
--
Error: .sig not found. Abort, Retry, Ignore?> i