diff options
author | Arun Isaac | 2022-03-18 16:10:04 +0530 |
---|---|---|
committer | Arun Isaac | 2022-03-18 16:24:19 +0530 |
commit | 40b6dccc645d5f51cca1a6235db45302f13fdfac (patch) | |
tree | f7abe98c851d5794f6245ec384ea3a50458d8e34 | |
parent | 5ca60b9297b551016ece6653e00d2a6f3f6f438e (diff) | |
download | tissue-40b6dccc645d5f51cca1a6235db45302f13fdfac.tar.gz tissue-40b6dccc645d5f51cca1a6235db45302f13fdfac.tar.lz tissue-40b6dccc645d5f51cca1a6235db45302f13fdfac.zip |
utils: Move memoize-thunk to utils.
* tissue/issue.scm (memoize-thunk): Move to ...
* tissue/utils.scm (memoize-thunk): ... here.
-rw-r--r-- | tissue/issue.scm | 8 | ||||
-rw-r--r-- | tissue/utils.scm | 11 |
2 files changed, 10 insertions, 9 deletions
diff --git a/tissue/issue.scm b/tissue/issue.scm index 7b43caa..00fcbcf 100644 --- a/tissue/issue.scm +++ b/tissue/issue.scm @@ -226,14 +226,6 @@ return #f." "--" file) result)) -(define (memoize-thunk thunk) - "Return a function memoizing THUNK." - (let ((result #f)) - (lambda () - (unless result - (set! result (thunk))) - result))) - (define issues (memoize-thunk (lambda () diff --git a/tissue/utils.scm b/tissue/utils.scm index 5fce26d..6832fb8 100644 --- a/tissue/utils.scm +++ b/tissue/utils.scm @@ -21,7 +21,8 @@ #:use-module (srfi srfi-26) #:use-module (ice-9 popen) #:export (call-with-input-pipe - get-line-dos-or-unix)) + get-line-dos-or-unix + memoize-thunk)) (define (call-with-input-pipe proc program . args) "Execute PROGRAM ARGS ... in a subprocess with a pipe to it. Call @@ -43,3 +44,11 @@ ports) in that it also supports DOS line endings." (if (eof-object? line) line (string-trim-right line #\return)))) + +(define (memoize-thunk thunk) + "Return a function memoizing THUNK." + (let ((result #f)) + (lambda () + (unless result + (set! result (thunk))) + result))) |