https://github.com/fuco1/dollar-if
Anaphoric if macro
https://github.com/fuco1/dollar-if
Last synced: about 2 months ago
JSON representation
Anaphoric if macro
- Host: GitHub
- URL: https://github.com/fuco1/dollar-if
- Owner: Fuco1
- Created: 2014-03-21T12:50:39.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-03-21T12:51:27.000Z (almost 12 years ago)
- Last Synced: 2025-04-01T13:15:31.232Z (11 months ago)
- Size: 97.7 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# $if---anaphoric if with named subexpressions
For when you want to refer to a subexpression of condition from the true/false body.
## Examples
The comments show the name of the preceeding expression.
```scheme
($if (or (< 10 3) ;; $1
(listp
'(1 2 3) ;; $3
) ;; $2
) ;; $0
(list $1 $2 (-sum $3))
(do-some-stuff)) => (nil t 6)
($if (not
(listp
'(1 2 3) ;; $2
) ;; $1
) ;; $0
(do-some-stuff)
$2) => (1 2 3)
($if (+ 1 2 3 4) $0) => 10
;; this is equivalent to (--if-let (...) it) from dash
```