### sequence function: swrite

description:
swrite(positions, write-seq) input-seq
the sequence write function
positions can be either superpositions, sequences or mixed
the resulting sequence will have the given positions over-written with write-seq
if len(write-seq) > 1 it will be inserted, and change the length of the returned sequence
if any of the positions are not integers, then they will not change the final sequence
if any of the positions are out of range, then they will not change the final sequence
index values start at 1, not 0. So 1 is the first element, 2 is the 2nd element, and so on.
negative index values work too. eg, -1 is the last element in the sequence, -2 is the 2nd last, and so on.
examples:
-- the superposition case:
swrite(|2> + |3> + |5>, |fish>) ssplit |abcdefg>
|a> . |fish> . |fish> . |d> . |fish> . |f> . |g>
-- the sequence case:
swrite(|2> . |3> . |5>, |fish>) ssplit |abcdefg>
|a> . |fish> . |fish> . |d> . |fish> . |f> . |g>
-- writing an empty ket:
swrite(|2> . |4> . |6>, |>) ssplit |abcdefg>
|a> . |> . |c> . |> . |e> . |> . |g>
-- writing a sequence:
swrite(|2> . |4> . |6>, |X> . |Y> . |Z>) ssplit |abcdefg>
|a> . |X> . |Y> . |Z> . |c> . |X> . |Y> . |Z> . |e> . |X> . |Y> . |Z> . |g>
-- writing with negative indices:
swrite(|2> + |-3>, |FISH>) ssplit |abcdefg>
|a> . |FISH> . |c> . |d> . |FISH> . |f> . |g>
see also:
sread, sread-range, swrite-range, sselect

Home