[REBOL] Re: Cunning use of [], () & {} in R# and in future? Rebol versions?
From: AJMartin:orcon at: 24-Dec-2003 22:41
Carl Read wrote:
> >> ? picks
> No information on picks (word has no value)
Hmmm, seems to work OK for me: :-)
>> source picks
picks: func [
[catch throw]
{Returns the values at the specified positions in the series.}
Series [series! pair! event! money! date! time! object! port! tuple!
any-function!]
Indexes [block!]
][
foreach Index Indexes collect/full/only [
if not number? Index [
throw make error! reduce ['script 'expect-arg 'Picks 'Indexes
mold [any number!]]
]
pick Series Index
]
]
Of course, you'll need the source for 'collect as well:
>> source collect
collect: func [
"Collects the results of block evaluations."
Block [block!] "The block to 'do."
/Only "Inserts the result as a series."
/Full "Don't ignore none! values."
/Initial Type [series! datatype!] "Specifies the type of the result."
][
use [Break Result Results] [
Break: func [
"Breaks out of the 'Collect."
/Return "Forces the loop function to return a Value."
Value [any-type!]
] [
system/words/break/return either Return [
Value
] [
Results
]
]
Results: any [
all [
datatype? Type
make Type 0
]
Type
copy []
]
compose/deep [
if not any [
unset? set/any 'Result do [(bind Block 'Break)]
(pick [[none? :Result] []] not Full)
] [
(pick [insert insert/only] not Only) tail Results :Result
Results
]
Results
]
]
]
Enjoy!
Andrew J Martin
Grail Jedi
ICQ: 26227169
http://www.rebol.it/Valley/
http://valley.orcon.net.nz/
http://Valley.150m.com/