Fork me on GitHub
#clojure
<
2017-08-19
>
seancorfield00:08:52

And #community-development is still there to discuss alternatives to Slack...

cjhowe03:08:12

is there a way to force syntax-quote to not resolve a symbol? something like

`(defui ~name static om/IQuery (query [this] '[]))

cjhowe03:08:33

so that static doesn't become my.ns/static

noisesmith03:08:44

one way to do it is ~'static

cjhowe03:08:02

that seems to work, thanks!

bbss05:08:14

why when I

(->> ["a" "b" "c"]
   (fn [coll] (nth coll 2)))
it returns an unapplied function but
(->> ["a" "b" "c"]
   (clojure.string/join))
it applies the join function?

bbss05:08:04

I run into this quite often when I want to third some collection in a this thread last macro.

bbss05:08:11

I guess it has to do with how the ->> macro resolves the fn. if I defn the third function it works.

cjhowe05:08:20

yeah, you've gotta wrap it in an extra parens

cjhowe05:08:28

(->> ["a" "b" "c"]
   ((fn [coll] (nth coll 2))))
i think

chrisjd05:08:47

->> just threads stuff into the last position of the forms. So with the second example, it just turns into (clojure.string/join ["a" "b" "c"]). If you think about the first one then, all its doing is adding more to a (fn ...) form.

bbss05:08:34

ah yes, that works. And makes perfect sense @chrisjd 🙂 thanks

yonatanel06:08:42

@baritonehands 4clojure also uses clojail and it has very fine grain restrictions for educational purposes

andrea.crotti10:08:49

given a vector like this

(def l [1 {:class "first"}
                             [2 {:class "second"}]])

andrea.crotti10:08:08

I would like to be able to add more lists inside the second nested vector

andrea.crotti10:08:16

and get something like this [1 {:class "first"} [2 {:class "second"} [["one"] ["two"]]]]

andrea.crotti10:08:26

this actually works (assoc-in l [2 2] [["one"] ["two"]])

andrea.crotti10:08:40

but I wonder if there is a better way that doesn't need to hard code indices?

nathanmarz12:08:47

@andrea.crotti with specter it's (setval [LAST AFTER-ELEM] [["one"] ["two"]] l)

nathanmarz12:08:39

will perform ~3x faster compared to assoc-in version

Takis_12:08:32

hello 🙂 i read on cascalog introduction that you can Query anything – Query HDFS data, database data, and/or local data

Takis_12:08:53

that means you can query a relational table with cascalog or any database?

nathanmarz12:08:59

@takis_ you do that by implementing cascading's "Tap" interface

nathanmarz12:08:20

depending on the db an implementation may already exist

Takis_12:08:25

i am so new that i don't understand , all i was thinking was using cascalog instead of sql, thank you

nathanmarz12:08:56

cascalog is for batch processing so isn't a drop-in replacement for sql

nathanmarz12:08:55

you could implement a special planner which incorporates the fine-grained query capabilities necessary, but afaik no one's done that yet

Takis_12:08:46

thanks alot for your time and cascalog 🙂 i will read to fully get it

pwrflx12:08:04

is it possible to get an exhaustive list of generated values by spec? similar to excercise, but give you all possible generated values. This would make sense for example for a spec that is #{:a 😛 :c}

schmee13:08:56

that is just about the only case I can think about where it is possible

schmee13:08:09

it is impossible for general fn specs

schmee13:08:22

for set specs you can use (s/form ::your-spec) to get all the values

andrea.crotti13:08:43

I don't quite get what's the desired shape for :prep-tasks in the :uberjar configuration

andrea.crotti13:08:05

it's a bit weird :prep-tasks [["protobuf" "compile"] "javac" "compile"]

andrea.crotti13:08:38

at the moment I have

:prep-tasks ["compile"
                          ["cljsbuild" "once" "min"]]
and it works to compile the js, but I have to add garden once as well now

andrea.crotti13:08:46

and can't find how I'm supposed to write it

pwrflx13:08:05

btw is it possible to share spec between clojurescript and clojure? for clojure I'm using the backported library with 1.8

schmee13:08:08

dunno off-hand, try asking in #clojure-spec 🙂

pwrflx13:08:01

@schmee is there a channel for everything? 😄

andrea.crotti14:08:12

btw answering myself this seems to work

:prep-tasks ["compile"
                          ["garden" "once"]
                          ["cljsbuild" "once" "min"]]
to compile both the js and the css

andrea.crotti14:08:27

still don't quite get what's the format it wants

andrea.crotti14:08:46

and it's quite different from that example in the lein docs, but well as long as it works 😄

noisesmith14:08:15

@andrea.crotti it accepts either a string (for a command that has no args) or a vector of strings

noisesmith14:08:21

and the whole thing should be in a vector

noisesmith14:08:09

so :prep-tasks [["compile"] ["garden" "once"] ["cljsbuild" "once" "min"]] would behave the same as what you have now

andrea.crotti14:08:27

Ah ok I get it now thanks

beoliver18:08:52

is there an accepted way of testing if a function/macro in the core namespace is side effecting?

noisesmith19:08:01

there's no reliable way to know

noisesmith19:08:26

not programmatically, that is

noisesmith19:08:14

many but not all things that are not safe in transactions have names ending in !

noisesmith19:08:50

and the thing that makes them transaction unsafe is some side effect that might be repeated (or a risk of bad state coordination)

pwrflx20:08:39

how to turn a collection into nil if it's empty, but return if it's not empty?

Lambda/Sierra20:08:22

or seq, if you want to get a sequence back

Lambda/Sierra20:08:27

you're welcome!

pwrflx21:08:53

is there some way of using spec's valid?, explain, conform, etc. with a map that contains the keys without namespace? The spec itself I've defined to accept let's say {:mypec/a "a" :myspec/b "b"}, but i have a map that has simply {:a "a" and 😛 "b"} and would like to know if it is valid or not..

pwrflx21:08:07

is that good practice at all?

pwrflx21:08:08

however, using the namespaced variants is a lot of extra typing 🙂 also, when deserializing a map from JSON, that is without a namespace by default..

pwrflx21:08:35

I see 1.9 has a convenience feature for this: https://dev.clojure.org/jira/browse/CLJ-1910

didibus22:08:09

@pwrflx there's also :req-un

didibus22:08:06

(s/keys :req-un [::a ::b])

didibus22:08:23

Stands for require unqualified

lxsameer22:08:22

is it possible to customize the way clojure printout the exceptions data ?

didibus22:08:11

Fir spec, there's explain-out

didibus22:08:37

But I'm not sure for normal exceptions