[REBOL] Copy/part series series (WAS :"piping" functions)
From: jf_allie::hotmail::com at: 24-Nov-2005 22:04
Thanks everyone for your help,
I think I got it now.
Here is a note explaining how I understand it at this point:
>>? copy
USAGE:
COPY value /part range /deep
DESCRIPTION:
Returns a copy of a value.
COPY is an action value.
ARGUMENTS:
value -- Usually a series (Type: series port bitset)
REFINEMENTS:
/part -- Limits to a given length or position.
range -- (Type: number series** port pair) <--
/deep -- Also copies series values within the block.
Notes: ** A SERIES holds a sequence of values (rebol values, characters, and
so on), AND a position in the sequence. When copying part of a series, the
RANGE argument can be this same series. COPY/PART will then copy starting at
the INDEX position of the first series and up to the INDEX position of the
second series.
In pictures:
1st argument a[b c d e] tail index-at-2
INDEX position ^
2nd argument a b c d[e] tail index-at-5
INDEX position ^
COPY/PART 1st-arg 2nd-arg a[b c d e] tail -> [b c d] tail index-at-1
^ ^
example B:
>>a: [1 2 3 4 5]
== [1 2 3 4 5]
>>butlast: func [series][
[ copy/part series back tail series]
==[1 2 3 4]
>>
example B:
>>life: [10 20 30 40 50 60 70]
== [10 20 30 40 50 60 70]
>>party: func [life n] [
[ copy/part skip life n skip tail life negate n]
>>party life 1
== [20 30 40 50 60]
>>party life 2
== [30 40 50]
>>party life 3
== [40]