[REBOL] Re: More on expressions
From: joel:neely:fedex at: 1-Feb-2003 13:18
Hi, Sunanda,
Ingenious! But I'll have to be picky... (Who, me? ;-)
[SunandaDH--aol--com] wrote:
> Joel:
> > GIVEN: Three variables, A, B, and C which we'll assume have
> > been set to numeric values.
> >
> > CHALLENGE: Write an expression whose value is the median of the
> > values.
> > CONSTRAINT: Just to make it iteresting ;-) the expression MAY NOT
> > use any of these REBOL words/functions:
> >
> > sort if either first second third
> >
> > nor any path expressions.
>
> I'll have a go. The median is the largest left after you remove the
> largest, so:
>
> pick maximum-of head remove maximum-of reduce [a b c] 1
>
Since
pick some-expresion 1
is really the same as
first expression
I'll have to say that this violates the spirit (if not the letter) of
the
constraints. Just to repeat the hint at the end of the original post:
> The trick, of course, is to find an expression that eliminates the
> need for any explicit "decision" or "selection" activity.
>
How about another go?
-jn-