True.

There's a variety of simple solutions for that. For example, in
addition to the one I posted a few minutes ago, there's

  foo=: (/: 3|3+*)@/:~

Thanks,

-- 
Raul

On Fri, Oct 22, 2021 at 8:09 AM Jan-Pieter Jacobs
<[email protected]> wrote:
>
> Raul,
>
> Your solution works for i: 10, but not in the general case, e.g. a random
> permutation of i:10:
>
>    (/: 3|3+*) ({~?~@#) i: 10
> 0 9 3 7 2 4 1 6 10 5 8 _9 _2 _10 _4 _1 _3 _7 _8 _5 _6
>
>    (/: 0&>)@/:~ ({~?~@#) i: 10
> 0 1 2 3 4 5 6 7 8 9 10 _10 _9 _8 _7 _6 _5 _4 _3 _2 _1
>
> Best regards,
> Jan-Pieter
>
> On Fri, Oct 22, 2021, 14:01 Raul Miller <[email protected]> wrote:
>
> >    foo=: /: 3|3+*
> >    foo i:10
> > 0 1 2 3 4 5 6 7 8 9 10 _10 _9 _8 _7 _6 _5 _4 _3 _2 _1
> >
> > --
> > Raul
> >
> > On Fri, Oct 22, 2021 at 5:14 AM R.E. Boss <[email protected]> wrote:
> > >
> > > Some time ago I stumbled on an elegant solution to sort a sequence of
> > numbers such, that first the non-negative numbers were sorted up,
> > immediately followed by the negative numbers sorted up, like
> > >
> > > foo i: 10
> > > 0 1 2 3 4 5 6 7 8 9 10 _10 _9 _8 _7 _6 _5 _4 _3 _2 _1
> > >
> > > Any takers?
> > >
> > >
> > > R.E. Boss
> > > ----------------------------------------------------------------------
> > > 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to