This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-04
Channels
- # beginners (8)
- # boot (20)
- # cider (8)
- # cljs-dev (263)
- # cljsjs (8)
- # cljsrn (20)
- # clojure (151)
- # clojure-argentina (1)
- # clojure-belgium (7)
- # clojure-dev (18)
- # clojure-italy (25)
- # clojure-spec (34)
- # clojure-uk (15)
- # clojurescript (89)
- # component (45)
- # core-async (27)
- # cursive (16)
- # datomic (53)
- # emacs (40)
- # figwheel (3)
- # hoplon (62)
- # jobs (1)
- # jobs-discuss (7)
- # luminus (8)
- # lumo (60)
- # off-topic (3)
- # parinfer (1)
- # precept (1)
- # protorepl (15)
- # re-frame (37)
- # reagent (7)
- # ring (3)
- # ring-swagger (73)
- # slack-help (1)
- # specter (19)
- # sql (4)
- # test-check (10)
- # uncomplicate (2)
- # unrepl (14)
- # untangled (52)
- # vim (5)
- # yada (42)
Not expecting an answer today, but figured I'd put this out there since I couldn't figure it out from the wiki this weekend: is there a way to just call select
on a sequence of keys? I would expect to at least be able to do something like this unless there's a simpler way, but it returns all kv pairs: (select [ALL (fn [[k v]] (map #(= k %) [2 3]))] {1 :a, 2 :b, 3, :c, 4 :d})
I'm also wondering if, after selecting based on keys, Specter has a faster way to return just the values than val
from clojure.core?
@sophiago I think you're looking for (select [(submap [2 3]) MAP-VALS] {1 :a 2 :b 3 :c 4 :d})
or possibly (select (multi-path (keypath 2) (keypath 3)) {1 :a 2 :b 3 :c 4 :d})
Thanks for responding, Nathan! Probably the first one, unless there's a performance difference?
the latter should be faster
but the former works with a dynamic sequence of keys
yes, but that won't perform optimally at the moment
both keypath
and multi-path
are dynamic navs
you'd have to benchmark to be sure, but that would be my guess
actually
you can do this: (map #(select-any (keypath %) data) key-seq)
nevermind
if performance is critical just do (map #(get data %) key-seq)