Created
May 20, 2019 13:53
-
-
Save nedzadarek/11183796d3733076c56e4d8d04ca861e to your computer and use it in GitHub Desktop.
each for nested blocks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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