REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 3-Aug-2010 Edit History  

REBOL 3 Functions: insert

insert  series  value  /part  length  /only  /dup  count

Inserts into a series and returns the series after the insert. (Modifies)

Arguments:

series [series! port! map! gob! object! bitset! port!] - Series at point to insert

value [any-type!] - The value to insert

Refinements:

/part - Limits to a given length or position

length [number! series! pair!]

/only - Only insert a block as a single value (not the contents of the block)

/dup - Duplicates the insert a specified number of times

count [number! pair!]

See also:

append   change   clear   remove   join  

Description

If the value is a series compatible with the first (block or string-based datatype), then all of its values will be inserted. The series position just past the insert is returned, allowing multiple inserts to be cascaded together.

Refinements

/part allows you to specify how many elements you want to insert.

/only will force a block to be insert, rather than its individual elements. (Is only done if first argument is a block datatype.)

/dup will cause the inserted series to be repeated a given number of times. (Positive integer or zero)

The series will be modified.

str: copy "here this"
insert str "now "
print str
now here this
insert tail str " message"
print str
now here this message
insert tail str reduce [tab now]
print str
now here this message   12-Feb-2009/17:47:52-8:00
insert insert str "Tom, " "Tina, "
print str
Tom, Tina, now here this message    12-Feb-2009/17:47:52-8:00
insert/dup str "." 7
print str
.......Tom, Tina, now here this message 12-Feb-2009/17:47:52-8:00
insert/part tail str next "!?$" 1
print str
.......Tom, Tina, now here this message 12-Feb-2009/17:47:52-8:00?
blk: copy ["hello"]
insert blk 'print
probe blk
[print "hello"]
insert tail blk http://www.rebol.com
probe blk
[print "hello" http://www.rebol.com]
insert/only blk [separate block]
probe blk
[[separate block] print "hello" http://www.rebol.com]


  TOC < Back Next > REBOL.com - WIP Wiki Feedback Admin