i am good at the computer boxes
Signed-off-by: Xe <me@christine.website>
This commit is contained in:
parent
c8430d6081
commit
47bd09bcd2
|
@ -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) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue