foldof foldodn worls

parent cd8f2122
......@@ -63,9 +63,11 @@ Version 0.6, TODO
* minikanren full interleaving operators DONE
* functions as vectors (SWI)
* GC of multiple resetted variables PARTIAL
* persistant continuations
* persistant dynamical functions
* persistant continuations DONE
* persistant dynamical functions DONE
* interpretter stores variables at stall DONE
* Improved iterator frmework for prolog DONE
* Types and type matching DONE
* GC of the (almost) unreachable tail of a stream (all)
* Multi threading capabilities (all)
* Sandboxing (prolog)
......@@ -868,13 +868,14 @@ floor(x) (floor x)
(mk-prolog-term-3 tr-bagof bagof bagof-mac a a a)
(<define> (gen F X XX X0)
(<define> (gen update F X XX X0)
(<recur> lp ((Y X0))
(<var> (YY)
(<call> ((YY XX)) (</.> (<and> (= X Y) (F))))
(<or> <cc> (lp YY)))))
(<call> ((YY XX)) (<and> (<=> X Y) (F update)))
(<or> (<=> X YY) (lp YY))))))
(<define> (foldof-fkn0 x xx x0 update)
(<define> (foldof-fkn0 x xx x0 update lam)
(<recur> lp ((gg update) (q '()) (i 0))
(<let> ((gg (<lookup> gg)))
......@@ -893,23 +894,27 @@ floor(x) (floor x)
(lambda (x s) x)
(<lambda> () (gen gg x xx x0))
(<lambda> () (gen gg lam x xx x0))
(<define> (foldof-fkn x xx x0 update)
(foldof-fkn0 x xx x0
(</.> (goal-eval update))))
(foldof-fkn0 x xx x0 update
(<lambda> (update) (goal-eval update))))
(<define> (foldofn-fkn m x xx x0 update)
(<var> (n nn)
(foldof-fkn0 (cons n x) (cons nn xx) (cons 0 x0)
(</.> (<let> ((n (<lookup> n))
(if (= (<lookup> m) 0)
(<=> x x0)
(<var> (n nn)
(foldof-fkn0 (cons n x) (cons nn xx) (cons 0 x0)
(<lambda> (update)
(<let> ((n (<lookup> n))
(m (<lookup> m)))
(when (< n m))
(<=> nn (+ n 1))
(goal-eval update))))))
(when (< n m))
(<=> nn ,(+ n 1))
(goal-eval update)))))))
(<define-guile-log-rule> (foldof-mac x xx x0 update)
(foldof-fkn x xx x0 update))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment