2021-11-23 13:18:07 -05:00
|
|
|
(module util (curry applied thunk just perhaps compose-symbols)
|
2021-11-18 08:52:15 -05:00
|
|
|
(import scheme)
|
2021-11-23 13:18:07 -05:00
|
|
|
(import chicken.base)
|
|
|
|
(import srfi-13)
|
2021-11-18 08:52:15 -05:00
|
|
|
|
|
|
|
(define (curry fn a)
|
|
|
|
(lambda (b)
|
|
|
|
(fn a b)))
|
|
|
|
|
|
|
|
(define (applied fn)
|
|
|
|
(curry apply fn))
|
|
|
|
|
|
|
|
(define-syntax thunk
|
|
|
|
(syntax-rules ()
|
|
|
|
((_ exp ...)
|
2021-11-20 07:04:05 -05:00
|
|
|
(lambda () exp ...))))
|
|
|
|
|
2021-11-23 13:18:07 -05:00
|
|
|
(define (just fn)
|
|
|
|
(lambda args
|
|
|
|
(fn)))
|
2021-11-20 07:04:05 -05:00
|
|
|
|
2021-11-23 13:18:07 -05:00
|
|
|
(define (perhaps fn arg)
|
|
|
|
(if arg
|
|
|
|
(fn arg)
|
|
|
|
arg))
|
|
|
|
|
|
|
|
(define (compose-symbols . ln)
|
|
|
|
(string->symbol (string-concatenate (intersperse (map symbol->string ln) "-")))))
|