jsonnet-microkanren

microKanren implementation in Jsonnet
git clone https://ccx.te2000.cz/git/jsonnet-microkanren
Log | Files | Refs

commit de43064245bd0ce3ea1f51019921abbef8c46b2d
parent 2866b340daec3a4dbf5570f205adabbceaeab701
Author: Jan Pobříslo <ccx@te2000.cz>
Date:   Wed, 29 Nov 2023 17:13:00 +0000

Fix runWithVars()

Diffstat:
Mexample.jsonnet | 11++++++-----
Mmicrokanren.libsonnet | 2+-
2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/example.jsonnet b/example.jsonnet @@ -10,17 +10,18 @@ local uKc = import 'microkanren_checks.libsonnet'; assert uKc.Stream(stream); stream.takeAll(), - anotherFive: uK.runSingleVar(function(q) uK.eq(q, 5)), + reifiedFive: uK.runSingleVar(function(q) uK.eq(q, 5)), a_and_b: uK.takeAll(uK.conj( uK.callFresh(function(a) ['eq', a, 7]), uK.callFresh(function(b) ['or', b.eq(5), ['eq', b, 6]]), )), -/* - another_a_and_b: uK.runWithVars(['a', 'b'], function(vars) - ['and', ['eq', vars.a, 7], ['or', vars.b.eq(5), ['eq', vars.b, 6]]] + reified_a_and_b: uK.runWithVars(['a', 'b'], function(vars) + ['and', + ['eq', vars.a, 7], + ['or', vars.b.eq(5), ['eq', vars.b, 6]], + ] ), - */ } // vim: sts=2 ts=2 sw=2 et diff --git a/microkanren.libsonnet b/microkanren.libsonnet @@ -288,7 +288,7 @@ local runWithVars(variableNames, func, count=null, state=null) = function(curr, name) local fresh = makeFreshVariable(curr.state); { - state: curr.state, + state: fresh.state, vars: curr.vars + {[name]: fresh.variable}, }, variableNames,