Contrary to Hui I like the right hook.

My moving to the front uses it

   3 ((}.,~ _1|.{.)~ >:)~ 'abc*ef'
*abcef

Moving to the back is almost completely the opposite 

   3 (({., 1|.}.)~ ])~ 'abc*ef'
abcef*


Swap is trivial with amend.

   1 5 ((|.@[` [`]} i.@#) { ]) 'abcdefgh'
afcdebgh


R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: programming-boun...@jsoftware.com [mailto:programming-
> boun...@jsoftware.com] Namens Raul Miller
> Verzonden: donderdag 2 februari 2012 21:10
> Aan: Programming forum
> Onderwerp: Re: [Jprogramming] Understanding C. , A.
> 
> I just now noticed that my 'move_to_front' was wrong.  Sorry about
> that -- I've been busy.
> 
>    move_to_front=: <@i.@-@>:@[ C. ]
>    3 move_to_front 'abc*ef'
> *abcef
> 
> I did a quick check of this thread, and I did not see this solution in
> the first line of any post.  (And, personally, I prefer i. over |. for
> something like this.)
> 
> --
> Raul
> 
> Three days ago, I wrote:
> >   swap=: <@[ C. ]
> >   move_to_front=: 0&,@[ swap ]
> >
> >   1 5 swap 'abcdefgh'
> > afcdebgh
> >   3 move_to_front 'abc*ef'
> > *bcaef
> >
> > --
> > Raul
> >
> > On Tue, Jan 31, 2012 at 10:44 AM, David Ward Lambert
> > <b49p23t...@stny.rr.com> wrote:
> >> Are there simple versions of swap and of move_to_front that use C. , A.
> >> or (other)?  My definitions use amend.  Thank you, Dave.
> >>
> >>   1 5 swap 'abcdefgh'
> >> afcdebgh
> >>
> >>   3 move_to_front 'abc*ef'
> >> *abcef
> >>
> >>
> >>   swap=: ({~ |.)~`[`]}
> >>   move_to_front=: ((({~ _1&|.)~`[`]})~ i.@:>:)~
> >>
> >>
> >> ----------------------------------------------------------------------
> >> 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