Yes... I had assumed that only one item would be moved, since that's what was originally proposed.
Here's a variation on move_to_front which does not have that assumption: move_to_front=: (-.~ i.@#) C. ] 3 6 move_to_front 'abc*ef*g' **abcefg -- Raul On Thu, Feb 2, 2012 at 8:50 PM, Linda Alvord <lindaalv...@verizon.net> wrote: > Raul, your version k worked with the first list, but failed as the list was > changed > > k=:move_to_front=: <@i.@-@>:@[ C. ] > l=: 13 :'(<i.->:x)C.y' > 3 k 'abc*ef' > *abcef > 3 l 'abc*ef' > *abcef > > 3 6 k 'abc*ef*g' > c*ab*efg > 3 6 l 'abc*ef*g' > |index error: l > | 3 6 l'abc*ef*g' > > Here is another application of the original function f > > 3 6 (f=:<:@-@[ C.&.|. ]) 'abc*ef*g' > **abcefg > > Linda > -----Original Message----- > From: programming-boun...@jsoftware.com > [mailto:programming-boun...@jsoftware.com] On Behalf Of Linda Alvord > Sent: Thursday, February 02, 2012 7:55 PM > To: 'Programming forum' > Subject: Re: [Jprogramming] Understanding C. , A. > > Here is another solution posted by Raul with the comment: > > . (And, personally, I prefer i. over |. for something like this.) > > 3 move_to_front 'abc*ef' > *abcef > k=: <@i.@-@>:@[ C. ] > k > <@i.@-@>:@[ C. ] > > l=: 13 :'(<i.->:x)C.y' > l > ] C.~ [: < [: i. [: - [: >: [ > 3 k 'abc*ef' > *abcef > 3 l 'abc*ef' > *abcef > > > > -----Original Message----- > From: programming-boun...@jsoftware.com > [mailto:programming-boun...@jsoftware.com] On Behalf Of Linda Alvord > Sent: Wednesday, February 01, 2012 6:01 PM > To: 'Programming forum' > Subject: Re: [Jprogramming] Understanding C. , A. > > Sorry I missed the version by Arie. Nice! > > 3 6 (i=:-@#@[ |. C.) 'abc*ef*g' > **abcefg > i > -@#@[ |. C. > > j=: 13 :'(-#x)|.x C.y' > j > C. |.~ [: - [: # [ > > 3 6 j 'abc*ef*g' > **abcefg > > Linda > -----Original Message----- > From: programming-boun...@jsoftware.com > [mailto:programming-boun...@jsoftware.com] On Behalf Of Linda Alvord > Sent: Wednesday, February 01, 2012 5:20 PM > To: 'Programming forum' > Subject: Re: [Jprogramming] Understanding C. , A. > > I'm happiest with the explicit version. It shows the arguments needed for > the application. > > 3 6 (f=:<:@-@[ C.&.|. ]) 'abc*ef*g' > **abcefg > 3 6 f a=:'abc*ef*g' > **abcefg > > g=: 13 :'(<:-x)C.&.|.y'! > 3 6 g a > **abcefg > > f > <:@-@[ C.&.|. ] > g > ] C.&.|.~ [: <: [: - [ > g=: 13 :'(<:-x)C.&.|.y' > > J provides the ~ which shows up in the tacit version above. > > Then there is h with no ~ and no &. > > h=: 13 :'|.(<:-x)C.|.y' > h > [: |. ([: <: [: - [) C. [: |. ] > 3 6 h a > **abcefg > > Linda > > > -----Original Message----- > From: programming-boun...@jsoftware.com > [mailto:programming-boun...@jsoftware.com] On Behalf Of Roger Hui > Sent: Wednesday, February 01, 2012 11:26 AM > To: Programming forum > Subject: Re: [Jprogramming] Understanding C. , A. > > Personally, I dislike expressions with multiple uses of ~ as they make my > head spin. > > 3 6 (C.&.|.~ <:@-)~ 'abc*ef*g' > **abcefg > 3 6 (<:@-@[ C.&.|. ]) 'abc*ef*g' > **abcefg > > I much prefer the second over the first. > > > > On Wed, Feb 1, 2012 at 8:05 AM, Aai <agroeneveld...@gmail.com> wrote: > >> Ah, I see that's a bit like yours David. >> >> Modifying it for 1< #x >> >> 3 6 (C. |.~ -@#@[) 'abc*ef*g' >> **abcefg >> >> >> (from Essays) >> >> 3 6 (C.&.|.~ <:@-)~ 'abc*ef*g' >> **abcefg >>k >> >> >> >> On 01-02-12 16:47, Aai wrote: >> > Sorry for the noise. You should forget the previous ones I sent: they >> > are wrong. >> > >> > It looks like this one is ok: >> > >> > mtf=:_1&|.@C. >> > >> > ]samples=: '*abcef' |."0 1 ~-i.6 >> > *abcef >> > f*abce >> > ef*abc >> > cef*ab >> > bcef*a >> > abcef* >> > >> > >> > ]res=: '*' ([,-.~) "1 samples >> > *abcef >> > *fabce >> > *efabc >> > *cefab >> > *bcefa >> > *abcef >> > >> > res -: mtf&>/"1 (;~I.@:('*'&=))"1 samples >> > 1 >> > >> > >> > >> > >> >> -- >> Met vriendelijke groet, >> @@i = Arie Groeneveld >> >> ---------------------------------------------------------------------- >> 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 > > ---------------------------------------------------------------------- > 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