How to insert an int at a specific index in a list ?

    Oct 24 2012 | 6:24 pm
    Title pretty much says it all. Say I have a list of 10 zeroes and I want to add a one at the 2nd position, how would I do that ?
    Also, any recommendations on a elegant way to generate a list of zeros ?
    Thank you, George

    • Oct 24 2012 | 7:04 pm
      If the number of places is known, why not just have a message box with that many zeros in it? At any rate, this is a completely non-general solution to the stated problem:
    • Oct 24 2012 | 7:08 pm
      is this what you mean?
      Cheers, Ádám
      P.S. My solution assumes that you work with 0-based list counting, so the '2nd element' in this example is the third item of the list.
    • Oct 24 2012 | 7:51 pm
      I think you could work with a jit.matrix object. That would be the easiest way to manipulate a list of numbers. Another way of creating a list of zeros is to use zl group with uzi sending 0 as a message.
    • Oct 24 2012 | 11:11 pm
      A slice-less version :)
    • Oct 25 2012 | 9:34 am
      You can also use this feature of [zl nth] -which I like.
    • Oct 25 2012 | 3:15 pm
      Wow, thanks a lot guys! This is very cool!