This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-19
Channels
- # aleph (8)
- # announcements (43)
- # babashka (43)
- # beginners (62)
- # calva (8)
- # cider (27)
- # clj-kondo (18)
- # cljs-dev (25)
- # cljsrn (16)
- # clojure (51)
- # clojure-europe (6)
- # clojure-nl (14)
- # clojure-spec (7)
- # clojure-uk (39)
- # clojurescript (17)
- # cursive (9)
- # datascript (12)
- # datomic (16)
- # events (1)
- # fulcro (7)
- # funcool (1)
- # graalvm (2)
- # graphql (5)
- # jobs (1)
- # juxt (6)
- # kaocha (9)
- # leiningen (11)
- # luminus (1)
- # malli (1)
- # off-topic (80)
- # other-languages (2)
- # overtone (3)
- # pedestal (5)
- # quil (1)
- # re-frame (6)
- # reagent (1)
- # reitit (4)
- # rewrite-clj (5)
- # shadow-cljs (207)
- # spacemacs (1)
- # specter (4)
- # sql (1)
- # vim (14)
- # xtdb (7)
hey everyone, working on a querying problem. It's a fun one. I have a database from which I have to make a csv slurp. the columns would be: (1) name, (2) group, (3 & ...) interests interests is a nested map {:interests {:sports {:football :tennis} :brands {:gucci :java} } }. I would like to slurp out a doc, and for the respective name, I mark in columns (3 & ...) whenever the value of a particular interest is true.
an example slurp
an idea would be to to string and interpose (str name ", " group ", " some kind of loop here marking true for the interests)
What database, and what format are the columns?
double checking now, i think it's firebase.
thanks for the help, i really appreciate it.
(and you say "make a csv slurp" but do you mean produce a CSV file from the database?)
yes, I am trying to produce it from the database, via slurping into a .csv
@ablazevix Is :interest
's value always exactly two levels deep? And you want to "throw away" the middle level (`:sports`, :brands
)?
No, it varies largely. Preferably would like to, yes.
@ablazevix How you turn that structure into flat columns with true/false is going to depend pretty critically on the structure of that data...
@U04V70XH6 Would you mind explaining the different structures there are.. sorry I am an intern with little CS background.
I just mean that if your interests
value has a whole bunch of different shapes, you need to know what those shapes can be in order to turn that into a flat set of true/false columns.
@ablazevix for a two-level map like that:
user=> (def interests {:sports [:football :tennis] :brands [:gucci :java]})
#'user/interests
user=> (zipmap (mapcat val interests) (repeat true))
{:football true, :tennis true, :gucci true, :java true}
user=>
That will only work for two levels where you are throwing away the top level.that actually would work perfectly. the depth is double, but there might be more values under the specific interests i.e. there might 7 sports, but only 5 brands.
Size won't matter in this case.
(mapcat val interests)
throws away the top level keys and con`cat`enates all the values from those keys.
wow... don't you just love clojure.. I am so thankful for finding it so early on.. it's taught me a lot of good basics
I've been programming professionally for 35+ years and I've been doing Clojure for the last 8, nearly 9, of them -- and I'm the happiest I've ever been writing software!
yea, i don't blame you.. rich hickeys charm can do that to ya
maybe a slightly harder version of the previous problem -- what if we wanted to slurp it out this way
we would have (1 group, 2 & .. Interests, with mappings of people in interests. sound computationally expensive haha!)
maybe a slightly harder version of the previous problem -- what if we wanted to slurp it out this way
@ablazevix That would just be (zipmap (mapcat val interests) (repeat (:name row)))
The main issue you'll have here is that for the CSV file you'll need the union of all the interests across all rows so you know which columns to use as headers, and then you'd need to inflate each row to have blanks/`nil` for the "missing" columns for a given row..
Hi, I'm trying to use luminus +boot +hoplon and can't understand how to get it to work correctly with cider. Does anyone has an experience with it?
Well, running boot figwheel repl results in this error, however, a repl does seem to start and I can connect to it with Cider, but when I connect to it It seems broken, no autocompletion, and a lot of ClassNotFound exceptions when I try to evaluate functions
The first error is "Address already in use". The second error looks like you did (in-ns foo)
before foo was loaded or required
the symptom being that it appears clojure.core is not loaded and it doesn't know what +
is
Looks like what I was trying to do was needed for starting the app from within the repl, But I feel I need to do some homework, I wasn't requiring things properly, now I get it to work better, But I still need to understand figwheel better
I'd take care of the "address already in use", I guess you are somehow running two instances of a server
Also, the clojure repl is "mutable", meaning you can only call functions that have been defined (evaluated), and you can only reference namespaces that have been loaded
I normally eval the whole namespace (if it's compilable) and then evaluate each function that I want to (re)write so the repl gets the updated version
Thanks @mping,I'm trying to evaluate the projects core, and it looks like there is a problem locating env
Not sure if this is the correct place, so sorry if not! Does anyone have any resources to help advocate for clojure in their place of employment? A few teams are still on Java, others C# (mostly business dev and linear broadcast teams), but most are python, node.js, or golang.
Hackatons are usually a good time to just do something in Clojure and win their hearts 😉
@U2J4FRT2T one day I'd like for WarnerMedia to be listed there
Hello everyone, I have some functions that are kind of tricky to manually fix (they need to preprocess their input in some specific ways). I am working on a macro to aid in making the changes easier to implement. I've got a working prototype of what I want, but there is a tiny bit of syntax that I would like to improve. I've got this:
(defn fix-input
[input]
(println "fixing input")
input)
(defmacro def-fixed
[symbol attr-map body]
`(def ~(with-meta symbol attr-map)
(comp ~body fix-input)))
(def-fixed funky
{:some-meta true}
(fn [x] (inc x)))
(funky 5)
(meta #'funky)
But I would like to have the syntax be like this:
(def-fixed funky
{:some-meta true}
[x]
(inc x))
So that I have a syntax more similar to defn
. How could I achieve this?(defmacro def-fixed
[symbol attr-map arglist & body]
`(def ~(with-meta symbol attr-map)
(comp (fn ~arglist [email protected]) fix-input)))
#'user/def-fixed
(cmd)user=> (macroexpand '(def-fixed funky {:some-meta true} [x] (inc x)))
(def funky (clojure.core/comp (clojure.core/fn [x] (inc x)) user/fix-input))
@diego.vid.eco I think that's the specific input and expansion you want
exposing the metadata
user=> (binding [*print-meta* true] (pr-str (macroexpand '(def-fixed funky {:some-meta true} [x] (inc x)))))
"(def ^{:some-meta true} funky (clojure.core/comp (clojure.core/fn [x] ^{:line 1, :column 91} (inc x)) user/fix-input))"
thanks a lot @noisesmith
the only tricks were using & foo
in order to allow arbitrary forms in the emitted function, and explicitly binding then templating an arglist
the &
isn't strictly needed, but makes it act like most other functions that allow a body argument