Hi Ladislav,
What do you think of this? It's sort of polymorphic, but it's not the
right approach to handle complex numbers.
bop: func [
{returns the results of operating on elements of b with those of bb -
last element of bb will be reused if necessary}
'op [word!] "name of function to use"
b [block!]
bb
/local r -
][
op: get in system/words op
if op? :op [set '- :op]
r: copy []
if not block? bb [bb: reduce [bb]]
while [not tail? b] [
append r either :- [(first b) - (first bb)][op first b first bb]
b: next b
if 1 < length? bb [bb: next bb]
]
r
]
>> bop * [$2.00 $1.53] 2
== [$4.00 $3.06]
>> bop ** [2 3 4] [4 3 2]
== [16 27 16]
>> bop and [1 2 3 4 5 6 7 8] 5
== [1 0 1 4 5 4 5 0]
See you,
Eric