summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-07-30 07:53:11 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-07-30 07:53:11 -0700
commitf22d21584b60d643e1c91d262a81af0cfb8ae9ed (patch)
tree1866b0183da0345d36504ae09ed0598e6c127bfa
parent6af9d73cff08f8324b0eb612b9befba6fe64e6da (diff)
downloadtxr-f22d21584b60d643e1c91d262a81af0cfb8ae9ed.tar.gz
txr-f22d21584b60d643e1c91d262a81af0cfb8ae9ed.tar.bz2
txr-f22d21584b60d643e1c91d262a81af0cfb8ae9ed.zip
tests: multiple evaluation issue in amb.
This issue doesn't affect the tests. This is for the benefit of someone who happens to be copy-and-pasting the amb implementation from here. * tests/012/cont.tl (amb): This function has an issue in that it calls the continuation (future calculation) and then if that succeeds, it normally returns the value. This means that the future is executed again. In the case of N amb expressions, the successful future is executed 2**N times. What amb must do is this: call the continuation and capture the value. If the value is successful, then that is the master return value; just return that from amb-scope, bypassing the second re-execution of the future.
-rw-r--r--tests/012/cont.tl4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/012/cont.tl b/tests/012/cont.tl
index 1d79b37b..b89b1502 100644
--- a/tests/012/cont.tl
+++ b/tests/012/cont.tl
@@ -24,8 +24,8 @@
(defun amb (. args)
(suspend amb-scope cont
(each ((a args))
- (when (and a (call cont a))
- (return-from amb a)))))
+ (whenlet ((res (and a (call cont a))))
+ (return-from amb-scope res)))))
(test (amb-scope
(let ((w1 (amb "the" "that" "a"))