#clojure logs

2014-10-22

00:27justin_smithrritoch: in clojure eval always compiles
01:23numbertenis there any reason that core's implementation of the 'take' function has a lazy-seq around the outter most sexpr?
01:24numbertenI'd have imagined that the second argument to cons would be wrapped in 'lazy-seq'
01:24numbertenthe second argument being the recursive call
01:26justin_smithnumberten: otherwise it would realize the first n elements
01:27justin_smith,(do (take 10 (map println (range))) nil)
01:27clojurebotnil
01:27BalvedaAny simple ways to check if a character is a number in clojurescript?
01:28justin_smith,(do ((fn tk [n coll] (when (pos? n) (when-let [s (seq coll)] (cons (first s) (lazy-seq (take (dec n) (rest s))))))) 10 (map println (range))) nil) ; numberten
01:28clojurebot0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n
01:28justin_smiththanks to chunking, it even realizes more than the first 10
01:29numberteni see
01:29dbaschjustin_smith: you want to replace take by tk probably
01:29numbertenthanks :)
01:29justin_smithdbasch: good point :)
01:29dbaschin the recursive call of tk
01:30justin_smithdbasch: it leads to the same result, but may as well demonstrate
01:30justin_smith,(do ((fn tk [n coll] (when (pos? n) (when-let [s (seq coll)] (cons (first s) (lazy-seq (tk (dec n) (rest s))))))) 10 (map println (range))) nil) ; numberten
01:30dbaschbut if you use a large number it will blow the stack
01:30clojurebot0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n
01:31numbertenshouldn't it have only printed the first element? in the case where you accidentally called take instead of tk?
01:31justin_smithnumberten: chunking
01:31numberteni see
01:31justin_smithnotice it is printing more than 10 elements too
01:32justin_smithit just grabs and processes the next chunk, but returns the count you asked for
01:32numbertenyeah
01:32numberteni see
01:32numbertenso chunks come in blocks of 32
01:32numbertenit looks like
01:32justin_smithside effects inside a lazy operation are a bad idea for this reason, better to feed a lazy input to your side effecting function
01:32numbertenalright
01:32justin_smithdoseq was designed for this case
01:33justin_smithdbasch: I still don't always get when a given lazy-seq will blow the stack or not - do you know of a good book chapter or blog post covering it in some depth?
01:36numbertenwouldn't processing a lazy-seq use O(1) space as long as you don't maintain a reference to the head?
01:37eggheadi'm pretty sure it happens inside a for loop in most cases
01:38eggheadi got bored and implemented a subset of clj in js, lazy seqs was one of the things
01:39justin_smithegghead: I have seen stacks blow up from combinations of reduce / concat
01:39BalvedaAnyone? Not sure how to handle this
01:39eggheadbut both of those should be happening inside of a while loop iirc justin_smith :/
01:40eggheadhttps://github.com/clojure/clojure/blob/master/src/clj/clojure/core/protocols.clj#L72-L77
01:41eggheadbut ya, guess there are many ways to skin a cat...
01:42vIkSiTHi all
01:42vIkSiTwhen using a simple compojure app, I'm getting empty params {}
01:42vIkSiTI can see the query string contains my params
01:43vIkSiThttps://gist.github.com/viksit/15464b3bbd6b70b7478d
01:43vIkSiTAny idea what the hell is going on?
01:43safety*/
01:43safetynvm
01:44vIkSiTboth /sample and /posts in that route show empty params
01:46eggheadhm vIkSiT
01:47eggheadusually I use (compojure.handler/site routes) instead or `wrap-params`
01:48dbaschjustin_smith: in that particular case, it’s just the recursive calls that create new stack frames for every call
01:48eggheadbut recursive calls to lazy seqs don't happen on the stack
01:48vIkSiTegghead, I didnt know that existed - trying to pieece together that!
01:48eggheadsince the recursion happens in a closure
01:49vIkSiTso you're saying I use instead of the (-> routes wrap-params) a simple (c.h/site routes)
01:49dbaschoh, lazy seqs, never mind
01:49vIkSiTI thought compjure.handler was deprecated in 1.2 though
01:49vIkSiTas per their docs
01:50vIkSiTegghead, still no luck
01:50eggheadvIkSiT: that is just because it was moved here: https://github.com/ring-clojure/ring-defaults/blob/master/src/ring/middleware/defaults.clj#L79
01:50vIkSiTegghead, hrm so I'm very new to compojure
01:51eggheadvIkSiT: :( - the example you posted looked fine to me tbqh
01:51dbaschjustin_smith: in your example you’d removed the lazy-seq
01:51vIkSiTwhat is the easiest way to get my params as a map from the request?
01:51eggheadwhy not try {:as req} and inspect the request object itself?
01:51eggheadmaybe something funny is happening, who knows
01:51vIkSiThow so?
01:51vIkSiToh I did that
01:51vIkSiTsee /posts?
01:52dbaschjustin_smith: actually you hadn’t, you’d moved it inside
01:52vIkSiTif I do : http://localhost:9000/posts?author=viksit&title=foo
01:52vIkSiTI see {:ssl-client-cert nil, :remote-addr "0:0:0:0:0:0:0:1", :params {}, :route-params {}, .... }
01:52vIkSiTand :query-string "author=viksit&title=foo"
01:53eggheadvIkSiT: i just do 'lein new compojure my-app-name'
01:53eggheadand then stuff usually works :shrugs:
01:53eggheadcondolences :p
01:53justin_smithdbasch: I put it inside the cons call, because that was the case numberten was describing / asking about
01:54dbaschjustin_smith: yes, it wouldn’t blow the stack, my bad
01:57dbaschspeaking of stack overflow, I’m running into this bug (apparently) when trying to serialize a large PersistentHashMap http://bugs.java.com/view_bug.do?bug_id=4152790
01:58justin_smithwoah, that sucks
01:58justin_smithdbasch: convert to /from an adjacency list representation?
01:59dbaschit’s a map of pairs word -> vector of words
01:59dbaschI can try making it a vector and see if it changes anything, or turn it into a java util hashmap
02:00justin_smithor even an array of two element arrays
02:00justin_smithyeah
02:00justin_smithno need for something that fancy if it's shallow
02:02piranhaanybody using prismatic's schema here? I've updated to 0.3.1 and coercer returns an arraymap (like {:error [:smth is-wrong]}), which is not considered error by schema.utils/error? - is this a known issue?
02:34piranhahm, 'lein clean' resolved problem :)
02:39justin_smithpiranha: ahh, yeah, should have thought of that
02:39piranha:)
02:39justin_smithlibrary upgrades and cached compiled stuff don't mix nicely
02:42piranhayeah, unfortunately
02:42piranhaI thought that's a problem mostly for clojurescript, but I was wrong apparently :)
02:53justin_smithregarding caching of compiled artifacts: http://33.media.tumblr.com/2f62641ff71d2ff0178d630549959903/tumblr_ncjpycT0Yj1s71q1zo1_1280.png
03:28mearnshlol
03:31kenrestivopersonal pet peeve: committing compiled artifacts into git.
04:21dysfunwhat's the easiest way to locally redefine a function for purposes of testing?
04:35sveridysfun: maybe this one? http://clojuredocs.org/clojure.core/with-redefs-fn
04:43dysfunthat looks perfect, thanks
04:57dysfunhrm. how about redefining macros?
04:59dysfuni want to do a macroexpand-1 to test a macro which calls a function, but of course i need to recompile the macro
05:05sveridysfun: well, I know nothing about macros, sry
05:06dysfunheh. it's a fairly unusual thing i'm doing. i expected to run into some difficulties
05:07clgvdysfun: what exactly do you mean? you can redefine macros as you can redefine functions
05:08clgvdysfun: or do you want to rebind a name to a macro in a local scope?
05:08dysfunyes
05:08clgvthe latter?
05:09dysfunwell, what i actually want to achieve is 'recompile the function with the same source so as to pick up the new version of the function you depend on'
05:10clgvwell, functions are looked up through the symbols when you call them directly, so you always get the latest definition in that case.
05:11clgvdysfun: can you provide a small example demonstrating the problem/feature?
05:14dysfunno, it works, and i've figured out why
05:15dysfunit's because of where the metadata is attached
05:15dysfunit's all working now
05:16clgvwell, fine. no idea what the problem was, though
05:23dysfunit was more i anticipated one where there wasn't one :)
05:24dysfuni've been doing this job for too long :)
07:01martinklepschwhat could be going wrong when it takes a long time for an alts! to pick up a value from a channel?
07:02martinklepschI'm sure the value has been put on the channel but it still takes seconds for the alts! block to start handling it
07:04martinklepsch(oh and the channel where the value has been put on is a pipeline-async channel, so it's not actually THE channel I use alts! on. (if my understanding of pipeline-async is correct))
07:04SagiCZ1,(meta cons)
07:04clojurebotnil
07:04mosddwhat is the current status for using clojure for creating small, short-running command line utilities that need a fast startup? how fast can we clojure program to start, and what would it take?
07:04SagiCZ1,(meta 'cons)
07:04clojurebotnil
07:04SagiCZ1why does it return nil, when the function clearly has meta data?
07:05cursork,(meta #'cons)
07:05clojurebot{:ns #<Namespace clojure.core>, :name cons, :added "1.0", :file "clojure/core.clj", :static true, ...}
07:05SagiCZ1cursork: thank you
07:05SagiCZ1why is that necessary?
07:06hyPiRion'foo refers to the symbol, whereas, #'foo refers to the var
07:06hyPiRion#'foo is sort-of shorthand for (resolve 'foo)
07:06martinklepschmosdd: I'm not sure if there's a right way of doing this. I always like to believe that cljs might work well it that spot but never tried
07:06hyPiRion,(meta (resolve 'cons))
07:06clojurebot{:ns #<Namespace clojure.core>, :name cons, :added "1.0", :file "clojure/core.clj", :static true, ...}
07:06SagiCZ1hyPiRion: thank you
07:07SagiCZ1and how could i just see docs for something?
07:07SagiCZ1,(doc #'+)
07:07clojurebot#<CompilerException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol, compiling:(NO_SOURCE_FILE:0:0)>
07:07SagiCZ1,(doc #'cons)
07:07clojurebot#<CompilerException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol, compiling:(NO_SOURCE_FILE:0:0)>
07:07SagiCZ1(doc cons)
07:07clojurebot"([x seq]); Returns a new seq where x is the first element and seq is the rest."
07:07SagiCZ1,(doc cons)
07:07clojurebot"([x seq]); Returns a new seq where x is the first element and seq is the rest."
07:07SagiCZ1my repl cant find the doc function
07:09hyPiRionare you using `lein repl` ? Clojure by default doesn't ship doc
07:09SagiCZ1,clojure.main/repl-requires
07:09clojurebot#<CompilerException java.lang.RuntimeException: Unable to find static field: repl-requires in class clojure.main, compiling:(NO_SOURCE_PATH:0:0)>
07:09hyPiRionClojure as in `clojure`, `lein repl` contains doc
07:09SagiCZ1yeah its lein repl
07:10hyPiRionwell then, that's strange. doc should be included there
07:10cursorkSagiCZ1: Changed namespace?
07:10SagiCZ1cursork: yes
07:10SagiCZ1cursork: wait so thats the problem?
07:10SagiCZ1thats why it works SOMETIMES
07:11cursorkSagiCZ1: Yep. Lein just does a (use 'clojure.repl) for you
07:11hyPiRionooh, yeah
07:11SagiCZ1damn im stupid.. thank you
07:13clgvmosdd: not optimal. you can speed up via "drip" or "grenchman" for leiningen
07:14jsandahi all. i am using the << (string interpolation) fn from clojure.core.strint. can someone tell me how to pass a variable to it?
07:14mosddclgv do you know the start up of hello world if you tested it?
07:14jsandai try unquoting like, (<< ~myvar), but that just evaluates to
07:15mosdd+time
07:15jsanda"(clojure.core/unquote myvar)"
07:15clgvmosdd: easy to check, just write one an aot compile it ;)
07:15scottjjsanda: (<< "This trial required ~{v}ml of solution.")
07:16scottjjsanda: http://clojure.github.io/core.incubator/clojure.core.strint-api.html
07:16SagiCZ1whats wrong with this function, that doc keeps returning nil for it? https://www.refheap.com/92146
07:16mosddlol ok, I hae to find out what aot is first
07:16jsandascottj: i want to pass a var
07:17jsanda(def myvar "This trial required ~{v}ml of solution.")
07:17jsanda(<< ~myvar) ;; does not work though
07:17noncomis it possible to modify a loaded java class bytecode in runtime? are there any clojure libs for that ?
07:18TEttingerSagiCZ1: docstring goes before arglist
07:18clgvjsanda: probably because the macro `<<` expects a string literal
07:18SagiCZ1TEttinger: ohh... missed that, thank you
07:18clgv$source clojure.core.strint
07:18lazybotSource not found.
07:19jsandaclgv: ok, thanks
07:20clgvjsanda: well the implementation is pretty strange
07:20clgvjsanda: https://github.com/clojure/core.incubator/blob/master/src/main/clojure/clojure/core/strint.clj#L49
07:21martinklepsch mosdd If you're familiar with javascript I'd recommend to evaluate that as well
07:21jsandaclgv: looking...
07:22mosddrecur is used when you have tail recursion and direct recursion otherwise?
07:22clgvjsanda: I think that might be a reason why it did not make it into clojure, yet
07:23jsandahmm...any suggestions on an alternative string interpolation fn?
07:24martinklepschhttp://gearon.blogspot.de/2013/03/clojurescript-and-nodejs.html
07:24clgvjsanda: you can just use that one with literal strings
07:24clgvjsanda: or are the string constants you tried to use mandatory?
07:24hyPiRionjsanda: cl-format?
07:24clgvjsanda: you can use `interpolate` directly instead of `<<` when using constants
07:25jsandaclgv: string constants don't work for me. i'm trying to pass in string that are loaded from files
07:25clgvjsanda: ok, use `interpolate` directly
07:25hyPiRion,(require '[clojure.string :as s])
07:25clojurebotnil
07:25jsandaok, thanks
07:25TEttinger,(format "This trial required %1ml of solution." 10)
07:25clojurebot#<UnknownFormatConversionException java.util.UnknownFormatConversionException: Conversion = 'm'>
07:25hyPiRion,(s/cl-format nil "~d duck~:p and ~d pig~:p" 13 1)
07:25clojurebot#<CompilerException java.lang.RuntimeException: No such var: s/cl-format, compiling:(NO_SOURCE_PATH:0:0)>
07:25clgvjsanda: ah lol that one is private...
07:26clgvjsanda: I usually just use clojure.core/format
07:26hyPiRionoh, derp
07:26TEttinger,(format "This trial required %dml of solution." 10)
07:26clojurebot"This trial required 10ml of solution."
07:26clgvjsanda: not exactly the same use case...
07:27jsandaeyah
07:27jsandayeah
07:27clgvhyPiRion: isn't that part of clojure.pprint?
07:27hyPiRionclgv:
07:27hyPiRionyeah
07:27hyPiRion,(require '[clojure.pprint :as pp])
07:27clojurebotnil
07:27hyPiRion,(pp/cl-format nil "~d duck~:p and ~d pig~:p" 13 1)
07:27clojurebot"13 ducks and 1 pig"
07:27hyPiRion,(pp/cl-format nil "~r duck~:p and ~r pig~:p" 13 1)
07:27clojurebot"thirteen ducks and one pig"
07:27TEttinger:p is pluralize?
07:28hyPiRionTEttinger: yeah, pluralize last arg
07:28TEttinger,(pp/cl-format nil "~r radius~:p and ~r pig~:p" 13 1)
07:28clojurebot"thirteen radiuss and one pig"
07:28TEttingerhm
07:28hyPiRionhave to use ~[~] for special cases
07:28clgvwell it isn't really gramar aware ;)
07:28TEttingerit's majjyyk
07:28clgv*grammar
07:29hyPiRionTEttinger: http://www.gigamonkeys.com/book/a-few-format-recipes.html if you're interested
07:31SagiCZ1files in clojure are sequencible? how about buffered readers?
07:31clgvSagiCZ1: what?
07:32SagiCZ1i thought i read that somewhere
07:32TEttinger(doc file-seq)
07:32clojurebot"([dir]); A tree seq on java.io.Files"
07:32SagiCZ1yeah
07:32clgvah well that explains more with fewer words ;)
07:32SagiCZ1well i need to read from buffered reader using readLine.. do i need loop for that?
07:33clgvSagiCZ1: you may also do it lazyly but with the problem that you dont know then too close the file
07:33clgvs/then/when/
07:33martinklepschanyone an idea regarding my core.async pipeline delay issue?
07:33SagiCZ1its not a file.. i need to read line from the stream and put it in a blocking queue
07:35ChazeHi there. Does clojure have a macro for "uncurrying" in the sense of putting its arguments into a vector?
07:35clgvSagiCZ1: well you could just have a thread in an endless loop doing that - but depends on your scenario if that is ok
07:36SagiCZ1cglv: but there is no while (true) in clojure, right?
07:36Chazeso, lets say i have a (def foo [x y]) and i want a macro that instead makes it a (def bar [[x y]])
07:36clgvSagiCZ1: interestingly there is
07:36clgv,(doc while)
07:36clojurebot"([test & body]); Repeatedly executes body while test expression is true. Presumes some side-effect will cause test to become false/nil. Returns nil"
07:36SagiCZ1Chaze: apply ?
07:36SagiCZ1clgv: oh
07:37ChazeSagiCZ1: nope, because i want to pass the "uncurried" function as an argument
07:37clgvSagiCZ1: so (future (while true ...)) might be an option. better: (future (while @continue ...))
07:37ChazeI can't say (map (apply foo) col) for instance
07:37SagiCZ1clgv: thank you
07:38ChazeOooh. I can do (map (partial apply foo) col)
07:38SagiCZ1clgv: where continue is an atom flag right?
07:38ChazeSagiCZ1: thanks for the hint
07:40clgvSagiCZ1: yeah, for example an atom
08:02SagiCZ1,(+ 5 3)
08:02clojurebot8
08:02SagiCZ1,*1
08:02clojurebot#<Unbound Unbound: #'clojure.core/*1>
08:03SagiCZ1,1*
08:03clojurebot#<NumberFormatException java.lang.NumberFormatException: Invalid number: 1*>
08:03SagiCZ1,*1*
08:03clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: *1* in this context, compiling:(NO_SOURCE_PATH:0:0)>
08:11TEttinger&*1
08:11lazybot⇒ #<Unbound Unbound: #'clojure.core/*1>
08:11TEttingerhm, looks like these don't fully act as REPLs
08:15hyPiRionThey're more like REP
08:48zapho53Anyone using Yesql?
08:49zapho53defqueries keeps giving me a java.io.FileNotFoundException
08:51jonathanjhrm, if i add aleph to my deps and run lein repl i get:
08:51jonathanj#<CompilerException java.lang.RuntimeException: No such namespace: d, compiling:(manifold/deferred.clj:721:7)>
08:52jonathanjand i can't require anything that depends on manifold
08:52jonathanjwhat gives? :(
08:52nonrecursivezapho53: can you share the full defqueries form you're using and the filesystem location of your queries file?
08:54zapho53nonrecursive: (defqueries "/Users/gmac/clj/db2/sql/db2.sql"). Exact file location.
08:57nonrecursivezapho53: hmm I'm not sure that would be on your classpath?
08:58nonrecursivezapho: I have my queries in "src/queries" and use e.g. (defqueries "queries/select/route.sql")
08:58nonrecursivezapho53: I just tried using the full filesystem path as well and got the same error as you
08:59zapho53nonrecursive: I'll try under src
09:00dysfunso i've volunteered to teach a friend of mine to program, but he uses windows. is it easy to get going with clojure and lein under windows?
09:00clgvdysfun: lighttable, counterclockwise and cursive are options to do that, easily
09:00zapho53nonrecursive: (defqueries "src/sql/db2.sql")
09:01zapho53... same Excetion
09:01dysfunhrm, i'd prefer something that
09:01nonrecursiveyou'll want to use
09:01dysfunwasn't tied to an IDE
09:01nonrecursivezapho53: (defqueries "sql/db2.sql")
09:02jonathanjlooks like there was a bug in manifold-0.1.0-beta2 and unfortunately aleph-0.4.0-alpha4 depends on that
09:02zapho53nonrecursive: That worked. Thanks. Maybe the docs should make all this a bit clearer.
09:02jonathanjsigh
09:03zapho53nonrecursive: Instead of "some/where/users_by_country.sql"
09:03nonrecursivezapho53: the reason is that "src" is included in your classpath, and yesql looks up paths relative to the directories in your classpath
09:04nonrecursivezapho53: yeah I had to fiddle with it a bit myself the first time I used yesql, I agree it could be a bit clearer
09:04zapho53nonrecursive: Some libraries also work with absolute paths so it needs to be made clear.
09:04roelofI cannot understand this :
09:04roelofI have a function divides which looks like this : (defn divides? [divisor n] (=(mod n divisor)0))
09:05roelofwhen I do (divides? 400 4) I see false
09:05roelofbut when I do ( mod 400 4) I see the output 0
09:05roelofwhy does divides still says false ?
09:08clgvdysfun: you need an editor and a repl (best when the editor can interact with the repl). all 3 options I listed provide that
09:14agarmanquick question on using dependencies installed in local .m2
09:15dysfunclgv: actually, i was thinking those plus midje. and editor rather than ide
09:16joegalloagarman: proceed
09:16roelofno one who can help me ?
09:16agarmanwhat is a good way of changing the class path for a mvn dependency that is only installed locally? pomegranate?
09:17dysfunroelof: you have the arguments the wrong way around
09:17joegalloagarman: installed locally in your .m2?
09:17agarmanyes,
09:17roelofdysfun: what do you mean ?
09:17dysfunroelof: you executed (mod 4 400), not mod (400 4)
09:17agarmanjoegallo: have a java project that only installs local and want to pull it in as a dependency, but lein & alembic can't find
09:18roelofdysfun: thanks, I will change it
09:18joegalloagarman: then something is slightly off, leiningen is totally cool with local only stuff in your .m2 -- i think
09:19joegallo(i've used it for testing new versions of things in development across different projects, for instance)
09:20agarmanyeah, I'll fiddle some more with groupids etc
09:24agarmanjoegallo: needed to add :extension "pom" to dependency
09:24agarman(inc joegallo)
09:24lazybot⇒ 5
09:28roelofdysfun: thanks, finally get this one working
09:28roelofany midje expert here ?
09:39roelofCan I somehow test only 1 function with midje instead of the whole namespace which happens with lein midje ???
09:39lazybotroelof: How could that be wrong?
09:41roelofI do not understand the answer which lazybof gives. What is wrong with my question ?
09:41llasramDoes lazybot give a silly response to questions with lots of question marks???
09:41lazybotllasram: Yes, 100% for sure.
09:42roelofllasram: thanks
09:42llasramroelof: With an editor-connected REPL you can send the form for just one test to be run
09:43llasramThe Emacs midje extension has/had explicit support for that
09:43llasramRunning just one test e.g. from the command line is pretty much impossible though
09:43llasramThe fundamental mode of midge is that it runs tests at what is normally Clojure "compile time"
09:43roelofoke, I wokr now with codio.com so I do not think they have a editor connected repl
09:43llasramWhich is one reason that I dislike it
09:44llasram(midje, not codio.com -- no idea what the latter even is)
09:44roelofllasram: thanks for the answer. Codio.com is a online solution to work with clojure
09:55puredangermartinklepsch: on your pipeline-async thing, it's important that you conform to the doc sentence: "The presumption is that af will return immediately, having launched some asynchronous operation (i.e. in another thread) whose completion/callback will manipulate the result channel." - are you?
09:56zotanybody have a suggestion for a more idiomatic-yet-clean way to do this? https://gist.github.com/anonymous/3d335b876c7303d9e687
09:57zoti did it with reduce and an anon function over [:a :b :c], but it wasn't very readable, imo, seeking something better. (this is a toy example, of course… longer list in real life.)
09:59roelofI need the help of the experts once again. What is wrong here : (defn do-a-thing [x] ( let [double_x (+ x x )] (Math/pow double_x double_x))) I see a this error message : unable to resolve symbol: x in this context
10:00puredanger,(defn do-a-thing [x] ( let [double_x (+ x x )] (Math/pow double_x double_x)))
10:00clojurebot#'sandbox/do-a-thing
10:00BRONSAzot: there's not something much better than (defn finish [mtrx] (reduce #(update-in % [%2] finish-child) mtrx [:a :b :c]))
10:01puredanger,(do-a-thing 5)
10:01clojurebot1.0E10
10:01zotBRONSA: tnx :)
10:01BRONSAzot: 1.7 will have `update` so you can write (update a b f) instead of (update-in a [b] f)
10:06jonathanjhow do people do async network io with Clojure?
10:06jonathanj(like writing custom protocol handlers, etc.)
10:07puredangerjonathanj: I haven't done it, but should probably look at Netty http://netty.io/
10:09scottjpuredanger: do you know if there has been a decision whether fastload will make it into 1.7? is there an issue I should follow?
10:09puredangerscottj: will not be in 1.7
10:09scottjahh, bummer
10:10puredangerscottj: might not be in ever - it has pros and cons
10:10puredangerpart of fastload is a class cache which is being evaluated vs Zach's patch in http://dev.clojure.org/jira/browse/CLJ-1529
10:10BRONSApuredanger: how about the direct stuff?
10:10puredangerI think one or the other of those will be in 1.7
10:11puredangerBronsa: will not be in 1.7, I would consider it experimental/research atm
10:12scottjpuredanger: is there anything in writing about the major cons of fastload?
10:13puredangerscottj: I have written about it here in the past. the major one is that while it makes vars faster on load, it makes them slower forever after that
10:13BRONSAiirc fastload was class cache + direct + lazy fn loading
10:13BRONSAit'd look like lazy fn loading is the problematic one
10:13puredangerBronsa: no, direct is a separate thing
10:14BRONSApuredanger: ah, I thought direct got merged into fastload at some point
10:14puredangerthe class cache part is just perf tuning and is independent (hence hopefully will be in 1.7)
10:14puredangerBronsa: direct is a branch from fastload branch
10:14BRONSApuredanger: I see, my memory got messed up then
10:15puredangerfastload does not change usage of anything; it just affects how vars are loaded and called
10:15csd_Is Company mode really flakey for anyone else? Sometimes it works, othertimes it inexplicably doesn't
10:15puredangerdirect compiles new static invocation paths and opens up many possible decision points every time you compile about whether you use static or dynamic invocation
10:16puredangerpotentially on a per-var basis
10:16puredangerthis has big usage ramifications in terms of what knobs you make available
10:17puredangerneither fastload nor direct actually made a significant difference in runtime performance though for most stuff I tested with
10:17BRONSAI'd have thought direct would have a significant impact
10:17puredangeryou would think so
10:17puredangerbut most hot cpu loops typically don't have var invocation in them anyways
10:19puredangerdirect doesn't affect protocol invocation either as that's a different path
10:19BRONSAright
10:20puredangerI think Ghadi's experiments with indy are far more interesting - they have the potential to get the benefits of both fastload and direct without most of their costs
10:20scottjpuredanger: do you have a link to this?
10:20puredangerto what?
10:21scottjghadi's experiments with indy
10:21puredangerhe's doing a talk at the conj, not sure if he's written anything up anywhere
10:21scottjok
10:21puredangerI've mostly just talked to him about it
10:22puredangerI gave him some invocation benchmarks I've used and he's seeing good numbers
10:22scottjfwiw on startup speeds for hello worlds I saw time decrease to 1/2 or 1/3 of normal with fastload.
10:22BRONSApuredanger: speaking about callpaths, I don't recall if I opened a ticket about that but the compiler generates an unused method for every fn w/ keyword-invokes
10:22BRONSAah I did
10:22BRONSAhttp://dev.clojure.org/jira/browse/CLJ-1351
10:23puredangerscottj: I did not find anything close to that with real programs
10:23puredangerBronsa: yeah, I did my part on that, Rich has never looked at it
10:27puredangerscottj: fastload makes every var invocation about 50% slower (post-inlining) for the rest of the time your program runs too. You mostly won't notice that as it's rarely the bottleneck but kinda sucks
10:28alexherbo2Hi
10:31puredangerindy has support for switchpoint method handles so you can delay loading on invocation, then switch to the new path without the check after it's loaded, which gives you the deferred loading + avoid the cost of the check after load
10:31BRONSAthat's nice
10:32EvanR_its a beautiful day in the neighborhood
10:32puredangerBronsa: I believe it was designed for this kind of use case
10:41mearnshBRONSA: HELLO
10:45SagiCZ1can we dump threads in repl?
10:53puredangersure
10:54puredangerdepends on what repl of course. ctrl-\ dumps it in *nix if you're in the jvm process started from command line, but that's not going to work in many setups
10:55puredangeryou can produce it via external means with jstack
10:56SagiCZ1ok
10:56puredangerand you can call through the jvm jmx beans too
10:58puredangeryou can get it as data with (.dumpAllThreads (java.lang.management.ManagementFactory/getThreadMXBean) true true) - not sure what gymnastics you'd need to print that usefully though
11:00johnwalkerping GFREDERICKS
11:00puredanger(pprint (seq (.dumpAllThreads (java.lang.management.ManagementFactory/getThreadMXBean) true true)))
11:00puredangerdoes an ok job
11:00GFREDERICKSjohnwalker: halooo
11:00johnwalkerare you feeling uppercase today
11:01GFREDERICKSBRONSA started it
11:01johnwalkeri kind of wish there were only one case
11:02johnwalkeranyway, i wondered if you wanted me to take TCHECK-46 with TCHECK-47
11:02GFREDERICKSyeah I think -46 is subsumed by -47
11:02johnwalkerok, and i also wanted to ask if that was the right procedure in jira
11:02johnwalkeri have never clicked the assign button
11:02GFREDERICKSyeah I believe so
11:02GFREDERICKSreid pointed it out to me after I started on it because I'm not used to paying attention
11:03johnwalkerahh
11:03reiddraperGFREDERICKS: HELLO
11:03johnwalkerwell, in that case i'd be happy if you took it
11:04clgvall caps day? :P
11:04johnwalkerit's up to you. i was planning on starting today, but if you already have some work done then thats a different story
11:04EvanR_known fact that the romans went around yelling at each other on a regular basis
11:05johnwalkeroh god ecci romani
11:06CookedGryphonecce*
11:07CookedGryphonromanes eunt domus!
11:07johnwalkerit's been a while
11:10llasramI wonder if Roman-era biblio-archaeologists get annoyed at people typing in whispers all the time
11:11llasramYOUARENTEECUMMINGSSOSPEAKUPANDSTOPUSINGTHATNEWFANGLEDPUNCTUATION
11:12johnwalkerjust check if e. e. cummings has haters
11:12teslanickRomans used to read everything aloud
11:12teslanickWHYAREYOUNOTREADINGALOUDDOYOUHAVESOMETHINGTOHIDE
11:14llasramteslanick: huh. TIL
11:14llasram /Space Between Words/ looks like an interesting read
11:21GFREDERICKSjohnwalker: reiddraper: https://github.com/gfredericks/test.check/commit/6fbb6bcecd89817774682406ffe84e470f2ccf10
11:22reiddraperGFREDERICKS: much appreciated
11:22GFREDERICKSI don't know if I got all of them yet, I quit as soon as reid pointed out the ticket-assignment
11:23BRONSAGFREDERICKS: it's capslock day!
11:25GFREDERICKShttps://twitter.com/timbaldridge/status/524904211037683712
11:26johnwalkernice
11:26johnwalkerwhat is line 467 ?
11:28GFREDERICKSjohnwalker: I guess I quit in the middle of a line
11:29johnwalkerthe only one that i notice missing is sample-seq
11:29GFREDERICKSreiddraper: I converted a (def ... (partial ...)) to a (defn ...) so I could have more consistent error reporting
11:29GFREDERICKSjohnwalker: that one doesn't have the delayed-error problem though does it?
11:30johnwalkeri'm not sure.
11:30reiddraperGFREDERICKS: no argument here
11:34GFREDERICKSthere are a lot of three-letter acronyms without wikipedia pages
12:01justin_smithtechnomancy: I found this image, and am convinced you will find many an amusing context to invoke it http://i.imgur.com/MdbUlkO.png
12:02EvanR_is there a update-in that does not create a key if it isnt there already
12:02SagiCZ1can i make a string literal containing double quotes?
12:02EvanR_,"\"\""
12:02llasram&"\"sure\""
12:02lazybot⇒ "\"sure\""
12:02clojurebot"\"\""
12:03justin_smithEvanR_: not that I know of, but you can make something with the help of contains?
12:03SagiCZ1and if i didnt want to use the backshlash?
12:03llasramEvanR_: What would it return in the non-extant case?
12:03mdrogalisEvanR_: I don't think so, no.
12:03EvanR_llasram: it would return the original map
12:03EvanR_justin_smith: ok
12:03SagiCZ1,\"
12:03clojurebot\"
12:03llasramEvanR_: Hmm. Sounds like a good source of bugs to me :-)
12:04BRONSAEvanR_: get-in is probably going to be more useful than contains? in this case
12:04technomancyjustin_smith: <3
12:04BRONSAyou can (get-in my-map [p a t h] ::not-found) but you can't (contains? my-map p a t h)
12:05EvanR_sounds good to me
12:07EvanR_"adjust-in"
12:08SagiCZ1EvanR_: can i somehow quote the entire string? tell the reader that this string will contain some double quotes and ignore them?
12:08SagiCZ1,<special_symbol>"ignore " the " inner " quotes " please "
12:08clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: <special_symbol> in this context, compiling:(NO_SOURCE_PATH:0:0)>
12:09EvanR_!"what language is this"!
12:09llasramSagiCZ1: If you're looking for something like a here-doc or Python's """-quoted strings, I am afraid you are out-of-luck
12:09llasramSagiCZ1: You can always `slurp` in an external resource file though
12:09EvanR_theres no reader macro for this?
12:09SagiCZ1thats too bad
12:10llasramNo
12:10llasramYou could hack one in by modifying the reader's syntax table, but that is "frowned upon"
12:10EvanR_the only issue with get-in and update-in so far are they nil may mean the key was not there, or it did and the value is nil
12:11technomancyugh nil =\
12:11justin_smithEvanR_: my attempt at update-in only if already present https://www.refheap.com/92164
12:12llasramEvanR_: You can provide default value to `get-in`, but yeah -- not `update-in`. With the latter you generally only allow `nil` for not-found and wrap the update function in `fnil`
12:12llasramBut doing something explicitly monoidal would definitely be nicer for some things
12:12EvanR_justin_smith: i see, so it somehow checks that the key is there
12:13andyf llasram: is someone particular being quoted in "frowned upon" ?
12:13EvanR_llasram: what default value would help?
12:13noonian,(get-in {:foo nil} [:foo] :not-found)
12:13clojurebotnil
12:14justin_smithEvanR_: that the "place" of the final key is there, and that place is associative so that you can even do lookup on it
12:14llasramandyf: Nah, I was being jokey. I mean, it's more "so crazy no one has done it except to show that it can be done and anyone who did do it in a library would be shunned"
12:14llasram(imho)
12:14arrdemBRONSA: you're capital today?
12:15BRONSAarrdem: capslock day
12:15EvanR_noonian: should work, most of the time
12:15justin_smitharrdem: it's caps lock day. This is an important part of our culture.
12:15justin_smithEND THE WAR ON CAPS LOCK DAY
12:15arrdemoh. right. PLT_HULK must be going nuts
12:15llasramEvanR_: Well, if the update function were treated as an explicit monoid, attempting to add an absent value would first call it's 0-arity version get the identity value
12:15noonianEvanR_: yeah looking at the source it calls seq on it and goes through the k,v pairs
12:15llasramEvanR_: If that's what you were asking?
12:15technomancy"I don't have a caps lock key you insensitive clod"
12:15arrdem^ that
12:15arrdemI just have a spare control key
12:15llasramMe too :-(
12:16EvanR_llasram: nope
12:17EvanR_:not-found is what i was looking for
12:17llasramAh
12:17llasramOh, yeah I meant "default return value if not found"
12:17llasramWhich may be a bit of a stretch :-)
12:19EvanR_this is what i have http://lpaste.net/113034
12:19EvanR_not really par with std lib but good enough
12:20BRONSAEvanR_: (m) doesn't really make sense to me
12:20clojurebotexcusez-moi
12:20EvanR_,(m)
12:20clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: m in this context, compiling:(NO_SOURCE_PATH:0:0)>
12:20BRONSAEvanR_: also I'd prefer ::not-found instead of :not-found
12:21arrdemoh we're namespace qualifying trash values now?
12:21BRONSAEvanR_: you're invoking your map with no args, that should be `m` not `(m)`
12:21BRONSA::arrdem
12:21arrdemwhy not just have done with it and use a full contract...
12:21justin_smith,({}) ; this is what (m) in your code does
12:21clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentArrayMap>
12:21justin_smithEvanR_: ^^
12:21EvanR_ah, i really wrote that
12:22EvanR_,::not-found
12:22clojurebot:sandbox/not-found
12:22EvanR_,:::not-found
12:22clojurebot#<RuntimeException java.lang.RuntimeException: Invalid token: :::not-found>
12:22EvanR_two colons ?
12:22justin_smithEvanR_: it's a shortcut for namespaced keywords
12:22EvanR_man
12:23justin_smithEvanR_: which helps ensure you are not shadowing the same keyword used for a different purpose
12:23EvanR_this is a lot of work for a get-in that returns an option type or something
12:24BRONSAI wouldn't call a 2-line function a lot of work
12:24arrdem"line"
12:24arrdemchallenge accepted
12:24EvanR_was talking about namespaced keywords to interpret whether a map has a key
12:25justin_smithEvanR_: mental work, sure, but it's a one-time cost if you plan on using clojure again :)
12:26EvanR_my function works, though im unsure on the exact semantics of the ::not-found value
12:26arrdem&(get {} :foo ::not-found)
12:26lazybot⇒ :clojure.core/not-found
12:26EvanR_does it have the same problem, map happens to contain the value ::not-found
12:26BRONSAEvanR_: you just need to get used to it, it gets obvious once you see it enough times :)
12:26arrdemif you ever (assoc ::not-found), wtf m8
12:27justin_smithEvanR_: sure, but someone in a namaspace other than yours using a keyword in your namespace is asking for trouble anyway
12:27BRONSAEvanR_: sure but the probability of somebody sticking in a map :not-found vs :your.namespace/not-found is different
12:27EvanR_alright then...
12:27EvanR_so we cut the probability in half
12:27EvanR_good stuff
12:27justin_smith"half"
12:27BRONSAEvanR_: if you want to be 100% sure that function will work even if your users are assholes, use a sentinel value
12:28justin_smith::not-found, in any namespace other than yours, is not equal to ::not-found in your namespace
12:28BRONSA(let [sentinel (Object.) value (get-in m path sentinel)] (if (identical? value sentinel) ..))
12:28EvanR_.oO(method to check if a key exists in a map or not)
12:28jonathanjis there an IRC channel for aleph and so forth?
12:28justin_smithEvanR_: that's contains?
12:28jonathanji'm apparently missing something crucial with aleph.tcp.client
12:28EvanR_justin_smith: ah ok
12:29justin_smithEvanR_: as seen in my paste prior
12:29EvanR_yeah yours probably is better
12:29jonathanjthe wiki talks about `tcp-client`: https://github.com/ztellman/aleph/wiki/TCP
12:29BRONSAEvanR_: the issue w/ contains? is that it only works on a single level, not on multiple level paths like get-in/update-in
12:29justin_smithEvanR_: the check for ILookup is because contains? errors on things you can't lookup on
12:29justin_smithBRONSA: I address this in the code I am referencing
12:30EvanR_still seems more solid
12:31BRONSAjustin_smith: yeah but it's a lot more work than using get-in w/ not-found value
12:32EvanR_i was initially going to be ok with a crap value being now impossible to use in a map, but if im going to start splitting improbabilities, ill just do it right
12:32justin_smithhttps://www.refheap.com/92164 updated. BRONSA: a lot more?
12:35EvanR_justin_smith: you have literal tabs in your code?
12:35EvanR_or is that just the pastebin
12:36justin_smithEvanR_: odd, whitespace-mode doesn't show any tabs
12:37justin_smithEvanR_: I don't see tabs in my original code, or in copy pasting from my code back into my editor
12:37BRONSAjustin_smith: ok, I was unfair
12:37EvanR_must be my
12:37technomancyjustin_smith: check whitespace-style
12:38justin_smithtechnomancy: is that from a package?
12:38technomancyno, it's a builtin defvar
12:38justin_smithahh, right
12:38technomancydefcustom
12:38dagda1_can anyone help me out with my understanding of this generic consume function https://github.com/suprematic/ascent.repl/blob/master/src/cljs/cdtrepl/util.cljs#L12. I can't quite work out what the kill channel is for
12:38EvanR_it obviously has no tabs in the pastebin, its a weird quirk of my vim setup
12:39dagda1_my idea of what a kill channel was is one where I destroy existing channels
12:39justin_smithtechnomancy: I just periodically turn on whitespace-mode and fix things that are red or yellow
12:40dagda1_or maybe it just avoids the channel being null
12:40llasramjustin_smith: Just leave it on all the time. It's a great way to be constantly slightly annoyed at other people.
12:40justin_smithllasram: hah
12:40justin_smithdagda1_: a kill channel is a channel that kills you
12:40justin_smithalso known as a poison channel
12:42justin_smithdagda1_: in that context, you can see that any input from the kill-ch will make the loop fail to recur
12:42dagda1_justin_smith: ha and kill the channel
12:42justin_smithno, kill the go loop
12:43justin_smiththe channel is fine (though likely soon to be collected)
12:43dagda1_justin_smith: so I would stil need to call close! to destroy the channel
12:43justin_smithor just don't hold onto it
12:43justin_smithgc
12:44dagda1_justin_smith: I'm trying to come up with the best plan for killing channels in clojurescript.
12:44justin_smithdagda1_: put a nil value in it
12:44justin_smiththis kills the channel
12:44hashpuppyi'm looking at some clojurescript code and i see (map (constantly true)) being passed to an arglist, where it is consumed with let [out (apply async/chan 1 args)]. i'm trying to figure out what's going on. is (map (constantly true)) returning a partially applied function? but when i key that into the clojure repl i get an error saying wrong number of args were passed. is this something clojurescript specific? or what's going on?
12:45dagda1_justin_smith: I thought close! kills the channel
12:45justin_smithhashpuppy: it's a clojure 1.7 thing
12:46dagda1_justin_smith and it would not be GC'd unless close! was called
12:46hashpuppythanks, justin. so what's being returned there?
12:46justin_smithdagda1_: I'll have to let someone else weigh in on that
12:46justin_smithhashpuppy: a reducer
12:46justin_smith*transducer
12:46justin_smithsorry
12:46dagda1_justin_smith: thanks
12:46hashpuppyoh... ok. thanks
12:47EvanR_i didnt know you could do (map f) by itself
12:47hashpuppyhow are you guys installing clojurescript on a mac? with brew? or just via source?
12:47EvanR_i have (partial map f) over here in a lot of places
12:47noonianEvanR_: thats new with transducers
12:47hashpuppyi meant clojure
12:47justin_smithhashpuppy: don't install clojure, install lein
12:47noonianhashpuppy: if you have clojure installed you just list clojurescript as a dependency in project.clj
12:48justin_smithnoonian: need lein for project.clj
12:48noonianhashpuppy: and when i say have clojure installed i really mean leiningen
12:48noonianjustin_smith: :)
12:48hashpuppyso i have lein installed. how do i update clojure to 1.7. it's on 1.6
12:49virmundiHello, when using fixtures in clojure, is it encumbant upon the fixture to try/finally around the function passed in to make sure the cleanup occurs.
12:49justin_smithhashpuppy: in project.clj, you should see a clojure dep
12:49noonianif you create a project, just change the version on the clojure dependency in project.clj; if you don't have a project yet type 'lein new my-project' to get one
12:49justin_smithhashpuppy: you can update that to a 1.7 version
12:50EvanR_justin_smith: your function cleaned up a lot of my code and the output, thx
12:50justin_smithnp
12:50hashpuppyok, so silly question. i have (def x (map (constantly true))) how can i apply a list to that? (x [1 2 3])???
12:50lazybothashpuppy: Oh, absolutely.
12:51noonianin this case lazybot is right
12:51justin_smith,(sequence (map (constantly true)) [1 2 3]) ;; hashpuppy:
12:51clojurebot(true true true)
12:51noonianer
12:51BRONSAEvanR_: (map f) is not (partial map f)
12:52EvanR_,((map (constantly true)) [false false false])
12:52clojurebot#<core$map$fn__4341$fn__4342 clojure.core$map$fn__4341$fn__4342@1695c8c>
12:52EvanR_,((partial map (constantly true)) [false false false])
12:52clojurebot(true true true)
12:52BRONSAEvanR_: read the docstring for map, (map f) returns a transducer
12:52EvanR_ah
12:53BRONSAEvanR_: a transducer can be passed to transduce/sequence/into/chan and a bunch of other functions
12:53BRONSAEvanR_: a lot of sequence functions now can return a transducer in their n-1 arity but don't confuse that with partial application
12:53BalvedaAnyone run a Hoplon app on a server?
12:55EvanR_when everything is something, nothing is obviously wrong ;)
12:55hashpuppyso feeding the transducer into sequence turns it into a sequence?
12:56justin_smith,(doc sequence)
12:56clojurebot"([coll] [xform coll] [xform coll & colls]); Coerces coll to a (possibly empty) sequence, if it is not already one. Will not force a lazy seq. (sequence nil) yields (), When a transducer is supplied, returns a lazy sequence of applications of the transform to the items in coll(s), i.e. to the set of first items of each coll, followed by the set of second items in each coll, until any one of the co...
12:56justin_smithI probably would have named that something dumb like transmap or mapduce
12:57BRONSAhashpuppy: it turns it into a lazy sequence, if you don't want the lazy behaviour you can use (into [] x [1 2 3])
12:57hashpuppythanks
12:58EvanR_mapdeuce
13:05EvanR_in doc strings can i highlight a variable name
13:05justin_smithEvanR_: it's just a string, there is no formatting layer defined
13:06EvanR_whats the convention for talking about the params
13:06justin_smithI mean you can put html in there if you want, but people don't have an html renderer attached
13:06EvanR_gross
13:06EvanR_looks like it starts with an arity list
13:07EvanR_(gross: html)
13:07justin_smiththat's something the clojure.repl/doc function throws in there yeah
13:07puredangeryou can override that with meta
13:07justin_smithso you can refer to parameters by the same name they are named in the args list, and that context will be present
13:08justin_smithpuredanger: yeah, that too
13:08EvanR_in vim, is there a combo for "enclose selection in quotes"
13:09justin_smithEvanR_: this is worth figuring out, but a bit weird at first https://github.com/vim-scripts/paredit.vim
13:09justin_smithstructural editing
13:10EvanR_im using vim-sexp at the moment
13:10justin_smithok, it likely has a command for what you are describing, or at least a very concise way to do it
13:10EvanR_nah
13:11EvanR_only for ( [ {
13:11EvanR_so maybe i picked the wrong horse
13:13EvanR_and now i get to either convert a giant map into a giant nested java object, or fiddle with existing code which applies a giant map to a preexisting java object for the same purpose
13:13EvanR_joy
13:37justin_smithEvanR_: for what consumer?
13:38EvanR_im using camel
13:40justin_smithEvanR_: have you seen this? http://codeabout.blogspot.com/2010/06/using-apache-camel-from-clojure.html
13:41justin_smithor even this - https://github.com/hmanish/clj-camel
13:42EvanR_good to know
13:45CookedGryphondoes anyone know why the buffer protocol in core.async changed from full? remove! add!, to full? remove! add!*
13:47EvanR_justin_smith: i am having some difficulty getting a trace of intermedia values between elements in a -> macro
13:48justin_smith(doc doto)
13:48clojurebot"([x & forms]); Evaluates x then calls all of the methods and functions with the value of x supplied at the front of the given arguments. The forms are evaluated in order. Returns x. (doto (new java.util.HashMap) (.put \"a\" 1) (.put \"b\" 2))"
13:48justin_smith,(-> 5 (doto println) inc (doto println) inc)
13:48clojurebot5\n6\n7
13:49EvanR_alrighty
13:49justin_smithfor values of "trace" where trace = print at least :)
13:49EvanR_yes
13:49technomancydoto prn instead
13:50justin_smithtechnomancy: yeah, that is a good idea
13:50justin_smith(doc prn) ; for the uninitiated
13:50clojurebot"([& more]); Same as pr followed by (newline). Observes *flush-on-newline*"
13:50justin_smith(doc pr)
13:50clojurebot"([] [x] [x & more]); Prints the object(s) to the output stream that is the current value of *out*. Prints the object(s), separated by spaces if there is more than one. By default, pr and prn print in a way that objects can be read by the reader"
13:51justin_smith,(prn "hello")
13:51clojurebot"hello"\n
13:51justin_smith,(println "hello")
13:51clojurebothello\n
13:51EvanR_i was actually going to use pprint
13:52justin_smiththat works too :)
13:52virmundiWhat is the guidance on using function names that are in clojure.core? I want to load collections from a document db. The method name is (load [ctx]). I have (:refer-clojure :exclude load). Is this acceptable?
13:53justin_smithvirmundi: I think it should be (:refer-clojure :exclude [load])
13:53virmundiSorry, typo in the box. But is that idomatic clojure, to overload/re-reference a function from core?
13:54justin_smithwell, I think it should be more a question of using it's name
13:54justin_smithsince you are not modifying anything by doing that
13:54EvanR_what about commenting out a piece of a ->
13:54justin_smithand using its name is fine, but I'll probably hate you if I am reading your code and you exclude def and replace it with something totally different
13:55justin_smithfor example
13:55virmundiI envision the api being (col/load [ctx])
13:55virmundiGo on.
13:55justin_smithEvanR_: #_
13:55justin_smith,(-> 5 #_ whatever inc)
13:55clojurebot6
13:55EvanR_i thought that made it take the value of nil
13:55EvanR_or thats only comment
13:56justin_smithvirmundi: yeah, it would only be an issue if it makes your code hard to read, so you are probably fine
13:56justin_smithEvanR_: it means skip the next form
13:56justin_smithEvanR_: (comment ...) returns nil, that just makes the next thing not be in your compiled code at all
13:57justin_smith,(#_#_#_ it nests, too + 1 1)
13:57clojurebot2
13:57justin_smithdon't do that in real code, it is evil
13:57virmundiThanks
14:06poushkardoes anybody has experience working with RoR as backend and Clojurescript + Om/Reagent as frontend? How do you set it up?
14:06poushkar*have
14:07SagiCZ1is there a better way to do this? (swap! atom #(new-value)) if i just want to set a new value to the atom?
14:07justin_smithSagiCZ1: reset!
14:07SagiCZ1thank you
14:11EvanR_how do i print a constant string in the middle of a ->
14:12EvanR_,(doc doto)
14:12clojurebot"([x & forms]); Evaluates x then calls all of the methods and functions with the value of x supplied at the front of the given arguments. The forms are evaluated in order. Returns x. (doto (new java.util.HashMap) (.put \"a\" 1) (.put \"b\" 2))"
14:12GFREDERICKSreiddraper: I wrote some documentation for my test.check fork: https://github.com/gfredericks/test.check
14:12EvanR_now i have no idea how doto was working with (doto pprint)
14:13EvanR_i think i need to eat lunch
14:13noonian,(-> "foo" (doto println) (str "bar"))
14:13clojurebotfoo\n"foobar"
14:13csd_anyone here use the data.json package?
14:15llasramcheshire 4 eva
14:16justin_smith(inc cheshire)
14:16lazybot⇒ 3
14:16mgaareEvanR_: (-> "a" ((fn [x] (println "static string") x)))
14:17justin_smithmgaare: yeah, I was looking for something more concise than that...
14:18mgaarecouldn't think of anything
14:18justin_smith,(-> 5 (doto ((constantly (println "OK")))) inc)
14:18clojurebotOK\n6
14:18justin_smithmaybe
14:18justin_smithstill ugly, probably merits writing an actual function
14:18mgaarethat's a little nicer
14:19mgaarealthough I think the explicit function is a bit easier to follow
14:19justin_smith,(defn do-print [x str] (println str) x)
14:19clojurebot#'sandbox/do-print
14:19justin_smith(-> 5 (do-print "hello") inc)
14:19justin_smith,(-> 5 (do-print "hello") inc)
14:19clojurebothello\n6
14:20justin_smithI think that writing that small helper function is the right way to do it
14:20noonian,(-> 5 (doto (do (println "a string)))
14:20clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
14:20noonian,(-> 5 (doto (do (println "a string")))
14:20clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
14:21noonian,(-> 5 (doto (do (println "a string"))))
14:21clojurebota string\n5
14:24borkdudewith transducers are things like mapv now also obsolete? (into [] (map inc) (range 10)) instead of (mapv inc (range 10)) ?
14:26sdegutisHi. What's a good Vim plugin for Clojure?
14:27sdegutisThanks in advance, and God bless.
14:28borkdudesdegutis fireplace maybe?
14:28sdegutisborkdude: Thank you sir, I'll investigate it.
14:29sdegutisOh tpope created it, who also created fugitive. Nice.
14:32borkdudewhat does it mean that a transducers is independent of its "context" (whatever in the blogpost)
14:33puredangerborkdude: transducer functions do not know where input values come from or where output values are going to
14:33sdegutisI have not looked into "transducers" yet. I heard it's the new big thing though.
14:33puredangeras opposed to seq functions which explicitly assemble outputs by creating new lazy seqs (for example)
14:33borkdudepuredanger right. I sensed that "independent of input" and "independent of whatever" were overlapping
14:34sdegutisIs http://clojure.org/transducers the best way to get started?
14:34puredangersdegutis: I think watching Rich's talk that's linked there is a very good intro to the ideas
14:35puredangerhttps://www.youtube.com/watch?v=6mTbuzafcII
14:35sdegutisAre transducers worth learning for someone who reluctantly uses Clojure in production and has no interest in pushing the envelop of computer science?
14:35CookedGryphonsdegutis: totally
14:36CookedGryphonthey make so much stuff easier in my day to day work
14:36CookedGryphonand faster as an added bonus
14:36puredangerborkdude: re mapv, that example is probably one where the into version may be faster esp if you are composed with other ops
14:37borkdudepuredanger will mapv be rewritten using a transducer then
14:37puredangerdunno, there are many questions like that still to be answered in the future
14:37puredangerat the moment, transducers are almost entirely additive - they don't change the behavior of stuff that already exists, just add new capabilities
14:38borkdudepuredanger were things like transducers and core.async more or less planned, or happy accidents that make clojure even cooler?
14:39puredangertransducers were a result of the work done in reducers and the (re-)work being done in core.async that led to the idea of factoring those parts out of applying transformations
14:41borkdudeCookedGryphon how does it make stuff easier?
14:41CookedGryphoncomposability
14:42CookedGryphonbeing able to combine bits of operations together in different ways
14:42CookedGryphonI make use of core.async a lot, and it's meant I can just get rid of 90% of my go loops
14:43CookedGryphonI just pipe things about with transforms, which are composable, when go-loops are hideously boilerplatey
14:43puredangerCookedGryphon: are you using the new pipeline fns?
14:43CookedGryphonnot yet, it's possible I should be
14:44borkdudepuredanger what are the new pipeline fns?
14:44CookedGryphonbut I wasn't sure how stateful transducers would behave given that parallelism seems obligatory
14:44puredangerborkdude: https://clojure.github.io/core.async/#clojure.core.async/pipeline
14:44CookedGryphonso I just stuck to chans with xforms and old fashioned pipe for now
14:44borkdudeCookedGryphon do you also "return" transducers from functions where you would return a lazy sequence before?
14:45CookedGryphonborkdude: yeah, that sort of thing
14:45CookedGryphonagain it's biggest win is in core.async
14:45CookedGryphonmeant I could take the core.async :require out of a lot of namespaces entirely
14:45CookedGryphonthey just return the transformation that they were doing in a go loop before
14:46CookedGryphon*and* as a bonus, testing is ridiculously simple, I just apply the same transform to a coll in, coll out
14:46CookedGryphonas opposed to nasty test setups where I'd need to make chans, onto-chan my data, then read the data back out and see if it was doing the right thing
14:48borkdudeCookedGryphon ah right, you can unit test without using core.async
14:48CookedGryphonprecisely
14:50CookedGryphonso yeah, totally worth it, and really not complicated. Use them about as much as normal function composition...
14:50technomancyis there any benefit vs normal composition if you're not using core.async?
14:50technomancyother than speed
14:51CookedGryphonand memory usage
14:51puredangerless gc, faster, clearer separation of algorithm
14:51mgaaredebuggability perhaps
14:52borkdudemgaare I don't see how this helps debuggability, I would say the opposite, because it's more difficult to inspect the intermediate stuff with println for example?
14:52hiredmantechnomancy: benefit to transducers?
14:52technomancyto me it kinda sounds like core.async has created its own world where different rules apply, and this feels like a workaround for that
14:52technomancyhiredman: yeah
14:52mi6x3mhey clojure, if I have something like (let [x y z w] [1 2 (throw blabla) 4] will the bindings up to z be established ?
14:52hiredmantechnomancy: yeah, lots
14:52mi6x3mis this behaviour even defined?
14:52puredangerthere are more pert-related improvements coming as well that aren't in 1.7 bucket http://dev.clojure.org/jira/browse/CLJ-1499 http://dev.clojure.org/jira/browse/CLJ-1515 for example
14:53mgaareborkdude: To be more precise, I was really thinking of stacktraces not containing n-levels of lazy seqs
14:54CookedGryphontechnomancy: map/reducing over collections that are bigger than memory is useful
14:54hiredmantechnomancy: tranducers can avoid lots of extra overhead
14:54technomancyCookedGryphon: it sounds like you're just using different words to say "performance" over and over =)
14:55amalloymi6x3m: do you mean (let [[x y z w] [1 2 (throw) 4]])?
14:55CookedGryphon:P well is performance such a bad thing?
14:55mi6x3mamalloy: mmm, yep
14:55hiredmantechnomancy: have you looked at reducers at all? how reducers get subsumed in to transducers seems to be up in the air, but the reducers work provides for a very compeling way to handle resources
14:56puredangerI do not expect that reducers will be subsumed into transducers
14:56technomancyCookedGryphon: I didn't say it was bad; I was asking if performance is the main point
14:56hiredmanpuredanger: oh, really?
14:56CookedGryphontechnomancy: but I don't even mean reduced overhead when I'm talking about bigger than memory, I'm talking about being able to map+reduce over a collection where the *source* data is bigger than you could fit in ram
14:56puredangertechnomancy: I think the main point is separating transformation from application
14:56CookedGryphonwhich is an entirely new thing, not just a performance improvement
14:56amalloymi6x3m: have you tried macroexpanding that? it's pretty clear what happens, really
14:56hiredmanpuredanger: why not?
14:57CookedGryphonand that's a practical limit that I have hit before, which even reducers couldn't cope with
14:58puredangerI don't think they'll be removed but I don't think there will be attempts made to retrofit it in any way. it's more likely that we will gain new core functions that use transducers in parallel (i.e. preduce) that leverage the same underlying FJ fold over vectors/maps
14:58hiredmanok
14:58hiredmansubsumed rich style
14:58puredanger:)
14:58technomancyCookedGryphon: you can already map and reduce over collections bigger than your memory can hold though.
15:00CookedGryphonnot so, certainly not in a composable way. Say you want to get a line-seq on a 400gb file, split the line into words, concatenate that into a list of all the words, filter from a list of stop words and then track the frequencies of the remaining words
15:00sdegutisgo on
15:01hiredmantechnomancy: how do you create a for comprehension over the results of two sql queries that don't fit in memory?
15:01hiredmanwith lazy-seqs it is hard because you don't just have the lazy seq, you have some database connection resources to manage
15:02hiredmantechnomancy: like, if you (with-query-results ...) whatever you get a lazy seq of results, but those are only valid for the life time of the result set, so if you haven't forced it before you leave the with-query-results the seq isn't valid
15:03technomancysure
15:03hiredmantechnomancy: I am using that particular api as an example of resource management around collections
15:03hiredman(not claiming it is great or anything)
15:03CookedGryphonwith transducers, you can do that as a (transduce (comp (mapcat tokens) (filter stop-words)) add-word-to-count (line-seq file)) and it won't hold the head of the seq
15:03CookedGryphonand I just plain couldn't do it before, try as i might
15:04hiredmanso (for [x (with-query-results ...) y (with-query-results ...)] [x y]) is going to fail, unless you force the results inside the with-query-results
15:04hiredmanbut for the sake of argument your result set is to large to fit in memory
15:04hiredmanso you can't
15:04CookedGryphonwithout writing the whole thing as a single reduce with no mapping, but that changes the problem, and you're basically reimplementing what transducers do under the hood anyway, so it may as well be readable
15:05hiredmanwith the reducers library you can formulate something that does that
15:06technomancyso it helps with managing scopes of resources
15:06hiredmansure
15:06hiredmanhttp://ce2144dc-f7c9-4f54-8fb6-7321a4c318db.s3.amazonaws.com/reducers.html#sec-2-2
15:08hiredmannow the reducers library is not the same thing as this new transducer stuff, but it seems like transducers will be superset of reducers functionality
15:08hiredman(even if the reducers namespace sits around for all time and #clojure has to constantly explain to people thay they should be using transducers instead)
15:08puredanger:)
15:09technomancylike clojure.core/partition
15:09technomancyor clojure.core/list?
15:09hiredmanexactly
15:09hiredmanalso filter
15:09hiredmanerr
15:09hiredmanflatten
15:09puredangerwhew, I thought I was behind :)
15:10llasramhiredman: As the face of reducers for resource-management, you may appreciate this: https://gist.github.com/llasram/e75c6bbd9b8567e96681
15:11hiredmanllasram: the irony is whene I tried to bring in reducers for resource management at work it got rejected on code review
15:11llasramwhaaaa
15:11hiredmanvery conservative organization
15:11llasramIt's such a great pattern though.
15:12llasramAlso "very conservative" :: "using Clojure"
15:12hiredmanwell, we've been using clojure since before 1.x was released, so continuing to use clojure is a conservative choice :)
15:13llasramFair enough!
15:13hiredmanuh, actually
15:13hiredmantechnomancy: is that right? since before 1.x was released? I don't remember
15:13technomancyhiredman: yeah totes
15:14technomancynov 2008 was when I started; right when AOT and atoms were added
15:14GFREDERICKSwhich have a lot of letters in common
15:14GFREDERICKSsmoat
15:14TimMcAre we doing uppercase names today?
15:15arrdemapparently
15:15TIMMCoh no it is catching
15:15GFREDERICKSis karma case sensitive?
15:15GFREDERICKS(inc TIMMC)
15:15lazybot⇒ 74
15:15ARRDEMit would seem not
15:16GFREDERICKS(dec TIMMC) ;; didn't earn that one
15:16lazybot⇒ 73
15:16TIMMChiredman: Do you want typo corrections on that piece?
15:16TIMMC(INC GFREDERICKS)
15:16ARRDEMTIMMC: dude this isn't common lisp
15:20justin_smith(𐌶𐌽𐌺 𐍄𐍇𐌼𐌼𐌺)
15:20GFREDERICKSwhat does an upper-case paren look like
15:20bbloomGUYS-WHAT-IS-GOING-ON?
15:20justin_smithCAPS LOCK DAY
15:21GFREDERICKSCAPSLOCKDAY.COM
15:21teslanickEVERYONE KNOWS IT'S CRUISE CONTROL FOR AWESOME
15:22GFREDERICKSthis is a pretty weird website
15:23bbloomi love the mobile version
15:23bbloommy capslock key has been ctrl for years, otherwise i'd participate
15:26ghadishaybanpuredanger: fwiw i've often wanted the fold-by-halves functionality to be independent of fork-join
15:27ghadishaybanfold-by-halves from some ticket ... searching
15:27ghadishaybanhttp://dev.clojure.org/jira/browse/CLJ-1045
15:28ghadishaybanthat way i can make an operation that's logically a fold (reduce + combine), but be invoked in a different way
15:29ghadishaybanlet's just say an asynchronous combine for the sake of example
15:29puredangerthat's pretty cool. I don't remember seeing the ticket.
15:29ghadishaybani want the subdivision of a collection as the API, building foldvec on top of it specifically for FJ
15:31ghadishaybanthis is in response to the hypothetical preduce
15:32amalloyBBLOOM: MINE TOO. YOU GOTTA SHOW WILLING BY HOLDING DOWN SHIFT FOR EVERYHING. EXCEPT PUNCTUATION. THAT'S TRICKIER
15:32bbloomamalloy: i used to type D#D(_TEXTURE all the time
15:32bbloomdrove me nuts
15:33evindorHi people! IRC seems to be last resort for me. I got a problem with cljs source maps
15:33puredangerghadishayban: I don't really know what shape a preduce would take
15:33evindorchrome shows me the source map file itself, not the source
15:34evindoranyone faced such an issue?
15:41amalloybbloom: what made you need to type d3d9-texture?
15:42bbloomamalloy: i worked on lots of directx stuff
15:42bbloomall the damn constants were all upper case
15:42bbloomstuff like this: http://msdn.microsoft.com/en-us/library/windows/desktop/ff471467(v=vs.85).aspx
15:43llasrambbloom: how do you know it's a constant if it isn't shouting at you?
15:43bbloomeven when not typing constant names, it was shit like ID3DXFile
15:43bbloomwhich i'd surely type as ID#DXFile
15:43bbloomargh.
15:43bbloomor I'd miss a shift
15:43bbloomIDireT#dStateBlock9
15:44bbloomhaunted me
15:44bbloomllasram: is it too late to make all the variables upper case? :-)
15:47EvanR_obviously variables should have names like IdIRet#DdTAT$z\%634/52345
15:48justin_smithEvanR_: no joke, I was talking to a guy who "solved" his clojure design issue by using gensym to create names for all his functions
15:48bbloombwha?
15:48teslanickIt solves one of those two hard problems.
15:48teslanickSo you can focus on cache invalidation.
15:49justin_smithbbloom: inorite
15:50justin_smithbbloom: http://clojure-log.n01se.net/date/2014-10-21.html it starts up for real on the first page where he asks about AOT compiled scripts
15:52amalloyoh, chouser's logger is back up again? i remember it had been down for weeks at some point
15:52GFREDERICKSclojurebot: chouser's logger is back up again
15:52clojurebotRoger.
15:53amalloygfredericks: you're killing me here. i refuse to acknowledge your all-caps name, which means i can't use tab completion
15:53drbobbeatyamalloy: He lives under a rainbow - what can you expect?
15:54amalloyhuge backpedal from justin_smith in that log: "I have namespaces with hundreds of functions in them. [...] well, at least two"
15:54justin_smithheh
15:54GFREDERICKSamalloy: I saw puredanger do that earlier to BRONSA and wondered if it was manual
15:55justin_smithamalloy: at least two namespaces with hundreds of functions in them
15:56justin_smithamalloy: and this is in context of a dude trying to load a file where calling a function would suffice (so treating a namspace as if it were one bit function)
15:56amalloyyes, i remember rritoch
15:56evindorDoes anyone have working source maps for cljs with advanced optimizations?
16:03justin_smithevindor: you may get more help on #clojurescript - couldn't hurt to try there if you haven't
16:03evindorjustin_smith: thx
16:14amalloyshame dnolen isn't here - i can't imagine he'd settle for non-working source maps
16:15evindoramalloy: they are generated but i guess i have messed up paths inside it
16:16evindorchrome even laods it but shows the source map file itself instead of source code
16:16amalloyyeah, i have no idea. if i did, i'd offer help myself instead of lamenting dnolen's absence
16:17teslanickevindor: What's the //#sourceMapingUrl at the end of your compiled JS look like?
16:18teslanickAnd then open the map file that it points at and check the "sources" array (a sourcemap is just a JSON file)
16:18evindorteslanick: //# sourceMappingURL=app.min.js.map
16:19evindormap file itself looks okay, except it has several empty strings in sources
16:19teslanickInteresting. That might be the source of your problems.
16:20teslanickHave you tried nuking all the built cljs and rebuilding?
16:20evindoryeah i think so as well. sure i tried rebuilding everything
16:25puredangeramalloy: re earlier, dnolen is currently on tour with his band in Europe so won't be around for a while
16:25puredangerafaik
16:25amalloyunacceptable. how will cljs patches be applied without him?
16:25puredangerhe does seem to be online occasionally doing stuff, not sure what his exact schedule is
16:26amalloyoh my gosh. i just had a vision of dnolen pausing mid-concert to apply a patch. he's just that committed
16:26bbloomheh committed, i get it
16:26amalloy(inc unintended-puns)
16:26lazybot⇒ 1
16:26clojurebotTitim gan éirí ort.
16:28amalloywhat does dnolen play? i have this vague notion that it's a brass instrument of some sort but i don't know how i got that idea
16:28bbloomamalloy: https://www.youtube.com/watch?v=4E9TGlDxE48 south park?
16:29amalloybbloom: brass, not bass
16:29amalloybut i don't watch south park
16:29bbloomamalloy: oh, reading comprehension failure
16:31andrewhroh man, I didn’t know there is a clojurescript channel
16:31andrewhru.u
16:38puredangeramalloy: See http://hairysands.bandcamp.com/album/sandy-hairs - I think he plays guitar?
16:39puredangeryeah, some pics here: https://twitter.com/hairysands
16:45justin_smithif he played keyboard, the references to patches above would be unintentional puns
16:55danielcomptonIs there any way to convert a record to a map without altering the keys or values of the record?
16:56technomancyinto?
16:56clojurebotinto is like a magical transformer ring. i.e. (into {} something) converts a surprisingly wide variety of things into maps.
16:56bbloom,(defrecord Point [x y])
16:56clojurebotsandbox.Point
16:56bbloom,(into {} (Point. 5 10))
16:56clojurebot{:x 5, :y 10}
16:57vIkSiThello all
16:58vIkSiTIm running an experiment : I have a function called myfn that takes about a second to execute. So, I run a (doseq [f files] (myfn f)) and time it.
16:58vIkSiT(by wrapping doseq with time)
16:58TIMMCAre you using criterium?
16:59SagiCZ1vIkSiT: yeah<
16:59danielcomptonbbloom, technomancy: of course
16:59TIMMC~benchmarking
16:59clojurebotbenchmarking is https://github.com/hugoduncan/criterium
16:59vIkSiTNow, I try a (map myfn (partition-all n files))
16:59vIkSiTI'd like to figure out how to measure times in this case.
16:59SagiCZ1vIkSiT: me too
16:59TIMMCdoall
16:59justin_smithvIkSiT: use criterium
16:59TIMMCor dorun, I guess
16:59vIkSiT(And ideally, Id like to figure out how to use pmap)
17:00vIkSiTah
17:04vIkSiThmm, thanks for that info - I think dorun really did the trick
17:04vIkSiTnow my follow up question :)
17:05vIkSiTwhat's a good guide to using pmap vs parallel programming using reducers?
17:05justin_smith~pmap
17:05clojurebotpmap is not what you want
17:06vIkSiTjustin_smith, hehe - well
17:06vIkSiTI'm not quite going to start using a 1000 node MR cluster just yet..
17:06SegFaultAXOh pmap. The function we love to hate.
17:06vIkSiTso why all the pmap ~love?
17:06SagiCZ1wait whats wrong with pmap?
17:06vIkSiT^^ that.
17:07SegFaultAXThe usual warning that your mapping fn better be more expensive than the coordination overhead of multiple threads.
17:07vIkSiTah that
17:07SegFaultAXEither way, try it and test.
17:07SagiCZ1SegFaultAX: so? thats something u discover with one test
17:07vIkSiTand how does one benchmark the coordination overhead of multiple threads?
17:07justin_smithalso, it chunks in unintuitive ways
17:07SagiCZ1just time pmap and time map
17:07vIkSiTfor instance in my case, I just saw a reduction in time from 20ms -> 7ms.
17:08justin_smithvIkSiT: with criterium
17:08vIkSiTprecisely - trying that now.
17:08SegFaultAXIt's not always bad. But usally it isn't worth it for what 99% of people ask about.
17:08SagiCZ1i wonder why is that thread overhead so huge
17:09SegFaultAXSagiCZ1: It's expensive in both time and space to start up a thread pool
17:09justin_smithSegFaultAX: and it's rarely better than an executor with a queue (via core.async abstractions or not to taste)
17:09vIkSiTSagiCZ1, coordination is always going to be expensive simply becase you need to maintain a threadpool, start it up. et al
17:09SegFaultAXjustin_smith: Precismo!
17:09vIkSiTjustin_smith, speaking of which..
17:09clojurebotPardon?
17:10vIkSiTis there a core.async based guide to multi-thread processing? channels, best practices, consuming, map/reduce?
17:10SegFaultAXOr reducers
17:10justin_smithvIkSiT: SagiCZ1: also, pmap ensures ordering - you can get faster results if you don't care about the ordering
17:10SegFaultAXI don't know if transducers have been ported to also leverage ForkJoinPool, but that.
17:10SagiCZ1justin_smith: how can it ensure ordering, when its parallel?
17:10SegFaultAXDepending on the nature of the work and the processing involved.
17:10SegFaultAXSagiCZ1: That's part of the coordination.
17:11justin_smithand part of why said coordination is expensive
17:11SegFaultAXSagiCZ1: But a really naive impl is to just create N futures, then map deref over them.
17:12justin_smith$source pmap
17:12lazybotpmap is http://is.gd/98SQJR
17:12puredangerthat's all pmap is doing
17:13justin_smithpuredanger: yeah, that was my intended point with that link :)
17:13hiredmanwell, pmap is doing weird stepping stuff
17:13SagiCZ1interesting......... well thats it for thinking pmap is amazing
17:13hiredmanand pmap does weird things with chunked seqs
17:13hiredmanetc
17:13puredangerpmap is perfect solution to a very narrow band of problems and pretty bad for everything else
17:14ghadishaybanWhat's a favorite resource for explaining the seq/first/rest/next subtleties to a beginner?
17:14SegFaultAXDoes transducers also already support ForkJoinPool the way reducers did?
17:14puredangerno
17:14puredangersee the back chat from the last hour or so :)
17:14SegFaultAXpuredanger: tl;dr? :D
17:14ghadishaybanSegFaultAX: transducers are irrespective of collection / eval strategy
17:15puredangerSegFaultAX: doesn't exist. but will eventually.
17:15SegFaultAXSure. You might want a fjtransduce fn.
17:15hiredmangenerally for lots of these parallel things, you don't actually care about ordering, lots of the time you have an unordered bag of work you want to happen and want the result of the work as it finishes
17:15hiredmanpmap and seqs force ordering
17:16SegFaultAXThat's the other implicit issue with pmap. You can't represent things where ordering doesn't matter.
17:16SegFaultAXYup
17:16puredangerasync/pipeline fits in that group too
17:16SagiCZ1so is there some sort of doseq that lets me specify how to exactly get the next element besides loop?
17:17justin_smithSagiCZ1: well I guess you could reify an iterator or something...
17:17hiredmansure, just make sure you aren't doing io on the go block threadpool
17:17justin_smithSagiCZ1: but loop seems more straightforwar
17:17SagiCZ1loop it is then..
17:18SegFaultAXpuredanger: In which group?
17:18justin_smithSagiCZ1: depending on what you are doing and how you want to view the result, there is also iterate
17:18puredangerthe group of things that force ordering :)
17:18justin_smithSagiCZ1: though "sort of doseq" I guess implies not using the results
17:19hiredmanpuredanger: is that entirely true?
17:19SegFaultAXNo.
17:19SegFaultAXBecuase you could use an input channel and an output channel and some number of goblocks or gothreads to read from the input channel and write to the output channel.
17:19puredangerhiredman: actually, I guess you're right - it produces results in an order corresponding to the inputs
17:20puredangerbut might not actually process them in that order
17:21SagiCZ1i might be overthinking this.. i have a queue, and i need to write its consumer.. i get next element by (.take queue).. then i just call (consume element) .. this is how i do it https://www.refheap.com/92176 maybe it can be done better?
17:22ghadishaybanIs there a resource like clojure.org/lazy but more current? http://clojure.org/sequences doesn't mention next vs rest.
17:22puredangerthere is actually a dead page that talks about that
17:23ghadishaybanI'm looking for a well-written link I can handily throw at a beginner to understand the subtleties of seq vs coll, first/rest, rest vs. next
17:23puredangeroh, the lazy page is what I was thinking of. I don't think there is a more current version of that but there should be
17:23hiredmanpuredanger: well that is interesting though, I didn't realize the pipelines were that strongly order preserving
17:23SegFaultAXSo... when are we going to kill clojuredocs?
17:23ghadishaybanyeah too much real estate devoted to how rest *used* to work
17:23ghadishaybanpre-github
17:24puredangerhiredman: they're designed to be used for things like pipeline stages where work passes through them, so the ordering is important
17:24hiredmanpuredanger: does what it says on the tin
17:25technomancySegFaultAX: just when it's sputtered back to life?
17:25SegFaultAXHas it?
17:26SegFaultAXtechnomancy: Wowza, that's awesome. I can't believe I didn't notice it.
17:26puredangerSagiCZ1: I'd prob refactor that to just have a single .take inside the loop. and you might need some kind of termination check
17:26SagiCZ1puredanger: thank you for having a look, how could i just have one .take call?
17:27hiredmanI am rethinking through the sort of things I have done, that I thought pipeline was a good fit for, and I think it still is with the ordering on the final results, what matters is the free for all ordering on actual running of the jobs
17:27puredanger(loop [] (let [event (.take queue] (consume event) (recur))
17:27SagiCZ1isnt that (while true ... ?
17:27SegFaultAXThat's why he said you need to check for termination.
17:27puredangeryeah, but you'll probably want some other stuff there too
17:28puredanger<advert>I have a section on this in my forthcoming book btw</advert>
17:28SagiCZ1i see
17:28SagiCZ1i am buying, are you selling?
17:29SegFaultAXpuredanger: EAP?
17:29puredangerwill be a Prag beta book soon, hopefully by the conj
17:30puredangerClojure Applied
17:39TIMMC~books
17:39clojurebotbooks is book
17:39TIMMC~book
17:39clojurebotbook is http://clojurebook.com/ http://joyofclojure.com/
17:39TIMMCYou'll have to add to the list.
17:41SegFaultAXTIMMC: Why are you yelling your name at us? :D
17:42TEttingerSegFaultAX, why are you yelling his name?
17:43SegFaultAXTEttinger: Anger issues, probably.
17:45bridgethillyerIt’s ALL CAPS DAY
17:51SagiCZ1any idea what could this mean? "No nREPL ack received"
17:52justin_smithSagiCZ1: I think that means cider
17:54justin_smithSagiCZ1: though if it helps, an ack is a confirmation in a communication protocol, and it sounds like something is out of sync with a clojure nrepl server (either because of a scrambled message on the line, or the nrepl having some error state)
17:54SagiCZ1thank you
17:54technomancyI think nrepl acks are sent to indicate the server is up
17:54technomancyso that could mean the server wasn't started successfully?
17:55justin_smithtechnomancy: it can also happen when cider fucks up the message parsing, and thus does not recognize the ack
17:55technomancyhuh
17:55justin_smithwhen its bencode gets in a bad state or something
17:55justin_smithtechnomancy: that is, you can get an ack, but the client (cider) sometimes does not recognize it as one
17:56SagiCZ1its a local lein repl
17:56technomancyoh cider http://p.hagelb.org/sisko.gif
17:57justin_smithSagiCZ1: any other error output?
17:58justin_smiththe failure to get an ack basically means the nrepl server did not confirm it was there and ready to accept evaluation requests
18:06EvanR_,()
18:06clojurebot()
18:07EvanR_,'()
18:07clojurebot()
18:07Bronsa,`()
18:07clojurebot()
18:07Bronsayep still a lisp
18:07EvanR_,(= () '())
18:07clojurebottrue
18:08stuartsierra,(= () nil)
18:08clojurebotfalse
18:10pmonks,(= * =)
18:10clojurebotfalse
18:10pmonks(sorry - couldn’t resist some rude ascii art...)
18:12pmonksOr is it a TIE fighter?
18:16EvanR_lol <- tie interceptor
18:31TIMMCSegFaultAX: I don't know, BRONSA started it! And then GFREDERICKS did it, and I caved to peer pressure.
18:31TIMMCSegFaultAX: Apparently HTTP://CAPSLOCKDAY.COM
18:33TimMcMaybe it is time to relax though.
18:33Bronsait's no longer CAPSLOCKDAY in Italy.
18:34justin_smith$google is it caps lock day
18:34lazybot[internetonal caps lock day home page] http://capslockday.com/
18:34justin_smithI was hoping for a single serving site
18:39SagiCZ1are Italians here?
18:39SagiCZ1why don't we talk about food all day? i am dissapointed
18:39EvanR_,[1 2 3]
18:39clojurebot[1 2 3]
18:39EvanR_,'[1 2 3]
18:39clojurebot[1 2 3]
18:39SegFaultAXTimMc: Hah
18:40EvanR_,'[1 (+ 2 2) 3]
18:40clojurebot[1 (+ 2 2) 3]
18:41justin_smith'(just about anything goes here, really- go nuts!)
18:41justin_smith,'(just about anything goes here, really- go nuts!)
18:41clojurebot(just about anything goes here ...)
18:41kenrestivohmm, this works, but it reeks of old socks and leftover lunch meat: https://www.refheap.com/92177
18:41SagiCZ1kenrestivo: here we go.. food
18:42EvanR_,''
18:42clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
18:42justin_smithkenrestivo: that's a pretty deep nest of anonymous functions
18:42kenrestivomy gawd, capslockday.com is actually a thing? that site... my eyes... myspace 2005...
18:43nooniankenrestivo: it might look a bit cleaner if you bound the parsed res in a let before swap, or broke it out into a helper function
18:43kenrestivojustin_smith: yeah, it's pretty ridiculous. i think core.async channels might be in order
18:43justin_smithkenrestivo: how about maybe flet?
18:43SagiCZ1can i create a defmethod which takes anything that couldnt be dispatched? something like default implementation
18:44kenrestivoflet?
18:44justin_smithkenrestivo: putting together an example
18:44kenrestivo“floor of a house; house”), from Old English flet,
18:44justin_smithSagiCZ1: a multi can take any function, including one that has a default
18:44kenrestivoand i am not going near urban dictionary on that, thankyouverymuch. it sounds filthy.
18:45SagiCZ1justin_smith: not sure i follow..
18:45justin_smithSagiCZ1: defmulti takes a dispatch function as an argument
18:45nooniankenrestivo: maybe something like: (swap! app-state update-in [:foo] #(merge % (parse-res res)))
18:45SagiCZ1so if i want default methods i can implement default dispatch in the dispatch function
18:46SegFaultAXkenrestivo: If it was myspace, there would have been javascript rain and a clock connected to your mouse.
18:46justin_smithSagiCZ1: but I take that back - really you just want to dispatch on type like normal, and then have a version for Object, probably
18:46justin_smithand others still work, being more specific and all
18:46kenrestivonoonian: good call, that fn [o] is totally superfluous
18:46SegFaultAXJust sayin: http://rainbow.arch.scriptmania.com/scripts/mouse_clock3.html
18:47EvanR_SegFaultAX: having never used myspace, this sounds rather bizarre without context
18:47kenrestivoforgot swap! can pass args, i'm so used to passing it anonymous fns
18:47noonianyeah, i forget too but it tends to clean things up when you remember :P
18:47SagiCZ1justin_smith: and if the dispatch value is nil, would the Object implementation take it?
18:47SegFaultAXEvanR_: It was a simpler time then.
18:48justin_smithSagiCZ1: what is your dispatch fn?
18:48SagiCZ1just a keyword lookup in map.. ":type"
18:48justin_smithSagiCZ1: then define a version for nil instead of Object
18:49justin_smithI had wrongly assumed you were using the "type" function
18:49SagiCZ1so (defmethod foo nil ?
18:49justin_smithSagiCZ1: yup
18:49SagiCZ1alright
18:49EvanR_and thats all i can about stand for today
18:49noonianSagiCZ1: you can also define an implementation for :default
18:49justin_smithor, instead of :type use #(get % :type :default) and then (defmethod foo :default ...)
18:49justin_smithyeah, what noonian said
18:50noonianbut you don't need to supply the :default key on nil's multimethods does it for you
18:50noonian,(doc defmulti)
18:50clojurebot"([name docstring? attr-map? dispatch-fn & ...]); Creates a new multimethod with the associated dispatch function. The docstring and attribute-map are optional. Options are key-value pairs and may be one of: :default The default dispatch value, defaults to :default :hierarchy The value used for hierarchical dispatch (e.g. ::square is-a ::shape) Hierarchies are type-like relationships that do not d...
18:50justin_smithnoonian: ahh, I had missed that subtlety, nice :)
18:51justin_smith(inc noonian)
18:51lazybot⇒ 8
18:52noonian:)
18:54justin_smithkenrestivo: a slightly silly attempt to use flet as I was suggesting https://www.refheap.com/92178
18:54justin_smithkenrestivo: translation likely imperfect
18:55noonianjustin_smith: is flet new in 1.7 or something?
18:55kenrestivowhat is this flet?
18:55noonian,flet
18:55clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: flet in this context, compiling:(NO_SOURCE_PATH:0:0)>
18:55justin_smithoh crap
18:55kenrestivoyeh
18:55justin_smithletfn
18:55amalloy_how do i pass options to javac when running lein javac?
18:55justin_smithI am so silly
18:55noonianahhh
18:55justin_smithbrain fart, my bad, fixing the paste
18:56amalloy_flet is secret technology of the T Elves, written backwards so we won't suspect a thing
18:56justin_smithfixed
18:56kenrestivoflet! flet! flet! sounds like a large bird taking off.
18:56noonianlol, urban dictionary does have an entry for flet...
18:56kenrestivooh, letfn, sure.
18:56justin_smithkenrestivo: flet is basically letfn in common lisp
18:56kenrestivook.
18:56justin_smithclearly I experienced a neural temporal anomoly, and/or a senior moment
18:57kenrestivohappens. the more languages you use, the more interference happens
18:57noonianruby hashmap syntax killed me after getting used to clojure keywords
18:58kenrestivoi like that device tho, if there are a lot of anon fn's, namign them in a letfn cleans up the nesting
18:59nooniani think it also allows for mutual recursion as if you had declared them beforehand
18:59justin_smithkenrestivo: and as a bonus, it allows mutual recurion and inlining thanks to the scope
18:59justin_smithright
18:59justin_smith*recursion
18:59kenrestivoclojurebot: recursion is recursion
18:59clojurebotAlles klar
19:00justin_smith,(nth (iterate identity 'recursion) 1000000)
19:00clojurebotrecursion
19:03SagiCZ1justin_smith: something very weird happens when you call (method nil "value2") .. the dispatch method skips the nil and tries to dispatch it on the "value2" ..
19:04justin_smithSagiCZ1: that's odd
19:04SagiCZ1let me try to replicate it here
19:04SagiCZ1,(defmulti foo :type)
19:04clojurebot#'sandbox/foo
19:05SagiCZ1,(foo nil "value")
19:05clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No method in multimethod 'foo' for dispatch value: value>
19:05SagiCZ1,(foo nil "second-value")
19:05clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No method in multimethod 'foo' for dispatch value: second-value>
19:05SagiCZ1see?
19:06justin_smith,(defmethod foo :default [a b] :default-value)
19:06clojurebot#<MultiFn clojure.lang.MultiFn@a4441a>
19:06justin_smith,(foo nil "value")
19:06clojurebot:default-value
19:06GFREDERICKSokay I think it's time to write hyper-shrink
19:07justin_smithSagiCZ1: the error message is confusing, but the behavior I show above should be fine, right?
19:07SagiCZ1is the :default keyword special?
19:07justin_smithSagiCZ1: yes, as noonian was pointing out above
19:07justin_smithit is the default default
19:08justin_smiththe meta default
19:08justin_smithlol
19:08SagiCZ1i missed that
19:08SagiCZ1its in the defmulti doc too.. never mind .. thanks for helping me
19:08SagiCZ1btw that error message is terrible
19:09justin_smithyeah, I can't see how that would even make sense in that context at the moment
19:09justin_smithperhaps worthy of a bug report?
19:10SagiCZ1perhaps
19:10clojurebotCool story bro.
19:17justin_smithgfredericks: wtg w/ tla research
19:18gfredericksjustin_smith: thx
19:21gfredericksI'm sure everybody is itching for the raw data: http://upload.gfredericks.com/tmp/missing-tlas.clj
19:21gfrederickseverybody pick a TLA and work on getting it into wikipedia
19:22justin_smithgfredericks: FUX is not taken, must find an acronym for FUX
19:22technomancywe can have this done by the weekend; let's get cracking people
19:23justin_smithTLA squatting: 1) claim TLA, 2) ??? ...
19:24noonian3) profit!
19:24noonianer, 4) i guess
19:25SegFaultAXgfredericks: Prismatic's pairing question?
19:25gfredericksis it?
19:25SegFaultAXI think it's one of them.
19:36mwfoglemani'm having troubles with the reloaded workflow -- my system.clj file is in my src/.../system.clj directory, and i can't make my users.clj find it.
19:37noonian(require [the.path.to.system :as system]) fails?
19:37mwfoglemanwithin the ns macro, yeah.
19:37mwfogleman i tried doing the simplest possible case with stuart's reloaded template and i bump into the same problem
19:37noonianyou should make sure you can do it manually first. if there is a problem with system.clj then it could block user.clj from loading
19:38mwfoglemanoh, in the repl?
19:38noonianyeah
19:38mwfoglemangood idea.
19:38mwfoglemani'll go try that.
19:39noonianalso, you might want to do that user stuff in a different namespace and have a function in user.clj that calls (in-ns 'dev-ns) so that you can still get a repl up if you have errors in your code
19:41mwfoglemannoonian: running require in the repl worked.
19:42mwfoglemani'm not sure i understand your suggestion.
19:42nooniandon't worry about it for now then
19:42noonianmaybe you don't tell clojure where your custom user.clj is in project.clj?
19:42noonianeither in :init-ns or include the directory in source-paths in the dev profile or something
19:42mwfoglemanit's in source-paths, that's not the problem.
19:43mwfoglemanit's only when i try to require my own code that the compiler hits an error.
19:43mwfoglemani'm noticing the problem when i do lein clean; lein deps; lein compile
19:44mwfoglemanone thing is that all the code i've tried to require is in a src/subdirectory/....file.clj
19:44mwfoglemanwhereas the user.clj is in dev/user.clj
19:45nooniancommon mistakes include using hyphens instead of underscores in your directory names
19:45mwfoglemanin the directory name, not the require, right?
19:45mwfoglemanthe namespaces have hyphens
19:45mwfoglemani think the directories are all underscores
19:45mwfoglemanlet me double check
19:45noonianyeah, what you put in the ns form
19:46noonianbut the ns form (with hyphens) still needs to correspond to the directory structure (with underscores)
19:46mwfoglemanohhh
19:46mwfoglemanthat's totally the problem. i'm inheriting the project
19:46mwfoglemanand it has a hyphen
19:46mwfoglemanin the directory. strange that hasn't shown up
19:46mwfoglemanuntil now
19:46noonianinheriting?
19:46mwfoglemanas in I have a new clojure job!
19:46mwfogleman:D
19:47nooniancongrats!
19:47mwfoglemanthanks! :)
19:47mwfoglemanit's strange that this problem hasn't surfaced until now.
19:48mwfoglemannoonian: do you use component and/or the reloaded workflow?
19:48noonianyes, although i'm not using clojure at work atm so just for personal stuff
19:49mwfoglemanok, ok
19:49mwfoglemanhmm, this might not be the problem. the repo is hyphenated, not the directory.
19:49mwfoglemani misread the misreading :P
19:49amalloymwfogleman: you shouldn't need to run clean, deps, *or* compile. those are all done pretty automatically. and if you really do need to run them, you can save yourself quite a bit of startup time by combining them into one lein invocation: lein do clean, deps, compile
19:49mwfoglemanoh, boy!
19:49mwfoglemani know i don't need to run them regularly
19:49mwfoglemanbut that's handy shortcut, thanks
19:49justin_smithin particular, pretty much any task will end up invoking deps
19:50nooniani don't think bad code in user would mess up your lein deps at all, i just typed some junk into my user.clj and it didn't trip up leiningen
19:50justin_smithclean is iffier - it is sometimes needed after you update a library version in your deps for example
19:51noonianmaybe your project depends on another project that is private to your company and you need to 'lein install' it manually?
19:51amalloyjustin_smith: updating a library version in your deps? how does that ever need a clean?
19:52justin_smithamalloy: just the other day someone was getting really weird errors because they upped a lib version, after a clean the errors went away
19:52justin_smithiirc it was schema
19:52mwfoglemannoonian: that second thing sounds promising
19:52amalloyjustin_smith: well. i'm not necessarily convinced it was *because* they updated a lib version, so much as that it happened at the same time
19:52mwfoglemannoonian: we have some git submodules
19:53justin_smithamalloy: yeah, it was piranha, they were getting schema exceptions after updating the version, they went away after running lein clean
19:53amalloythe main reason to need clean is if you're doing a bunch of AOT compilation and want to make sure old artifacts aren't lying around; i ended up deleting a class once, and then forgot to update the code that was using that class: the old classfile was still around, so it "worked" for days
19:53justin_smithamalloy: yeah, aot may have been a contributing factor there
19:54mwfoglemannoonian: fyi, the problem isn't "bad code" in the user.clj-- there's actually nothing in there yet, really
19:54noonianmwfogleman: if your :dependencies vector has anything that looks like an in-house lib you should track it down and lein install it; or maybe just ask someone :P
19:54amalloythe main time i end up running lein deps myself is if i want to update a snapshot version: lein -U deps
19:54noonianmwfogleman: what error do you get?
19:55mwfogleman java.lang.ClassNotFoundException
19:55mwfoglemanhmm. how do i figure out which in-house lib is the problem?
19:56noonianand its your system class that isn't found?
19:56mwfoglemanno-- i don't have to be requiring the system for this error to be thrown. as best i can tell, it's any in-project, in-house code
19:56mwfoglemanthings like midje or component don't throw an error.
19:57noonianmwfogleman: you can look in your ~/.m2/repository to see which libs are installed are installed. if you have multiple in-house deps you will need to install all of them
19:57nooniani.e. cd to the project directory and type 'lein install'
19:57ARRDEMjohnwalker: you should come lurk #clojure-social. 'tis a silly place.
19:58mwfoglemanok, good idea.
20:00mwfoglemani seem to have all the dependencies. and upon reflection they seem to be publically available, albeit developed by our folks
20:01noonianthey need to be published to clojars or maven for lein to find them
20:01johnwalkerhehe 7 nicks
20:01noonianhmm, do you have any deps or plugins in ~/.lein/profiles.clj that might be causing it?
20:02mwfoglemanhmm. i do have a plugin: lein-midje (that's also in our project.clj dev dependency); and a dependency on tools.namespace.
20:02mwfoglemanwhich the reloaded workflow requires in the project.clj.
20:02mwfoglemanas you know
20:03johnwalkermwfogleman: has anyone suggested that you run lein deps :tree
20:03noonianwell, lein deps throws an error for him
20:03johnwalkeroh.
20:03mwfoglemanit's actually lein compile that throws the error
20:03mwfoglemanas best i can tell
20:04justin_smithmwfogleman: then it should tell your which file is causing the error - can you share the stacktrace?
20:04mwfoglemanexcerpts--- let me get it again. what am i looking for?
20:05noonianthe file that is not found
20:05justin_smithmwfogleman: pastebin the whole trace
20:05justin_smithor I should say refheap.com it
20:08mwfoglemannoonian: justin_smith: https://www.refheap.com/f7e08862a611525c7a24dd8d7
20:08justin_smithmwfogleman: there should never be a class called yeti-stack.StackPailStructure
20:08mwfoglemana clojure pastebin, nice :D
20:08justin_smiththat isn't a valid class name
20:09noonianyeah, the underscore thing applies to class names also
20:09mwfoglemanjustin_smith: okay, that sounds promising.
20:09justin_smithin system_pail.clj, change any reference to yeti-stack.StackPailStructure to yeti_stack.StackPailStructure
20:10justin_smithnoonian: we could even say that it only applies to class names, and the file name requirement is a side effect of this :)
20:10mwfoglemanjustin_smith: clever ;)
20:10mwfoglemani think that's coming from the namespaces
20:11mwfoglemanoops
20:11mwfoglemanit's not
20:11mwfoglemanthe namespaces are no problem, right?
20:11mwfoglemanit's just hyphens elsewhere in the code
20:11justin_smithmwfogleman: the namespace should be called yeti-stack
20:11justin_smithclasses defined in the namespace should be referenced as yeti_stack.*
20:11mwfoglemani have a line like this in the ns macro: (:import [yeti-stack StackPailStructure])
20:12noonianif you're importing anything they need underscores
20:12justin_smithchange that to (yeti_stack StackPailStructure)
20:12mwfoglemanok, imports need underscores.
20:12mwfoglemani'm thinking this is probably going to need changes in more than one place
20:12mwfoglemanthanks for helping me track this down, justin_smith and noonian.
20:13justin_smithmwfogleman: yeah, you may just want to grep for :import :) emacs has a wonderful M-x rgrep that lets you jump to each usage with a mouse click
20:13nooniannp, happy coding!
20:13mwfoglemanjustin_smith: nice, i'll do that :D
20:14justin_smithmwfogleman: glad I could help, this stuff is hard the first 100 times or so, but eventually the heuristics are second nature :)
20:14mwfogleman justin_smith: glad to hear that.
20:14justin_smithwe should do an "interpret clojure stacktraces as a service" startup
20:14mwfoglemanhaha, totally.
20:15mwfoglemani'm getting better at picking out the important parts.
20:15justin_smithyeah, it's a kind of literacy basically
20:16justin_smithmy big hint this time: CamelCase means java level stuff, which means you need _ instead of -
20:16justin_smithso - with CamelCase was a red flag
20:16mwfoglemanokay, good hint.
20:17andyfmwfogleman: Eastwood should help you find such namespace/file name mismatches. github.com/jonase/Eastwood
20:17andyfAmong other issues
20:17mwfoglemanandyf: i've been meaning to check that out for a while. thanks for the reminder.
20:19andyfI had the weirdest time testing Eastwood on projects with such mismatches before putting that check in. Adding it was a sanity-preserver
20:25mwfoglemanjustin_smith: does this look problematic to you?: (gen-structure yeti_stack.StackPailStructure
20:25mwfoglemanerm
20:25mwfogleman(gen-structure yeti-stack.StackPailStructure
20:25mwfoglemanwhich is better? ;)
20:30justin_smiththe first is correct - class names can't have -
20:30justin_smiththough I don't know what gen-structure is
20:33mwfoglemanjustin_smith: it's a macro in clj-pail.
20:34mwfoglemanjustin_smith: thanks for the reassurance. i think it's definitely the _'s and the -'s :)
20:36hashpuppyreading a clojure book online and they give an example of ((or + -) 1 2 3). what is that doing?
20:36justin_smithhashpuppy: the cool thing with clojure is usually each part of a form can be run individually
20:37justin_smith,(or + -)
20:37clojurebot#<core$_PLUS_ clojure.core$_PLUS_@afe405>
20:37justin_smiththat looks weird, but it is the value of +
20:37justin_smith,+
20:37clojurebot#<core$_PLUS_ clojure.core$_PLUS_@afe405>
20:37mwfoglemanthe one cool thing ;)
20:37justin_smithmwfogleman: one of many :)
20:37mwfogleman:D
20:37justin_smithso, we substitute + into your form
20:37justin_smith,(+ 1 2 3)
20:37clojurebot6
20:37mwfoglemanerror messages are one of the few not cool things ;)
20:37justin_smithright
20:38hashpuppyi see now. thanks
20:38justin_smithhashpuppy: since everything is prefix in clojure, we can allow arbitrary numbers of arguments, but I hope it is clear what's happening
20:39hashpuppyam i correct that it's just + evaluates to true and so or short-circuits and picks + which it then inserts as you showed above
20:39justin_smithright
20:39justin_smith,(or 1 2 3)
20:39clojurebot1
20:39hashpuppyi don't know why i didn't see that earlier. thanks. i'm just not used to or'ing two function expressions
20:40hashpuppyit was just an example, though
20:40justin_smith,((rand-nth [+ -]) 1 2 3)
20:40clojurebot6
20:40justin_smith,((rand-nth [+ -]) 1 2 3)
20:40clojurebot-4
20:40justin_smith,((rand-nth [+ -]) 1 2 3)
20:40clojurebot-4
20:40justin_smith:)
20:40hashpuppy:)
20:40amalloyhashpuppy: well, not "true" so much as "truthy", which is a slang word for "acts like true in a boolean context"
20:40amalloybecause true is after all a different thing from plus
20:40hashpuppyamalloy: thanks for that
20:42Wild_Catamalloy: just double-checking, in Clojure only false and nil are falsey, right?
20:42amalloyright
20:43amalloyand then there's some stuff in clojure 1.6 that treats even false as truthy, with nil being the only falsey value. stuff like some? and when-some
20:43justin_smithand keep
20:44justin_smithkeep is an underused gem
20:44hashpuppylast question, why does (map inc [0 1 2 3]) return (1 2 3 4) instead of [1 2 3 4]?
20:44dbaschhashpuppy: because map evaluates to a sequence, if you want a vector use mapv
20:44justin_smithhashpuppy: because it isn't fmap :) - map coerces the input via seq
20:45hashpuppyi see. thanks again
20:45justin_smithand mapv coerces to vector via into :)
20:46mikefikeshashpuppy: Another aspect of map evaluating to a sequence is that it supports lazyness
20:46amalloyhashpuppy: most sequence functions in clojure convert their input to a sequence, and produce a sequence as a result. sequences are kinda the lowest common denominator, the most light-weight abstraction. you can't expect to get out the same type you put in, except for functions that are specific to that type
20:49johnwalker(inc justin_smith)
20:49lazybot⇒ 103
20:57amalloyjustin_smith: does it really? i thought the point of mapv was that it's more performant than using into
20:58justin_smith$source mapv
20:58lazybotmapv is http://is.gd/n1z2gs
20:58amalloyyeah, indeed, (mapv f xs) uses reduce/transient/persistent!
20:58justin_smithaha, the others use into though
20:58amalloyit's only the multi-collection arities that use into, because there's no single collection to reduce
20:58justin_smithmaybe I was just remembering the old version
20:58mikefikesWas going through _Clojure High Performance Programming_, and it shows that last for a vector is O(n). Maybe it is too expensive to check type to do something like (defn lastv [v] (get v (dec (count v))))?
20:59amalloymikefikes: ##(doc peek)
20:59lazybot⇒ "([coll]); For a list or queue, same as first, for a vector, same as, but much more efficient than, last. If the collection is empty, returns nil."
20:59mikefikesthanks amalloy
21:00justin_smithamalloy: no, even 1.5 had the same definition, my bad
21:00amalloyyeah, the point of mapv was to be more efficient than into/map
21:05mikefikesThere's no such thing as an "unconj", is there? Sounds like that may be ill defined.
21:05mikefikespop?
21:05gfrederickssounds like a parallel conference
21:06mikefikesYep, like an unconference
21:06jeffterrellfor recovering Clojure addicts
21:06gfredericksmikefikes: yeah pop works for stacky and queuey things; otherwise it's not clear what unconj would do; like for a map or set
21:07gfredericksnote disj and dissoc
21:09mikefikesgfredericks: Yeah, perhaps it is fair to say pop works for sequential collections
21:10dbaschif you use pop on non-sequential collections, it explodes
21:10gfrederickseven the sorted collections though
21:10gfrederickswhich side would you pop from?
21:11gfredericks,(sorted-set 9 2 83 4 7)
21:11mikefikesgfredericks: Right, I was thinking the same wrt sorted
21:11clojurebot#{2 4 7 9 83}
21:17gfredericks,(nth nil 42)
21:17clojurebotnil
21:17gfredericks,(nth () 42)
21:17clojurebot#<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>
21:19mikefikes,(get nil 42)
21:19clojurebotnil
21:19mikefikes,(get () 42)
21:19clojurebotnil
21:28justin_smith,(get get get)
21:28clojurebotnil
21:29justin_smith,(get get get get)
21:29clojurebot#<core$get clojure.core$get@1e70c7>
21:29jeremyheilerlol
21:30justin_smithfind . -exec sed -i 's/get /(get get get get) /g' {} ;;
21:31justin_smith,((get get get get) {:a 0} :a)
21:31clojurebot0
21:32akurilinquick question: I need to push a change against a clojure lib on github, how do I use a modified local copy of that lib first?
21:32akurilinlein deploy?
21:32jeremyheilerakurilin: change the version and do `lein install`
21:32akurilinoh right lein install
22:28TimMc,((comp comp) ((get get get get) (get get get get) (get get get get) (get get get get)))
22:28clojurebot#<core$get clojure.core$get@1ddfe97>
22:30mikefikes,(get some nil)
22:30clojurebotnil
22:30TimMcQuestion: For which f in clojure.core is there some n such that (= (apply f (repeat n f)) f)?
22:32mikefikesidentity
22:33bjamikefikes, I don't think that's true. Pretty sure identity only has arity 1
22:33TimMc,(identity identity)
22:33clojurebot#<core$identity clojure.core$identity@46d87b>
22:33mikefikes,(= (apply identity (repeat 1 identity)) identity)
22:33clojurebottrue
22:34bja,(= (apply identity (repeat 3 identity)) identity)
22:34clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: core/identity>
22:34el3ctro,(str "hello")
22:34clojurebot"hello"
22:34jeffterrellTimMc: Are there any others?
22:35jeffterrellbja: I think he was saying some n (assuming n > 0), not all n.
22:35bjaoh, fair enough
22:36justin_smith,(= (apply (constantly identity) (repeat 1000 (constantly identity))))
22:36clojurebottrue
22:36bjacomp
22:37justin_smith,(= comp (apply comp (repeat 1000 comp)))
22:37clojurebotfalse
22:37justin_smithmy constantly identity above is broken
22:37justin_smithonly one arg
22:39TimMc,(comp comp comp)
22:39clojurebot#<core$comp$fn__4292 clojure.core$comp$fn__4292@9027f3>
22:39TimMchmm
22:42justin_smith,(((apply comp (repeat 1000 comp)) inc inc) 1)
22:42clojurebot3
22:42justin_smithit's efectively equal, just not value equal
22:46TimMc=> (filter (fn [f] (try (deref (future (= (apply f (repeat 0 f)) f)) 100 false) (catch Throwable t false))) (map deref (vals (ns-publics 'clojure.core))))
22:46TimMcSocketException The transport's socket appears to have lost its connection to the nREPL server
22:46TimMc:-(
22:50bjan = 1 yields macroexpand dissoc comp disj eval disj! min identity force macroexpand-1 merge partial max
22:50justin_smithn = 2 you get any keyword or symbol
22:50justin_smithor hash-map
22:50bjan=2 I got merge-with max-key min-key
22:52bjanothing on n=3
22:53TimMcNothing? It should turn up get.
22:54mikefikesWhat about n=0?
22:55justin_smith,(= get (apply get (repeat 3 get)))
22:55clojurebottrue
22:55justin_smithwhich is exactly the silliness I was playing with earlier :)
23:03jsandai want to iterate over a map and for each key/value pair i want to create 2 new key/value pairs that are stored into a new map. any suggestions on how to do this?
23:04justin_smithjsanda: reduce
23:05jsandahow would that work?
23:05bjafor some reason (probably me typing wrong), my run of n=3 didn't work before. here is is now: -> get or .> and ->>
23:05jsandai want to create more not less values
23:05justin_smith,(let [input {:a 0 :b 1}] (reduce (fn [m [k v]] (assoc m k v [k k] [v v])) input input))
23:05clojurebot{[:a :a] [0 0], [:b :b] [1 1], :b 1, :a 0}
23:05bjaerr
23:06justin_smithjsanda: you want to create exactly one value, a map
23:06justin_smithoh, new map, my bad
23:07justin_smith,(reduce (fn [m [k v]] (assoc m k v [k k] [v v])) {} {:a 0 :b 1})
23:07clojurebot{[:a :a] [0 0], :a 0, [:b :b] [1 1], :b 1}
23:07bjaignore some oerr, .> isn't in the real clojure.core
23:07TimMcbja: Oh hah, because they're macros.
23:07bjahmm
23:07TimMc,(let [m @#'and] (m m m m))
23:07clojurebot#<core$and clojure.core$and@e22c0d>
23:07bjawell, I was checking for fn?
23:08justin_smithTimMc: you did explicitly mention apply, didn't you?
23:08jsandajustin_smith: thanks. i'll play around with that
23:08TimMcYeah, does it matter?
23:09justin_smith,(apply @#'and (repeat 10 @#'and))
23:09clojurebot(clojure.core/let [and__4069__auto__ #<core$and clojure.core$and@e22c0d>] (if and__4069__auto__ (clojure.core/and #<core$and clojure.core$and@e22c0d> #<core$and clojure.core$and@e22c0d> #<core$and clojure.core$and@e22c0d> #<core$and clojure.core$and@e22c0d> ...) and__4069__auto__))
23:09bjaI was using (defn tc [f n] (= (apply f (repeat n f)) f))
23:09TimMc(off to bed, may see reply in morning)
23:09justin_smithTimMc: that monstrosity definitly is not equal to @#'and
23:10bja((fn [f n] (= (apply f (repeat n f)) f)) @#'and)
23:10bja,((fn [f n] (= (apply f (repeat n f)) f)) @#'and)
23:10clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox/eval129/fn--130>
23:10bja,((fn [f n] (= (apply f (repeat n f)) f)) @#'and 3)
23:10clojurebottrue
23:11justin_smith(= @#'and (apply @#'and (repeat 4 @#'and)))
23:11justin_smithit works with three args, but not with four
23:11bja,((fn [f n] (= (apply f (repeat n f)) f)) @#'and 4)
23:11clojurebotfalse
23:11bja,((fn [f n] (= (apply f (repeat n f)) f)) @#'and 5)
23:11clojurebotfalse
23:21bbloomwhoa just got a crash in nrepl.bencode
23:46justin_smithbbloom: on the clojure side?
23:46bbloomyeah, long time in the scroll back
23:46bbloomwon't bother reporting it unless it happens again
23:48justin_smithwith what on the client side?