Hi, Tim,
Tim Johnson wrote:
Hello All:
I would like to apply the same operation to all members
of a nested block.
;Example:
blk: [[1 2 3 4] [5 6 7 8] [9 10 11 12] [13 14 15 16 17] one]
blk: do-all blk next ; set all members to next element
;result sought:
[[2 3 4] [6 7 8] [10
Hi Tim,
I think map will do what you want.
; Larry Palmiter's version but Ladislav and Andrew also have them
map: func [fn blk args /local result][
result: copy []
repeat el blk [append/only result fn :el args]
return result
]
test: [[1 2 3 4] [5 6 7 8] [9 10 11 12] [13 14 15 16
Dont use 'foreach. 'Foreach makes a copy of the value, bungling your method. Use
'forall or 'repeat. I like using 'repeat for this sort of thing because I can do it
without the awkward [block: head block] at the end.
Also you might want to use 'block? instead of 'series? to validate whether
On Tue, Oct 16, 2001 at 11:18:05AM -0600, Gregg Irwin wrote:
Hi Tim,
I think map will do what you want.
Yes indeed. It's exactly what I want. :)
==I note a bonus: I think I'm seeing how one passes a function
as an argument.
Thank you Gregg
; Larry Palmiter's version but Ladislav
Hi Tim,
by now you've heard about map more than once, one other
possibility would be, e.g.
Once upon a time Tim Johnson spoketh thus:
Hello All:
I would like to apply the same operation to all members of a nested block.
;Example:
blk: [[1 2 3 4] [5 6 7 8] [9 10 11 12] [13 14 15 16
On Tue, Oct 16, 2001 at 02:09:26PM -0500, Joel Neely wrote:
Hi, Tim,
Tim Johnson wrote:
I see Ryan's opinion not to use 'foreach.
Could you comment on his opinion on this.
(I've seen references to a foreach bug and
I almost never use it