Skip to content

Instantly share code, notes, and snippets.

@nedzadarek
Created May 6, 2018 15:54
Show Gist options
  • Save nedzadarek/d1e34e32ccd31cf1820e018cefc30270 to your computer and use it in GitHub Desktop.
Save nedzadarek/d1e34e32ccd31cf1820e018cefc30270 to your computer and use it in GitHub Desktop.
<ACTION> X from Y doing Z
; more info here:
; https://gitter.im/red/red?at=5aef1a635cf0b830045e6264
from: make op! func [a b] [reduce [a b]]
each: make op! func ['a b] [reduce [a b]]
keep each [x y] from [1 2 3 4]
; == [[keep [x y]] [1 2 3 4]]
each: make op! func ['a b] [
either find [remove keep map] a [
print ["found " a]
][cause-error 'user 'message ["action not found"] ]
print ["doing something with " b]
reduce [a b]
]
keep each [x y] from [1 2 3 4]
nope each [x y ] from [1 2 4 42]
doing: make op! func [a b /local arr] [
; arr: copy [main]
arr: copy []
append arr a
append/only arr b
; reduce arr
arr
]
keep each x from [1 2 3 4] doing [x > 2]
main: func [a b c] [
print "^/Main code::"
print ["a:: " a]
print ["b:: " b]
print ["c:: " c]
]
doing: make op! func [a b /local arr] [
arr: copy [main]
append arr a
append/only arr b
do arr
]
keep each x from [1 2 3 4] doing [x > 2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment