summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-02-03 14:23:17 -0800
committerKaz Kylheku <kaz@kylheku.com>2022-02-03 14:23:17 -0800
commit8bb8739fb9f641f39481c12c9ea9bc96762bbae4 (patch)
treeb50cb520a76bab258e38bc27b9b8d60c6839148a
parent61525817e020c293f9626d836b8250191b019236 (diff)
downloadtxr-8bb8739fb9f641f39481c12c9ea9bc96762bbae4.tar.gz
txr-8bb8739fb9f641f39481c12c9ea9bc96762bbae4.tar.bz2
txr-8bb8739fb9f641f39481c12c9ea9bc96762bbae4.zip
doc: fix in amb macro.
* txr.1: when the amb macro detects that the continuation has succeeded, it should return that successful value from the amb-scope, rather than returning the local successful argument a from the amb function. Although it works both ways, it is inefficient when it returns from the function. The reason is that each call to amb executes the successful future twice: once via (call cont a) and then again by returning the a value. This then causes an exponential cascade in calls: each successive amb call sthe successful future twice, so for instance if the solution has a sequence of 8 amb calls, the successful case is reached 256 times.
-rw-r--r--txr.15
1 files changed, 3 insertions, 2 deletions
diff --git a/txr.1 b/txr.1
index fcf6ce6b..68582448 100644
--- a/txr.1
+++ b/txr.1
@@ -52008,8 +52008,9 @@ and
(defun amb (. args)
(suspend amb-scope cont
(each ((a args))
- (when (and a (call cont a))
- (return-from amb a)))))
+ (if a
+ (iflet ((r (call cont a)))
+ (return-from amb-scope r))))))
.brev
Use