This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-14
Channels
- # adventofcode (62)
- # beginners (78)
- # boot (26)
- # boot-dev (9)
- # cider (73)
- # cljs-dev (33)
- # cljsrn (36)
- # clojure (159)
- # clojure-android (1)
- # clojure-austin (1)
- # clojure-greece (79)
- # clojure-italy (10)
- # clojure-nl (3)
- # clojure-russia (11)
- # clojure-spec (33)
- # clojure-uk (26)
- # clojurescript (107)
- # core-async (22)
- # core-logic (12)
- # cursive (16)
- # datomic (13)
- # devcards (5)
- # duct (36)
- # emacs (4)
- # figwheel (3)
- # fulcro (107)
- # graphql (171)
- # hoplon (27)
- # instaparse (24)
- # jobs-discuss (34)
- # juxt (3)
- # lein-figwheel (1)
- # leiningen (8)
- # lumo (11)
- # off-topic (9)
- # onyx (79)
- # parinfer (1)
- # pedestal (75)
- # re-frame (27)
- # rum (1)
- # shadow-cljs (11)
- # spacemacs (20)
- # specter (17)
- # unrepl (96)
hi guys
for this data:
[{:s1 "cool", :p1 [{:name "hello", :sen "good"} {:name "world", :sen "nothing"}]} {:s2 "cool2", :p1 [{:name "wow", :sen "fine"} {:name "world", :sen "none"}]}][{:s1 "cool", :p1 [{:name "hello", :sen "good"} {:name "world", :sen "nothing"}]}]
i want to get only hash maps which contain :name "world" and :sen "nothing"
i have tried:
(select [ALL (selected? :p1 ALL (multi-path :token :sen) [#(= "world" (:name %)) #(= "nothing" (:sen %))])] data)
@abdullahibra (select [ALL (selected? :p1 ALL #(= (:name %) "world") #(= (:sen %) "nothing"))] data)
thanks man 🙂, your video is very worthwhile i have watched it
it's pretty out of date though, my blog post is the best introductory resource
Hi there, a question about walkers. If I have a data structure like this and I want to get all the leaves that have more than just whitespace in them, but still return the structure where they live:
(def structure [
"leaf1"
"\n"
{:contents [
{:contents ["leaf3"]}
{:contents [
{:contents [
"leaf5"
"leaf6"
"\n"]}]}
"\n"
{:contents [
"\n"
"\n"]}]}
{:contents [
"leaf2"
{:contents []}]}
"leaf4"])
So I’d hope to return a structure like this:
[
"leaf1"
{:contents [
{:contents ["leaf3"]}
{:contents [
{:contents [
"leaf5"
"leaf6"]}]}]}
{:contents ["leaf2"]}
"leaf4"]
I can get all the right leaves but not the structure with this:
(select [(walker #(and (string? %) (re-find #"\S" %)))] structure)
I thought maybe filterer
would be the right tool for this but couldn’t get it to work. Am I going about this the right way?@benstox the right approach is to do a transform
and remove elements that have whitespace
don't use walker
(def NODES
(recursive-path [] p
(continue-then-stay
(cond-path vector? [ALL p]
map? [MAP-VALS p])
)))
(defn whitespace? [s] (= "\n" s))
(setval [NODES (if-path string? whitespace? empty?)] NONE structure)
just fill in whitespace?
with a complete implementation