diff options
Diffstat (limited to 'guile/starlet/utils.scm')
-rw-r--r-- | guile/starlet/utils.scm | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/guile/starlet/utils.scm b/guile/starlet/utils.scm index be87321..049bd86 100644 --- a/guile/starlet/utils.scm +++ b/guile/starlet/utils.scm @@ -1,7 +1,13 @@ (define-module (starlet utils) + #:use-module (srfi srfi-1) #:export (return-unspecified print-hash-table - copy-hash-table)) + copy-hash-table + partial + in-range + mean + flatten-sublists + more-than-one)) (define (return-unspecified) @@ -21,3 +27,39 @@ (hash-set! new-ht key value)) ht) new-ht)) + + +(define (partial f second-val) + (lambda (first-val) + (f first-val second-val))) + + +(define (in-range a val1 val2) + (or + (and (>= a val1) + (<= a val2)) + (and (>= a val2) + (<= a val1)))) + + +(define (mean vals) + (/ (fold + 0 vals) + (length vals))) + + +(define (flatten-sublists l) + + (define (listify a) + (if (list? a) + a + (list a))) + + (fold (lambda (a prev) + (append prev (listify a))) + '() l)) + + +(define (more-than-one a) + (if (nil? a) + #f + (not (nil? (cdr a))))) |