(define-module (radix utils) #:use-module (srfi srfi-26) #:export (associate-left associate-right flatmap)) (define-syntax-rule (associate-left (key associations) ...) `(,@(map (cut cons key <>) associations) ...)) (define-syntax-rule (associate-right (association keys) ...) `(,@(map (cut cons <> association) keys) ...)) (define (flatmap proc . args) (if (null? (cdr args)) (map proc (car args)) (apply append (map (lambda (x) (apply flatmap (lambda arglist (apply proc x arglist)) (cdr args))) (car args)))))