See Example 6 in the dictionary page for ^: http://www.jsoftware.com/help/dictionary/d202n.htm
----- Original Message ----- From: Richard Donovan <[email protected]> Date: Friday, March 27, 2009 14:02 Subject: [Jprogramming] Speed problem (Head, Drop, Append, ?) To: J Programming <[email protected]> > > I have the following code to remove prefixes from data. > > msgin=:y > msgout=:'' > > while. 0=0 do. > if. 0={.msgin do. msgout{a. return. end. > prefixcount=:>:0{msgin > msgin=:prefixcount}.msgin NB. Drop prefix > msgout=:msgout,{.msgin NB. Append a message char > msgin=:}.msgin NB. Drop char > end. > > The idea is that a prefix consists of a one byte count (#prefix) > followed by the prefix. These bytes all get removed and the > following byte is appended to the output string. If the one > byte count is zero, the data is finished. > > The code works fine but takes an unacceptable amount of time > to run (several minutes for a 100,000 byte input.) The only > verbs used are {. head }. drop and , append. > > How can I find which of these is calling the slowdown and is > there a quicker alternative? > > Thanks in advance ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
