core.logic

featurec or something similar to provide recursive partial partial map constraints

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Activity

Hide
David Nolen added a comment -

Basically, it should be ok for the `fs` argument to a be a nested map.

Show
David Nolen added a comment - Basically, it should be ok for the `fs` argument to a be a nested map.
Hide
Kevin Downey added a comment -

the following seems to be pretty close:

    (defn rfeaturec [m f]
      (let [new-f (reduce (fn [m [k v]]
                            (assoc m k (logic/lvar (name k)))) {} (seq f))]
        (logic/fresh []
          (logic/featurec m new-f)
          (fn [s]
            (logic/to-stream
              (for [[k lvar] new-f]
                ((let [v (get f k)]
                   (if (map? v)
                     (logic/fresh [x]
                       (logic/featurec m {k lvar})
                       (rfeaturec lvar v))
                     (logic/== lvar v))) s)))))))
Show
Kevin Downey added a comment - the following seems to be pretty close:
    (defn rfeaturec [m f]
      (let [new-f (reduce (fn [m [k v]]
                            (assoc m k (logic/lvar (name k)))) {} (seq f))]
        (logic/fresh []
          (logic/featurec m new-f)
          (fn [s]
            (logic/to-stream
              (for [[k lvar] new-f]
                ((let [v (get f k)]
                   (if (map? v)
                     (logic/fresh [x]
                       (logic/featurec m {k lvar})
                       (rfeaturec lvar v))
                     (logic/== lvar v))) s)))))))
Hide
Kevin Downey added a comment -

the above falls apart quickly under use, the below works well so far:

(defn rfeaturec [m f]
  (let [new-f (reduce (fn [m [k v]] (assoc m k (logic/lvar (name k)))) {} (seq f))]
    (logic/fresh []
      (logic/featurec m new-f)
      (logic/everyg
       (fn [[k lvar]]
         (let [v (get f k)]
           (if (map? v)
             (logic/fresh []
               (logic/featurec m {k lvar})
               (rfeaturec lvar v))
             (logic/== lvar v))))
       new-f))))
Show
Kevin Downey added a comment - the above falls apart quickly under use, the below works well so far:
(defn rfeaturec [m f]
  (let [new-f (reduce (fn [m [k v]] (assoc m k (logic/lvar (name k)))) {} (seq f))]
    (logic/fresh []
      (logic/featurec m new-f)
      (logic/everyg
       (fn [[k lvar]]
         (let [v (get f k)]
           (if (map? v)
             (logic/fresh []
               (logic/featurec m {k lvar})
               (rfeaturec lvar v))
             (logic/== lvar v))))
       new-f))))
Hide
David Nolen added a comment -

recursive featurec should work by recursively applying constraints like you've done but by using the lower level apis - we don't want to put the search language into a constraint.

Show
David Nolen added a comment - recursive featurec should work by recursively applying constraints like you've done but by using the lower level apis - we don't want to put the search language into a constraint.
David Nolen made changes -
Field Original Value New Value
Status Open [ 1 ] In Progress [ 3 ]
David Nolen made changes -
Resolution Completed [ 1 ]
Status In Progress [ 3 ] Resolved [ 5 ]
David Nolen made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: