aboutsummaryrefslogtreecommitdiff
path: root/module/util.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-12-23 02:17:26 +0100
committerHugo Hörnquist <hugo@hornquist.se>2019-12-23 02:17:26 +0100
commit2af715fe4ac1ed36a4809307f5a177c1e6161574 (patch)
tree6c9a9d58b33259ff936f09202e1900975ece1e83 /module/util.scm
parentBroke out nav-link into function. (diff)
downloadcalp-2af715fe4ac1ed36a4809307f5a177c1e6161574.tar.gz
calp-2af715fe4ac1ed36a4809307f5a177c1e6161574.tar.xz
Add awhen.
Diffstat (limited to 'module/util.scm')
-rw-r--r--module/util.scm18
1 files changed, 17 insertions, 1 deletions
diff --git a/module/util.scm b/module/util.scm
index 0d4d20d6..0bbab9bc 100644
--- a/module/util.scm
+++ b/module/util.scm
@@ -11,7 +11,7 @@
quote?
re-export-modules
use-modules*
- -> set aif
+ -> set aif awhen
tree-map let-lazy let-env)
#:replace (let* set! define-syntax
when unless if))
@@ -44,6 +44,7 @@
((@ (guile) if) p t
(begin f ...))]))
+
(define-syntax aif
(lambda (stx)
(syntax-case stx ()
@@ -51,6 +52,21 @@
(with-syntax ((it (datum->syntax stx 'it)))
#'(let ((it condition))
(if it true-clause false-clause)))])))
+
+(define-syntax awhen
+ (lambda (stx)
+ (syntax-case stx ()
+ [(_ condition body ...)
+ (with-syntax ((it (datum->syntax stx 'it)))
+ #'(let ((it condition))
+ (when it body ...)))])))
+
+#;
+(define-macro (awhen pred . body)
+ `(let ((it ,pred))
+ (when it
+ ,@body)))
+
(define-public upstring->symbol (compose string->symbol string-upcase))