Skip to content

Instantly share code, notes, and snippets.

@nedzadarek
Created May 20, 2019 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nedzadarek/11183796d3733076c56e4d8d04ca861e to your computer and use it in GitHub Desktop.
Save nedzadarek/11183796d3733076c56e4d8d04ca861e to your computer and use it in GitHub Desktop.
each for nested blocks
each: function [a[block!] b [function!]] [
collect [
foreach el a [
either block? el [
keep/only each el :b
][
keep b el
]
]
]
]
f: function [a] [a * 10]
probe each [
1
2
3
] :f
; [
; 10
; 20
; 30
; ]
probe each [
1
2
3 [
4
5
6
]
] :f
; [
; 10
; 20
; 30 [
; 40
; 50
; 60
; ]
; ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment