>>  <<  Ndx  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  wd  Help  Release

, Append in Place Implemented initial writing: 2003-07-17
last updated: 2004-03-19

The phrases abc=:abc,expression and abc=.abc,expression are now done in place if possible, reducing the amount of time required if done repeatedly. For append in place to be possible,

The following benchmark demonstrates that ordinary append takes quadratic time while append in place takes linear time.

append=: 3 : 0    
 z=. i.0
 for_i. i.y. do.
  z=. i,z        NB. not append in place
 end.
)

appendip=: 3 : 0
 z=. i.0
 for_i. i.y. do.
  z=. z,i        NB. append in place
 end.
)
 
ts=: 6!:2 , 7!:2@]   NB. time and space
ts 'append n'  
n    Append    Append in Place        Ratio
1000  0.014100  15040  0.010849  13056  1.30  1.15
2000  0.033592  27328  0.021497  23296  1.56  1.17
4000  0.082590  51904  0.044137  43776  1.87  1.19
8000  0.836611  101056  0.085612  84736  9.77  1.19
16000  3.763209  199360  0.174779  166656  21.53  1.20
32000  15.665998  395968  0.350860  330496  44.65  1.20
64000  66.094799  789184  0.689447  658176  95.87  1.20
128000  283.322519  1575616  1.394492  1313536  203.17  1.20


>>  <<  Ndx  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  wd  Help  Release