I can't tell if I'm being silly, but I'm having issues figuring out how to record the results of my computation in Core.Logic.
The basic idea is that I'm trying to determine if a schedule a user has requested is solvable or not. I'm trying to find out how to assign to each hash-map what resource I determined can be used for it. The following case is simplistic, but I need to get this code working before attempting to generalize what the user has requested.
(defn solve [types reservations]
(let [reservations (map #(assoc % :assigned-resource (l/lvar)) reservations)
resources (flatten (map :resources types))
vars (repeatedly (count reservations) l/lvar)
resource-vars (take (count by-resource) vars)
]
(l/run 1 [q]
(l/== q vars)
;;
(l/everyg #(l/membero % reservations) resource-vars)
(l/everyg #(l/fresh [resource]
(l/membero resource resources)
(l/== % (l/partial-map {:resource resource}))
;; Somehow assign resource to :assigned-resource here.
)
resource-vars)
(l/distincto resource-vars)
)))