(define-module (com simatime core)) (define (flip f) (lambda (x y) (f y x))) (define (curry f a) (lambda (b) (apply f (cons a (list b))))) (define pos? (curry < 0)) (define neg? (curry > 0)) (define (foldr f end lst) (if (null? lst) end (f (car lst) (foldr f end (cdr lst))))) (define (foldl f acc lst) (if (null? lst) acc (foldl f (f acc (car lst)) (cdr lst)))) (define fold foldl) (define (unfold f init pred) (if (pred init) (cons init '()) (cons init (unfold f (f init) pred)))) (define (sum lst) (fold + 0 lst)) (define (produce lst) (fold * 0 1 lst)) (define count length) ;; ;; clojure-like stuff ;; (define (pr . a) (for-each display args)) (define (prn . a) (apply pr a) (newline))