pythological/kanren

How to write facts based on other facts

Closed this issue · 0 comments

The following code doesn't work as expected because two invocation of Line('B', 'C') result in different goal functions.

Line = Relation()
LengthOf = Relation()

facts(LengthOf, (Line('B', 'C'), 1))
l = var()
run(1, l, LengthOf(Line('B', 'C'), l))

Though possible, the workaround is not elegant:

g = Line('B', 'C')
facts(LengthOf, (g, 1))
l = var()
run(1, l, LengthOf(g, l))

What's the best practice to state facts based on other facts?