HI, I'm looking for functionality like the "featurec" function, but I need 
to be able to capture the unused keys.

Here is how "featurec" currently works:

      (run* [q]
           (== q {:a 1 :b 2})
           (featurec q {:b 2})))
      ==> ({:a 1 :b 2})

However, I need to capture the keys that a not part of the "feature 
requirement". It seems this could be handled via another parameter to 
featurec (or via an extra, similar command) What I want to be able to write 
is something like this:

      (run* [q p]
           (== q {:a 1 :b 2})
           (my-featurec q {:b 2} p)))
      ==> ([{:a 1 :b 2} {:a 1}])

In this case, it puts all kv pairs not in the feature check (in this case 
just ":a 1") in a separate variable.

Is there any other way I can achieve this functionality? Is this a command 
that would be valuable for me to write/issue a pull request for? I don't 
know core.logic well enough to know whether this is a worthwhile endeavor.

RATIONALE
      
Since the likely next question will be "why do you need to do this?", let 
me explain the problem I'm trying to solve... I'm creating a DSL that can 
operate against nested maps to perform transformations. A simple example of 
the DSL would look something like this:

{:b ?x & ?y} --> {:b 77 & ?y}

So this statement would say "Find the value assigned to the key ':b' and 
overwrite it with '77' - Leave the rest of the map unchanged". The part at 
the end "& ?y" grabs all remaining kv pairs (Or "reconstitutes" them, in 
the second "results" map). For instance, if you applied this rule against 
the following:

{:a 3 :b 4 :c 5}

It would return this:

{:a 3 :b 77 :c 5}

Anyway, thanks for any pointers!

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to