diff options
-rw-r--r-- | chickadee/utils.scm | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/chickadee/utils.scm b/chickadee/utils.scm index 8869e8d..2d218c4 100644 --- a/chickadee/utils.scm +++ b/chickadee/utils.scm @@ -17,9 +17,25 @@ ;;; <http://www.gnu.org/licenses/>. (define-module (chickadee utils) - #:export (memoize + #:use-module (ice-9 match) + #:export (file-extension + absolute-file-name + tmpdir + memoize for-range)) +(define (file-extension file-name) + (match (string-split file-name #\.) + ((_ ... ext) ext))) + +(define (absolute-file-name file-name) + (if (absolute-file-name? file-name) + file-name + (string-append (getcwd) "/" file-name))) + +(define (tmpdir) + (or (getenv "TMPDIR") "/tmp")) + ;; Written by Ludovic Courtès. Taken from GNU Guix. (define (memoize proc) "Return a memoizing version of PROC." |