diff options
Diffstat (limited to 'atk16_schasm/core.scm')
| -rw-r--r-- | atk16_schasm/core.scm | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/atk16_schasm/core.scm b/atk16_schasm/core.scm index 08a0bd5..7c292f1 100644 --- a/atk16_schasm/core.scm +++ b/atk16_schasm/core.scm @@ -1,7 +1,8 @@ (import (chicken base) (chicken bitwise) (chicken format) - (chicken io)) + (chicken io) + (only srfi-1 iota)) ;; Utils @@ -15,6 +16,12 @@ ((_ fn-body expr ...) (lambda (x) (fn-body expr ... x))))) +(define (zip alist blist) + (if (null? alist) + '() + ;; else, cons and recurse + (cons (cons (car alist) (car blist)) (zip (cdr alist) (cdr blist))))) + (define (type-of pair) (if (pair? pair) (car pair) (error "not a pair" pair))) (define (val-of pair) @@ -27,6 +34,19 @@ (let ((v (assoc k alist))) (and v (cdr v)))) +(define-syntax inc! + (syntax-rules () + ((_ n) + (set! n (+ n 1))) + ((_ n m) + (set! n (+ n m))))) +(define-syntax sub! + (syntax-rules () + ((_ n) + (set! n (- n 1))) + ((_ n m) + (set! n (- n m))))) + (define (string->ascii-list s) (let* ((len (string-length s)) (dummy (cons #f '())) |
