#clojure log - Nov 29 2014

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:46 kenrestivo: what would be the right clojure data structure to use, for a sliding buffer queue, where i want to look at the last 2 items every time something new is added?

0:47 was originally going to use core.async sliding-buffer, but it's not quite right

0:49 and i'd like to stay in the safe confines of clojure-land instead of having to read jcip

1:23 DrCherry: clojure n00b question. Trying to read some data from a txt file into some kind of data structure. anyone around to give me a starting point?

1:24 andyf: kenrestivo: It doesn't have the nicest Clojure-y API, but Clojure does have queues

1:25 DrCherry: the data looks like this: http://pastebin.com/M9MHyBVc

1:25 I'm exploring StructMaps and records which seem like black magick.

1:26 the data will ultimately be consumed by Factual/geo functions as polygons.

1:27 andyf: DrCherry: Clojure maps are nice and generic.

1:28 They take up more memory than something customized, but if the data set doesn't stress the memory you have available ...

1:28 DrCherry: looking into maps now.

1:29 thx, I thought this part would be trivial, lol.

4:11 hellofunk: is the "g" in leiningen pronounced like "good" or like "giraffe" ?

4:12 _segfault: hellofunk: giraffe

4:12 hellofunk: thanks. i've been doing it wrong.

4:28 rritoch: Is there any way to get the unicode integer value of a character directly without converting it into a string? Character/getNumericValue doesn't seem to work

4:29 ,(map #(.getCodePointAt (str %) 0) "\u04D21234")

4:29 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: getCodePointAt for class java.lang.String>

4:29 rritoch: ,(map #(.codePointAt (str %) 0) "\u04D21234")

4:29 clojurebot: (1234 49 50 51 52)

4:29 rritoch: Tjat

4:29 That is the output I'm expecting

4:30 SagiCZ1: and the char is not originally part of a string?

4:31 rritoch: SagiCZ1: It is part of a string, but I need the values of each character, this is for a cryptography function

4:31 ,(map #(Character/getNumericValue %) "\u04D21234")

4:31 clojurebot: (-1 1 2 3 4)

4:32 rritoch: As far as I can tell from the documentation, this getNumericValueshould work, but it isn't returning the correccct values

4:38 I finally found a solution :)

4:38 TEttinger: ,"\u04D2"

4:38 clojurebot: "Ӓ"

4:38 rritoch: ,(map int "\u04D21234")

4:38 clojurebot: (1234 49 50 51 52)

4:38 TEttinger: heh yep

4:38 rritoch: Apparently int does it automatically :)

4:40 TEttinger: ,(map int "int")

4:40 clojurebot: (105 110 65279 116)

4:40 TEttinger: ,[(count "int") (count "int")]

4:40 clojurebot: [4 3]

4:41 rritoch: ?

4:41 Did you find a bug or are you using characters that require 32 bits to represent?

4:41 hellofunk: in emacs, does anyone know how to interrupt/break a running REPL command? I know you can do this in Eclipse with CCW using the "interrupt" feature, but I've never done that successfully in emacs and usually have to restart the REPL.

4:43 mavbozo: hellofunk: cider-interrupt

4:43 hellofunk: mavbozo thanks

4:49 TEttinger: rritoch, invisible chars

4:49 ,(char (int \ufeff))

4:49 clojurebot: \

4:51 TEttinger: rritoch: ##(Character/getNumericValue \百)

4:51 lazybot: ⇒ -1

4:52 TEttinger: aww

4:52 rritoch: Yeah, I have no idea what getNumericValue is supposed to be doing

4:52 TEttinger: ##(Character/getNumericValue \2)

4:52 lazybot: ⇒ 2

4:52 TEttinger: ##(int \2)

4:52 lazybot: ⇒ 50

4:53 TEttinger: see the difference?

4:53 rritoch: ,(Character/getNumericValue \A)

4:53 clojurebot: 10

4:53 TEttinger: geNumericValue converts a char that represents a digit to the int value of that digit

4:53 rritoch: ,(Character/getNumericValue \a)

4:53 clojurebot: 10

4:53 TEttinger: ,(Character/getNumericValue \z)

4:53 clojurebot: 35

4:53 rritoch: Aaah

4:54 TEttinger: base 36 there

4:54 it returns -1 if it can't figure out what base it should use or whatever

4:55 you can specify radix in clojure numbers, which is ##(+ 36rCOOL 36rSTUFF)

4:55 lazybot: ⇒ 49013568

5:12 rritoch: Thats cool, I try to avoid using anything other than base 10 in code, but there are probably some cases where it will help make code more readable when dealing with bitwise operations.

5:13 SagiCZ1: ,(Character/getNumericValue \ť)

5:13 clojurebot: -1

5:48 SagiCZ1: when i have a collection, how can i remove some elements?

5:48 [:a :b :a :c :d :b] --> remove :a :b --> [:c :d]

5:48 im not sure if is should make it into a set first

5:50 yeah i guess i will use set and disj

5:50 thanks

5:52 ucb: SagiCZ1: alternatively you can filter the collection

5:53 SagiCZ1: ucb: but that would still remove everything, not just the first occurence, so it has the same effect as disjoining set

5:53 ucb: you never said you wanted to remove just the first occurrence ^_^

5:54 SagiCZ1: ucb: i know.. i am not sure whether i want it or not :)

5:54 ucb: I was mentioning filter in case you don't want to turn your original collection into a set

5:55 but in any case you could do something like (filter (complement #{:a :b}) [:a :b :c :d])

5:55 ,(filter (complement #{:a :b}) [:a :b :c :d])

5:55 clojurebot: (:c :d)

5:55 SagiCZ1: ,(remove #{:a :b} [:a :b :c :d])

5:55 clojurebot: (:c :d)

5:55 ucb: heh

5:55 YES

5:55 SagiCZ1: good idea with the predicate

5:55 very concise

5:55 ucb: didn't know remove existed :)

6:29 SagiCZ1: ,(= (new JFrame) (JFrame.))

6:29 clojurebot: #<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: JFrame, compiling:(NO_SOURCE_PATH:0:0)>

6:30 SagiCZ1: ,(= (new String) (String.))

6:30 clojurebot: true

6:46 jonathanj: could someone explain the reasoning behind writing HTML in a Lisp DSL (ala hiccup etc) instead of serving an HTML file?

6:49 geekyvin: Hi Everyone, I am new to clojure and I'm stuck with a small problem.Any help will be appreciated than you. I have a list of map say, [{:name Tom :child {:name Mark :child{:name Jimmy}} } {:name Ben :child {:name John}} {:name Tom :child {:name Lucy}}] it should be converted to something like [{:name Tom :child [{:name Mark :child {:name Jimmy}} {:name Lucy}]} {:name Ben :child [{:name John}] }]

6:49 I tried a few methods unsuccessfully...could anyone kindly help.

6:50 SagiCZ1: geekyvin: hi, i remember you from yesterday

6:50 geekyvin: yeah...I am still stuck I could not find any significant suggestion yesterday :(

6:51 SagiCZ1: it would be better if you could specify the problem more than with just one example

6:52 geekyvin: basically I have a list of hash-map with nested children I need to merge them but instead of replacing the values for a given key I want it to be added to the existing value

6:53 SagiCZ1: geekyvin: let me look into it, but it might take a long time

6:54 geekyvin: no problem, thanks :)

6:56 rritoch: SagiCZ1: When using comparables you should use compare instead of =, I had a hard time finding a good example but the following seems to show this fairly clearly

6:56 ,(= (reify Comparable (compareTo [this x] 0)) (reify Comparable (compareTo [this x] 0)))

6:56 clojurebot: false

6:57 rritoch: ,(compare (reify Comparable (compareTo [this x] 0)) (reify Comparable (compareTo [this x] 0)))

6:57 clojurebot: 0

6:58 SagiCZ1: geekyvin: are the names like Tom and Mark variables?

6:58 geekyvin: no they are values

6:58 SagiCZ1: geekyvin: values? containing what?

6:59 they have to be either strings or symbols

6:59 this is invalid

6:59 ,{:name Tom :child nil}

6:59 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: Tom in this context, compiling:(NO_SOURCE_PATH:0:0)>

6:59 geekyvin: string values

6:59 SagiCZ1: why do you missing the quotes then?

6:59 ,{:name "Tom" :child nil}

6:59 clojurebot: {:name "Tom", :child nil}

6:59 geekyvin: there should be quotes its just a example.

6:59 SagiCZ1: alright

7:03 geekyvin: sorry i cant wrap my brain around it

7:05 geekyvin: @SagiCZ1: which part? may be I can elaborate.

7:06 SagiCZ1: geekyvin: i think i understand what you need, but i dont think i am able to code it

7:07 geekyvin: @SagiCZ1: thats ok. I appreciate the effort. thank you :)

7:07 alhimik45: hi! what mean #_ here: https://github.com/clojure/clojure/blob/clojure-1.6.0/src/clj/clojure/core.clj#L3044

7:07 SagiCZ1: alhimik45: it comments out the whole sexp

7:08 forcing the reader to skip it entirely

7:09 alhimik45: SagiCZ1: thanks!

7:11 SagiCZ1: alhimik45: np

7:31 rritoch: geekyvin: You should be able to achieve the results you want with reduce. I have a solution but I'm not sure if the line is too long to paste here, working on a reduction of it now

7:36 ,(def data [{:name "Tom" :child {:name "Mark" :child {:name "Jimmy"}}} {:name "Ben" :child {:name "John"}} {:name "Tom" :child {:name "Lucy"}}])

7:36 clojurebot: #'sandbox/data

7:36 rritoch: ,(reduce (fn [f s] (if-let [p1 (first(filter(partial (fn [p1 p2] (= (:name p1) (:name p2)))s)f))] (conj(filterv(partial (fn [p1 p2] (not= (:name p1) (:name p2))) s)f) (if (and (:child p1) (:child s)) (assoc p1 :child (conj(conj [] (:child p1)) (:child s)))p1)) (conj f s))) [] data)

7:36 clojurebot: [{:name "Ben", :child {:name "John"}} {:name "Tom", :child [{:name "Mark", :child {:name "Jimmy"}} {:name "Lucy"}]}]

7:39 rritoch: geekyvin: You may need to modify this a bit to more generically deal with child values, but it takes conditional logic to turn single items into lists when combined, and leave them singular otherwise.

8:01 geekyvin: Here is a better version that's less order dependent

8:01 ,(def data [{:name "Tom" :child {:name "Mark" :child {:name "Jimmy"}}} {:name "Ben" :child {:name "John"}} {:name "Tom" :child {:name "Lucy"}}])

8:01 clojurebot: #'sandbox/data

8:01 rritoch: ,(reduce (fn [f s] (if-let [p1 (first(filter(partial (fn [p1 p2] (= (:name p1) (:name p2)))s)f))] (conj(filterv(partial (fn [p1 p2] (not= (:name p1) (:name p2))) s)f) (if (and (:child p1) (:child s)) (assoc p1 :child (conj(conj [] (:child p1)) (:child s))) (if (or (:child p1) (:child s))(assoc p1 :child (or (:child p1) (:child s)))p1))) (conj f s))) [] data)

8:01 clojurebot: [{:name "Ben", :child {:name "John"}} {:name "Tom", :child [{:name "Mark", :child {:name "Jimmy"}} {:name "Lucy"}]}]

8:13 OscarZ: i was reading up on core.async.. was wondering would it be good practice to try to implement a web server on core.async ?

8:17 im not sure if i understood it right.. but is it good for the kind of stuff that in javascript you use promise api for? like on a web server i have a http request, then i want to start 3 async calls to get some results, and when all of the results are ready, then do some next thing etc. ?

8:18 but with core.async, theres no callbacks like in nodejs

8:37 alhimik45: I have clojurescript and clojure code in my project. I have constants which I want to use at clojure and clojurescript side, but I don't want to copy-paste it. How to me require this file in clj and cljs file? http://code.re/6T1

8:43 annelies: gfredericks: in your Deutsch–Jozsa example shouldn't you be observing output instead of (first inputs)?

8:44 You don't do seem to do anything to output except CNOTting it.

8:46 gfredericks: annelies: no I think it's correct as is, but definitely counterintuitive

8:46 annelies: the fact that they're entangled means doing things to one can affect the other

8:51 annelies: these 3 slides attempt to explain how it works, but I'm not sure if they make much sense standalone: http://upload.gfredericks.com/tmp/qc/qc.html#sec-6-1-1

8:56 maybe should have pointed to this slide too for better context: http://upload.gfredericks.com/tmp/qc/qc.html#sec-4-1-2

8:57 H4ns: any recommendations for a sql dsl? my db is postgres and i need no portability. jql, slingvo, sqlkorma, something else?

9:01 gfredericks: H4ns: I use honeysql and don't know anything about the ones you mentioned

9:03 H4ns: gfredericks: thanks, looks nice.

9:08 jonathanj: how does one bootstrap a database (ie. the database doesn't exist) with something like korma?

9:08 SagiCZ1: does :refer :all refer even private functions? defn- ?

9:11 gfredericks: SagiCZ1: no

9:12 jonathanj: probable via whatever raw-sql fallback korma provides

9:13 jonathanj: bleh

9:13 maybe ragtime is a better starting point

9:14 SagiCZ1: gfredericks: why can i still call the function from other namespace then?

9:17 gfredericks: SagiCZ1: you shouldn't be able to; maybe giving a more complete example would be helpful

9:18 SagiCZ1: gfredericks: ok

9:18 gfredericks: SagiCZ1: e.g., compare to this I just did: https://www.refheap.com/94173

9:19 SagiCZ1: i think maybe its some bug in my editor

9:19 btw does anyone know if count on clojure.lang.Cons is O(1) ?

9:20 gfredericks: I believe it's not

9:20 ,(doc counted?)

9:20 clojurebot: "([coll]); Returns true if coll implements count in constant time"

9:20 gfredericks: ,(counted? "hey")

9:20 clojurebot: false

9:20 gfredericks: hrm.

9:20 SagiCZ1: cool

9:20 gfredericks: that's misleading though

9:21 SagiCZ1: ,(counted? [:a :b])

9:21 clojurebot: true

9:21 gfredericks: SagiCZ1: in any case I think of the seq-like things only a PersistentList will be counted

9:21 ,(counted? '(1 2 3))

9:21 clojurebot: true

9:21 gfredericks: ,(counted? (cons :haha '(1 2 3)))

9:21 clojurebot: false

9:21 SagiCZ1: i need the quickest way to find out that a coll contains at least 2 elements.. if one element was enough, i would use (empty? ..) but now i have to use (< 1 (count clusters)) which is overkill.. any idea?

9:22 gfredericks: (-> coll rest empty?)

9:23 SagiCZ1: cool thanks!

9:24 wow so much faster! i think i knocked it from n^3 to n^2

9:24 gfredericks: ha great :)

9:27 SagiCZ1: is this true? (-> coll rest empty?) == (empty? (rest coll))

9:27 mearnsh: yes

9:28 SagiCZ1: thanks

9:31 gfredericks: does anybody know if there's a ticket or discussion about how misleading counted? is?

9:31 I could at least update the docstring

9:32 alhimik45: I have clojurescript and clojure code in my project. I have constants which I want to use at clojure and clojurescript side, but I don't want to copy-paste it. How to me require this file in clj and cljs file? http://code.re/6T1

9:34 gfredericks: alhimik45: have you seen cljx?

9:40 annelies: gfredericks: is there also a talk with these slides or just the slides?

9:41 alhimik45: gfredericks: I am using Hoplon, that uses boot instead lein, but cljx is lein plugin

9:42 gfredericks: annelies: not a recorded talk

9:42 alhimik45: ah, that sounds difficult then.

9:42 maybe there is a hoplon-specific way of doing it

9:43 annelies: oh ok

9:46 SirRobin: Hi

9:46 gfredericks: hi

9:46 SirRobin: since things like filter<, map< are deprecated in favor of transformers

9:47 is there an example/article on how to do this nicely?

9:47 justin_smith: SirRobin: transducers

9:48 right prefix though

9:48 mavbozo: SirRobin: what clojure version are you using?

9:48 SirRobin: the doc says "Use transformer instead", so I thought I'd use that word too

9:48 justin_smith: oh, weird

9:48 could be a doc typo?

9:49 or maybe there is a "transformer" i have yet to hear of

9:49 SirRobin: I don't think so, I've heard thte term in the context of transducers

9:49 we're talking about the same thing

9:50 and I'm using clojurescript "0.0-2371" with core.async "0.1.338.0-5c5012-alpha"

9:51 justin_smith: SirRobin: this is from martinklepsch, who may even be here :) http://www.martinklepsch.org/posts/using-coreasync-and-transducers-for-direct-s3-upload.html

9:51 SirRobin: yeah, just found it searching with transducers instead of transformers :)

9:51 martinklepsch: haha, does the documentation still call them transformers? :)

9:52 justin_smith: yeah, I think the transducer search term will find better results

9:52 SirRobin: in core.async, yes

9:53 mavbozo: martinklepsch: your code is meant for clojure, not clojurescript, right?

9:53 martinklepsch: SirRobin: depending on what you want to do it might also be worth looking at pipeline-async

9:53 mavbozo: clojurescript

9:54 I still haven't really come accross a problem where I thought "transducers are the right solution"

9:55 recently a guy on twitter asked me about real-world usage of transducers because my post was apparently the only one he found in that direciton

9:55 justin_smith: martinklepsch: I think most problems where transducers are the right solution are performance problems

9:55 mavbozo: back to SirRobin question, I think filter> and filter< is deprecated because in clojure 1.7 we can use ordinary filter

9:55 justin_smith: martinklepsch: that, or you are making a new thing in league with collections or channels, and want cheap map / filter / etc. impl

9:55 mavbozo: but I don't know about clojurescript

9:56 justin_smith: mavbozo: yes, you can, because transducers

9:56 they generalize map / filter over data sources

9:56 SirRobin: ok right, that makes sense

9:56 martinklepsch: mavbozo: thanks for keeping this on track, got off a bit I guess :)

9:57 mavbozo: but what clojurescript version that starts to support ordinary map, filter, etc for tranducers?

9:58 justin_smith: mavbozo: transducers are a new impl of map, filter etc.

9:58 as soon as you have transducers, you can use them with channels

9:58 do you mean, which version of cljs has transducers?

9:58 mavbozo: justin_smith: yes

10:00 SagiCZ1: can gc free up some cache used by memoized function?

10:00 justin_smith: no

10:01 SagiCZ1: well can i set manually the maximum cache for memoized function or at least an expiration date?

10:01 justin_smith: https://groups.google.com/forum/#!topic/clojurescript/ghpbnZKjx3w mavbozo - here is the announcement of cljs transducers

10:01 SagiCZ1: things like core.cached can, but regular memoize cannot

10:02 mavbozo: (inc justin_smith)

10:02 lazybot: ⇒ 150

10:02 justin_smith: I didn't like some of the complexities of core.cached (and some issues with using it with lein) so I made something I thought was simpler - https://github.com/caribou/spawning-grounds

10:03 mavbozo: then SirRobin can use filter in his clojurescript version

10:03 SagiCZ1: justin_smith: cool thanks

10:03 justin_smith: mavbozo: well, the presence of that warning was a good indicator :)

10:05 SagiCZ1: much of that README can be ignored unless you want to use spawning-grounds to make a new type of cache. Also, it could be the issues I saw with core.cached are fixed

10:06 sorry, core.cache https://github.com/clojure/core.cache

10:06 SagiCZ1: justin_smith: it looks good and easy to use..

10:08 justin_smith: if you mean spawning-grounds - thanks

10:08 SagiCZ1: justin_smith: yes thats what i meant

10:08 justin_smith: I think the api for implementing caches could be cleaner, but I tried to keep the basic caches pretty simple

10:08 SagiCZ1: the api seems very powerful though..

10:09 justin_smith: that was the goal, yeah

10:10 SagiCZ1: im just wondering.. with regular memoize.. is it possible that the cache gets so big, that looking up the parameters in cache takes more time than actually evaluating the memoized function?

10:11 DrCherry: I'm having trouble with the truthyiess of this test. Why is it failing? http://pastebin.com/Hdqps751

10:11 justin_smith: SagiCZ1: regarding you initial question about memoize removing unused items, the timed cache is more about requesting new data from the source after some time, it doesn't clean up it's store

10:12 SagiCZ1: though it could be modified to do a sweep / purge on each usage

10:12 DrCherry: whoops let me repost the code

10:12 SagiCZ1: justin_smith: i see.. that is different

10:12 mavbozo: ,(true? (true))

10:12 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IFn>

10:12 justin_smith: SagiCZ1: it's for caching data from a backend

10:12 mavbozo: true is not a function

10:12 SagiCZ1: i understand

10:13 justin_smith: SagiCZ1: I think the core.cache LRU cache may be closer to what you need

10:13 mavbozo: justin_smith: oops, dumb copy-paste from DrCherry gist :)

10:13 DrCherry: http://pastebin.com/pLv8SE9C

10:13 mavbozo: ,(not (true? '(true))

10:13 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

10:13 justin_smith: DrCherry: map will never return true

10:14 mavbozo: ,(not (true? '(true)))

10:14

10:14 clojurebot: true

10:14 DrCherry: I'm trying to see if the file is there.

10:14 justin_smith: &(true? [1 2 3])

10:14 lazybot: ⇒ false

10:14 DrCherry: I'm trying to see if the file is there.

10:14 justin_smith: then don't use a predicate

10:14 just use seq

10:14 SagiCZ1: justin_smith: and what do you think about the possibilty of the cache getting so big it diminishes the advantages of look up?

10:14 justin_smith: ,(if (seq []) :yes :no)

10:14 clojurebot: :no

10:15 DrCherry: so just drop the true?

10:15 justin_smith: ,(if (seq [1]) :yes :no)

10:15 clojurebot: :yes

10:15 justin_smith: yes

10:15 haha

10:15 or you can use not-empty if you feel that makes it more clear

10:15 but not-empty is not strictly needed

10:15 ,(not-empty [])

10:15 clojurebot: nil

10:15 justin_smith: ,(not-empty [1])

10:15 clojurebot: [1]

10:15 DrCherry: derp

10:16 mavbozo: &(some? [])

10:16 lazybot: ⇒ true

10:16 justin_smith: mavbozo: that's why I used seq or not-empty

10:17 &(some? (not-empty []))

10:17 lazybot: ⇒ false

10:17 annelies: gfredericks: thanks, I think I get it now except it seems to contradict with http://physics.stackexchange.com/a/2209/1313

10:18 the "the correlation only becomes evident after combining the results from the measurements afterwards" part

10:19 Or does this work because the qubits are known to be in state |0⟩ when the algorithm begins?

10:20 DrCherry: okay, I changed the name of the file to a file that doesn't exist and test doesn't fail

10:23 gfredericks: annelies: well it certainly relies on them starting at 0, yeah

10:23 DrCherry: it appears to return an object even if it fails, making it true.

10:24 annelies: gfredericks: right, and the spin of the pions in the Physics SE answer is unknown unlike the qubit states

10:24 thanks a lot!

10:24 gfredericks: hrm

10:24 I'm not quite making the connection

10:25 but one thing to note is that the measurement at the end is deterministic

10:26 which might be what you meant

10:29 annelies: Oh I meant electron and positron, not pion.

10:30 I should read up on Bell's theorem.

10:43 DrCherry: So in repl this comes back as (false) as it should: (map #(.exists (clojure.java.io/as-file %)) '("data/gr_neighborhoods.tx"))

10:43 how do I make test recognize that?

10:44 I tried wrapping it in (true? ) didn't work.

10:44 justin_smith: ,(= [false] '(false)) ; DrCherry

10:44 clojurebot: true

10:45 DrCherry: justin_smith, I don't exactly understand your syntax

10:45 justin_smith: ,(some? identity [false]) ; alternatively

10:45 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core/some?>

10:45 justin_smith: ,(some identity [false]) ; alternatively

10:45 clojurebot: nil

10:46 justin_smith: DrCherry: which part don't you understand?

10:46 DrCherry: justin_smith, how to apply your response to my line of code

10:47 justin_smith: (= [false] (map ...))

10:47 that only works if you know it is only one item

10:47 and then I wonder why you are mapping at all

10:47 you could also verify (nil? (some identity (map ...)))

10:47 DrCherry: (=[false] (map #(.exists (clojure.java.io/as-file %)) '("data/gr_neighborhoods.tx"))) : ok!

10:48 justin_smith: you are verifying that it returns a collection, with only one item, that is false

10:49 DrCherry: that passes weather I use [true] or [false]

10:49 justin_smith: it shouldn't

10:49 are you using is?

10:49 DrCherry: nope, let me try that

10:50 justin_smith: without is, no test is run

10:50 DrCherry: oh. Is there a good tutorial on test?

10:50 justin_smith: https://clojure.github.io/clojure/clojure.test-api.html

10:50 DrCherry: that was it. I had no is

10:51 this is going to be a long day

10:51 justin_smith: DrCherry: clojure is worth it though

10:51 note that the very beginning of the docs for clojure.test is the "is" macro :)

10:51 DrCherry: Meh, it's just for a job. I'm going to fail this programming test.

10:52 They gave me an exercise in a language I've never used.

10:52 bobpoekert: I should be able to import clojure.lang.Murmur3, right?

10:52 DrCherry: thinking about becoming a gypsy

10:53 justin_smith: bobpoekert: looks like it, yeah

10:54 bobpoekert: hm. I get a ClassNotFoundException when I try

10:55 dbasch: bobpoekert: are you importing it or requiring it?

10:55 bobpoekert: dbasch: I’m importing it

10:56 justin_smith: bobpoekert: works for me in a clojure 1.7-alpha3 repl

10:56 dbasch: &(import 'clojure.lang.Murmur3)

10:56 lazybot: ⇒ clojure.lang.Murmur3

10:56 justin_smith: &(import clojure.lang.Murmur3)

10:56 lazybot: ⇒ clojure.lang.Murmur3

10:56 justin_smith: hehe

10:56 bobpoekert: weird

10:56 must be a version issue

10:56 dbasch: also works for me on 1.6.0

10:57 bobpoekert: this project was originally using 1.4.0, so maybe lein-vimclojure is still using 1.4.0 for some reason

11:01 dbasch: bobpoekert: what is the value of *clojure-version* ?

11:01 bobpoekert: dbasch: {:major 1, :minor 5, :incremental 0, :qualifier "RC17"}

11:01 dbasch: bobpoekert: Murmur3 is from 1.6.0

11:02 bobpoekert: yeah

11:02 so the question is why is this running under 1.5

11:02 when my project.clj says 1.6

11:02 justin_smith: bobpoekert: lein deps :tree

11:02 one of your deps is overriding your clojure version

11:02 bobpoekert: [org.clojure/clojure "1.6.0”], it says

11:03 justin_smith: run lein deps :tree

11:03 bobpoekert: justin_smith: all of my deps are java libraries

11:03 I don’t have any clojure libraries as deps

11:03 justin_smith: so you are saying when you run the deps tree, it gives you a different version of clojure than the one that runs?

11:03 bobpoekert: yes

11:04 than runs /in vimclojure/

11:04 justin_smith: vimclojure uses lein

11:04 it will use the project.clj

11:04 unless vimclojure is seriously fucked up...

11:04 bobpoekert: it’s supposed to

11:04 lein repl is using 1.6.0

11:05 justin_smith: OK, file a bug with vimclojure I guess

11:05 do you know the exact command line vimclojure uses to run lein? maybe you can grab it from ps x

11:06 bobpoekert: justin_smith: good idea

11:06 justin_smith: it could be they are adding their own middleware that overrides the clojure version

11:06 redwire: Hello everyone. Is anyone here familiar enough with Clojure's transducers to tell me a bit about whether there is a relation between them and tranditional finite state transducers?

11:07 gfredericks: honk if you like better docstrings http://dev.clojure.org/jira/browse/CLJ-1607

11:07 dbasch: maybe it’s picking up a version of clojure from your classpath or something

11:10 justin_smith: dbasch: what other than project.clj would be influencing his classpath?

11:10 bobpoekert: dbasch: it’s definitely adding it. when I delete the jar file for that version it downloads it again when I restart the vimclojure server

11:21 mattrepl: anyone using a graph/plot library?

11:25 leandro: why printf prints with leiningen and not in a .jar? this is my simple script http://ur1.ca/ixkpg

11:26 andyf: leandro: Try putting a (flush) call at the end, or at least after the last printf. printf does not flush for you

11:26 println does

11:27 leandro: yea, but println doesnt allow "%s\n", isnt it?

11:27 mattrepl: (println (format …))

11:27 andyf: If you move the @ from your printf to your format call, you can just do (println (format ...)) as mattrepl suggests

11:27 leandro: oh, yes

11:28 andyf: or do (flush) at the end and use printf, or a mix of printf and println

11:28 leandro: :)

11:28 thanks

11:28 didn't know about the thing with flush & printf

11:32 andyf: Yeah, it is not obvious. I just added some notes about it to ClojureDocs.org here: http://clojuredocs.org/clojure.core/printf

11:47 SagiCZ1: is there some abstract function like recur or something that lets me modify the source collection?

11:48 andyf: SagiCZ1: When you say 'let me modify the source collection' do you mean to mutate it? Actually modify something intended to be immutable?

11:48 SagiCZ1: something like this (reduce ... [] [1 2 3 4 5 6]), but in the function i need to have the whole second collection, and modify it

11:48 andyf: no

11:49 andyf: its something i am able to achieve with regular loop.. im just wondering if there is a nicer way

11:50 justin_smith: SagiCZ1: what about (reduce f coll coll)

11:50 gfredericks: SagiCZ1: why not make it part of the "accumulator" arg in your reduce fn?

11:50 justin_smith: you get the collection as a base case to work with, and also deal with each element individually

11:50 SagiCZ1: justin_smith: oh.. interesting

11:51 justin_smith: i also need to be building a destination collection at the same time though

11:52 justin_smith: SagiCZ1: OK, (reduce f [coll []] coll)

11:52 andyf: you can pass an init value to reduce containing as much or little data as you wish, e.g. a map where one of the keys has a value that is the collection, and other keys with other values

11:52 justin_smith: exactly

11:52 SagiCZ1: andyf: i see.. i could do that

11:52 thank you both

11:53 justin_smith: SagiCZ1: with the help of destructuring on your reducing function, the parts of the accumulator can even look like separate args

11:54 SagiCZ1: the source collection is still passed into the function sequentially right?

11:54 andyf: The collection that is the last arg to reduce is still stepped through, and your reduce fn called once per element, yes

11:54 reduce doesn't know whether the same collection is all or part of the init arg value, and doesn't care.

11:56 gfredericks: ,(let [xs (range 5)] (reduce conj xs xs))

11:56 clojurebot: (4 3 2 1 0 ...)

11:57 gfredericks: ,(let [xs (range 5)] (pr-str (reduce conj xs xs)))

11:57 clojurebot: "(4 3 2 1 0 ...)"

11:57 gfredericks: pff

11:57 SagiCZ1: this is refheap of my loop https://www.refheap.com/94174

11:57 gfredericks: ,(let [xs (range 5)] (clojure.string/join " " (reduce conj xs xs)))

11:57 SagiCZ1: not sure i can use reduce

11:57 clojurebot: "4 3 2 1 0 0 1 2 3 4"

11:58 gfredericks: SagiCZ1: depends on what "choose-one" is doing

11:58 SagiCZ1: are you just trying to pull things out of your collection in a random order?

11:58 SagiCZ1: it returns one element from the source collection depending on what the previous chosen was

11:58 the order is not random..

11:58 gfredericks: SagiCZ1: btw (last a-vector) is slower than (peek a-vector)

11:59 bbloom: SagiCZ1: a loop is fine, but you can also consider reducing where your accumulator is a vector of [x coll]

11:59 SagiCZ1: ,(peek [1 2 3])

11:59 clojurebot: 3

11:59 SagiCZ1: thanks

11:59 * bbloom lets you other two fine gents handle this

11:59 gfredericks: but yeah the different-order thing probably precludes reduce

12:00 SagiCZ1: bbloom: could you elaborate please? i am slow..

12:01 gfredericks: bbloom might be lagging

12:01 bbloom: SagiCZ1: nothing new tha thasn't been said by the others here

12:01 justin_smith: SagiCZ1: I think you could use reduce if you rewrite choose-one

12:01 bbloom: dammit.

12:01 wtf?

12:01 SagiCZ1: what s

12:01 gfredericks: bbloom: I take it back

12:01 bbloom: gfredericks: ping

12:01 gfredericks: bbloom: pong

12:01 bbloom: ok...

12:01 i guess i'm ok :-P

12:02 gfredericks: bbloom: it was a kind of gray case

12:02 clojurebot: bbloom |lags| sometimes

12:02 clojurebot: Ok.

12:02 andyf: SagiCZ1: The first time through your loop, dest is [] and (last dest) is nil. I guess choose-one does something reasonable then?

12:02 bbloom: gfredericks: but i think i've fixed it :-PP

12:02 SagiCZ1: andyf: yeah it was pseudocode, the first thing in dest is chosen randomly from source.. the others always depend on the previous chosen

12:02 gfredericks: bbloom: okay I'm gonna keep bringing this up every week for the next three years and if we don't have another case of it by then then I'll drop it

12:03 bbloom: *sigh*

12:11 grandy: anyone know if there is a way to pass in a map to a yesql query-function (for passing in values for an insert)?

12:12 (new to clojure so apologies if this is obvious)

12:12 justin_smith: SagiCZ1: yeah, if that's the case, there is no pre-determined order of usage of items from source, so reduce won't make sense. Maybe something with iterate / take-last, but that wouldn't be much clearer than loop.

12:15 grandy: not that I see, but you can construct it using juxt

12:15 grandy: justin_smith: juxt?

12:15 justin_smith: ,((juxt :id :name :id) {:id 1 :name "bob"})

12:15 clojurebot: [1 "bob" 1]

12:15 justin_smith: that lets you pass a map, and get specific keys in the order needed

12:16 grandy: justin_smith: awesome I didn't realize that existed :)

12:16 justin_smith: then you would (apply your-yesql-fn coll) with that collection

12:16 and obviously you can use every key in the map 0 or more times as needed

12:16 grandy: justin_smith: excellent, oh what about the other arg I have to have first (the db spec) ... best practice for including that ?

12:17 justin_smith: you could make a wrapper function that inserts that automatically, or include it in the map you pass in

12:17 grandy: justin_smith: ahh ok excellent

12:18 justin_smith: maybe you want a small helper (defn mapply-db [db] (fn [opts] (apply yesql-fn db ((juxt :keys :to :use) opts))))

12:18 grandy: justin_smith: i had thought of doing it with a let binding to allow destructuring and then just wrapping the function call in the let binding, is that bad?

12:19 justin_smith: not at all

12:19 just showing how apply / juxt can get you most of the way there

12:19 grandy: justin_smith: yeah indeed it does, and I think it's a bit more concise in this case

12:21 martinklepsch: anyone here aware of a small java library that helps with syncing static websites to S3?

12:22 thinking of this: https://github.com/laurilehmijoki/s3_website but hopefully more pluggable

12:22 justin_smith: martinklepsch: no, but clj-aws-s3 is easy to use

12:22 I guess you probably considered that already, I know you've used clj-aws-s3

12:23 martinklepsch: justin_smith: yeah, that could work. was hoping something more specialized existed already :)

12:24 also cloudfront stuff in s3_website is useful

12:40 jjttjj: I keep getting a "clojure.lang.Compiler$CompilerException: java.lang.Exception: No namespace: clojure.core.memoize" when trying to compile. I've narrowed it down to the dependency causing the issue. I think I just need to add an exclusion. How do I figure out what to exclude? I've just been staring at lein deps :tree for a while and trial/error isn't working

12:41 I think the issue is with mixing this project here: https://github.com/jamesmacaulay/shopify-clj/blob/master/project.clj with pedestal service

12:41 gfredericks: jjttjj: try `lein deps :tree` and look at the bits at the top

12:44 bobpoekert: update: upgrading lein and lein-tarsier fixed my clojure version problem

12:48 jjttjj: gfredericks: I fixed all the lein deps: tree warnings but still having the same issue

12:51 gfredericks: jjttjj: and you did `lein clean`?

12:52 jjttjj: gfredericks: yes

12:53 gfredericks: jjttjj: if you could share your project.clj we could try to reproduce

12:53 justin_smith: jjttjj: and you have org.clojure/core.memoize in your deps? it isn't part of clojure.core's artifact

12:54 oh wait, it is contrib, so it isn't even org.clojure

12:54 jjttjj: justin_smith: I don't have it but im not using it (i guess another dep is though so I'll try adding it)

12:54 gfredericks: here's the project.clj https://www.refheap.com/94176

12:55 justin_smith: clearly if they are not explicitly depending it, but they use it, that would be a reportable bug

12:55 grandy: would anyone mind critiquing the style of this function for me? i'm new to clojure and building a simple compojure website for a friend as a first project...

12:55 https://gist.github.com/anonymous/06326dd2adb3048d14e3

12:56 justin_smith: grandy: that if / let combo could be a single when-let

12:56 err - no, I guess not

12:56 heh

12:56 I mean you could shoehorn it

12:57 grandy: justin_smith: yeah good point

12:57 justin_smith: anothe option (defn create-user [params] {pre [(b/valid? params user-validator)]} (let ...))

12:57 jjttjj: justin_smith: ok adding the core.memoize dep worked! thanks!

12:57 justin_smith: depending on whether you want an error in that case

12:57 grandy: justin_smith: ahh interesting

12:57 justin_smith: jjttjj: you should figure out which project was using core.memoize and file a bug report

12:58 grandy: justin_smith: i do like the way the pre feels

12:58 justin_smith: grandy: should that be an error, or just silently nil

12:58 jjttjj: justin_smith: yup looking into it now

12:58 justin_smith: because a :pre will trigger an AssertionError

12:58 weavejes_: grandy: Why do you have b/validate and v/valid?

12:58 Asserts shouldn't be used for validation purposes.

12:59 Because a validation fail is not an error.

12:59 Preconditions are there for fast failure.

12:59 grandy: weavejes_: i wanted to validate the data first, and if it's invalid then return the errors map

12:59 weavejes_: ahh interesting

12:59 weavejes_: grandy: Which library is b/validate from?

13:00 grandy: bouncer

13:00 justin_smith: grandy: oh wait, I was mislead by the indentation

13:00 there are two clauses in that if...

13:01 grandy: justin_smith: oops hit tab in emacs and fixed it, not sure how that happened :)

13:01 justin_smith: so yeah, definitely don't want when there

13:01 grandy: fixed:

13:01 https://www.irccloud.com/pastebin/MErdwEfv

13:01 weavejes_: If b/validate returns nil if there are no errors, you can only validate once.

13:02 Or may only validate once.

13:02 grandy: weavejes_: true, do you think that is a smarter way to write it? was going for clarity

13:03 weavejes_: Hm, the bouncer library is built a little differently to how I'd expect.

13:03 grandy: weavejes_: ahh also if you recommend a different way to validate data i'd be interested to hear your thoughts

13:03 weavejes_: It looks like it doesn't return nil if there are no errors, which is a shame.

13:03 grandy: weavejes_: yeah that is what i would have expected actually, to allow just one call

13:04 justin_smith: weavejes_: if it did, you could just do an if-let on the validator, and make the error case the first branch

13:04 grandy: weavejes_: I think it's done that way so the calls can chained or something... not sure

13:04 weavejes_: Right. Then you could just write: (if-let [errors (b/validate params)] ...)

13:05 grandy: any recommendations for other validation libraries? this one seemed nice but i haven't really done much research on that

13:06 weavejes_: I haven't found a validation library that does everything I want to, yet...

13:06 justin_smith: seems like prismatic/schema would be flexible enough to build whatever

13:06 weavejester: grandy: Are you just validating URL params?

13:07 Yeah, schema is one solution, but it's not as flexible as I'd like.

13:07 grandy: hmm interesting, ok i'll look at that one,... weavejester well yeah just putting some validation logic between the web forms and the db

13:07 SagiCZ1: can i use apply on interop method?

13:07 (apply .javaMethod args)

13:07 weavejester: Some validations are complex. For example, checking to make sure that a password typed twice is the same.

13:07 justin_smith: SagiCZ1: no, because methods are not first class

13:07 SagiCZ1: ok

13:08 grandy: weavejester: yeah i haven't figured out the best way to handle that case using bouncer yet

13:09 schema does look very nice actually

13:10 weavejester: grandy: You might want to try out the schema/check function

13:11 grandy: weavejester: ok will check it out (pardon the pun)

13:12 weavejester: ahh yeah it looks like the exact behavior i'm looking for

13:12 weavejester: Ah crap, clojars has failed on a jar upload

13:14 technomancy: Looks like I caught a 500 error in Clojars which resulted in a partially uploaded package: https://clojars.org/generators/lein-template/versions/0.2.2

13:14 grandy: weavejester: really liking compojure... thanks much for creating it.

13:14 weavejester: grandy: You're welcome

13:26 engblom: Is there any IRC-client written in Clojure? I want to have an IRC-client with spell-checker. As I am wanting to learn Clojure, I could as well take it as a project to add the spell checker to a ready client (unless it already got spell-checker)

13:26 justin_smith: engblom: lazybot uses irclj

13:27 oh, you mean like a human usable client with a UI

13:27 irclj is a client in that it can connect to IRC and communicate with it

13:27 * gfredericks has been having ambiguous issues with irclj

13:27 engblom: I would want something similar to Irssi/Weechat, but written in Clojure

13:28 justin_smith: engblom: yeah, pretty sure you would have to write that yourself

13:28 leandro: given a map, i want to acces to ":sunday", but i have the value in a variable "day" how can do (get mymap :day) ?

13:28 gfredericks: I've heard of precious few terminal UIs written in clojure

13:28 engblom: OK, bad luck then. I do not have time to write a whole irc client but I could have been modifying an existing one.

13:28 justin_smith: leandro: ##(let [day :sunday] (get {:sunday "hello"} day)) like this?

13:28 weavejester: leandro: What does the map look like?

13:28 lazybot: ⇒ "hello"

13:29 justin_smith: what do you mean by variable?

13:29 gfredericks: this is probably the only one I've heard of: https://github.com/maitria/avi

13:29 metellus: engblom: this doesn't help with the clojure but irssi has a couple spellcheck scripts

13:30 leandro: i get the day string with clj-time. the map has an index for each weekday

13:30 engblom: metellus: Those spell-check scripts for irssi are spamming the screen with suggestions, even for nicks. It is not important to see how the word should be spelled, but to know when I spelled a word wrongly.

13:30 metellus: Like changing color for badly spelled words.

13:30 justin_smith: engblom: how about erc and fly-spell?

13:31 err, flyspell that is

13:31 I just turned it on, the only issue I see so far is that flyspell is highlighting the ERC> prompt. Otherwise does what I expect.

13:31 creese: What's the best way to load a dependency when I start cider if I don't have a project? For example, clj-http.

13:32 engblom: justin_smith: That is what I am using right now, but I would rather have a good irc client than running emacs. Emacs is single threaded and will lock everything while reconnecting. Also it slowly eats a lot of memory. Today I restarted because it went up to 410Mb of RAM.

13:32 metellus: engblom: the one i use just cycles through spelling options when i press tab. you could modify it to do what you want but that's a whole perl effort rather than clj

13:32 justin_smith: creese: do you want it to always be available?

13:32 creese: sure

13:32 gfredericks: creese: I keep a library for loading deps dynamically

13:32 justin_smith: creese: I use pallet/alembic (in my .lein/profiles.clj) to load deps at runtime

13:33 but a lot of things in lein don't make much sense without a project

13:33 engblom: metellus: What script do you use?

13:34 metellus: aspell_complete.pl

13:34 engblom: Thanks

13:36 creese: justin_smith: even to use pallet/alembic, I need a project right?

13:39 gfredericks: hey does anybody [not] like utility libs? https://github.com/palletops/lein-shorthand/issues/2

13:40 justin_smith: creese: no

13:40 creese: you can specify deps that should always be present in ~/.lein/profiles.clj

13:40 rritoch: Does anyone know about this error which I just started getting while compiling after upgrading to clojure 1.7.0-alpha4 : Exception in thread "main" java.lang.IllegalAccessError: tried to access method clojure.lang.RT.classForNameNonLoading(Ljava/lang/String;)Ljava/lang/Class;

13:41 gfredericks: rritoch: did you need to `lein clean`?

13:41 justin_smith: rritoch: either you need to run lein clean because of stale compiled artifacts, or you were relying on undocumented internals of clojure that have changed

13:41 rritoch: Yes, I ran lein do clean, compile

13:42 justin_smith: I seem to recall you had some hack to compile from a URI

13:43 rritoch: justing_smith: It has nothing to do with that hack, but I do call (.newInstance (.loadClass .... in the file that is crashing

13:43 bbloom: gfredericks: i've thought a bit about that problem. i generally don't use utility libs simply b/c they are often of inconsistent quality and extra stuff that i don't particularly want

13:43 gfredericks: i really want to pull in ONE function

13:43 gfredericks: bbloom: yeah and this would let you do that, with a bit of project.clj noise

13:44 rritoch: This is the file that's crashing, and it doesn't do much

13:44 https://github.com/rritoch/clj-grid-core/blob/master/src/com/vnetpublishing/clj/grid/lib/grid/jsp/instance_manager.clj

13:44 bbloom: gfredericks: was talking w/ somebody at clj/nyc too about a sort of utilities database site

13:45 gfredericks: with some crazy custom dependency resolution thing? :)

13:45 bbloom: gfredericks: basically idea was you have utility functions that are each in their own little namespace and you make your own (or your company's) utility database and then click a button and get a unified .clj file

13:45 which could of course be part of the build process

13:45 i think it would be super cool to see which utils were popular

13:45 and to get dependency resolution at the def-level, rather than the project level

13:46 rritoch: Running lein clean doesn't make a difference, it's still crashing

13:46 bbloom: there's also Joe Armstrong's rant on this: http://lambda-the-ultimate.org/node/5079

13:46 seems more of a social/community problem than a technical one

13:47 gfredericks: bbloom: yeah

13:47 andyf: Not entirely sure, but I believe the annex project is shooting for function-level dependency management. Don't know how far along they are to realizing such a goal.

13:51 xelxebar: I've got a lazy, but naive, implementation of the sieve of erastothenes, so (take 5 (primes)) returns (2 3 5 7 11) etc. However, when trying to get largish primes it hammers the stack pretty hard: (nth (primes) 2000) produces a StackOverflowException.

13:51 gfredericks: xelxebar: is it a bunch of filters?

13:52 xelxebar: just a sec, gonna give you a pastebin, but yeah.

13:53 gfredericks: yeah I don't know if there's any good way to get that kind of code structure

13:53 composing a whole bunch of lazy operations inevitably becomes pretty stackful, and since you're presumably using an infinite seq you can't just give up laziness

13:53 xelxebar: what's a good pastebin for clojure? :P

13:53 gfredericks: ~paste

13:53 clojurebot: paste is https://refheap.com/

13:54 xelxebar: https://www.refheap.com/94179

13:54 kenrestivo: i think "we need letrec" would make a good t-shirt design

13:54 ricky_: -/nick ricky_____

13:55 justin_smith: kenrestivo: letfn isn't good enough?

13:55 kenrestivo: or like a protest, occupy kids on the street, with signs that say "we need letrec!"

13:55 justin_smith: kenrestivo: or you need it for recursive values, not just recursive functions?

13:55 kenrestivo: justin_smith: i'm referring to that joe armstrong post

13:55 http://lambda-the-ultimate.org/node/5079

13:55 letfn works just fine in clojure, yes.

13:56 in fact someone showed me a very cool technique for avoiding nested lets by using letfn

13:56 gfredericks: xelxebar: so are you still wondering why you get the exception?

13:57 xelxebar: gfredericks: well, I abstractly get why we're hammering the stack, but I was wondering if there's a good way to not do that.

13:58 Here, I also hacked together a sieve that finds the nth prime

13:58 https://www.refheap.com/94180

13:58 And well, it's horrendously ugly.

13:59 gfredericks: xelxebar: I feel like this doesn't tend to show up in other programming problems. you can do something a little more manual with the lazy-seq macro wherein you keep a set of the primes so far and just check each one explicitly

13:59 xelxebar: Yeah, that's pretty much what the nth-prime func is doing.

14:00 gfredericks: I'll whip up a lazy-seq version that might be instructive

14:00 ricky_____: If anyone has a chance, I'm having some get-metadata-from-ref problems @ http://pastebin.com/xdFuQVn5

14:00 xelxebar: Thanks!

14:01 gfredericks: xelxebar: it's a different style of recursion so it's useful to see the difference

14:01 rritoch: justin_smith: Just to test I commented out the Compiler/compile function and it didn't make a difference. The odd part is this is crashing during loading

14:02 Exception in thread "main" java.lang.IllegalAccessError: tried to access method clojure.lang.RT.classForNameNonLoading(Ljava/lang/String;)Ljava/lang/Class; from class com.vnetpublishing.clj.grid.lib.grid.kernel$loading__5295__auto____15, compiling:(instance_manager.clj:1:1)

14:03 Is there now a block that you can't load child dependencies?

14:04 I have another library that depends directly on the kernel and that compiled without a problem.

14:04 weavejester: ricky_____: You're trying to get metadata from vars that don't exist, not from refs.

14:05 ricky_____: There's a distinction between a var and the data contained within it.

14:05 justin_smith: yeah, instead of using a macro to try to access a var, why not pass the var to the function? or attach the metadata to the account? or use a map which includes account info instead of a number in the ref

14:05 weavejester: #(do (def ^{:owner "foo"} v {:bar "baz}) (meta v))

14:06 ##(do (def ^{:owner "foo"} v {:bar "baz}) (meta v))

14:06 gfredericks: xelxebar: https://www.refheap.com/94183

14:06 weavejester: &(do (def ^{:owner "foo"} v {:bar "baz}) (meta v))

14:06 lazybot: java.lang.RuntimeException: EOF while reading string

14:06 weavejester: &(do (def ^{:owner "foo"} v {:bar "baz"}) (meta v))

14:06 lazybot: java.lang.SecurityException: You tripped the alarm! def is bad!

14:06 gfredericks: I tried to do a larger example of nth but it took too long :)

14:06 weavejester: ,(do (def ^{:owner "foo"} v {:bar "baz"}) (meta v))

14:06 clojurebot: nil

14:06 xelxebar: gfredericks: cool. taking a look

14:06 weavejester: ,(do (def ^{:owner "foo"} v {:bar "baz"}) (meta #'v))

14:06 clojurebot: {:ns #<Namespace sandbox>, :name v, :file "NO_SOURCE_PATH", :column 0, :line 0, ...}

14:06 rritoch: I was able to fix this compile error simply by adding the dependency directly, is this a bug in clojure?

14:07 Until upgrading I had no problem accessing dependencies of dependencies.

14:08 gfredericks: xelxebar: could be a bit confusing since there's logically two different collections of primes involved

14:08 ricky_____: weavejester: OK. Trying to "get it," but just started trying the concurrency stuff last night and it seems like a lot to take in.

14:09 justin_smith: ricky_____: this isn't about concurrency though

14:09 weavejester: ricky_____: Well, vars are essentially pointers to values.

14:09 xelxebar: gfredericks: cool!

14:09 weavejester: ricky_____: So if I (def x 1), then if I type x it automatically gets the value.

14:10 ricky_____: OK

14:10 weavejester: ricky_____: It's essentially the opposite behaviour of refs

14:10 xelxebar: I had to look up what some did

14:10 weavejester: ricky_____: With a ref, you deref with @, and if you don't deref you get the ref itself, right?

14:10 ricky_____: With vars, they're derefed automatically, and if you want to get the var itself, you use #'

14:11 xelxebar: gfredericks: I really like this! Thanks for taking the time to whip that up.

14:11 weavejester: ricky_____: You want to add metadata to the refs themselves, right? Not the vars?

14:11 ricky_____: Ahhh, yeah!

14:11 gfredericks: xelxebar: np

14:12 weavejester: ricky_____: The ^ form attaches metadata at compile time. Runtime metadata can be added with with-meta

14:12 gfredericks: xelxebar: normally you don't have to stoop to using the lazy-seq macro directly, but lazy prime computation is kind of special

14:12 weavejester: ricky_____: So (with-meta (ref 100) {:owner "foo"}) to attach metadata, and meta to detach it.

14:13 Or read it, rather

14:13 ,(let [r (with-meta (ref 100) {:owner "foo"})] (meta r))

14:13 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Ref cannot be cast to clojure.lang.IObj>

14:13 weavejester: Huh... Refs aren't IObjs?

14:13 justin_smith: in general, representing the bank account as a map makes sense though, and you can have a :value key for the numeric value contained

14:13 xelxebar: gfredericks: Do you mean that usually we can just bank on the laziness of core functions and stuff?

14:13 gfredericks: And what makes primes special here?

14:14 gfredericks: xelxebar: it's unusual to take a collection and call filter on it *over and over and over*

14:14 weavejester: ricky_____: Looks like you might need to do something like: {:owner "foo", :value (ref 100)} instead

14:14 gfredericks: as long as you're just using a handful of transformation functions you should be fine

14:14 there's a related gotcha with repeated use of concat, which people run into pretty frequently

14:15 justin_smith: weavejester: why not (ref {:owner "foo" :value 100}) ?

14:16 ricky_____: I would guess so the owner can't change?

14:16 Depends if that's desired or not.

14:16 weavejester: justin_smith: I assumed the owner of the ref was fixed, but yep, you could do it like that.

14:16 justin_smith: ricky_____: it's easy to change metadata, and changing metadata isn't even thread safe

14:17 weavejester: justin_smith: When isn't it thread safe?

14:17 with-meta obviously is, and I thought vary-meta! was as well...

14:17 xelxebar: gfredericks: hmmm. do you mean like if you concat an expensive-to-calculate eager seq to the head of a lazy one?

14:18 gfredericks: makes me wonder how lazy concated to eager works...

14:19 I'd guess that you keep getting lazily evaluated stuff until you hit the head of the eager seq.

14:19 gfredericks: xelxebar: no it's only a problem if you concat repeatedly

14:19 ,(->> (range 10000) (map list) (reduce concat) (last))

14:19 clojurebot: #<StackOverflowError java.lang.StackOverflowError>

14:19 gfredericks: xelxebar: note that ^that involves 10000 calls to concat

14:20 xelxebar: gfredericks: noob question: what is the ->> , I'm guessing a macro?

14:20 gfredericks: yeah

14:21 ,(last (reduce concat (map list (range 10000)))) ;; same thing

14:21 clojurebot: #<StackOverflowError java.lang.StackOverflowError>

14:21 xelxebar: cute

14:22 ricky_____: weavejester and justin_smith: The map-based approach looks like the way to go, so I'm going to give it a shot. Thanks for the help.

14:22 xelxebar: gfredericks: ->> feels like do notation in Haskell

14:22 gfredericks: it's definitely used about as often

14:23 at least if you include ->

14:24 justin_smith: weavejester: oh, you're right, they both return a new object

14:30 gfredericks: xelxebar: I just realized mine would be slightly more efficient with a vector for primes-so-far instead of a list

14:30 so that you check the smaller ones first

14:30 xelxebar: oh? let me look at that

14:31 I was just checking out how fast it was compared to my shitty nth-prime

14:31 gfredericks: it should be assymptotically the same

14:31 we're ignoring all sorts of numeric optimisations of course

14:33 kenrestivo: this crossclj has become indispensible. i have to wonder where the source code is for it though? does it use codeq? datomic?

14:33 also, if it's not open source, maybe i shouldn't get used to it, otherwise soon it'll start demanding $10/month subscription fee or similar

14:39 xelxebar: gfredericks: what's a good way to profile clojure code?

14:40 I don't get why the vector would be more efficient...

14:41 gfredericks: xelxebar: criterium

14:41 xelxebar: the difference is which end of the collection conj adds to

14:41 ,(conj '(1 2 3) :zoo)

14:41 clojurebot: (:zoo 1 2 3)

14:41 gfredericks: ,(conj [1 2 3] :zoo)

14:41 clojurebot: [1 2 3 :zoo]

14:42 gfredericks: which in turn determines whether you're starting with big primes or small primes when calling `some`

14:42 obviously starting with small primes is faster in aggregate

14:42 your original filter algorithm gets this right

14:47 xelxebar: gfredericks: Thanks. I sort of just assumed that the compiler behaved as expected and it would be better to mod small primes. What's actually going on under the hood is still quite mysterious to me.

14:50 gfredericks: your expectation is different from what I described?

14:51 I was talking about a distinction that would be way over any compiler's head

15:00 xelxebar: I think we're talking about the same thing. Cutting out multiples of small primes first cuts out more numbers up front.

15:02 I'm just not sure how the code actually is getting evaluated and so just have some unspecified feeling that the compiler might be doing something that will go counter to what I expect.

15:04 gfredericks: well in my code there's a collection called `primes-so-far` which is what it uses to check divisibility

15:05 and the order it checks in depends on the order of that collection

15:05 if the collection has smaller primes up front, that's what you're checking first, and vice versa

15:06 justin_smith: xelxebar: for a functional language, clojure has a very simple compiler, most of the optimization work (other than smart design of datatypes and algorithms up front) is done by the jvm JIT compiler

15:06 rritoch: This is odd, I found a second solution to the compilation error I was getting. After checking the classpath generated by leiningen I realized that the wrong version of clojure was being used so adding the latest version of clojure to the dependencies also repairs the compile error.

15:10 I believe that since there were gen-classes in the dependencies which were produced by 1.7.0-alpha4 when something caused 1.5.1 to load instead, it could no longer use the namespaces from 1.7.0-alpha4

15:56 hiredman: java.nio.channels.ClosedChannelException

15:57 pardon me

15:58 bbloom: clojure.irc.channels.WrongChannelError

18:05 gfredericks: ~ping

18:05 clojurebot: PONG!

18:08 andyf: clojurebot plays a mean game of table tennis

18:08 justin_smith: $ping

18:08 lazybot: justin_smith: Ping completed in 0 seconds.

18:09 gfredericks: ,(println "$ping")

18:09 clojurebot: $ping\n

18:09 gfredericks: ,(print "$ping")

18:09 clojurebot: $ping

18:09 lazybot: clojurebot: Ping completed in 0 seconds.

18:09 clojurebot: Excuse me?

18:09 gfredericks: nice

18:09 justin_smith: oh no...

18:10 llasram: yay!

18:10 Let the cross-bot games resume!

18:11 gfredericks: there wouldn't happen to be an existing lib with an instaparse grammar for jvm regexes would there?

18:11 I don't need a complete one

18:11 cuz I'm about to make my own otherwise

18:12 andyf: after your getting the bots talking to each other, and then asking that question, it sounds like a kid who just set off his first model rocket in the back yard without permission asking where the gas station is.

18:12 umm.... no reason.

18:13 gfredericks: it's just a 3-msg chain that doesn't suggest any method for getting anything longer

18:13 no reason to call the botcops

18:15 andyf: I'd check crossclj.info for uses of instaparse

18:15 lazybot: gfredericks: too late, you're in trouble now

18:16 * andyf wonders if someone will write botcop

18:16 justin_smith: andyf: someone really should

18:16 andyf: or even batbot

18:17 The vigilante bot

18:17 justin_smith: the bot #clojure deserves

18:20 gfredericks: Looking forward to testing this with test.check by generating random strings and filtering on passing the regex parser. no way that'll be efficient.

18:20 I guess and can special case just the things that make it unlikely to pass, like parethesis balancementhood

18:20 andyf: Skew test.check's string generation to have 15% backslash characters and you'll get coverage faster :)

18:21 gfredericks: yeah was gonna get a list of special chars and give'em a boost

18:26 * gfredericks just made a namespace with 6 segments

18:29 gfredericks: huh; including /resources with a library means you should probably namespace things

18:29 * andyf gives gfredericks a hexagonal cookie

18:29 gfredericks: andyf: thanks can I have chocolate next time

18:31 andyf: sure

18:42 SagiCZ1: how do i peek into transient vector?

18:43 ,(peek (transient [1 2 3]))

18:43 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector$TransientVector cannot be cast to clojure.lang.IPersistentStack>

18:43 SagiCZ1: ,(peek [1 2 3])

18:43 clojurebot: 3

18:43 andyf: SagiCZ1: Operations allowed on transients are quite limited

18:44 SagiCZ1: but i just want a little peek!

18:44 andyf: Have you tried (vec (dec (count vec))) ?

18:44 SagiCZ1: how should that work

18:45 oh

18:45 i see how

18:45 sorry

18:45 will try

18:45 andyf: seems to work

18:45 SagiCZ1: yup

18:46 not getting the speed up they promised in the doc.. :<

18:46 it probably wasnt the bottleneck

18:50 alpheus: Is Clojurescript on-topic here?

18:50 SagiCZ1: alpheus: yes

18:51 pllx: alpheus: what is clojurescript used for?

18:52 alpheus: clojurescript is clojure compiled to javascript, through Google closure.

18:53 I'm failing to get a browser repl working. Some of the advice on the web suggests removing ~/.m2/repository, which sounds kind of drastic to me.

18:53 SagiCZ1: alpheus: try to rename it if you dont want to remove it altogether

19:00 alpheus: OK, I did, and now my browser connects.

19:01 That feels a lot like the Windows solution, but I guess I'd accumulated a lot of cruft.

19:01 gfredericks: xelxebar: I just made this "optimized" version out of curiosity and it was like 30 times faster

19:02 using an internal mutable data structure and primitives

19:02 (i.e., no number-theory tricks)

19:02 it's sooper ugly though

19:02 https://www.refheap.com/94188

19:14 TEttinger: gfredericks, I wonder how that would (or could it?) compare to a version using transients

19:14 gfredericks: I think it could; it feels like an icky use of transients to me though

19:14 since you never convert them back

19:14 I don't have a specific reason why that would be bad

19:15 I'll go write it

19:15 SagiCZ1: is there a way to remove first key and value from sorted map?

19:15 rest returns a sequence.. not the map

19:16 gfredericks: yeah

19:16 what does first give you?

19:16 SagiCZ1: key value pair in vector

19:16 TEttinger: remove the key?

19:17 (doc remove)

19:17 clojurebot: "([pred] [pred coll]); Returns a lazy sequence of the items in coll for which (pred item) returns false. pred must be free of side-effects. Returns a transducer when no collection is provided."

19:17 TEttinger: hm no

19:17 gfredericks: (doc dissoc)

19:17 clojurebot: "([map] [map key] [map key & ks]); dissoc[iate]. Returns a new map of the same (hashed/sorted) type, that does not contain a mapping for key(s)."

19:17 TEttinger: (inc gfredericks)

19:17 lazybot: ⇒ 111

19:17 SagiCZ1: i want this {:a 0 :b 1 :c 2} to become this {:b 1 :c 2}

19:17 andyf: SagiCZ1: dissoc

19:17 SagiCZ1: i cant dissoc, i dont know what the first key is

19:17 gfredericks: TEttinger: looks a little bit slower

19:18 SagiCZ1: you can get the key from the key value pair, no?

19:18 (doc key)

19:18 clojurebot: "([e]); Returns the key of the map entry."

19:18 andyf: SagiCZ1: (dissoc sorted-m (key (first sorted-m)))

19:18 bbloom: ,(ffirst (sorted-map 1 2 3 4))

19:18 TEttinger: ,(let [sm (sorted-map :a 0 :b 1 :c 2)] (dissoc sm (ffirst sm)))

19:18 clojurebot: 1

19:18 {:b 1, :c 2}

19:18 SagiCZ1: ,(apply sorted-map (flatten (rest (sorted-map :a 0 :b 1 :c 3))))

19:18 clojurebot: {:b 1, :c 3}

19:18 SagiCZ1: this is what i want

19:18 looks ugly though

19:18 gfredericks: ,(def my-map (sorted-map :a 0 :b 1 :c 3))

19:18 clojurebot: #'sandbox/my-map

19:18 gfredericks: ,(dissoc my-map (key (first my-map)))

19:18 clojurebot: {:b 1, :c 3}

19:19 gfredericks: SagiCZ1: ^^

19:19 SagiCZ1: ok i must say that does look better

19:19 dbasch: ,(let [m (sorted-map :a 0 :b 1 :c 2)] (dissoc m (ffirst m)))

19:19 clojurebot: {:b 1, :c 2}

19:19 SagiCZ1: thank you

19:19 dbasch: oh, already there

19:19 TEttinger: yep

19:19 SagiCZ1: thank you all

19:19 TEttinger: no prob

19:19 dbasch: SagiCZ1: avoid flatten btw

19:19 TEttinger: yes

19:19 ~flatten

19:19 clojurebot: flatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.

19:19 SagiCZ1: oh gosh

19:20 i know i know i know..

19:20 was just throwing it out

19:20 ;)

19:20 flatten haters

19:20 TEttinger: ,(into (sorted-map) (rest (sorted-map :a 0 :b 1 :c 3)))

19:20 clojurebot: {:b 1, :c 3}

19:21 TEttinger: does the same thing without flattening nesting

19:21 hyPiRion: could just do conj on it

19:21 SagiCZ1: ,(sorted-map)

19:21 clojurebot: {}

19:21 SagiCZ1: ,(empty sorted-map)

19:21 clojurebot: nil

19:21 hyPiRion: ,(conj (sorted-map) (rest (sorted-map :a 0 :b 1 :c 3)))

19:21 clojurebot: {:b 1, :c 3}

19:21 SagiCZ1: um

19:22 metellus: ,(empty? (sorted-map))

19:22 clojurebot: true

19:22 SagiCZ1: what is empty for then?

19:22 metellus: ,(doc empty)

19:22 clojurebot: "([coll]); Returns an empty collection of the same category as coll, or nil"

19:22 hyPiRion: ,(empty [1 2])

19:22 clojurebot: []

19:22 hyPiRion: ,(empty (sorted-map 1 2))

19:22 clojurebot: {}

19:22 SagiCZ1: so its when you have FULL collection and want an empty coppy of the same type?

19:23 metellus: ,(empty "s")

19:23 clojurebot: nil

19:24 hyPiRion: yess

19:24 SagiCZ1: metellus: :(

19:24 dbasch: ,(coll? “s”) ; SagiCZ1

19:24 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: “s” in this context, compiling:(NO_SOURCE_PATH:0:0)>

19:25 dbasch: &(coll? “s”)

19:25 lazybot: java.lang.RuntimeException: Unable to resolve symbol: “s” in this context

19:25 dbasch: stupid smart quotes

19:25 SagiCZ1: ,(coll? "s")

19:25 clojurebot: false

19:25 dbasch: ,(coll? (seq "s"))

19:25 clojurebot: true

19:27 SagiCZ1: if i do this on an atom, the (count @a) has to be unchanged right?

19:27 (do

19:27 (swap! a #(dissoc % (first %)))

19:27 (swap! a assoc key val))

19:28 hyPiRion: SagiCZ1: no – key may already be present in a.

19:29 SagiCZ1: that way the count would lower by one correct?

19:29 it keeps increasing

19:30 dbasch: SagiCZ1: why would you do two swaps?

19:30 TEttinger: also, SagiCZ1, you want ffirst to get the first element of the first pair

19:31 (doc ffirst)

19:31 clojurebot: "([x]); Same as (first (first x))"

19:31 SagiCZ1: TEttinger ok so its probably not removing anything

19:31 dbasch: enjoyin mutability i guess?

19:31 dbasch: SagiCZ1: but two swaps defeats the purpose of swap

19:31 if you're going to swap atomically, swap atomically

19:32 SagiCZ1: dbasch: then they are two atomic swaps

19:32 TEttinger: (swap! a #(do (dissoc % (ffirst %)) (assoc % key val)))

19:32 dbasch: SagiCZ1: which is silly

19:32 hyPiRion: TEttinger: what

19:33 TEttinger: technicaly atomic?

19:33 remember, this is dissocing a different key than it is associng to

19:34 dbasch: SagiCZ1: it's like opening a drawer to put in a pair of socks, closing it, and then opening it again to remove another pair of socks

19:34 hyPiRion: TEttinger: what you wrote is equal to (swap! a #(assoc % key val))

19:34 TEttinger: ah, right dammit

19:34 hyPiRion: You probably meant (swap! a #(-> (dissoc % (ffirst %)) (assoc key val)))

19:34 SagiCZ1: #(assoc (dissoc % (ffirst %)) key val) ?

19:35 dbasch: thank tou for the explanation

19:35 makes sense

20:21 Morgawr: ,(str "test")

20:21 clojurebot: "test"

20:22 Morgawr: ,(sort-by (comp :z second) (complement compare) { :one {:z 1} :two {:z 0} :three {:z 10} :four {:z 5}})

20:22 clojurebot: ([:one {:z 1}] [:three {:z 10}] [:four {:z 5}] [:two {:z 0}])

20:22 Morgawr: what am I doing wrong?

20:22 ,(sort-by (comp :z second) { :one {:z 1} :two {:z 0} :three {:z 10} :four {:z 5}})

20:22 clojurebot: ([:two {:z 0}] [:one {:z 1}] [:four {:z 5}] [:three {:z 10}])

20:22 Morgawr: ^ this works

20:22 why does inverting the comparison function (using complement) doesn't reverse the order?

20:23 oh.. compare returns -1, 0 and 1, not true/false.. nevermind

21:17 kenrestivo: this smells bad ##(apply concat (conj '([1 0] [3 2]) '(4 5)))

21:17 lazybot: ⇒ (4 5 1 0 3 2)

21:28 justin_smith: kenrestivo: is ##(apply concat '(4 5) '([1 0] [3 2])) an option?

21:28 lazybot: ⇒ (4 5 1 0 3 2)

21:29 kenrestivo: that's simpler, thanks. the apply concat still bothers me a bit though.

21:29 justin_smith: it's the best way to concatenate items of a collection

21:36 Morgawr: kenrestivo: what about ##(concat '(4 5) (flatten '([1 0] [3 2])))

21:36 lazybot: ⇒ (4 5 1 0 3 2)

21:37 kenrestivo: yeah, i was tryin to avoid flatten too

21:37 Morgawr: I mean, it's not that different but it shows the intent in the code

21:37 alright

21:37 D:

21:37 justin_smith: (dec flatten)

21:37 lazybot: ⇒ -6

21:38 Morgawr: what's bad about flatten?

21:38 justin_smith: ~flatten

21:38 clojurebot: flatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.

21:38 kenrestivo: the first time i used flatten i got something like [\w \t \f \ \h \a \p \p \e \n \e d] and gave up ever using it again

21:38 Morgawr: ahah ok, fair enough

21:38 thanks justin_smith

21:38 justin_smith: kenrestivo: Morgawr: even better ##(flatten {:a 0 :b 1})

21:38 lazybot: ⇒ ()

21:38 justin_smith: lol

21:39 kenrestivo: wat?

21:39 justin_smith: inorite

21:39 Morgawr: well, it does look more flat

21:39 kenrestivo: what could be flatter than an empty list?

21:39 maybe nil

21:39 Frozenlock: o_O

21:39 metellus: why does that happen?

21:40 Morgawr: ,(flatten '())

21:40 clojurebot: ()

21:40 Frozenlock: ##(-> {:a 1} first flatten)

21:40 lazybot: ⇒ (:a 1)

21:40 Frozenlock: ##(-> {:a 1} flatten)

21:40 lazybot: ⇒ ()

21:40 kenrestivo: ,(flatten :pancake)

21:40 clojurebot: ()

21:40 metellus: ##(flatten {})

21:40 lazybot: ⇒ ()

21:40 Frozenlock: (╯°□°)╯︵ ┻━┻

21:40 justin_smith: &(flatten (seq {:a 0 :b 1}))

21:40 lazybot: ⇒ (:b 1 :a 0)

21:40 metellus: ##(flatten (seq {:a 1 :b 2{)

21:40 kenrestivo: things that are not flattenable return empty list? hmm.

21:40 Morgawr: ,(flatten [1 2 3 4]))

21:40 clojurebot: (1 2 3 4)

21:40 Morgawr: heh

21:40 metellus: beaten by typing speed and syntax errors

21:41 justin_smith: ,(flatten "hello, world!")

21:41 clojurebot: ()

21:41 Morgawr: t-t-thanks clojure

21:41 metellus: ,(doc flatten)

21:41 clojurebot: "([x]); Takes any nested combination of sequential things (lists, vectors, etc.) and returns their contents as a single, flat sequence. (flatten nil) returns an empty sequence."

21:41 kenrestivo: has anyone compiled a list of clojure wat's? there are only a handful IIRC

21:42 Morgawr: my favorite is

21:42 ,(str (map + [1 2 3 4 5]))

21:42 clojurebot: "clojure.lang.LazySeq@1c3e4a2"

21:42 Morgawr: every time

21:43 kenrestivo: mapv ftw

21:44 laziness, yeah, there's a whole class of those

21:44 godd2: .(str (doall (map + [1 2 3 4 5])))

21:44 kenrestivo: like... why does my code work in the repl but not in production

21:44 godd2: ,(str (doall (map + [1 2 3 4 5])))

21:44 clojurebot: "clojure.lang.LazySeq@1c3e4a2"

21:44 kenrestivo: ,(str (mapv + [1 2 3 4 5]))

21:44 clojurebot: "[1 2 3 4 5]"

21:45 justin_smith: ,(pr-str (map + [1 2 3 4 5]))

21:45 clojurebot: "(1 2 3 4 5)"

21:46 TEttinger: ,(pr-str (map inc (range)))

21:46 clojurebot: "(1 2 3 4 5 ...)"

21:46 godd2: ,(doall str (doall (map + [1 2 3 4 5]))))

21:46 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.core$str cannot be cast to java.lang.Number>

21:46 Morgawr: ,(apply str (map inc [1 2 3 4 5]))

21:46 clojurebot: "23456"

21:47 godd2: wait, whose threw an exception

21:47 Morgawr: yours

21:47 godd2: oh miner

21:47 justin_smith: godd2: yeah (doall str ...) makes no sense

21:47 godd2: ,(doall (str (doall (map + [1 2 3 4 5]))))

21:47 clojurebot: "clojure.lang.LazySeq@1c3e4a2"

21:47 Morgawr: ,(let [str 1] (doall str (map inc [1 2 3 4])))

21:47 clojurebot: (2 3 4 5)

21:47 Morgawr: ^ this made sense

21:47 ;)

21:47 justin_smith: haha

22:46 gfredericks: guys I've been using clojure for 18 years and I had no idea that do{all,run} took a second arg.

22:56 fairuz: gfredericks: Clojure is that old?

22:59 gfredericks: ~clojure |was invented by| C++

22:59 clojurebot: You don't have to tell me twice.

23:00 jeremyheiler: huh

23:00 justin_smith: ~clojure

23:00 clojurebot: clojure can make the Kessel Run in under twelve parsecs.

23:01 justin_smith: OK, but can it calculate a prime number in under a millimeter?

23:02 gfredericks: I sure hope so

23:03 kenrestivo: is there a way in schema to have an either key that is exclusive? i.e. :foo OR :bar is required but both together are disallowed?

23:03 gfredericks: kenrestivo: pred at worst

23:04 kenrestivo: suppose, could just write a fn

23:04 gfredericks: kenrestivo: and I bet if you glance at the impl of `either` it'd be straightforward to implement the xeither you want

23:04 kenrestivo: it does some pretty hairy tree walking

23:04 gfredericks: those dang hairy trees

23:05 kenrestivo: not to mix metfers

23:05 anyway, will ponder, thanks

23:06 justin_smith: https://www.google.com/search?q=hairy+tree&safe=on&espv=2&biw=1263&bih=954&source=lnms&tbm=isch&sa=X&ei=Npd6VK3REcSuogT9vYKQBQ&ved=0CAYQ_AUoAQ hairy trees

23:28 kenrestivo: that's not a tree, that's a graph

23:30 emaczen: does anyone here know how to configure a MongoDB database for a luminus project?

23:31 Balveda-2: There's an automatic configuration for that

23:31 like, for when you make a project in leiningen

23:32 emaczen: yes if you do +mongo it sets up a 'db' folder with a default mongo connection

23:32 lein new app +mongo

23:32 It works when I test in the REPl, so I am very lost...

23:33 Balveda-2: What is your problem exactly?

23:34 emaczen: Balveda: Are you familiar with luminus projects?

23:36 Balveda-2: Are you familiar with luminus projects?

23:36 Balveda-2: Sort of

23:37 emaczen: When you run "lein ring server," It will open up a browser and point you it to "localhost:3000/"

23:37 On that page, there is a message that says: "MongoDB configuration is required"

23:38 Under that it says "add the connection parameters in a .db.core"

23:39 ^^ I did that too -- and tested it in the REPL

23:39 uris77: newbie question, how can I load a properties file in clojure? I'm coming from java/groovy and writing my first clojure web app. Normally, I'd have a .env file that is just a property file with credentials for database, etc. When I deploy to heroku, those creds are just environment variables. But in development, I read the credentials from the .env file when the application boots up, and set them as property variables. What is the idiomatic way to do this in

23:42 Balveda-2: Weird, the db core file has a config built in iirc

23:43 emaczen: Balveda-2: What is iirc?

23:43 Balveda-2: if i recall correctly

23:52 justin_smith: uris77: you can use interop pretty easily, if you have specific questions about how the top answer here works, feel free to ask

23:52 http://stackoverflow.com/questions/7777882/loading-configuration-file-in-clojure-as-data-structure here, I mean

23:59 uris77: sweet, thank you @justin_smith

Logging service provided by n01se.net