swap=: <@[ C. ] s=: 13 :'(<x) C. y' s ] C.~ [: < [ 1 5 swap 'abcdefgh' afcdebgh 1 5 s 'abcdefgh' afcdebgh move_to_front=:0&,@[ swap ] move_to_front 0&,@[ swap ] mtf=: 13 :'(0,x) s y' mtf ] s~ 0 , [ 3 move_to_front 'abc*ef' *bcaef 3 mtf 'abc*ef' *bcaef
Linda -----Original Message----- From: programming-boun...@jsoftware.com [mailto:programming-boun...@jsoftware.com] On Behalf Of Aai Sent: Tuesday, January 31, 2012 11:18 AM To: Programming forum Subject: Re: [Jprogramming] Understanding C. , A. move_to_front 3 ( C.~ 1&,;0&,)~ 'abc*ef' *acbef On 31-01-12 16:44, David Ward Lambert 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 -- 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