Fork me on GitHub
#clojure
<
2016-06-08
>
sparkofreason03:06:51

@gfredericks: splittable random number stuff is going to work out well for us. Also considerably faster than the Mersenne twister algo we had been using. Thanks for the tip.

gfredericks03:06:17

dave.dixon: np; are you just using the one in test.check?

escherize05:06:46

Should destructure throw when it gets collisions between :keys, :strs, and :syms?

escherize05:06:49

(let [{:strs [a b c] :keys [a b c] :syms [a b c]} 
      {:a 1 "a" 2 'a 3 
       :b 10 "b" 20 'b 30 
       :c 100 "c" 200 'c 300}]
  [a b c])
;;=> [3 30 300]

bcbradley07:06:40

can you bind a keyword like :keys in a map?

bcbradley07:06:46

{:keys #{home-key car-key garage-key work-key}}

bcbradley07:06:54

i mean if you did, how would you destructure it?

meowy09:06:40

@bcbradley:

(let [{:keys [keys]} {:keys "meow"}] (println keys))
meow

meowy09:06:55

Works just fine!

jannis13:06:43

Are there any circumstances under which (name :my.ns/foo) would return nil if the input is a regular fully-qualified, namespaced keyword? I get this behavior in a sofware of mine and it puzzles me.

jannis13:06:49

Especially since (namespace :my.ns/foo) returns "my.ns".

jannis13:06:03

Oh. Name shadowing. Doh.

Alex Miller (Clojure team)13:06:29

also (namespace (keyword nil "my.ns/foo"))

Alex Miller (Clojure team)13:06:20

oh, you were asking about name, so no then :)

bronsa13:06:17

name can never return nil

gborghi14:06:29

dear all, I am trying to load an external namespace, stored in a file, into my repl

gborghi14:06:03

but an error message tells me the file is not in my classpath

gborghi14:06:27

how do I update my classpath (and how do I understand which is my classpath)?

arkh14:06:40

gborghi: are you using leiningen for your project?

arkh14:06:23

if you are you can do a 'lein install' from the other project / namespace to make it available to your other projects

arkh14:06:40

alternatively, you can place code in primary project's lib directory which is part of the leiningen managed classpath

gborghi14:06:52

ok, in lib, not src

gborghi14:06:34

ok thanks, now it finds the file of my namespace

gborghi14:06:14

but it fails to find a :use I am calling from my file snake.clj (which is the one I have just put into lib)

gborghi14:06:16

:use examples.import-static

gborghi14:06:37

though I copied the directory examples (which contains import-static.clj) into my lib

arkh14:06:24

can you jar up your other project so it's dependencies are collected?

gborghi14:06:09

sorry my being dumb, but what to you mean by "jar up"?

arkh14:06:40

in your other project you could do a 'lein jar'

gborghi14:06:25

I did that

arkh14:06:05

and then if you copy the generated jar over to your primary project lib directory, does that work?

arkh14:06:47

I'd recommend 'lein install' from the dependent project over this process, though

arkh14:06:14

the only caveat is you'll need to run 'lein install' from the dependent project any time you make a code change

arkh14:06:42

(any time there's a code change in the dependent project, not your primary project)

gborghi14:06:57

so, I copied the .jar of the project (containing the examples directory) to the lib of my primary project

gborghi14:06:03

which arguments should I suppy to "lein install"?

gborghi14:06:50

thank you!

arkh14:06:51

it's very thorough and covers lein install as well as 'checkouts'

arkh14:06:10

er .. checkout dependencies

mj_langford15:06:01

Someone posted something on the web that explained the different position of the collection in calls like (get col key) vs (map fn col). Do you know what the resource is that explained that, or does someone have a easy to communicate rule in their head about it

mj_langford15:06:13

(i.e. why the col position is sometimes first, and sometimes last)

Alex Miller (Clojure team)15:06:26

I go over this in Clojure Applied

Alex Miller (Clojure team)15:06:54

in collection functions (take a coll / return a coll), the coll goes first

Alex Miller (Clojure team)15:06:01

you are operating a data structure and returning it

Alex Miller (Clojure team)15:06:18

in sequence functions (take a seqable / return a seqable), the seqable goes last

Alex Miller (Clojure team)15:06:36

collection functions chain well with ->, sequence functions chain well with ->>

mj_langford15:06:07

that’s where I read it!

Alex Miller (Clojure team)15:06:36

you can extend the collection analogy even to things like clojure.string where the string is the "collection" and in almost every case goes first

Alex Miller (Clojure team)15:06:48

except for a few places where something else goes first to enable partial-ing

arkh15:06:06

Clojure Applied looks good - buying it. : )

Alex Miller (Clojure team)15:06:38

they make great holiday gifts - I recommend buying 10-15 at a time

bostonaholic16:06:03

@arkh: Clojure Applied is very good. I go through it with a highlighter so I can reference patterns in the future. I also have been refactoring existing code after “AH HA” moments from the book.

erichmond16:06:32

Are people still using transit?

arkh16:06:54

libraries I use use transit

erichmond16:06:06

thanks, I assumed so. we’re starting our first cljs <-> clj app, so I was curious if others were still using it

shaunxcode17:06:12

to be clear, http://dev.clojure.org/jira/browse/CLJ-1910 will require changes to the edn-format right? To indicate that there are new built in tagged elements?

Alex Miller (Clojure team)17:06:21

yes, 1910 will carry over to edn

mike_ananev17:06:49

Hello all! Is there any library to make queries (a la select) to clojure data strucutres? (nested maps, vectors...)

fenton18:06:40

trying to use the new specs with alpha5, but am getting error that spec is undefined?

fenton18:06:31

i had it over-ridden in ~/.lein/profiles.clj ! doh!

mateus.henrique.brum18:06:02

Hey guys, I am curious about some techniques you use to achieve a good design in clojure and TDD, someone has a good resource of knowledge for this ?

mateus.henrique.brum20:06:46

@hrathod: Thansk man, this is a good things.

mateus.henrique.brum20:06:35

But do you know something about TTD, some videos, some patterns to implement a more expressive test and program in clojure ?

hrathod22:06:32

@mbrum: Unfortunately, I do not. Google seems to have some good results, though

lvh22:06:05

Huh; is ^”[B” a valid alternative to ^bytes from the compiler’s POV? as in:

(defn ^"[B” some-fn

aengelberg22:06:20

@lvh yes

user> (Class/forName "[B")
[B

aengelberg22:06:33

user> (set! *warn-on-reflection* true)
true
user> (fn [b] (String. b))
Reflection warning, *cider-repl staging-service*:63:14 - call to java.lang.String ctor can't be resolved.
#function[user/eval48179/fn--48180]
user> (fn [^bytes b] (String. b))
#function[user/eval48183/fn--48184]
user> (fn [^"[B" b] (String. b))
#function[user/eval48189/fn--48190]

lvh22:06:45

Heh, I guess I could just have tried that 🙂

lvh22:06:56

that seems, uh, weird. maybe it’s vestigial?

lvh22:06:58

either way, cool

deactivateduser22:06:08

JVM internals leaking out?

lvh22:06:33

I know that [B is the JVM name for a byte array; I guess I was just surprised that it worked as a tag

lvh22:06:00

I originally wanted reflection-free dispatch for caesium but it looks like that’s not happening unless I write some java; so I might as well settle on a consistent-but-easy interface that converts to ByteBuffer (since that seems to be the obvious lingua franca) and then have specialized APIs that don’t dispatch

aengelberg22:06:13

have you looked at ztellman/byte-streams?

dg22:06:14

can anyone remind me how to modify the results of (s/conform (s/or :kw keyword? :uuid uuid?) :something) so it returns only the value and not the label?

dg22:06:27

I know I read this somewhere but I can't figure out the right thing to search for

lvh22:06:34

aengelberg: That’s where I got that code from

lvh22:06:57

aengelberg: (byte-streams still does dispatch though)

lvh22:06:52

(specifically, it’ll switch on type; so I’m just trading in finding the right method to call on my libffi binding)

lvh22:06:23

Maybe that is what I want I suppose, assuming I can consistently discern the right length from the bytebuffer (or expose an API that lets you specify it)

nwjsmith22:06:09

@dg: I think all matches must have be labeled, I don't think there's a way around it.

dg23:06:47

I'd swear I read something in an article where you could apply a function to the result before it's returned, and there was a warning to be careful about doing that

dg23:06:50

Maybe I'm crazy

danielcompton23:06:27

@dg that’s in the tutorial somewhere I think

nwjsmith23:06:42

clojure.spec/conformer will let you provide your own conforming function for a spec.