bsort very nicely combines some ideas I was
also considering. Here's just another rending of bsort:
NB. select mins, recurse complement while not empty.
((#~ , ($:@#~ -.)) (= <./)) ^: (1<#) C
0 0 2 4 4 5 6 7 9 9
Though I have reservations about recursion depth capacity.
--- On Mon, 4/28/08, Roger Hui <[EMAIL PROTECTED]> wrote:
> bsort=: ] ` ((=<./) (# , [: $: [EMAIL PROTECTED] # ]) ]) @. (1<#)
>
--- On Mon, 4/28/08, Oleg Kobchenko <[EMAIL PROTECTED]> wrote:
> Here are a couple of closer shots:
>
> NB. recurse the above on tail while not empty
> ({. , $:@}.)@(((,~`,@.< [EMAIL PROTECTED]) , [EMAIL PROTECTED])/)^:(1<#) C
> 0 0 2 4 4 5 6 7 9 9
>
> NB. successively move mins from {: to {.
> >{.(( ,&.>&{. , {:@]) ((#~ ; (#~ -.)) (= <./))@>@{:)^:_ '';C
> 0 0 2 4 4 5 6 7 9 9
> ----- Original Message -----
> From: Oleg Kobchenko <[EMAIL PROTECTED]>
> Date: Sunday, April 27, 2008 23:26
> Subject: [Jprogramming] Bubble sort
> To: Programming forum <[email protected]>
>
> > I wanted to model bubble sort.
> > Here's a first shot. Any improvements?
> >
> > ]C=. 10 [EMAIL PROTECTED] 10
> > 6 5 9 2 4 9 0 7 0 4
> > /:~ C
> > 0 0 2 4 4 5 6 7 9 9
> > <./ C
> > 0
> > (([ ,`(,~)@.> [EMAIL PROTECTED]) , [EMAIL PROTECTED])/ C
> > 0 6 5 9 2 4 9 0 7 4
> > (([ ,`(,~)@.> [EMAIL PROTECTED]) , [EMAIL PROTECTED])/^:_ C
> > 0 0 2 4 4 5 6 7 9 9
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm