diff options
Diffstat (limited to 'module/language/cps/util.scm')
-rw-r--r-- | module/language/cps/util.scm | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/module/language/cps/util.scm b/module/language/cps/util.scm index 8fa6591b3..a5de59341 100644 --- a/module/language/cps/util.scm +++ b/module/language/cps/util.scm @@ -1,7 +1,7 @@ (define-module (language cps util) #:use-module (ice-9 q) #:use-module (srfi srfi-1) - #:export (append-qs! int-range generate-shuffle)) + #:export (append-qs! int-range maybe-append generate-shuffle)) ;; The functions in this file are not directly related to CPS or ;; compilation; they're here because the CPS compiler needs them and @@ -19,6 +19,15 @@ (cons start (int-range (+ start 1) end)) '())) +;; this is a totally generic utility +(define (maybe-append . args) + (cond ((null? args) '()) + ((eq? (car args) #f) + (apply maybe-append (cdr args))) + (else + (append (car args) + (apply maybe-append (cdr args)))))) + ;; this function returns a list of `mov' instructions that accomplish a ;; shuffle in the stack. each tail argument is a pair (from . to) that ;; indicates how a value should move. the first argument is the number |