One of the more elegant solutions is

   ((/:&(* </. ])) *) data
+---------------+---+-----+
|_3 _1 _10 _2 _4|0 0|1 1 6|
+---------------+---+-----+


R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: programming-boun...@jsoftware.com [mailto:programming-
> boun...@jsoftware.com] Namens Marshall Lochbaum
> Verzonden: woensdag 22 september 2010 23:57
> Aan: Programming forum
> Onderwerp: Re: [Jprogramming] Classification problem
> 
> It looks to me like the most terse way is
> ((</. /: ~...@[)~ f) data
> 
> Although this computes the nub twice, unlike some earlier solutions.
> 
> Marshall
> 
> ________________________________________
> From: programming-boun...@jsoftware.com [programming-
> boun...@jsoftware.com] On Behalf Of Raul Miller [rauldmil...@gmail.com]
> Sent: Wednesday, September 22, 2010 3:29 PM
> To: Programming forum
> Subject: Re: [Jprogramming] Classification problem
> 
> Note, if * is the universe of interesting
> functions (if it does not need to be generic) then
> I would be tempted to use a variation on Dan's
> second suggestion:
> 
>    (<@}./.~ *) _1 0 1,data
> 
> Note that this also preserves the relative
> ordering of the data items.
> 
> --
> 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

Reply via email to