Question

This line of code:

dates (distinct (map (keyword :cobdate) data))

had to be amended to this line of code

dates (distinct (map #(get % "cobdate") data))

in order to use in the way I required

Could anyone tell me how to convert this line of code:

grouped-by-token (group-by :severity data)

in order to make the same conversion?

Était-ce utile?

La solution

The first argument to group-by is a function. :severity, in your third sample, is being used as a function, because keywords can be treated as functions: (:severity {:severity 1}) ;; => 1.

Because strings cannot be treated as functions, you must use the alternate syntax to extract the value.

grouped-by-token (group-by #(% "severity") data)


Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top