Skip to content

Instantly share code, notes, and snippets.

@toomasv
Created June 12, 2018 12:09
Show Gist options
  • Save toomasv/4eb4c6c673276ce309ff42437ab6ca22 to your computer and use it in GitHub Desktop.
Save toomasv/4eb4c6c673276ce309ff42437ab6ca22 to your computer and use it in GitHub Desktop.
Some incrementation funcs
Red [
Original-idea: "Dave Andersen"
Source: https://gitter.im/red/red?at=5a2a4fb9a2be46682876463d
]
inc: func ['val][set val (get val) + 1]
dec: func ['val][set val (get val) - 1]
incr: func ['val step][set val (get val) + step]
decr: func ['val step][set val (get val) - step]
++: make op! :incr
--: make op! :decr
increment: func ['val /by step][set val (get val) + any [step 1]]
decrement: func ['val /by step][set val (get val) - any [step 1]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment