Memoize redex thunk/e's.
Tests run over twice as fast.
This commit is contained in:
parent
5c82ab06c3
commit
0f2a640d02
|
@ -670,11 +670,16 @@
|
|||
|
||||
;; thunk/e : Nat or +-Inf, ( -> enum a) -> enum a
|
||||
(define (thunk/e s thunk)
|
||||
(enum s
|
||||
(λ (n)
|
||||
(decode (thunk) n))
|
||||
(λ (x)
|
||||
(encode (thunk) x))))
|
||||
(let* ([e #f]
|
||||
[get-e (λ ()
|
||||
(or e
|
||||
(and (set! e (thunk))
|
||||
e)))])
|
||||
(enum s
|
||||
(λ (n)
|
||||
(decode (get-e) n))
|
||||
(λ (x)
|
||||
(encode (get-e) x)))))
|
||||
|
||||
;; many/e : enum a -> enum (listof a)
|
||||
;; or : enum a, #:length natural -> enum (listof a)
|
||||
|
|
Loading…
Reference in New Issue
Block a user