Zsbán, I have simplified your function and removed @ , and it hope it is still evil! I haven't studied it yet.
f=: 13 :'(+/%#)([: }.}:)^:(2<#)^:_ y' f /:~ 8 1 6 7 6.5 f [: (+/ % #) ([: }. }:)^:(2 < #)^:_ Linda -----Original Message----- From: programming-boun...@forums.jsoftware.com [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Zsbán Ambrus Sent: Monday, March 11, 2013 6:12 AM To: programm...@jsoftware.com Subject: Re: [Jprogramming] Find the median On Sun, Mar 10, 2013 at 11:29 PM, km <k...@math.uh.edu> 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. Ok, here's an evil variant: median =: ([: (+/%#) }.@}:^:(2<#)^:_) : [: -- Ambrus ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm