Insert does not return the inserted item immediately

Discussion in 'Rebol' started by RonG, Feb 21, 2010.

  1. RonG

    RonG New Member

    I'm completely new to Rebol. Fantastic, addictive language! I'm going through the "Absolute Beginner's Guide.." I find a problem using "Insert". The inserted value is not immediately returned. It is however, available later. Am I missing something?

    somecolors ["red" "yellow" "blue" "black"]
    == ["red" "yellow" "blue" "black"]
    >> insert somecolors "mauve"
    == ["red" "yellow" "blue" "black"] <= this should be ["mauve" "red" "yellow" "blue" "black"]????
    >> somecolors
    == ["mauve" "red" "yellow" "blue" "black"]
  2. Graham

    Graham Developer Staff Member

    Hello RonG,

    Welcome to the addictive language of Rebol!

    somecolors refers too your 4 color series, and poiints to a particular location. Since you insert at the head, somecolors still refers to "red" et seq.

    If you want to see the whole series, try

    head insert somecolors 'white

    INSERT series value /part range /only /dup count

    Inserts a value into a series and returns the series after the insert.
    INSERT is an action value.

    series -- Series at point to insert (Type: series port bitset)
    value -- The value to insert (Type: any-type)

    /part -- Limits to a given length or position.
    range -- (Type: number series port pair)
    /only -- Inserts a series as a series.
    /dup -- Duplicates the insert a specified number of times.
    count -- (Type: number pair)

Share This Page