Ric, Sometimes a style change spurs a new direction for understanding a
problem. This didn't.
midpt2
[: -: [: <: #
medianRS
[: ([: -: +/) ([: (<. , >.) midpt2) { /:~
medianRS 8 1 6 7
6.5
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Ric Sherlock
Sent: Sunday, March 10, 2013 9:13 PM
To: Programming JForum
Subject: Re: [Jprogramming] Find the median
which is pretty close to the implementation in the stats/base addon
midpt=: -:@<:@#
median=: -:@(+/)@((<. , >.)@midpt { /:~)
On Mon, Mar 11, 2013 at 1:48 PM, Raul Miller <[email protected]> wrote:
> On Sun, Mar 10, 2013 at 6:29 PM, km <[email protected]> wrote:
> > The median of list 1 2 2 4 6 is 2 ("middle" value of sorted list),
> > the
> median of 2 2 4 6 is 3 (average of two "middle" values). Write a verb
> to find the median of a sorted list of numbers.
>
> Here's one implementation of this definition of median:
>
> mean=: +/ % #
> median=: (<.,>.)@-:@<:@# mean@:{ /:~
>
> --
> Raul
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm