[REBOL] Who is that grouch? -or- Fun with functions! Re:(8)
From: al:bri:xtra at: 5-Oct-2000 15:45
Andrew wrote:
> As 'pair-wise can be extended to three (or more) arguments functions as
well.
Much like this:
>> Apply: function [Blocks [block!] F [any-function!]] [Results F-Block] [
[ Results: none
[ if equal? length? Blocks length? first :F [
[ Results: make block! length? first blocks
[ repeat i length? first Blocks [
[ F-Block: copy []
[ append F-Block :F
[ foreach Block Blocks [
[ append/only F-Block Block/:i
[ ]
[ append/only Results do F-Block
[ ]
[ ]
[ Results
[ ]
>> apply [[1.0 3.3]] :form
== ["1" "3.3"]
>> apply [[1.0 3.3] [2.3 99.0]] :+
== [3.3 102.3]
>> apply [[true false true] [["I'm true!"] ["not not"] [1]] [["I'm true!"]
["not"] [0]]] :either
== ["I'm true!" "not" 1]
Andrew Martin
ICQ: 26227169
http://members.nbci.com/AndrewMartin/