[REBOL] Who is that grouch? -or- Fun with functions! Re:(5)
From: al:bri:xtra at: 5-Oct-2000 12:45
jn wrote:
> nondiv: func [d] [func [n] [either n // d = 0 [none] [n]]]
This could be quicker as:
nondiv: func [d] [func [n] [if n // d <> 0 [n]]]
as 'if returns 'none when the condition is false.
Also, this:
> map: function [[catch] b [block!] f [function!] /all]
is better as:
map: function [[catch] b [block!] f [any-function!] /all]
so you can use native! functions as well.
jn, is there a name for a generic function like:
something: function [B [block!] F [any-function!]] [Arg1] [
Arg1: first B
B: next B
foreach Arg2 B [
Arg1: F Arg1 Arg2
]
Arg1
]
something [1 2 3 4 5] :+
>> something: function [B [block!] F [any-function!]] [Arg1] [
[ Arg1: first B
[ B: next B
[ foreach Arg2 B [
[ Arg1: F Arg1 Arg2
[ ]
[ Arg1
[ ]
>>
>> something [1 2 3 4 5] :+
== 15
For a sum function?
And if you're Grouchy, who's Sneezy, Happy, Doc,... ? :-)
Andrew Martin
ICQ: 26227169
http://members.nbci.com/AndrewMartin/