Fork me on GitHub
#specter
<
2017-01-24
>
Busy escaping the comfort zone01:01:41

Hey, I'm looking for a way to replace a single nested value {:one #{:two}} with a splattered list of values {:one #{1 2 3 4}} using transform

Busy escaping the comfort zone01:01:05

Not sure if thats possible

james07:01:58

@narkisr How about setval?

james07:01:14

(setval [:one] #{1 2 3 4} {:one #{:two}})
> {:one #{1 4 3 2}}

Busy escaping the comfort zone08:01:41

Hey James, I need the to be a result of a function call (transformation) and not a static value like in setval

james09:01:49

@narkisr

(transform [:one] (constantly #{1 2 3 4}) {:one #{:two}})

james09:01:52

Does that help?

Busy escaping the comfort zone12:01:53

So In my case I'm transforming the keys into a list of vectors for example (tranform [:one :two] (fn [_] [[1 2] [3 4]]) {:one #{:two}}) I would like to get {:one #{[1 2] [3 4]}}

Busy escaping the comfort zone12:01:13

And not {:one #{[[1 2] [3 4]]}}

Busy escaping the comfort zone12:01:28

Its looks like partial flatten but I didn't manage to come without any working example

nathanmarz13:01:00

@narkisr I think you're looking for this: (transform [:one (subset #{:two})] (fn [_] #{[1 2] [3 4]}) {:one #{two}})

james13:01:27

@narkisr Do you actually want the inner data structure to be a set? Because you’re trying to access it like a hashmap (with a keyword), and talking about “transforming keys".

Busy escaping the comfort zone14:01:23

The actual code contains a hash which values are days like :sunday which I want so substitute for all the Sundays within a month (so you get multiple values out from a single value)

Busy escaping the comfort zone14:01:04

A set matches this use since the values are always unique

Busy escaping the comfort zone14:01:01

Thanks Natan ill give it a go

Busy escaping the comfort zone14:01:04

for example {:foo #{:sunday}} => {:foo #{[1 1] [8 1] [15 1] [22 1] [29 1]}

Busy escaping the comfort zone14:01:25

all the Sundays in Jan 2017