Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: COLLECTing results

From: andrew:martin:colenso:school at: 25-Jul-2003 8:34

Brett wrote:
> /init result "Initialise the result series."
Andrew wrote:
> /Initial Results [series! datatype!] "Specifies the type of
the result." I'm using /Initial for my version of 'Collect, because it's like the /Initial refinement in the 'Array function:
>> help array
USAGE: ARRAY size /initial value DESCRIPTION: Makes and initializes a series of a given size. ARRAY is a function value. ARGUMENTS: size -- Size or block of sizes for each dimension (Type: integer block) REFINEMENTS: /initial -- Specify an initial value for all elements value -- Initial value (Type: any) And the 'datatype! specification allows me to be weird! :)
>> foreach c "abcde" collect/Initial [to integer! c] string!
== "979899100101"
>> foreach c "abcde" collect/Initial [to integer! c] block!
== [97 98 99 100 101]
>> foreach c "abcde" collect/Initial [to integer! c] hash!
== make hash! [97 98 99 100 101] Collect: function [ {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 Results [series! datatype!] "Specifies the type of the result." ] [ Result ] [ Results: any [ all [ datatype? Results make Results 0 ] Results copy [] ] compose/deep [ if not any [ unset? set/any 'Result do [(Block)] (pick [[none? :Result] []] not Full) ] [ (pick [insert insert/only] not Only) tail Results :Result ] Results ] ] Andrew J Martin Attendance Officer & Information Systems Trouble Shooter Colenso High School Arnold Street, Napier. Tel: 64-6-8310180 ext 826 Fax: 64-6-8336759 DISCLAIMER: Colenso High School and its Board of Trustees is not responsible (or legally liable) for materials distributed to or acquired from user e-mail accounts. You can report any misuse of an e-mail account to our ICT Manager and the complaint will be investigated. (Misuse can come in many forms, but can be viewed as any material sent/received that indicate or suggest pornography, unethical or illegal solicitation, racism, sexism, inappropriate language and/or other issues described in our Acceptable Use Policy.) All outgoing messages are certified virus-free by McAfee GroupShield Exchange Phone: +64 6 843 5095 or Fax: +64 6 833 6759 or E-mail: [postmaster--colenso--school--nz]