Skip to content

Instantly share code, notes, and snippets.

@livecode-bot
Created June 28, 2025 07:21
Show Gist options
  • Save livecode-bot/3503ea25b364bfc58c380e5a65309146 to your computer and use it in GitHub Desktop.
Save livecode-bot/3503ea25b364bfc58c380e5a65309146 to your computer and use it in GitHub Desktop.
io.livecode.ch/learn/webyrd/webmk
(define anyo
(lambda (g)
(conde
(g)
((anyo g)))))
(fresh (x y z) (== x z) (== 3 y))
(run* (q)
(let loop ()
(conde
((== #f q))
((== #t q))
((loop)))))
(run* (q)
(conde
((anyo (== #f q)))
((== #t q))))
(run 10 (q)
(anyo
(conde
((== 1 q))
((== 2 q))
((== 3 q)))))
(run 3 (q)
(let ((nevero (anyo (== #f #t))))
(conde
((== 1 q))
(nevero)
((conde
((== 2 q))
(nevero)
((== 3 q)))))))
(run* (q) (symbolo q))
(run* (q)
(symbolo q)
(== 4 q))
(run* (q)
(symbolo q)
(numbero q))
(run* (p) (=/= p 1))
(run* (p) (=/= 1 p) (== 1 p))
(run* (q)
(fresh (p r)
(=/= '(1 2) `(,p ,r))
(== `(,p ,r) q)))
(run 1 (q) (fresh (x y z) (== x z) (== 3 y)))
(run* (q)
(fresh (p r)
(=/= '(1 2) `(,p ,r))
(== 1 p)
(== `(,p ,r) q)))
(run* (q)
(fresh (p r)
(=/= '(1 2) `(,p ,r))
(== 1 p)
(== 2 r)
(== `(,p ,r) q)))
(run* (q)
(fresh (x y)
(== `(jackal (,y leopard ,x)) q)
(absento 'panda q)))
(run* (q)
(fresh (x y)
(== `(jackal (,y leopard ,x)) q)
(absento 'panda q)
(== 'panda x)))
(run* (q)
(fresh (x y)
(== `(jackal (,y leopard ,x)) q)
(absento 'panda q)
(symbolo x)))
(run* (q)
(fresh (x y z)
(== `(jackal (,y leopard ,x)) q)
(absento 'panda q)
(symbolo x)
(== `(c ,z d) y)
(== 'panda z)))
(run 1 (q) (fresh (x y) (== x q) (== 3 y)))
(run 1 (y)
(fresh (x z)
(== x z)
(== 3 y)))
(run 1 (q)
(fresh (x z)
(== x z)
(== 3 z)
(== q x)))
(run 1 (y)
(fresh (x y)
(== 4 x)
(== x y))
(== 3 y))
(run 1 (x) (== 4 3))
(run 1 (x) (== 5 x) (== 6 x))
(run 2 (q)
(fresh (w x y)
(conde
((== `(,x ,w ,x) q)
(== y w))
((== `(,w ,x ,w) q)
(== y w)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment