1. Minimum & Maximum - Reply
function minimum(object a, object b)
if atom(a) and atom(b) then
if b<a then a=b end if
elsif sequence(a) and sequence(b) then
if length(a)=length(b) then
for i=1 to length(a) do
a[i]=minimum(a[i],b[i])
end for
else
puts(1,"Error: unequal lengths of sequences!")
abort(0)
end if
else
puts(1,"Error: unmatched objects!")
abort(0)
end if
return a
end function
? minimum(5,3)
? minimum({5,3,1},{-5,2,6})
? minimum({5,3,{4,5},1},{-5,2,{-7,7},6})
-- Safer! jiri
2. Re: Minimum & Maximum - Reply
BABOR, JIRI wrote:
> function minimum(object a, object b)
snip
> end function
heh, pretty close... i like that extra check to see
if we are looking at atom versus sequence. i had thought
that just checking lengths would do that, but...
also, heh, i fergot my element indexing in the recursive
line... definite bonehead manuever on my part...
x[i]=maximum(a,b)
*blush* that won't quite cut it eh? infinite recursion?
glad you caught that.
> -- Safer!
for the place (new library--top secret--defn'ly kewl)
this routine is going, a tad bit of speed can defn'ly
be sacrificed for penultimate safety...
good code jiri... thanx oodles (or is that noodles? :)
--Hawke'