#clojure logs

2014-11-29

00:46kenrestivowhat 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?
00:47kenrestivowas originally going to use core.async sliding-buffer, but it's not quite right
00:49kenrestivoand i'd like to stay in the safe confines of clojure-land instead of having to read jcip
01:23DrCherryclojure 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?
01:24andyfkenrestivo: It doesn't have the nicest Clojure-y API, but Clojure does have queues
01:25DrCherrythe data looks like this: http://pastebin.com/M9MHyBVc
01:25DrCherryI'm exploring StructMaps and records which seem like black magick.
01:26DrCherrythe data will ultimately be consumed by Factual/geo functions as polygons.
01:27andyfDrCherry: Clojure maps are nice and generic.
01:28andyfThey take up more memory than something customized, but if the data set doesn't stress the memory you have available ...
01:28DrCherrylooking into maps now.
01:29DrCherrythx, I thought this part would be trivial, lol.
04:11hellofunkis the "g" in leiningen pronounced like "good" or like "giraffe" ?
04:12_segfaulthellofunk: giraffe
04:12hellofunkthanks. i've been doing it wrong.
04:28rritochIs 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
04:29rritoch,(map #(.getCodePointAt (str %) 0) "\u04D21234")
04:29clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: getCodePointAt for class java.lang.String>
04:29rritoch,(map #(.codePointAt (str %) 0) "\u04D21234")
04:29clojurebot(1234 49 50 51 52)
04:29rritochTjat
04:29rritochThat is the output I'm expecting
04:30SagiCZ1and the char is not originally part of a string?
04:31rritochSagiCZ1: It is part of a string, but I need the values of each character, this is for a cryptography function
04:31rritoch,(map #(Character/getNumericValue %) "\u04D21234")
04:31clojurebot(-1 1 2 3 4)
04:32rritochAs far as I can tell from the documentation, this getNumericValueshould work, but it isn't returning the correccct values
04:38rritochI finally found a solution :)
04:38TEttinger,"\u04D2"
04:38clojurebot"Ӓ"
04:38rritoch,(map int "\u04D21234")
04:38clojurebot(1234 49 50 51 52)
04:38TEttingerheh yep
04:38rritochApparently int does it automatically :)
04:40TEttinger,(map int "int")
04:40clojurebot(105 110 65279 116)
04:40TEttinger,[(count "int") (count "int")]
04:40clojurebot[4 3]
04:41rritoch?
04:41rritochDid you find a bug or are you using characters that require 32 bits to represent?
04:41hellofunkin 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.
04:43mavbozohellofunk: cider-interrupt
04:43hellofunkmavbozo thanks
04:49TEttingerrritoch, invisible chars
04:49TEttinger,(char (int \ufeff))
04:49clojurebot\
04:51TEttingerrritoch: ##(Character/getNumericValue \百)
04:51lazybot⇒ -1
04:52TEttingeraww
04:52rritochYeah, I have no idea what getNumericValue is supposed to be doing
04:52TEttinger##(Character/getNumericValue \2)
04:52lazybot⇒ 2
04:52TEttinger##(int \2)
04:52lazybot⇒ 50
04:53TEttingersee the difference?
04:53rritoch,(Character/getNumericValue \A)
04:53clojurebot10
04:53TEttingergeNumericValue converts a char that represents a digit to the int value of that digit
04:53rritoch,(Character/getNumericValue \a)
04:53clojurebot10
04:53TEttinger,(Character/getNumericValue \z)
04:53clojurebot35
04:53rritochAaah
04:54TEttingerbase 36 there
04:54TEttingerit returns -1 if it can't figure out what base it should use or whatever
04:55TEttingeryou can specify radix in clojure numbers, which is ##(+ 36rCOOL 36rSTUFF)
04:55lazybot⇒ 49013568
05:12rritochThats 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.
05:13SagiCZ1,(Character/getNumericValue \ť)
05:13clojurebot-1
05:48SagiCZ1when i have a collection, how can i remove some elements?
05:48SagiCZ1[:a :b :a :c :d :b] --> remove :a :b --> [:c :d]
05:48SagiCZ1im not sure if is should make it into a set first
05:50SagiCZ1yeah i guess i will use set and disj
05:50SagiCZ1thanks
05:52ucbSagiCZ1: alternatively you can filter the collection
05:53SagiCZ1ucb: but that would still remove everything, not just the first occurence, so it has the same effect as disjoining set
05:53ucbyou never said you wanted to remove just the first occurrence ^_^
05:54SagiCZ1ucb: i know.. i am not sure whether i want it or not :)
05:54ucbI was mentioning filter in case you don't want to turn your original collection into a set
05:55ucbbut in any case you could do something like (filter (complement #{:a :b}) [:a :b :c :d])
05:55ucb,(filter (complement #{:a :b}) [:a :b :c :d])
05:55clojurebot(:c :d)
05:55SagiCZ1,(remove #{:a :b} [:a :b :c :d])
05:55clojurebot(:c :d)
05:55ucbheh
05:55ucbYES
05:55SagiCZ1good idea with the predicate
05:55SagiCZ1very concise
05:55ucbdidn't know remove existed :)
06:29SagiCZ1,(= (new JFrame) (JFrame.))
06:29clojurebot#<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: JFrame, compiling:(NO_SOURCE_PATH:0:0)>
06:30SagiCZ1,(= (new String) (String.))
06:30clojurebottrue
06:46jonathanjcould someone explain the reasoning behind writing HTML in a Lisp DSL (ala hiccup etc) instead of serving an HTML file?
06:49geekyvinHi 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}] }]
06:49geekyvinI tried a few methods unsuccessfully...could anyone kindly help.
06:50SagiCZ1geekyvin: hi, i remember you from yesterday
06:50geekyvinyeah...I am still stuck I could not find any significant suggestion yesterday :(
06:51SagiCZ1it would be better if you could specify the problem more than with just one example
06:52geekyvinbasically 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
06:53SagiCZ1geekyvin: let me look into it, but it might take a long time
06:54geekyvinno problem, thanks :)
06:56rritochSagiCZ1: 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
06:56rritoch,(= (reify Comparable (compareTo [this x] 0)) (reify Comparable (compareTo [this x] 0)))
06:56clojurebotfalse
06:57rritoch,(compare (reify Comparable (compareTo [this x] 0)) (reify Comparable (compareTo [this x] 0)))
06:57clojurebot0
06:58SagiCZ1geekyvin: are the names like Tom and Mark variables?
06:58geekyvinno they are values
06:58SagiCZ1geekyvin: values? containing what?
06:59SagiCZ1they have to be either strings or symbols
06:59SagiCZ1this is invalid
06:59SagiCZ1,{:name Tom :child nil}
06:59clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: Tom in this context, compiling:(NO_SOURCE_PATH:0:0)>
06:59geekyvinstring values
06:59SagiCZ1why do you missing the quotes then?
06:59SagiCZ1,{:name "Tom" :child nil}
06:59clojurebot{:name "Tom", :child nil}
06:59geekyvinthere should be quotes its just a example.
06:59SagiCZ1alright
07:03SagiCZ1geekyvin: sorry i cant wrap my brain around it
07:05geekyvin@SagiCZ1: which part? may be I can elaborate.
07:06SagiCZ1geekyvin: i think i understand what you need, but i dont think i am able to code it
07:07geekyvin@SagiCZ1: thats ok. I appreciate the effort. thank you :)
07:07alhimik45hi! what mean #_ here: https://github.com/clojure/clojure/blob/clojure-1.6.0/src/clj/clojure/core.clj#L3044
07:07SagiCZ1alhimik45: it comments out the whole sexp
07:08SagiCZ1forcing the reader to skip it entirely
07:09alhimik45SagiCZ1: thanks!
07:11SagiCZ1alhimik45: np
07:31rritochgeekyvin: 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
07:36rritoch,(def data [{:name "Tom" :child {:name "Mark" :child {:name "Jimmy"}}} {:name "Ben" :child {:name "John"}} {:name "Tom" :child {:name "Lucy"}}])
07:36clojurebot#'sandbox/data
07:36rritoch,(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)
07:36clojurebot[{:name "Ben", :child {:name "John"}} {:name "Tom", :child [{:name "Mark", :child {:name "Jimmy"}} {:name "Lucy"}]}]
07:39rritochgeekyvin: 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.
08:01rritochgeekyvin: Here is a better version that's less order dependent
08:01rritoch,(def data [{:name "Tom" :child {:name "Mark" :child {:name "Jimmy"}}} {:name "Ben" :child {:name "John"}} {:name "Tom" :child {:name "Lucy"}}])
08:01clojurebot#'sandbox/data
08:01rritoch,(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)
08:01clojurebot[{:name "Ben", :child {:name "John"}} {:name "Tom", :child [{:name "Mark", :child {:name "Jimmy"}} {:name "Lucy"}]}]
08:13OscarZi was reading up on core.async.. was wondering would it be good practice to try to implement a web server on core.async ?
08:17OscarZim 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. ?
08:18OscarZbut with core.async, theres no callbacks like in nodejs
08:37alhimik45I 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
08:43anneliesgfredericks: in your Deutsch–Jozsa example shouldn't you be observing output instead of (first inputs)?
08:44anneliesYou don't do seem to do anything to output except CNOTting it.
08:46gfredericksannelies: no I think it's correct as is, but definitely counterintuitive
08:46gfredericksannelies: the fact that they're entangled means doing things to one can affect the other
08:51gfredericksannelies: 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
08:56gfredericksmaybe should have pointed to this slide too for better context: http://upload.gfredericks.com/tmp/qc/qc.html#sec-4-1-2
08:57H4nsany recommendations for a sql dsl? my db is postgres and i need no portability. jql, slingvo, sqlkorma, something else?
09:01gfredericksH4ns: I use honeysql and don't know anything about the ones you mentioned
09:03H4nsgfredericks: thanks, looks nice.
09:08jonathanjhow does one bootstrap a database (ie. the database doesn't exist) with something like korma?
09:08SagiCZ1does :refer :all refer even private functions? defn- ?
09:11gfredericksSagiCZ1: no
09:12gfredericksjonathanj: probable via whatever raw-sql fallback korma provides
09:13jonathanjbleh
09:13jonathanjmaybe ragtime is a better starting point
09:14SagiCZ1gfredericks: why can i still call the function from other namespace then?
09:17gfredericksSagiCZ1: you shouldn't be able to; maybe giving a more complete example would be helpful
09:18SagiCZ1gfredericks: ok
09:18gfredericksSagiCZ1: e.g., compare to this I just did: https://www.refheap.com/94173
09:19SagiCZ1i think maybe its some bug in my editor
09:19SagiCZ1btw does anyone know if count on clojure.lang.Cons is O(1) ?
09:20gfredericksI believe it's not
09:20gfredericks,(doc counted?)
09:20clojurebot"([coll]); Returns true if coll implements count in constant time"
09:20gfredericks,(counted? "hey")
09:20clojurebotfalse
09:20gfrederickshrm.
09:20SagiCZ1cool
09:20gfredericksthat's misleading though
09:21SagiCZ1,(counted? [:a :b])
09:21clojurebottrue
09:21gfredericksSagiCZ1: in any case I think of the seq-like things only a PersistentList will be counted
09:21gfredericks,(counted? '(1 2 3))
09:21clojurebottrue
09:21gfredericks,(counted? (cons :haha '(1 2 3)))
09:21clojurebotfalse
09:21SagiCZ1i 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?
09:22gfredericks(-> coll rest empty?)
09:23SagiCZ1cool thanks!
09:24SagiCZ1wow so much faster! i think i knocked it from n^3 to n^2
09:24gfredericksha great :)
09:27SagiCZ1is this true? (-> coll rest empty?) == (empty? (rest coll))
09:27mearnshyes
09:28SagiCZ1thanks
09:31gfredericksdoes anybody know if there's a ticket or discussion about how misleading counted? is?
09:31gfredericksI could at least update the docstring
09:32alhimik45I 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
09:34gfredericksalhimik45: have you seen cljx?
09:40anneliesgfredericks: is there also a talk with these slides or just the slides?
09:41alhimik45gfredericks: I am using Hoplon, that uses boot instead lein, but cljx is lein plugin
09:42gfredericksannelies: not a recorded talk
09:42gfredericksalhimik45: ah, that sounds difficult then.
09:42gfredericksmaybe there is a hoplon-specific way of doing it
09:43anneliesoh ok
09:46SirRobinHi
09:46gfrederickshi
09:46SirRobinsince things like filter<, map< are deprecated in favor of transformers
09:47SirRobinis there an example/article on how to do this nicely?
09:47justin_smithSirRobin: transducers
09:48justin_smithright prefix though
09:48mavbozoSirRobin: what clojure version are you using?
09:48SirRobinthe doc says "Use transformer instead", so I thought I'd use that word too
09:48justin_smithoh, weird
09:48justin_smithcould be a doc typo?
09:49justin_smithor maybe there is a "transformer" i have yet to hear of
09:49SirRobinI don't think so, I've heard thte term in the context of transducers
09:49SirRobinwe're talking about the same thing
09:50SirRobinand I'm using clojurescript "0.0-2371" with core.async "0.1.338.0-5c5012-alpha"
09:51justin_smithSirRobin: this is from martinklepsch, who may even be here :) http://www.martinklepsch.org/posts/using-coreasync-and-transducers-for-direct-s3-upload.html
09:51SirRobinyeah, just found it searching with transducers instead of transformers :)
09:51martinklepschhaha, does the documentation still call them transformers? :)
09:52justin_smithyeah, I think the transducer search term will find better results
09:52SirRobinin core.async, yes
09:53mavbozomartinklepsch: your code is meant for clojure, not clojurescript, right?
09:53martinklepschSirRobin: depending on what you want to do it might also be worth looking at pipeline-async
09:53martinklepschmavbozo: clojurescript
09:54martinklepschI still haven't really come accross a problem where I thought "transducers are the right solution"
09:55martinklepschrecently 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
09:55justin_smithmartinklepsch: I think most problems where transducers are the right solution are performance problems
09:55mavbozoback to SirRobin question, I think filter> and filter< is deprecated because in clojure 1.7 we can use ordinary filter
09:55justin_smithmartinklepsch: that, or you are making a new thing in league with collections or channels, and want cheap map / filter / etc. impl
09:55mavbozobut I don't know about clojurescript
09:56justin_smithmavbozo: yes, you can, because transducers
09:56justin_smiththey generalize map / filter over data sources
09:56SirRobinok right, that makes sense
09:56martinklepschmavbozo: thanks for keeping this on track, got off a bit I guess :)
09:57mavbozobut what clojurescript version that starts to support ordinary map, filter, etc for tranducers?
09:58justin_smithmavbozo: transducers are a new impl of map, filter etc.
09:58justin_smithas soon as you have transducers, you can use them with channels
09:58justin_smithdo you mean, which version of cljs has transducers?
09:58mavbozojustin_smith: yes
10:00SagiCZ1can gc free up some cache used by memoized function?
10:00justin_smithno
10:01SagiCZ1well can i set manually the maximum cache for memoized function or at least an expiration date?
10:01justin_smithhttps://groups.google.com/forum/#!topic/clojurescript/ghpbnZKjx3w mavbozo - here is the announcement of cljs transducers
10:01justin_smithSagiCZ1: things like core.cached can, but regular memoize cannot
10:02mavbozo(inc justin_smith)
10:02lazybot⇒ 150
10:02justin_smithI 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:03mavbozothen SirRobin can use filter in his clojurescript version
10:03SagiCZ1justin_smith: cool thanks
10:03justin_smithmavbozo: well, the presence of that warning was a good indicator :)
10:05justin_smithSagiCZ1: 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:06justin_smithsorry, core.cache https://github.com/clojure/core.cache
10:06SagiCZ1justin_smith: it looks good and easy to use..
10:08justin_smithif you mean spawning-grounds - thanks
10:08SagiCZ1justin_smith: yes thats what i meant
10:08justin_smithI think the api for implementing caches could be cleaner, but I tried to keep the basic caches pretty simple
10:08SagiCZ1the api seems very powerful though..
10:09justin_smiththat was the goal, yeah
10:10SagiCZ1im 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:11DrCherryI'm having trouble with the truthyiess of this test. Why is it failing? http://pastebin.com/Hdqps751
10:11justin_smithSagiCZ1: 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:12justin_smithSagiCZ1: though it could be modified to do a sweep / purge on each usage
10:12DrCherrywhoops let me repost the code
10:12SagiCZ1justin_smith: i see.. that is different
10:12mavbozo,(true? (true))
10:12clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IFn>
10:12justin_smithSagiCZ1: it's for caching data from a backend
10:12justin_smithmavbozo: true is not a function
10:12SagiCZ1i understand
10:13justin_smithSagiCZ1: I think the core.cache LRU cache may be closer to what you need
10:13mavbozojustin_smith: oops, dumb copy-paste from DrCherry gist :)
10:13DrCherryhttp://pastebin.com/pLv8SE9C
10:13mavbozo,(not (true? '(true))
10:13clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
10:13justin_smithDrCherry: map will never return true
10:14mavbozo,(not (true? '(true)))
10:14mavbozo
10:14clojurebottrue
10:14DrCherryI'm trying to see if the file is there.
10:14justin_smith&(true? [1 2 3])
10:14lazybot⇒ false
10:14DrCherryI'm trying to see if the file is there.
10:14justin_smiththen don't use a predicate
10:14justin_smithjust use seq
10:14SagiCZ1justin_smith: and what do you think about the possibilty of the cache getting so big it diminishes the advantages of look up?
10:14justin_smith,(if (seq []) :yes :no)
10:14clojurebot:no
10:15DrCherryso just drop the true?
10:15justin_smith,(if (seq [1]) :yes :no)
10:15clojurebot:yes
10:15justin_smithyes
10:15justin_smithhaha
10:15justin_smithor you can use not-empty if you feel that makes it more clear
10:15justin_smithbut not-empty is not strictly needed
10:15justin_smith,(not-empty [])
10:15clojurebotnil
10:15justin_smith,(not-empty [1])
10:15clojurebot[1]
10:15DrCherryderp
10:16mavbozo&(some? [])
10:16lazybot⇒ true
10:16justin_smithmavbozo: that's why I used seq or not-empty
10:17justin_smith&(some? (not-empty []))
10:17lazybot⇒ false
10:17anneliesgfredericks: thanks, I think I get it now except it seems to contradict with http://physics.stackexchange.com/a/2209/1313
10:18anneliesthe "the correlation only becomes evident after combining the results from the measurements afterwards" part
10:19anneliesOr does this work because the qubits are known to be in state |0⟩ when the algorithm begins?
10:20DrCherryokay, I changed the name of the file to a file that doesn't exist and test doesn't fail
10:23gfredericksannelies: well it certainly relies on them starting at 0, yeah
10:23DrCherryit appears to return an object even if it fails, making it true.
10:24anneliesgfredericks: right, and the spin of the pions in the Physics SE answer is unknown unlike the qubit states
10:24anneliesthanks a lot!
10:24gfrederickshrm
10:24gfredericksI'm not quite making the connection
10:25gfredericksbut one thing to note is that the measurement at the end is deterministic
10:26gfrederickswhich might be what you meant
10:29anneliesOh I meant electron and positron, not pion.
10:30anneliesI should read up on Bell's theorem.
10:43DrCherrySo in repl this comes back as (false) as it should: (map #(.exists (clojure.java.io/as-file %)) '("data/gr_neighborhoods.tx"))
10:43DrCherryhow do I make test recognize that?
10:44DrCherryI tried wrapping it in (true? ) didn't work.
10:44justin_smith,(= [false] '(false)) ; DrCherry
10:44clojurebottrue
10:45DrCherryjustin_smith, I don't exactly understand your syntax
10:45justin_smith,(some? identity [false]) ; alternatively
10:45clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core/some?>
10:45justin_smith,(some identity [false]) ; alternatively
10:45clojurebotnil
10:46justin_smithDrCherry: which part don't you understand?
10:46DrCherryjustin_smith, how to apply your response to my line of code
10:47justin_smith(= [false] (map ...))
10:47justin_smiththat only works if you know it is only one item
10:47justin_smithand then I wonder why you are mapping at all
10:47justin_smithyou could also verify (nil? (some identity (map ...)))
10:47DrCherry(=[false] (map #(.exists (clojure.java.io/as-file %)) '("data/gr_neighborhoods.tx"))) : ok!
10:48justin_smithyou are verifying that it returns a collection, with only one item, that is false
10:49DrCherrythat passes weather I use [true] or [false]
10:49justin_smithit shouldn't
10:49justin_smithare you using is?
10:49DrCherrynope, let me try that
10:50justin_smithwithout is, no test is run
10:50DrCherryoh. Is there a good tutorial on test?
10:50justin_smithhttps://clojure.github.io/clojure/clojure.test-api.html
10:50DrCherrythat was it. I had no is
10:51DrCherrythis is going to be a long day
10:51justin_smithDrCherry: clojure is worth it though
10:51justin_smithnote that the very beginning of the docs for clojure.test is the "is" macro :)
10:51DrCherryMeh, it's just for a job. I'm going to fail this programming test.
10:52DrCherryThey gave me an exercise in a language I've never used.
10:52bobpoekertI should be able to import clojure.lang.Murmur3, right?
10:52DrCherrythinking about becoming a gypsy
10:53justin_smithbobpoekert: looks like it, yeah
10:54bobpoekerthm. I get a ClassNotFoundException when I try
10:55dbaschbobpoekert: are you importing it or requiring it?
10:55bobpoekertdbasch: I’m importing it
10:56justin_smithbobpoekert: works for me in a clojure 1.7-alpha3 repl
10:56dbasch&(import 'clojure.lang.Murmur3)
10:56lazybot⇒ clojure.lang.Murmur3
10:56justin_smith&(import clojure.lang.Murmur3)
10:56lazybot⇒ clojure.lang.Murmur3
10:56justin_smithhehe
10:56bobpoekertweird
10:56bobpoekertmust be a version issue
10:56dbaschalso works for me on 1.6.0
10:57bobpoekertthis project was originally using 1.4.0, so maybe lein-vimclojure is still using 1.4.0 for some reason
11:01dbaschbobpoekert: what is the value of *clojure-version* ?
11:01bobpoekertdbasch: {:major 1, :minor 5, :incremental 0, :qualifier "RC17"}
11:01dbaschbobpoekert: Murmur3 is from 1.6.0
11:02bobpoekertyeah
11:02bobpoekertso the question is why is this running under 1.5
11:02bobpoekertwhen my project.clj says 1.6
11:02justin_smithbobpoekert: lein deps :tree
11:02justin_smithone of your deps is overriding your clojure version
11:02bobpoekert[org.clojure/clojure "1.6.0”], it says
11:03justin_smithrun lein deps :tree
11:03bobpoekertjustin_smith: all of my deps are java libraries
11:03bobpoekertI don’t have any clojure libraries as deps
11:03justin_smithso you are saying when you run the deps tree, it gives you a different version of clojure than the one that runs?
11:03bobpoekertyes
11:04bobpoekertthan runs /in vimclojure/
11:04justin_smithvimclojure uses lein
11:04justin_smithit will use the project.clj
11:04justin_smithunless vimclojure is seriously fucked up...
11:04bobpoekertit’s supposed to
11:04bobpoekertlein repl is using 1.6.0
11:05justin_smithOK, file a bug with vimclojure I guess
11:05justin_smithdo you know the exact command line vimclojure uses to run lein? maybe you can grab it from ps x
11:06bobpoekertjustin_smith: good idea
11:06justin_smithit could be they are adding their own middleware that overrides the clojure version
11:06redwireHello 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:07gfrederickshonk if you like better docstrings http://dev.clojure.org/jira/browse/CLJ-1607
11:07dbaschmaybe it’s picking up a version of clojure from your classpath or something
11:10justin_smithdbasch: what other than project.clj would be influencing his classpath?
11:10bobpoekertdbasch: 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:21mattreplanyone using a graph/plot library?
11:25leandrowhy printf prints with leiningen and not in a .jar? this is my simple script http://ur1.ca/ixkpg
11:26andyfleandro: Try putting a (flush) call at the end, or at least after the last printf. printf does not flush for you
11:26andyfprintln does
11:27leandroyea, but println doesnt allow "%s\n", isnt it?
11:27mattrepl(println (format …))
11:27andyfIf you move the @ from your printf to your format call, you can just do (println (format ...)) as mattrepl suggests
11:27leandrooh, yes
11:28andyfor do (flush) at the end and use printf, or a mix of printf and println
11:28leandro:)
11:28leandrothanks
11:28leandrodidn't know about the thing with flush & printf
11:32andyfYeah, it is not obvious. I just added some notes about it to ClojureDocs.org here: http://clojuredocs.org/clojure.core/printf
11:47SagiCZ1is there some abstract function like recur or something that lets me modify the source collection?
11:48andyf SagiCZ1: When you say 'let me modify the source collection' do you mean to mutate it? Actually modify something intended to be immutable?
11:48SagiCZ1something 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:48SagiCZ1andyf: no
11:49SagiCZ1andyf: its something i am able to achieve with regular loop.. im just wondering if there is a nicer way
11:50justin_smithSagiCZ1: what about (reduce f coll coll)
11:50gfredericksSagiCZ1: why not make it part of the "accumulator" arg in your reduce fn?
11:50justin_smithyou get the collection as a base case to work with, and also deal with each element individually
11:50SagiCZ1justin_smith: oh.. interesting
11:51SagiCZ1justin_smith: i also need to be building a destination collection at the same time though
11:52justin_smithSagiCZ1: OK, (reduce f [coll []] coll)
11:52andyfyou 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:52justin_smithexactly
11:52SagiCZ1andyf: i see.. i could do that
11:52SagiCZ1thank you both
11:53justin_smithSagiCZ1: with the help of destructuring on your reducing function, the parts of the accumulator can even look like separate args
11:54SagiCZ1the source collection is still passed into the function sequentially right?
11:54andyfThe collection that is the last arg to reduce is still stepped through, and your reduce fn called once per element, yes
11:54andyfreduce doesn't know whether the same collection is all or part of the init arg value, and doesn't care.
11:56gfredericks,(let [xs (range 5)] (reduce conj xs xs))
11:56clojurebot(4 3 2 1 0 ...)
11:57gfredericks,(let [xs (range 5)] (pr-str (reduce conj xs xs)))
11:57clojurebot"(4 3 2 1 0 ...)"
11:57gfrederickspff
11:57SagiCZ1this is refheap of my loop https://www.refheap.com/94174
11:57gfredericks,(let [xs (range 5)] (clojure.string/join " " (reduce conj xs xs)))
11:57SagiCZ1not sure i can use reduce
11:57clojurebot"4 3 2 1 0 0 1 2 3 4"
11:58gfredericksSagiCZ1: depends on what "choose-one" is doing
11:58gfredericksSagiCZ1: are you just trying to pull things out of your collection in a random order?
11:58SagiCZ1it returns one element from the source collection depending on what the previous chosen was
11:58SagiCZ1the order is not random..
11:58gfredericksSagiCZ1: btw (last a-vector) is slower than (peek a-vector)
11:59bbloomSagiCZ1: a loop is fine, but you can also consider reducing where your accumulator is a vector of [x coll]
11:59SagiCZ1,(peek [1 2 3])
11:59clojurebot3
11:59SagiCZ1thanks
11:59gfredericksbut yeah the different-order thing probably precludes reduce
12:00SagiCZ1bbloom: could you elaborate please? i am slow..
12:01gfredericksbbloom might be lagging
12:01bbloomSagiCZ1: nothing new tha thasn't been said by the others here
12:01justin_smithSagiCZ1: I think you could use reduce if you rewrite choose-one
12:01bbloomdammit.
12:01bbloomwtf?
12:01SagiCZ1what s
12:01gfredericksbbloom: I take it back
12:01bbloomgfredericks: ping
12:01gfredericksbbloom: pong
12:01bbloomok...
12:01bbloomi guess i'm ok :-P
12:02gfredericksbbloom: it was a kind of gray case
12:02gfredericksclojurebot: bbloom |lags| sometimes
12:02clojurebotOk.
12:02andyfSagiCZ1: The first time through your loop, dest is [] and (last dest) is nil. I guess choose-one does something reasonable then?
12:02bbloomgfredericks: but i think i've fixed it :-PP
12:02SagiCZ1andyf: yeah it was pseudocode, the first thing in dest is chosen randomly from source.. the others always depend on the previous chosen
12:02gfredericksbbloom: 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:03bbloom*sigh*
12:11grandyanyone know if there is a way to pass in a map to a yesql query-function (for passing in values for an insert)?
12:12grandy(new to clojure so apologies if this is obvious)
12:12justin_smithSagiCZ1: 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:15justin_smithgrandy: not that I see, but you can construct it using juxt
12:15grandyjustin_smith: juxt?
12:15justin_smith,((juxt :id :name :id) {:id 1 :name "bob"})
12:15clojurebot[1 "bob" 1]
12:15justin_smiththat lets you pass a map, and get specific keys in the order needed
12:16grandyjustin_smith: awesome I didn't realize that existed :)
12:16justin_smiththen you would (apply your-yesql-fn coll) with that collection
12:16justin_smithand obviously you can use every key in the map 0 or more times as needed
12:16grandyjustin_smith: excellent, oh what about the other arg I have to have first (the db spec) ... best practice for including that ?
12:17justin_smithyou could make a wrapper function that inserts that automatically, or include it in the map you pass in
12:17grandyjustin_smith: ahh ok excellent
12:18justin_smithmaybe you want a small helper (defn mapply-db [db] (fn [opts] (apply yesql-fn db ((juxt :keys :to :use) opts))))
12:18grandyjustin_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:19justin_smithnot at all
12:19justin_smithjust showing how apply / juxt can get you most of the way there
12:19grandyjustin_smith: yeah indeed it does, and I think it's a bit more concise in this case
12:21martinklepschanyone here aware of a small java library that helps with syncing static websites to S3?
12:22martinklepschthinking of this: https://github.com/laurilehmijoki/s3_website but hopefully more pluggable
12:22justin_smithmartinklepsch: no, but clj-aws-s3 is easy to use
12:22justin_smithI guess you probably considered that already, I know you've used clj-aws-s3
12:23martinklepschjustin_smith: yeah, that could work. was hoping something more specialized existed already :)
12:24martinklepschalso cloudfront stuff in s3_website is useful
12:40jjttjjI 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:41jjttjjI think the issue is with mixing this project here: https://github.com/jamesmacaulay/shopify-clj/blob/master/project.clj with pedestal service
12:41gfredericksjjttjj: try `lein deps :tree` and look at the bits at the top
12:44bobpoekertupdate: upgrading lein and lein-tarsier fixed my clojure version problem
12:48jjttjjgfredericks: I fixed all the lein deps: tree warnings but still having the same issue
12:51gfredericksjjttjj: and you did `lein clean`?
12:52jjttjjgfredericks: yes
12:53gfredericksjjttjj: if you could share your project.clj we could try to reproduce
12:53justin_smithjjttjj: and you have org.clojure/core.memoize in your deps? it isn't part of clojure.core's artifact
12:54justin_smithoh wait, it is contrib, so it isn't even org.clojure
12:54jjttjjjustin_smith: I don't have it but im not using it (i guess another dep is though so I'll try adding it)
12:54jjttjjgfredericks: here's the project.clj https://www.refheap.com/94176
12:55justin_smithclearly if they are not explicitly depending it, but they use it, that would be a reportable bug
12:55grandywould 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:55grandyhttps://gist.github.com/anonymous/06326dd2adb3048d14e3
12:56justin_smithgrandy: that if / let combo could be a single when-let
12:56justin_smitherr - no, I guess not
12:56justin_smithheh
12:56justin_smithI mean you could shoehorn it
12:57grandyjustin_smith: yeah good point
12:57justin_smithanothe option (defn create-user [params] {pre [(b/valid? params user-validator)]} (let ...))
12:57jjttjjjustin_smith: ok adding the core.memoize dep worked! thanks!
12:57justin_smithdepending on whether you want an error in that case
12:57grandyjustin_smith: ahh interesting
12:57justin_smithjjttjj: you should figure out which project was using core.memoize and file a bug report
12:58grandyjustin_smith: i do like the way the pre feels
12:58justin_smithgrandy: should that be an error, or just silently nil
12:58jjttjjjustin_smith: yup looking into it now
12:58justin_smithbecause a :pre will trigger an AssertionError
12:58weavejes_grandy: Why do you have b/validate and v/valid?
12:58weavejes_Asserts shouldn't be used for validation purposes.
12:59weavejes_Because a validation fail is not an error.
12:59weavejes_Preconditions are there for fast failure.
12:59grandyweavejes_: i wanted to validate the data first, and if it's invalid then return the errors map
12:59grandyweavejes_: ahh interesting
12:59weavejes_grandy: Which library is b/validate from?
13:00grandybouncer
13:00justin_smithgrandy: oh wait, I was mislead by the indentation
13:00justin_smiththere are two clauses in that if...
13:01grandyjustin_smith: oops hit tab in emacs and fixed it, not sure how that happened :)
13:01justin_smithso yeah, definitely don't want when there
13:01grandyfixed:
13:01grandyhttps://www.irccloud.com/pastebin/MErdwEfv
13:01weavejes_If b/validate returns nil if there are no errors, you can only validate once.
13:02weavejes_Or may only validate once.
13:02grandyweavejes_: true, do you think that is a smarter way to write it? was going for clarity
13:03weavejes_Hm, the bouncer library is built a little differently to how I'd expect.
13:03grandyweavejes_: ahh also if you recommend a different way to validate data i'd be interested to hear your thoughts
13:03weavejes_It looks like it doesn't return nil if there are no errors, which is a shame.
13:03grandyweavejes_: yeah that is what i would have expected actually, to allow just one call
13:04justin_smithweavejes_: if it did, you could just do an if-let on the validator, and make the error case the first branch
13:04grandyweavejes_: I think it's done that way so the calls can chained or something... not sure
13:04weavejes_Right. Then you could just write: (if-let [errors (b/validate params)] ...)
13:05grandyany recommendations for other validation libraries? this one seemed nice but i haven't really done much research on that
13:06weavejes_I haven't found a validation library that does everything I want to, yet...
13:06justin_smithseems like prismatic/schema would be flexible enough to build whatever
13:06weavejestergrandy: Are you just validating URL params?
13:07weavejesterYeah, schema is one solution, but it's not as flexible as I'd like.
13:07grandyhmm interesting, ok i'll look at that one,... weavejester well yeah just putting some validation logic between the web forms and the db
13:07SagiCZ1can i use apply on interop method?
13:07SagiCZ1(apply .javaMethod args)
13:07weavejesterSome validations are complex. For example, checking to make sure that a password typed twice is the same.
13:07justin_smithSagiCZ1: no, because methods are not first class
13:07SagiCZ1ok
13:08grandyweavejester: yeah i haven't figured out the best way to handle that case using bouncer yet
13:09grandyschema does look very nice actually
13:10weavejestergrandy: You might want to try out the schema/check function
13:11grandyweavejester: ok will check it out (pardon the pun)
13:12grandyweavejester: ahh yeah it looks like the exact behavior i'm looking for
13:12weavejesterAh crap, clojars has failed on a jar upload
13:14weavejestertechnomancy: 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:14grandyweavejester: really liking compojure... thanks much for creating it.
13:14weavejestergrandy: You're welcome
13:26engblomIs 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:26justin_smithengblom: lazybot uses irclj
13:27justin_smithoh, you mean like a human usable client with a UI
13:27justin_smithirclj is a client in that it can connect to IRC and communicate with it
13:27engblomI would want something similar to Irssi/Weechat, but written in Clojure
13:28justin_smithengblom: yeah, pretty sure you would have to write that yourself
13:28leandrogiven a map, i want to acces to ":sunday", but i have the value in a variable "day" how can do (get mymap :day) ?
13:28gfredericksI've heard of precious few terminal UIs written in clojure
13:28engblomOK, bad luck then. I do not have time to write a whole irc client but I could have been modifying an existing one.
13:28justin_smithleandro: ##(let [day :sunday] (get {:sunday "hello"} day)) like this?
13:28weavejesterleandro: What does the map look like?
13:28lazybot⇒ "hello"
13:29justin_smithwhat do you mean by variable?
13:29gfredericksthis is probably the only one I've heard of: https://github.com/maitria/avi
13:29metellusengblom: this doesn't help with the clojure but irssi has a couple spellcheck scripts
13:30leandroi get the day string with clj-time. the map has an index for each weekday
13:30engblommetellus: 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:30engblommetellus: Like changing color for badly spelled words.
13:30justin_smithengblom: how about erc and fly-spell?
13:31justin_smitherr, flyspell that is
13:31justin_smithI 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:31creeseWhat's the best way to load a dependency when I start cider if I don't have a project? For example, clj-http.
13:32engblomjustin_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:32metellusengblom: 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:32justin_smithcreese: do you want it to always be available?
13:32creesesure
13:32gfrederickscreese: I keep a library for loading deps dynamically
13:32justin_smithcreese: I use pallet/alembic (in my .lein/profiles.clj) to load deps at runtime
13:33justin_smithbut a lot of things in lein don't make much sense without a project
13:33engblommetellus: What script do you use?
13:34metellusaspell_complete.pl
13:34engblomThanks
13:36creesejustin_smith: even to use pallet/alembic, I need a project right?
13:39gfrederickshey does anybody [not] like utility libs? https://github.com/palletops/lein-shorthand/issues/2
13:40justin_smithcreese: no
13:40justin_smithcreese: you can specify deps that should always be present in ~/.lein/profiles.clj
13:40rritochDoes 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:41gfredericksrritoch: did you need to `lein clean`?
13:41justin_smithrritoch: 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:41rritochYes, I ran lein do clean, compile
13:42justin_smithI seem to recall you had some hack to compile from a URI
13:43rritochjusting_smith: It has nothing to do with that hack, but I do call (.newInstance (.loadClass .... in the file that is crashing
13:43bbloomgfredericks: 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:43bbloomgfredericks: i really want to pull in ONE function
13:43gfredericksbbloom: yeah and this would let you do that, with a bit of project.clj noise
13:44rritochThis is the file that's crashing, and it doesn't do much
13:44rritochhttps://github.com/rritoch/clj-grid-core/blob/master/src/com/vnetpublishing/clj/grid/lib/grid/jsp/instance_manager.clj
13:44bbloomgfredericks: was talking w/ somebody at clj/nyc too about a sort of utilities database site
13:45gfrederickswith some crazy custom dependency resolution thing? :)
13:45bbloomgfredericks: 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:45bbloomwhich could of course be part of the build process
13:45bbloomi think it would be super cool to see which utils were popular
13:45bbloomand to get dependency resolution at the def-level, rather than the project level
13:46rritochRunning lein clean doesn't make a difference, it's still crashing
13:46bbloomthere's also Joe Armstrong's rant on this: http://lambda-the-ultimate.org/node/5079
13:46bbloomseems more of a social/community problem than a technical one
13:47gfredericksbbloom: yeah
13:47andyfNot 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:51xelxebarI'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:51gfredericksxelxebar: is it a bunch of filters?
13:52xelxebarjust a sec, gonna give you a pastebin, but yeah.
13:53gfredericksyeah I don't know if there's any good way to get that kind of code structure
13:53gfrederickscomposing 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:53xelxebarwhat's a good pastebin for clojure? :P
13:53gfredericks~paste
13:53clojurebotpaste is https://refheap.com/
13:54xelxebarhttps://www.refheap.com/94179
13:54kenrestivoi think "we need letrec" would make a good t-shirt design
13:54ricky_-/nick ricky_____
13:55justin_smithkenrestivo: letfn isn't good enough?
13:55kenrestivoor like a protest, occupy kids on the street, with signs that say "we need letrec!"
13:55justin_smithkenrestivo: or you need it for recursive values, not just recursive functions?
13:55kenrestivojustin_smith: i'm referring to that joe armstrong post
13:55kenrestivohttp://lambda-the-ultimate.org/node/5079
13:55kenrestivoletfn works just fine in clojure, yes.
13:56kenrestivoin fact someone showed me a very cool technique for avoiding nested lets by using letfn
13:56gfredericksxelxebar: so are you still wondering why you get the exception?
13:57xelxebargfredericks: 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:58xelxebarHere, I also hacked together a sieve that finds the nth prime
13:58xelxebarhttps://www.refheap.com/94180
13:58xelxebarAnd well, it's horrendously ugly.
13:59gfredericksxelxebar: 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:59xelxebarYeah, that's pretty much what the nth-prime func is doing.
14:00gfredericksI'll whip up a lazy-seq version that might be instructive
14:00ricky_____If anyone has a chance, I'm having some get-metadata-from-ref problems @ http://pastebin.com/xdFuQVn5
14:00xelxebarThanks!
14:01gfredericksxelxebar: it's a different style of recursion so it's useful to see the difference
14:01rritochjustin_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:02rritochException 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:03rritochIs there now a block that you can't load child dependencies?
14:04rritochI have another library that depends directly on the kernel and that compiled without a problem.
14:04weavejesterricky_____: You're trying to get metadata from vars that don't exist, not from refs.
14:05weavejesterricky_____: There's a distinction between a var and the data contained within it.
14:05justin_smithyeah, 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:05weavejester#(do (def ^{:owner "foo"} v {:bar "baz}) (meta v))
14:06weavejester##(do (def ^{:owner "foo"} v {:bar "baz}) (meta v))
14:06gfredericksxelxebar: https://www.refheap.com/94183
14:06weavejester&(do (def ^{:owner "foo"} v {:bar "baz}) (meta v))
14:06lazybotjava.lang.RuntimeException: EOF while reading string
14:06weavejester&(do (def ^{:owner "foo"} v {:bar "baz"}) (meta v))
14:06lazybotjava.lang.SecurityException: You tripped the alarm! def is bad!
14:06gfredericksI tried to do a larger example of nth but it took too long :)
14:06weavejester,(do (def ^{:owner "foo"} v {:bar "baz"}) (meta v))
14:06clojurebotnil
14:06xelxebargfredericks: cool. taking a look
14:06weavejester,(do (def ^{:owner "foo"} v {:bar "baz"}) (meta #'v))
14:06clojurebot{:ns #<Namespace sandbox>, :name v, :file "NO_SOURCE_PATH", :column 0, :line 0, ...}
14:06rritochI was able to fix this compile error simply by adding the dependency directly, is this a bug in clojure?
14:07rritochUntil upgrading I had no problem accessing dependencies of dependencies.
14:08gfredericksxelxebar: could be a bit confusing since there's logically two different collections of primes involved
14:08ricky_____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:09justin_smithricky_____: this isn't about concurrency though
14:09weavejesterricky_____: Well, vars are essentially pointers to values.
14:09xelxebargfredericks: cool!
14:09weavejesterricky_____: So if I (def x 1), then if I type x it automatically gets the value.
14:10ricky_____OK
14:10weavejesterricky_____: It's essentially the opposite behaviour of refs
14:10xelxebarI had to look up what some did
14:10weavejesterricky_____: With a ref, you deref with @, and if you don't deref you get the ref itself, right?
14:10weavejesterricky_____: With vars, they're derefed automatically, and if you want to get the var itself, you use #'
14:11xelxebargfredericks: I really like this! Thanks for taking the time to whip that up.
14:11weavejesterricky_____: You want to add metadata to the refs themselves, right? Not the vars?
14:11ricky_____Ahhh, yeah!
14:11gfredericksxelxebar: np
14:12weavejesterricky_____: The ^ form attaches metadata at compile time. Runtime metadata can be added with with-meta
14:12gfredericksxelxebar: normally you don't have to stoop to using the lazy-seq macro directly, but lazy prime computation is kind of special
14:12weavejesterricky_____: So (with-meta (ref 100) {:owner "foo"}) to attach metadata, and meta to detach it.
14:13weavejesterOr read it, rather
14:13weavejester,(let [r (with-meta (ref 100) {:owner "foo"})] (meta r))
14:13clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Ref cannot be cast to clojure.lang.IObj>
14:13weavejesterHuh... Refs aren't IObjs?
14:13justin_smithin general, representing the bank account as a map makes sense though, and you can have a :value key for the numeric value contained
14:13xelxebargfredericks: Do you mean that usually we can just bank on the laziness of core functions and stuff?
14:13xelxebargfredericks: And what makes primes special here?
14:14gfredericksxelxebar: it's unusual to take a collection and call filter on it *over and over and over*
14:14weavejesterricky_____: Looks like you might need to do something like: {:owner "foo", :value (ref 100)} instead
14:14gfredericksas long as you're just using a handful of transformation functions you should be fine
14:14gfredericksthere's a related gotcha with repeated use of concat, which people run into pretty frequently
14:15justin_smithweavejester: why not (ref {:owner "foo" :value 100}) ?
14:16ricky_____I would guess so the owner can't change?
14:16ricky_____Depends if that's desired or not.
14:16weavejesterjustin_smith: I assumed the owner of the ref was fixed, but yep, you could do it like that.
14:16justin_smithricky_____: it's easy to change metadata, and changing metadata isn't even thread safe
14:17weavejesterjustin_smith: When isn't it thread safe?
14:17weavejesterwith-meta obviously is, and I thought vary-meta! was as well...
14:17xelxebargfredericks: hmmm. do you mean like if you concat an expensive-to-calculate eager seq to the head of a lazy one?
14:18xelxebargfredericks: makes me wonder how lazy concated to eager works...
14:19xelxebarI'd guess that you keep getting lazily evaluated stuff until you hit the head of the eager seq.
14:19gfredericksxelxebar: no it's only a problem if you concat repeatedly
14:19gfredericks,(->> (range 10000) (map list) (reduce concat) (last))
14:19clojurebot#<StackOverflowError java.lang.StackOverflowError>
14:19gfredericksxelxebar: note that ^that involves 10000 calls to concat
14:20xelxebargfredericks: noob question: what is the ->> , I'm guessing a macro?
14:20gfredericksyeah
14:21gfredericks,(last (reduce concat (map list (range 10000)))) ;; same thing
14:21clojurebot#<StackOverflowError java.lang.StackOverflowError>
14:21xelxebarcute
14:22ricky_____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:22xelxebargfredericks: ->> feels like do notation in Haskell
14:22gfredericksit's definitely used about as often
14:23gfredericksat least if you include ->
14:24justin_smithweavejester: oh, you're right, they both return a new object
14:30gfredericksxelxebar: I just realized mine would be slightly more efficient with a vector for primes-so-far instead of a list
14:30gfredericksso that you check the smaller ones first
14:30xelxebaroh? let me look at that
14:31xelxebarI was just checking out how fast it was compared to my shitty nth-prime
14:31gfredericksit should be assymptotically the same
14:31gfrederickswe're ignoring all sorts of numeric optimisations of course
14:33kenrestivothis crossclj has become indispensible. i have to wonder where the source code is for it though? does it use codeq? datomic?
14:33kenrestivoalso, 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:39xelxebargfredericks: what's a good way to profile clojure code?
14:40xelxebarI don't get why the vector would be more efficient...
14:41gfredericksxelxebar: criterium
14:41gfredericksxelxebar: the difference is which end of the collection conj adds to
14:41gfredericks,(conj '(1 2 3) :zoo)
14:41clojurebot(:zoo 1 2 3)
14:41gfredericks,(conj [1 2 3] :zoo)
14:41clojurebot[1 2 3 :zoo]
14:42gfrederickswhich in turn determines whether you're starting with big primes or small primes when calling `some`
14:42gfredericksobviously starting with small primes is faster in aggregate
14:42gfredericksyour original filter algorithm gets this right
14:47xelxebargfredericks: 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:50gfredericksyour expectation is different from what I described?
14:51gfredericksI was talking about a distinction that would be way over any compiler's head
15:00xelxebarI think we're talking about the same thing. Cutting out multiples of small primes first cuts out more numbers up front.
15:02xelxebarI'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:04gfrederickswell in my code there's a collection called `primes-so-far` which is what it uses to check divisibility
15:05gfredericksand the order it checks in depends on the order of that collection
15:05gfredericksif the collection has smaller primes up front, that's what you're checking first, and vice versa
15:06justin_smithxelxebar: 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:06rritochThis 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:10rritochI 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:56hiredmanjava.nio.channels.ClosedChannelException
15:57hiredmanpardon me
15:58bbloomclojure.irc.channels.WrongChannelError
18:05gfredericks~ping
18:05clojurebotPONG!
18:08andyfclojurebot plays a mean game of table tennis
18:08justin_smith$ping
18:08lazybotjustin_smith: Ping completed in 0 seconds.
18:09gfredericks,(println "$ping")
18:09clojurebot$ping\n
18:09gfredericks,(print "$ping")
18:09clojurebot$ping
18:09lazybotclojurebot: Ping completed in 0 seconds.
18:09clojurebotExcuse me?
18:09gfredericksnice
18:09justin_smithoh no...
18:10llasramyay!
18:10llasramLet the cross-bot games resume!
18:11gfredericksthere wouldn't happen to be an existing lib with an instaparse grammar for jvm regexes would there?
18:11gfredericksI don't need a complete one
18:11gfrederickscuz I'm about to make my own otherwise
18:12andyfafter 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:12andyfumm.... no reason.
18:13gfredericksit's just a 3-msg chain that doesn't suggest any method for getting anything longer
18:13gfredericksno reason to call the botcops
18:15andyfI'd check crossclj.info for uses of instaparse
18:15lazybotgfredericks: too late, you're in trouble now
18:16justin_smithandyf: someone really should
18:16andyfor even batbot
18:17andyfThe vigilante bot
18:17justin_smiththe bot #clojure deserves
18:20gfredericksLooking 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:20gfredericksI guess and can special case just the things that make it unlikely to pass, like parethesis balancementhood
18:20andyfSkew test.check's string generation to have 15% backslash characters and you'll get coverage faster :)
18:21gfredericksyeah was gonna get a list of special chars and give'em a boost
18:29gfrederickshuh; including /resources with a library means you should probably namespace things
18:29gfredericksandyf: thanks can I have chocolate next time
18:31andyfsure
18:42SagiCZ1how do i peek into transient vector?
18:43SagiCZ1,(peek (transient [1 2 3]))
18:43clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector$TransientVector cannot be cast to clojure.lang.IPersistentStack>
18:43SagiCZ1,(peek [1 2 3])
18:43clojurebot3
18:43andyfSagiCZ1: Operations allowed on transients are quite limited
18:44SagiCZ1but i just want a little peek!
18:44andyfHave you tried (vec (dec (count vec))) ?
18:44SagiCZ1how should that work
18:45SagiCZ1oh
18:45SagiCZ1i see how
18:45SagiCZ1sorry
18:45SagiCZ1will try
18:45andyfseems to work
18:45SagiCZ1yup
18:46SagiCZ1not getting the speed up they promised in the doc.. :<
18:46SagiCZ1it probably wasnt the bottleneck
18:50alpheusIs Clojurescript on-topic here?
18:50SagiCZ1alpheus: yes
18:51pllxalpheus: what is clojurescript used for?
18:52alpheusclojurescript is clojure compiled to javascript, through Google closure.
18:53alpheusI'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:53SagiCZ1alpheus: try to rename it if you dont want to remove it altogether
19:00alpheusOK, I did, and now my browser connects.
19:01alpheusThat feels a lot like the Windows solution, but I guess I'd accumulated a lot of cruft.
19:01gfredericksxelxebar: I just made this "optimized" version out of curiosity and it was like 30 times faster
19:02gfredericksusing an internal mutable data structure and primitives
19:02gfredericks(i.e., no number-theory tricks)
19:02gfredericksit's sooper ugly though
19:02gfrederickshttps://www.refheap.com/94188
19:14TEttingergfredericks, I wonder how that would (or could it?) compare to a version using transients
19:14gfredericksI think it could; it feels like an icky use of transients to me though
19:14gfrederickssince you never convert them back
19:14gfredericksI don't have a specific reason why that would be bad
19:15gfredericksI'll go write it
19:15SagiCZ1is there a way to remove first key and value from sorted map?
19:15SagiCZ1rest returns a sequence.. not the map
19:16gfredericksyeah
19:16gfrederickswhat does first give you?
19:16SagiCZ1key value pair in vector
19:16TEttingerremove the key?
19:17TEttinger(doc remove)
19:17clojurebot"([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:17TEttingerhm no
19:17gfredericks(doc dissoc)
19:17clojurebot"([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:17TEttinger(inc gfredericks)
19:17lazybot⇒ 111
19:17SagiCZ1i want this {:a 0 :b 1 :c 2} to become this {:b 1 :c 2}
19:17andyfSagiCZ1: dissoc
19:17SagiCZ1i cant dissoc, i dont know what the first key is
19:17gfredericksTEttinger: looks a little bit slower
19:18gfredericksSagiCZ1: you can get the key from the key value pair, no?
19:18gfredericks(doc key)
19:18clojurebot"([e]); Returns the key of the map entry."
19:18andyfSagiCZ1: (dissoc sorted-m (key (first sorted-m)))
19:18bbloom,(ffirst (sorted-map 1 2 3 4))
19:18TEttinger,(let [sm (sorted-map :a 0 :b 1 :c 2)] (dissoc sm (ffirst sm)))
19:18clojurebot1
19:18clojurebot{:b 1, :c 2}
19:18SagiCZ1,(apply sorted-map (flatten (rest (sorted-map :a 0 :b 1 :c 3))))
19:18clojurebot{:b 1, :c 3}
19:18SagiCZ1this is what i want
19:18SagiCZ1looks ugly though
19:18gfredericks,(def my-map (sorted-map :a 0 :b 1 :c 3))
19:18clojurebot#'sandbox/my-map
19:18gfredericks,(dissoc my-map (key (first my-map)))
19:18clojurebot{:b 1, :c 3}
19:19gfredericksSagiCZ1: ^^
19:19SagiCZ1ok i must say that does look better
19:19dbasch,(let [m (sorted-map :a 0 :b 1 :c 2)] (dissoc m (ffirst m)))
19:19clojurebot{:b 1, :c 2}
19:19SagiCZ1thank you
19:19dbaschoh, already there
19:19TEttingeryep
19:19SagiCZ1thank you all
19:19TEttingerno prob
19:19dbaschSagiCZ1: avoid flatten btw
19:19TEttingeryes
19:19TEttinger~flatten
19:19clojurebotflatten 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:19SagiCZ1oh gosh
19:20SagiCZ1i know i know i know..
19:20SagiCZ1was just throwing it out
19:20SagiCZ1;)
19:20SagiCZ1flatten haters
19:20TEttinger,(into (sorted-map) (rest (sorted-map :a 0 :b 1 :c 3)))
19:20clojurebot{:b 1, :c 3}
19:21TEttingerdoes the same thing without flattening nesting
19:21hyPiRioncould just do conj on it
19:21SagiCZ1,(sorted-map)
19:21clojurebot{}
19:21SagiCZ1,(empty sorted-map)
19:21clojurebotnil
19:21hyPiRion,(conj (sorted-map) (rest (sorted-map :a 0 :b 1 :c 3)))
19:21clojurebot{:b 1, :c 3}
19:21SagiCZ1um
19:22metellus,(empty? (sorted-map))
19:22clojurebottrue
19:22SagiCZ1what is empty for then?
19:22metellus,(doc empty)
19:22clojurebot"([coll]); Returns an empty collection of the same category as coll, or nil"
19:22hyPiRion,(empty [1 2])
19:22clojurebot[]
19:22hyPiRion,(empty (sorted-map 1 2))
19:22clojurebot{}
19:22SagiCZ1so its when you have FULL collection and want an empty coppy of the same type?
19:23metellus,(empty "s")
19:23clojurebotnil
19:24hyPiRionyess
19:24SagiCZ1metellus: :(
19:24dbasch,(coll? “s”) ; SagiCZ1
19:24clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: “s” in this context, compiling:(NO_SOURCE_PATH:0:0)>
19:25dbasch&(coll? “s”)
19:25lazybotjava.lang.RuntimeException: Unable to resolve symbol: “s” in this context
19:25dbaschstupid smart quotes
19:25SagiCZ1,(coll? "s")
19:25clojurebotfalse
19:25dbasch,(coll? (seq "s"))
19:25clojurebottrue
19:27SagiCZ1if i do this on an atom, the (count @a) has to be unchanged right?
19:27SagiCZ1(do
19:27SagiCZ1 (swap! a #(dissoc % (first %)))
19:27SagiCZ1 (swap! a assoc key val))
19:28hyPiRionSagiCZ1: no – key may already be present in a.
19:29SagiCZ1that way the count would lower by one correct?
19:29SagiCZ1it keeps increasing
19:30dbaschSagiCZ1: why would you do two swaps?
19:30TEttingeralso, SagiCZ1, you want ffirst to get the first element of the first pair
19:31TEttinger(doc ffirst)
19:31clojurebot"([x]); Same as (first (first x))"
19:31SagiCZ1TEttinger ok so its probably not removing anything
19:31SagiCZ1dbasch: enjoyin mutability i guess?
19:31dbaschSagiCZ1: but two swaps defeats the purpose of swap
19:31dbaschif you're going to swap atomically, swap atomically
19:32SagiCZ1dbasch: then they are two atomic swaps
19:32TEttinger(swap! a #(do (dissoc % (ffirst %)) (assoc % key val)))
19:32dbaschSagiCZ1: which is silly
19:32hyPiRionTEttinger: what
19:33TEttingertechnicaly atomic?
19:33TEttingerremember, this is dissocing a different key than it is associng to
19:34dbaschSagiCZ1: 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:34hyPiRionTEttinger: what you wrote is equal to (swap! a #(assoc % key val))
19:34TEttingerah, right dammit
19:34hyPiRionYou probably meant (swap! a #(-> (dissoc % (ffirst %)) (assoc key val)))
19:34SagiCZ1#(assoc (dissoc % (ffirst %)) key val) ?
19:35SagiCZ1dbasch: thank tou for the explanation
19:35SagiCZ1makes sense
20:21Morgawr,(str "test")
20:21clojurebot"test"
20:22Morgawr,(sort-by (comp :z second) (complement compare) { :one {:z 1} :two {:z 0} :three {:z 10} :four {:z 5}})
20:22clojurebot([:one {:z 1}] [:three {:z 10}] [:four {:z 5}] [:two {:z 0}])
20:22Morgawrwhat am I doing wrong?
20:22Morgawr,(sort-by (comp :z second) { :one {:z 1} :two {:z 0} :three {:z 10} :four {:z 5}})
20:22clojurebot([:two {:z 0}] [:one {:z 1}] [:four {:z 5}] [:three {:z 10}])
20:22Morgawr^ this works
20:22Morgawrwhy does inverting the comparison function (using complement) doesn't reverse the order?
20:23Morgawroh.. compare returns -1, 0 and 1, not true/false.. nevermind
21:17kenrestivothis smells bad ##(apply concat (conj '([1 0] [3 2]) '(4 5)))
21:17lazybot⇒ (4 5 1 0 3 2)
21:28justin_smithkenrestivo: is ##(apply concat '(4 5) '([1 0] [3 2])) an option?
21:28lazybot⇒ (4 5 1 0 3 2)
21:29kenrestivothat's simpler, thanks. the apply concat still bothers me a bit though.
21:29justin_smithit's the best way to concatenate items of a collection
21:36Morgawrkenrestivo: what about ##(concat '(4 5) (flatten '([1 0] [3 2])))
21:36lazybot⇒ (4 5 1 0 3 2)
21:37kenrestivoyeah, i was tryin to avoid flatten too
21:37MorgawrI mean, it's not that different but it shows the intent in the code
21:37Morgawralright
21:37MorgawrD:
21:37justin_smith(dec flatten)
21:37lazybot⇒ -6
21:38Morgawrwhat's bad about flatten?
21:38justin_smith~flatten
21:38clojurebotflatten 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:38kenrestivothe 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:38Morgawrahah ok, fair enough
21:38Morgawrthanks justin_smith
21:38justin_smithkenrestivo: Morgawr: even better ##(flatten {:a 0 :b 1})
21:38lazybot⇒ ()
21:38justin_smithlol
21:39kenrestivowat?
21:39justin_smithinorite
21:39Morgawrwell, it does look more flat
21:39kenrestivowhat could be flatter than an empty list?
21:39kenrestivomaybe nil
21:39Frozenlocko_O
21:39metelluswhy does that happen?
21:40Morgawr,(flatten '())
21:40clojurebot()
21:40Frozenlock##(-> {:a 1} first flatten)
21:40lazybot⇒ (:a 1)
21:40Frozenlock##(-> {:a 1} flatten)
21:40lazybot⇒ ()
21:40kenrestivo,(flatten :pancake)
21:40clojurebot()
21:40metellus##(flatten {})
21:40lazybot⇒ ()
21:40Frozenlock(╯°□°)╯︵ ┻━┻
21:40justin_smith&(flatten (seq {:a 0 :b 1}))
21:40lazybot⇒ (:b 1 :a 0)
21:40metellus##(flatten (seq {:a 1 :b 2{)
21:40kenrestivothings that are not flattenable return empty list? hmm.
21:40Morgawr,(flatten [1 2 3 4]))
21:40clojurebot(1 2 3 4)
21:40Morgawrheh
21:40metellusbeaten by typing speed and syntax errors
21:41justin_smith,(flatten "hello, world!")
21:41clojurebot()
21:41Morgawrt-t-thanks clojure
21:41metellus,(doc flatten)
21:41clojurebot"([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:41kenrestivohas anyone compiled a list of clojure wat's? there are only a handful IIRC
21:42Morgawrmy favorite is
21:42Morgawr,(str (map + [1 2 3 4 5]))
21:42clojurebot"clojure.lang.LazySeq@1c3e4a2"
21:42Morgawrevery time
21:43kenrestivomapv ftw
21:44kenrestivolaziness, yeah, there's a whole class of those
21:44godd2.(str (doall (map + [1 2 3 4 5])))
21:44kenrestivolike... why does my code work in the repl but not in production
21:44godd2,(str (doall (map + [1 2 3 4 5])))
21:44clojurebot"clojure.lang.LazySeq@1c3e4a2"
21:44kenrestivo,(str (mapv + [1 2 3 4 5]))
21:44clojurebot"[1 2 3 4 5]"
21:45justin_smith,(pr-str (map + [1 2 3 4 5]))
21:45clojurebot"(1 2 3 4 5)"
21:46TEttinger,(pr-str (map inc (range)))
21:46clojurebot"(1 2 3 4 5 ...)"
21:46godd2,(doall str (doall (map + [1 2 3 4 5]))))
21:46clojurebot#<ClassCastException java.lang.ClassCastException: clojure.core$str cannot be cast to java.lang.Number>
21:46Morgawr,(apply str (map inc [1 2 3 4 5]))
21:46clojurebot"23456"
21:47godd2wait, whose threw an exception
21:47Morgawryours
21:47godd2oh miner
21:47justin_smithgodd2: yeah (doall str ...) makes no sense
21:47godd2,(doall (str (doall (map + [1 2 3 4 5]))))
21:47clojurebot"clojure.lang.LazySeq@1c3e4a2"
21:47Morgawr,(let [str 1] (doall str (map inc [1 2 3 4])))
21:47clojurebot(2 3 4 5)
21:47Morgawr^ this made sense
21:47Morgawr;)
21:47justin_smithhaha
22:46gfredericksguys I've been using clojure for 18 years and I had no idea that do{all,run} took a second arg.
22:56fairuz gfredericks: Clojure is that old?
22:59gfredericks~clojure |was invented by| C++
22:59clojurebotYou don't have to tell me twice.
23:00jeremyheilerhuh
23:00justin_smith~clojure
23:00clojurebotclojure can make the Kessel Run in under twelve parsecs.
23:01justin_smithOK, but can it calculate a prime number in under a millimeter?
23:02gfredericksI sure hope so
23:03kenrestivois 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:03gfrederickskenrestivo: pred at worst
23:04kenrestivosuppose, could just write a fn
23:04gfrederickskenrestivo: and I bet if you glance at the impl of `either` it'd be straightforward to implement the xeither you want
23:04kenrestivoit does some pretty hairy tree walking
23:04gfredericksthose dang hairy trees
23:05kenrestivonot to mix metfers
23:05kenrestivoanyway, will ponder, thanks
23:06justin_smithhttps://www.google.com/search?q=hairy+tree&amp;safe=on&amp;espv=2&amp;biw=1263&amp;bih=954&amp;source=lnms&amp;tbm=isch&amp;sa=X&amp;ei=Npd6VK3REcSuogT9vYKQBQ&amp;ved=0CAYQ_AUoAQ hairy trees
23:28kenrestivothat's not a tree, that's a graph
23:30emaczendoes anyone here know how to configure a MongoDB database for a luminus project?
23:31Balveda-2There's an automatic configuration for that
23:31Balveda-2like, for when you make a project in leiningen
23:32emaczenyes if you do +mongo it sets up a 'db' folder with a default mongo connection
23:32emaczenlein new app +mongo
23:32emaczenIt works when I test in the REPl, so I am very lost...
23:33Balveda-2What is your problem exactly?
23:34emaczenBalveda: Are you familiar with luminus projects?
23:36emaczenBalveda-2: Are you familiar with luminus projects?
23:36Balveda-2Sort of
23:37emaczenWhen you run "lein ring server," It will open up a browser and point you it to "localhost:3000/"
23:37emaczenOn that page, there is a message that says: "MongoDB configuration is required"
23:38emaczenUnder that it says "add the connection parameters in a .db.core"
23:39emaczen^^ I did that too -- and tested it in the REPL
23:39uris77newbie 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:42Balveda-2Weird, the db core file has a config built in iirc
23:43emaczenBalveda-2: What is iirc?
23:43Balveda-2if i recall correctly
23:52justin_smithuris77: you can use interop pretty easily, if you have specific questions about how the top answer here works, feel free to ask
23:52justin_smithhttp://stackoverflow.com/questions/7777882/loading-configuration-file-in-clojure-as-data-structure here, I mean
23:59uris77sweet, thank you @justin_smith