Inverse append
[1/6] from: lethalman:fyrebird at: 17-Oct-2004 14:56
Is there a function like append but that insert a value at the beginning
of another one?
c: []
a: "test 2"
b: []
append b a
c: join b c
a: "test"
b: []
append b a
c: join b c
c
== ["test" "test 2"]
--
Fyrebird Hosting Provider - Technical Department
[2/6] from: andreas:bolka:gmx at: 17-Oct-2004 15:06
Sunday, October 17, 2004, 2:56:17 PM, Lethalman wrote:
> Is there a function like append but that insert a value at the
> beginning of another one?
insert
>> ? insert
USAGE:
INSERT series value /part range /only /dup count
DESCRIPTION:
Inserts a value into a series and returns the series after the insert.
INSERT is an action value.
ARGUMENTS:
series -- Series at point to insert (Type: series port bitset)
value -- The value to insert (Type: any-type)
REFINEMENTS:
/part -- Limits to a given length or position.
range -- (Type: number series port)
/only -- Inserts a series as a series.
/dup -- Duplicates the insert a specified number of times.
count -- (Type: number)
--
Best regards,
Andreas
[3/6] from: lethalman:fyrebird at: 17-Oct-2004 15:11
Andreas Bolka wrote:
>Sunday, October 17, 2004, 2:56:17 PM, Lethalman wrote:
>>Is there a function like append but that insert a value at the
<<quoted lines omitted: 19>>
> /dup -- Duplicates the insert a specified number of times.
> count -- (Type: number)
Ehm, es i found it but i didn't understand how to use it, made several
tests...
My english is not so good sorry :(
--
Fyrebird Hosting Provider - Technical Department
[4/6] from: lethalman::fyrebird::net at: 17-Oct-2004 15:13
Lethalman wrote:
>Andreas Bolka wrote:
>>Sunday, October 17, 2004, 2:56:17 PM, Lethalman wrote:
<<quoted lines omitted: 45>>
>tests...
>My english is not so good sorry :(
Sorry, insert c "test" works fine
--
Fyrebird Hosting Provider - Technical Department
[5/6] from: andreas::bolka::gmx::net at: 17-Oct-2004 17:18
Sunday, October 17, 2004, 3:11:38 PM, Lethalman wrote:
> Andreas Bolka wrote:
>>Sunday, October 17, 2004, 2:56:17 PM, Lethalman wrote:
<<quoted lines omitted: 4>>
> several tests... My english is not so good sorry :(
>> c: copy []
== []
>> insert c "test 2"
== []
>> c
== ["test 2"]
>> insert c "test"
== ["test 2"]
>> c
== ["test" "test 2"]
please note that insert returns the series (the block) at the position
_after_ the inserted item (that's the reason why the 2nd statement in
the above example returns a seemingly empty block).
--
Best regards,
Andreas
[6/6] from: AJMartin::orcon::net::nz at: 18-Oct-2004 4:31
Lethalman wrote:
> Is there a function like append but that insert a value at the beginning
> of another one?
You might also be interested in 'Push:
Push: func [
"Inserts a value into a series and returns the series head."
Stack [series! port! bitset!] "Series at point to insert."
Value [any-type!] /Only "The value to insert."
][
head either Only [
insert/only Stack :Value
][
insert Stack :Value
]
]
Together with 'Pop and 'Top, this allows making stacks.
---
Andrew Martin
ICQ: 26227169
http://www.rebol.it/Valley/
http://valley.orcon.net.nz/
http://valley.150m.com/
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted