Fork me on GitHub
#core-logic
<
2018-11-27
>
schmee06:11:21

here’s the actual thing:

(run* [q]
    (init vars legs)
    (with-fresh
      (membero ?1 vars)
      (membero ?2 vars)
      (membero ?3 vars)
      (membero ?4 vars)
      (== ?1 ["M" ?a1 ?b1])
      (== ?2 ["T" ?a2 ?b2])
      (== ?3 ["W" ?a3 ?b3])
      (== ?4 ["R" ?a4 ?b4])
      (== ?b1 ?a2)
      (== ?b2 ?a3)
      (== ?b3 ?a4)
      (== q [?1 ?2 ?3 ?4]))))

schmee06:11:47

vars is a collection of tuples like this: ["M" "SAN_ANTONIO" "HOUSTON"] (day of week, start, end)

schmee06:11:19

I’m messing around with a core.logic solution to https://kevinlynagh.com/notes/shipping-puzzle/

schmee06:11:08

but running the above with just 100 tuples take 15 minutes to produce one result

schmee06:11:31

(`with-fresh` just binds all ? variables to a fresh lvar)

norman19:11:02

How much faster does it go if you move the memberos to the end?