function 1: sread


sread:
    description:
        sread(positions) input-seq
        replace positions with their index in the input sequence
        we try to preserve the 'structure' of 'positions'
        index values start from 1, not 0
        negative values are also valid, so -1 is last element, -2 is second last element, etc
        if out of range, or not a number, return |> for that slot

    examples:
        -- preserve superposition structure of 'positions':
        sread(|1> + |3> + |5>) (|one> . |two> . |three> . |four> . |five> . |six> . |seven>)
            |one> + |three> + |five>

        -- preserve sequence structure of 'positions':
        sread(|1> . |3> . |5>) (|one> . |two> . |three> . |four> . |five> . |six> . |seven>)
            |one> . |three> . |five>

        -- handle negative indices:
        sread(|-1> . |-2> . |-3>) (|one> . |two> . |three> . |four> . |five> . |six> . |seven>)
            |seven> . |six> . |five>

        -- if out of range, or not a number, return |> for that slot:
        sread(|1> . |fish> . |11> . |4>) (|one> . |two> . |three> . |four> . |five> . |six> . |seven>)
            |one> . |> . |> . |four>

    see also:
        not-sread, read, not-read

Home