inserting an element in a list at position n

Mar 30, 2011 at 9:12am

inserting an element in a list at position n

my case is even more simple (position is 2)

1/ I don’t see how to do it simply
2/ I am searching for a fast / efficient way to use it at low level

Thanks in advance

#55874
Mar 30, 2011 at 9:39am

Sorry, it’s completely wrong.

[zl nth] is more appropriate.

– Pasted Max Patch, click to expand. –

leo

#200832
Mar 30, 2011 at 9:49am

still wrong you are doing a replace
here a good one ( slice join join ) but too complex

– Pasted Max Patch, click to expand. –
#200833
Mar 30, 2011 at 10:47am

Hello Maa,

– Pasted Max Patch, click to expand. –

HTH

#200834
Mar 30, 2011 at 11:25am

from your I simplified mine
I don’t know what the most efficient one (depend on zl implementation)
but I’d like better (in term of CPU)

Thanks

– Pasted Max Patch, click to expand. –
#200835
Mar 30, 2011 at 2:38pm

oups,

next time I’ll read the first word of the post twice.

For the most efficient one, I don’t know, repeat 2000 times the operation (uzi) and compare cpu time (see cpuclock helpfile)

léo

#200836
Mar 30, 2011 at 3:25pm

Hello,

for benchmark addicts Maa’s last way [zl slice] option is best than [zl rot] but IMHO here the difference is not enough significant to contradict the main rule : do it simple and easy to understand … so : choose method you prefer ; actually i prefer Maa’s one ;-)

#200837

You must be logged in to reply to this topic.