Fork me on GitHub
#core-logic
<
2018-06-14
>
mrchance13:06:07

Is it possible to define a lookup relation for map keys, similar to (geto k m v) ? I saw that maps unify only over values, so this might be hard.

mrchance21:06:26

Okay,

(defn geto [m k v]
  (featurec m {k v}))
Seems to do the trick, at least when k really is a keyword. I don't understand why it's limited to values though

hiredman21:06:49

it is very tricky

hiredman21:06:24

if k is a key in m, and v is a value in m, and q unifies with m, what values does q have?

hiredman21:06:32

(values in the sense of, what are the possible values of q)

mrchance21:06:58

Hmm, I'd assume all values that (featurec m {k v}) produces? 😉

hiredman21:06:35

it is trivial to determine the values when keys are ground

mrchance21:06:57

What do you mean by ground?

hiredman21:06:06

a concrete value

hiredman21:06:17

a known keyword

hiredman21:06:32

(as opposed to a logic variable with an unknown value)

mrchance21:06:47

Yeah, got it

hiredman22:06:20

basically you can't use just a clojure map to represent that

hiredman22:06:52

you need some more complicated datastructure that understands unification and can do things like merge keys that are unified

hiredman22:06:25

like if you say (get m k v) (get m y x) (== y k)

mrchance22:06:47

Hm, so it would be possible, but only if I converted my maps to that richer datastructure before?

mrchance22:06:12

And I'd have to make it extend the unification protocol?

hiredman22:06:20

I am not sure

hiredman22:06:52

I feel like I was reading a paper on unifying maps recently

mrchance22:06:29

Really? Nice coincidence then 🙂

hiredman22:06:30

oh, no, it was clp(set)

hiredman22:06:40

but I think that would be really similar

hiredman22:06:56

e.g. you would represent the map as a set of k/v pairs

hiredman22:06:54

there is a scheme implementation somewhere that needs porting

mrchance22:06:31

Hm yeah, it looks like this would do it, if it were implemented, which it doesn't seem to be 😄

hiredman22:06:54

(the link to the paper is in the readme on that repo)

mrchance22:06:45

Hm, that looks more like a weekend-y kind of thing 😉

mrchance22:06:21

I wouldn't mind a simpler way to achieve my goal, which is basically have an interpreter for a very simple language

hiredman22:06:16

I think the scheme guys just use a list of pairs

mrchance22:06:36

Yeah, that might be the way to go for now

mrchance22:06:43

Thanks, I'll try that

mrchance22:06:57

Also read the paper when I have a moment, which might be a while 😉