-
-
Save maximvl/640aa095ab13792d21032a9e171c77bd to your computer and use it in GitHub Desktop.
@steveGit's version of LC in Red
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
Red [] | |
lc: function [rule] [ | |
parse rule [ | |
some [ | |
s: word! 'in skip | |
(in: last reduce/into ['foreach s/1 s/3 make block! 4] in) | |
| 'if skip | |
(in: last reduce/into ['if to-paren s/2 make block! 4] in) | |
| skip '| | |
(res: s/1 fun: in: make block! 4) | |
| (reduce/into ['reduce/into res 'tail 'out] in) break | |
] | |
] | |
has [out] compose [out: make block! 10 (fun) out] | |
] | |
x-set: [1 2 3] | |
r: lc [[x + y ] | x in x-set y in [10 100 1000] if [ x <> 2]] | |
print source r | |
print r | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment