i am good at the computer boxes

Signed-off-by: Xe <me@christine.website>
This commit is contained in:
Cadey Ratio 2022-04-25 06:01:38 -04:00
parent c8430d6081
commit 47bd09bcd2
1 changed files with 3 additions and 6 deletions

View File

@ -40,12 +40,9 @@ func TestThunkFib(t *testing.T) {
var fib func(int) int var fib func(int) int
fib = func(n int) int { fib = func(n int) int {
if cache[n].o.IsSome() { return cache[n-1].Force() + cache[n-2].Force()
return *cache[n].o.val
}
return fib(n-1) + fib(n-2)
} }
for i := range cache { for i := range cache {
i := i i := i
cache[i] = NewThunk(func() int { return fib(i) }) cache[i] = NewThunk(func() int { return fib(i) })
@ -57,5 +54,5 @@ func TestThunkFib(t *testing.T) {
} }
func TestThunkDelay(t *testing.T) { func TestThunkDelay(t *testing.T) {
} }