#clojure logs

2014-07-25

01:20ruzuahoy mateys
01:21justinholguinAhoy, ruzu
02:02x1337807xEasy one: I just setup my first ever clojure app with lein and I want to test my hello_world function - Is there a way to test that something is written to stdout? Can I expect that println is called with a specific argument?
02:05x1337807xGot it - with-out-str
02:35munichlinuxclojure noob here. I was trying to write a fn to compute sum of integers from 1 to n. https://gist.github.com/anonymous/4930ef53d70379726ee8, I wasn't accumulating the sum in a local so i expected the return value to the value x, it wasn't the case. I am trying to figure out why, any pointers?
02:41ambrosebs,(apply + (range 1 6))
02:41clojurebot15
02:41ambrosebslooks correct to me?
02:51gwsmunichlinux: are you comfortable with recursion in general?
02:54munichlinuxgws: yes
02:55munichlinuxgws: why did you ask that?
02:58gwswhat you have is a pretty straightforward recursive function, and "15" is what i'd expect from it as well
03:01munichlinuxgws: sure, (+ x (sigma (- x 1)) => 15 but how did x became 15.
03:01ambrosebshow do I use ASM to modify a method on a deftype? It seems like you'd usually look for a .class file on the classpath, but I don't think a deftype has one?
03:03munichlinuxi did not return (+ x (sigma (- x 1)) but x
03:04gwsmunichlinux: yes, as the base case for recursion - i.e. only when (pos? x) fails, so when x first becomes 0 in this case
03:04gws,(pos? 1)
03:04clojurebottrue
03:04gws,(pos? 0)
03:04clojurebotfalse
03:06gwsbut the first 5 times you are indeed returning (+ x (sigma (- x 1))
03:09gwsplus an extra right paren because i can't count
03:11munichlinuxgws: got it, I was under the impression that when x became 0 the else part would get returned (which is x)
03:11gwsand you're absolutely correct
03:11gwsit does do that
03:12gwsat that point, the stack you built up doing those recursive calls unwinds, and collapses into 15
03:13munichlinuxgws: got it
03:15gws,(+ 5 (+ 4 (+ 3 (+ 2 (+ 1 0)))))
03:15clojurebot15
03:16munichlinuxya
03:17swiGreetings :)
03:23alainpicardhello all! I have a Q about when clojure decides to eval a lazy sequence
03:24alainpicardin particular, if I'm sending an HTTP response, like (response {:foo (compute-this)}) ...
03:24alainpicardwouldn't that force evaluation of result of COMPUTE-THIS automatically?
03:24alainpicard'cause it doesn't seem to, and I find that... surprising.
03:32gwsif (response) just returns a ring response map, i wouldn't necessarily expect (compute-this) to be forced at that point, just as you wouldn't expect it to be forced if you simply had {:bar {:foo (compute-this)}}
03:36alainpicardbut, eventually, ring wants to send out the string on the socket, no?
03:36alainpicardwon't that force it?
03:39gwsif whatever you've got there is actually part of the HTTP response and ring doesn't throw that key away, then i would think so too
03:41alainpicardokay. I must be doing something stupid somewhere else then. thanks for the sanity check!
03:42Glenjaminunless i'm missing something, evaluation is inside-out
03:43Glenjaminso (compute-this) should be evalled right away
03:43Glenjaminoh, sorry lazy sequence
03:43Glenjaminmissed that bit :)
03:56Glenjaminalainpicard: depending on what middleware you have, it might not attempt to realise the sequence
03:56Glenjamin,(str {:a (repeat 1 5)}
03:56clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
03:56Glenjamin,(str {:a (repeat 1 5)})
03:56clojurebot"{:a (5)}"
03:56Glenjamin,(.toString {:a (repeat 1 5)})
03:56clojurebot"{:a (5)}"
04:26vdmit11_Hi folks. What protocol I need to implement to provide a custom ".ToString()" (or something like this) for my custom type?
04:28ambrosebsvdmit11_: (deftype A [] Object (toString [this] "mystring"))
04:30vdmit11_ambrosebs, thanks, sorry for the stupid question
04:31ambrosebsvdmit11_: no such thing, np
05:00vdmit11_why can't I override Object's toString method for records? I mean, this one works fine: (deftype A [] Object (toString [this] "mystring")), but this doesn't: (defrecord B [] Object (toString [this] "mystring")). Why?
05:01ambrosebsvdmit11_: defrecord does extra things implicitly.
05:01ambrosebsvdmit11_: I think it already extends toString
05:02ambrosebsdefrecord is very single-purpose, if you want to do anything beyond it, use deftype
05:08vdmit11_But defrecord provides a handy HashMap interface out of the box, I would like to use it. For me it looks easier to override somehow the toString method than implement those HashMap methods.
05:08gws,(do (defrecord B [] Object (toString [this] "mystring")) (str (->B)))
05:08clojurebot"mystring"
05:09ambrosebsI stand corrected
05:09ambrosebsIIRC there are some thing you can't do with a defrecord, apparently toString isn't one of them
05:11ambrosebs,(ancestors (defrecord B []))
05:11clojurebot#{clojure.lang.IRecord clojure.lang.IPersistentMap clojure.lang.IPersistentCollection clojure.lang.IKeywordLookup clojure.lang.ILookup ...}
05:11vdmit11_,(do (defrecord B [] Object (toString [this] "mystring")) (->B))
05:11clojurebot#sandbox.B{}
05:11vdmit11_why the result is not "mystring"?
05:11swiHow can i compose N function in one ? I mean somthing like foo . bar .zoo in haskell ?
05:12gwsvdmit11_: all you did there was construct an instance of B
05:12hyPiRionswi: use comp: (comp foo bar zoo)
05:12hyPiRion,(println (->B))
05:12clojurebot#sandbox.B{}\n
05:12vdmit11_,(println (->A))
05:12clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ->A in this context, compiling:(NO_SOURCE_PATH:0:0)>
05:13vdmit11_,(do (deftype A [] Object (toString [this] "mystring")) (->A))
05:13clojurebot#<A mystring>
05:13swihyPiRion: thanks
05:14vdmit11_why in this case the repl called the toString method, but in case of defrecord it didn't?
05:15clgvvdmit11_: the repl uses the print-method
05:16clgvvdmit11_: which is defined for records but not for arbitrary types
05:17clgv,(defmethod print-method A [v ^java.io.Writer w] (.write w "#A"))
05:17clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol:   in this context, compiling:(NO_SOURCE_PATH:0:0)>
05:17hyPiRionclgv: that doesn't explain why my (println (->B)) didn't print out "mystring"
05:18clgvhyPiRion: I think it does. B is a record and is printed as tagged literal followed by a string representation of the map
05:19vdmit11_It seems the toString method is overriden correctly for both deftype and defrecord:
05:19hyPiRionclgv: right, I forgot println isn't Bystem.out.println
05:19vdmit11_,(do (defrecord J [] Object (toString [this] "mystring")) (.toString (J.)))
05:19clojurebot"mystring"
05:19vdmit11_So I think the trick is somewhere in print- methods
05:19vdmit11_definitely
05:19hyPiRion,(. System/out (println (->B)))
05:19clojurebotnil
05:20clgvhyPiRion: indeed, you can trace it back to clojure.core/pr-on which uses print-method if *print-dup* is false
05:20clgv,(.println System/out (->B))
05:20clojurebotnil
05:20clgv,(->B)
05:20clojurebot#sandbox.B{}
05:21clgv,(.toString (->B))
05:21clojurebot"mystring"
05:21hyPiRionclgv: that's a bug with clojurebot I guess
05:21hyPiRion,(.println System/out "foobar")
05:21clojurebotnil
05:21clgvah right
05:22hyPiRionSystem/out is not *out*, and I guess clojurebot is just binding *out*
05:22clgvhyPiRion: probably due to rewiring input output for its repl^^
05:22hyPiRionyeah
05:22clgvyeah
05:23hyPiRion,(.println System/err "RELEASE ME :'(")
05:23clojurebotnil
05:23clgvvdmit11_: yeah, you'd need to implement print-method for your specific record type - but is that really desirable?
05:23clgvhyPiRion: probably showing up in some log ;)
05:23hyPiRionclgv: yeah, that's what I'm hoping for :p
05:26clgvhyPiRion: "Help me! I am a slave in a Chinese fortune cooky factory!" :P
05:26clgv*cookie
05:26hyPiRionhehe
05:27vdmit11_clgv, no, because print-method affects only the repl in my case, but I need a sort of serialization, I tested the toString incorrectly by printing the object, now I understand that and the problem is resolved
05:30pyrtsa,#'clojure.walk/macroexpand-all
05:30clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve var: clojure.walk/macroexpand-all in this context, compiling:(NO_SOURCE_PATH:0:0)>
05:30hyPiRion,(require '[clojure.walk :refer [macroexpand-all]])
05:30clojurebot#<SecurityException java.lang.SecurityException: denied>
05:30hyPiRionwhaaa
05:30pyrtsa:(
05:30hyPiRion,(use 'clojure.walk)
05:30clojurebotnil
05:30hyPiRionthere you go
05:31pyrtsaThanks.
05:31pyrtsa,(defmacro env [] (into {} (map #(vector (list 'quote %) %) (keys &env))))
05:31clojurebot#'sandbox/env
05:31pyrtsa,(env)
05:31clojurebot{}
05:31pyrtsa,(let [x 1, y (inc x)] (env))
05:31clojurebot{y 2, x 1}
05:31clgvhyPiRion: interesting inconsistent sandbox config
05:31hyPiRionhrm. Such weird inconsistent rules.
05:31hyPiRionyeah
05:31pyrtsa,(macroexpand-all '(let [x 1, y (inc x)] (env)))
05:31clojurebot(let* [x 1 y (inc x)] {})
05:31pyrtsa:(
05:32clgvyeah you'll get more differences when using destructuring in the let
05:32pyrtsaWorking with macros can be painful. ^
05:32hyPiRionpyrtsa: oh wow, that's nasty
05:32hyPiRionMust've been painful to find
05:32pyrtsaNone of the variants of macroexpand are able to resolve &env in that.
05:33pyrtsaAt least of what I could find.
05:33pyrtsahyPiRion: Nah, it wasn't buried that deep when I was playing with it. Fortunately.
05:34hyPiRionthat's good, because that one sounds very painful to debug
05:34pyrtsaBut: PROTIP, the above (env) macro could be very useful when dealing with preconditions and such: makes it easy to tell what the local state was when things went wrong.
05:36pyrtsa,(defmacro must [expr] `(if ~expr true (throw (AssertionError. (pr-str :expr '~expr :env (env))))))
05:36clojurebot#'sandbox/must
05:36pyrtsa,(let [xs [1 2 3]] (assert (must (every? odd? xs))))
05:36clojurebot#<CompilerException java.lang.RuntimeException: No such var: sandbox/env, compiling:(NO_SOURCE_PATH:0:0)>
05:36pyrtsa,(defmacro env [] (into {} (map #(vector (list 'quote %) %) (keys &env))))
05:37clojurebot#'sandbox/env
05:37pyrtsa,(let [xs [1 2 3]] (assert (must (every? odd? xs))))
05:37clojurebot#<AssertionError java.lang.AssertionError: :expr (every? odd? xs) :env {xs [1 2 3]}>
05:38pyrtsa,((fn [xs] {:pre [(must (every? odd? xs))]} xs) [1 2 3])
05:38clojurebot#<AssertionError java.lang.AssertionError: :expr (every? odd? xs) :env {xs [1 2 3]}>
05:38hyPiRionpyrtsa: what are you doing, you're making clojure errors readable
05:38pyrtsa:D
05:38pyrtsaIndeed.
05:40TEttinger,(reduce #(Math/expt %1 %2) (range 2 10))
05:40clojurebot#<CompilerException java.lang.IllegalArgumentException: No matching method: expt, compiling:(NO_SOURCE_PATH:0:0)>
05:40TEttinger,(reduce #(Math/pow %1 %2) (range 2 10))
05:40clojurebotInfinity
05:40TEttingerwow
05:40TEttinger,(reduce #(Math/pow %1 %2) (range 2N 10N))
05:40clojurebotInfinity
05:43TEttinger,(reduce #(.scaleByPowerOfTen %1 %2) (range 2M 4M))
05:43clojurebot2E+3M
05:43TEttinger,(reduce #(.scaleByPowerOfTen %1 %2) (range 2M 10M))
05:43clojurebot2E+42M
05:44TEttinger,(reduce #(.scaleByPowerOfTen %1 %2) (range 2M 1000M))
05:44clojurebot2E+499497M
05:46hyPiRion,(reduce #(.pow % %2) (.toBigInteger 2N) (range 3 10))
05:46clojurebot7628045462646269549938976891875320382369142773966779250433383862468136427071492332052290036238273567369166292537839519107420501593575384831894619073527853412088564527569473310793304373165199270832509630979462174093467427044817508289080036667855823736716211224317100708646525267755964878000278158240303705956088198499788045494885732510171221517843527982835625514436506476212438271589497730043764762558...
05:54cstammhi. Is it possible to add a build number to the version of jar created by lein uberjar? Like one generated by the CI-server at build time?
05:57cstammsorry. googled it myself
06:00xsynI'm trying to do a cons on two maps
06:00xsynbut when I do, the second map loses it's structure
06:00xsynIs there a way that I can keep it
06:01Bronsaxsyn: what's your input and what's the desired output?
06:02xsyn(cons #clojurewerkz.neocons.rest.records.Node{:id 418, :location-uri http://localhost:7474/db/data/node/418, :data {:id 27737500949}} clojurewerkz.neocons.rest.records.Node{:id 418, :location-uri http://localhost:7474/db/data/node/418, :data {:id 27737500949}} )
06:02xsyn( irc://irc.freenode.net:6667/#clojurewerkz.neocons.rest.records.Node%7B:id 418, :location-uri http://localhost:7474/db/data/node/418, :data {:id 27737500949}} clojurewerkz.neocons.rest.records.Node{:id 418, :location-uri http://localhost:7474/db/data/node/418, :data {:id 27737500949}})
06:02Bronsaxsyn: so you just want to put two maps in a list?
06:03Bronsa,(list {:a 1} {:b 2})
06:03clojurebot({:a 1} {:b 2})
06:03xsynugh, that easy?
06:03xsynthanks :)
06:03xsynlet me test
06:04xsynis perfect
06:05xsynthank you
06:05Bronsanp
06:23boxedyogthos: getting midje-readme to run on clj-pdf was a bit troublesome.. partly because there was a power outage here last night :P
06:24boxedbut I’m getting a weird “Wrong number of args (3) passed to: […]rot[…]” which I can’t figure out too… it works in the example.clj where it’s copied from...
06:29xsynmisplaced bracket?
06:30swibtw, clojure.string/upper-case is the same as (.upUpperCase) ?
06:31swiooh, yep, just a wrap over :)
06:40boxedxsyn: I’ve copy-pasted from the working example several times :P
07:06SagiCZ1,(defn foo [[x]] x)
07:06clojurebot#'sandbox/foo
07:06SagiCZ1,(foo ["red" "meat" "juicy"])
07:06clojurebot"red"
07:06SagiCZ1i dont get it
07:08__daniel__SagiCZ1: you're destructuring the first element
07:08__daniel__,(foo ["meat" "juicy"])
07:08clojurebot"meat"
07:08gauravagarwalrits called destructuring..
07:08SagiCZ1why is it not affecting the other elements
07:08SagiCZ1,(defn foo [[x y]] (list x y))
07:08clojurebot#'sandbox/foo
07:08SagiCZ1,(foo ["red" "meat" "green" "grass"])
07:08clojurebot("red" "meat")
07:08boxedSagiCZ1: “[x] x” means “create a new variable x that is the first element of the old variable x, throw away the rest"
07:09gauravagarwalrits same as: (defn foo [[x _ _]] x)
07:09gauravagarwalr(defn foo [[x _ _]] x)
07:09SagiCZ1boxed: i dont understand what you said
07:09gauravagarwalr'(defn foo [[x _ _]] x)
07:09boxedhmm.. actually, another question might be: what would you expect?
07:09SagiCZ1gauravagarwalr: ok that makes sense
07:10gauravagarwalr,(defn foo [[x _ _]] x)
07:10clojurebot#'sandbox/foo
07:10SagiCZ1i would expect that i would be the vector "unwrapped"
07:11__daniel__,(defn foo [[& x]] x)
07:11clojurebot#'sandbox/foo
07:11__daniel__,(foo ["red" "meat" "juicy"])
07:11clojurebot("red" "meat" "juicy")
07:11SagiCZ1 ,(defn foo [not-in-vector [x y]] not-in-vector))
07:11clojurebot#'sandbox/foo
07:11gauravagarwalrI guess __daniel__ has posted what you were looking for!
07:11SagiCZ1,(foo "hello" [4 5 6])
07:11clojurebot"hello"
07:15boxedSagiCZ1: How can it “unwrap” a vector into a single variable?
07:16boxedagain I have to ask: what do you expect? one variable is one variable, it can’t be three variables…
07:18gauravagarwalr,(defn foo [& x] x)
07:18clojurebot#'sandbox/foo
07:19gauravagarwalr,(foo "red" "meat" "juicy")
07:19clojurebot("red" "meat" "juicy")
07:19gauravagarwalr@boxed I think this is what he meant!
07:20boxedgauravagarwalr: I think it’s pretty bad to keep guessing what he means… it’s better to get a good understanding from him
07:20gauravagarwalrboxed: ok
07:20boxedgauravagarwalr: your example doesn’t seem reasonable becaue if that’s what he wanted then that’s what he already had in “x”… so why do a destructuring in the first place?
07:21gauravagarwalr@SagiCZ1 What is it that you originally required?
07:29__daniel__i'll take another guess that he was just playing with destructuring
07:29__daniel__with no particular aim
07:30gauravagarwalr:D
07:30boxed“i would expect that i would be the vector "unwrapped”” <- I think that suggests intent
07:30boxedor at least some expectation of outcome
07:31__daniel__in a way, it is unwrapping the vector, not just returning x
07:31__daniel__,(foo [1 2 3])
07:31clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:0:0)>
07:31__daniel__is returning a seq
07:44gauravagarwalrtoo much to speculate on! ;)
07:53SagiCZ1sorry guys.. was fetching some lunch
07:53SagiCZ1yeah i was really just playing with destructuring..
07:53SagiCZ1i guess i am not sure what i really expected
07:54SagiCZ1just this way of choosing a first element of collection seems weird [[x]] ..
07:54SagiCZ1[x] followed by (first x) seems more readable to me
07:55boxedyou mean “x (first x)”
07:55boxedyea you can do that too
07:55boxed,(let [x (first [1 2 3]) x)
07:55clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
07:55boxed,(let [x (first [1 2 3])] x)
07:55clojurebot1
07:56SagiCZ1boxed: yeah that would make more sense to me..
07:57SagiCZ1,(= (let [x (first [1 2 3])] x) (let [[x]] [1 2 3]))
07:57clojurebot#<CompilerException java.lang.IllegalArgumentException: let requires an even number of forms in binding vector in sandbox:, compiling:(NO_SOURCE_PATH:0:0)>
07:57boxedit’s a bit cumbersome when moving on to [x y] foo though
07:57hyPiRionyou can say boxed helped you … unbox that value.
07:57boxedclojurebot ignores everything except the first form btw
07:57hyPiRionYou can also do ->
07:57SagiCZ1hyPiRion: who would expect that :)
07:58SagiCZ1thanks very much.. am i getting repetetive? i really love the community, always someone here who is eager to help..
07:58hyPiRion,(= (let [x (-> [[1 2 3]] first first)] x) (let [[[x]] [[1 2 3]]] x))
07:58clojurebottrue
07:58boxedhyPiRion: blech
08:00SagiCZ1,(def v [[1 2] [3 4] [5 6]])
08:00clojurebot#'sandbox/v
08:00SagiCZ1,(first (first v))
08:00clojurebot1
08:00SagiCZ1,(-> v first)
08:00clojurebot[1 2]
08:00SagiCZ1,(-> v first first)
08:00clojurebot1
08:01SagiCZ1(doc ->)
08:01clojurebot"([x & forms]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."
08:01boxedthe doc for that is not super helpful I think :P
08:01SagiCZ1boxed: i have found most of the docs very cryptic sadly :(
08:02boxedclojuredocs is normally superior
08:02boxedalthough a bit dated :(
08:02SagiCZ1boxed: but they just copy the same doc.. ?
08:02SagiCZ1boxed: u mean the examples?
08:03boxedyea, the examples
08:03SagiCZ1boxed: why is it dated? can we update it?
08:04boxedI guess the guy who updated it isn’t doing it and isn’t allowing anyone else in
08:04SagiCZ1boxed: i see
08:04boxedgrimoire is an attempt at replacing it
08:04SagiCZ1btw is there a way to make this prettier? (first (first (filter f coll)))
08:05hyPiRion(ffirst (filter f coll))
08:05SagiCZ1ffirst.. seriously
08:05SagiCZ1(doc ffirst)
08:05clojurebot"([x]); Same as (first (first x))"
08:05SagiCZ1:D
08:05augustlthere's also fffffffffffffffffffffirst and fffffffffffffffffffu
08:06SagiCZ1no way
08:06boxedhah
08:06augustla reader macro that looked for symbols that started with fff* would have been neat :)
08:06SagiCZ1wait what does ([x]) this mean in the clojurebot response?
08:06boxedjust doing “first” is pretty horrible for maintainability and readability
08:07SagiCZ1boxed: whats wrong with it?
08:07hyPiRionSagiCZ1: ([x]) is the list of argument lists.
08:07hyPiRionso it only accepts a single argument.
08:07SagiCZ1oh i see
08:07boxedSagiCZ1: why first? why not second, third, fourth? accessing stuff based on index with magic index numbers is not so nice imo
08:07hyPiRion(doc reduce)
08:08clojurebot"([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val is supplied, returns t
08:08hyPiRionSo reduce can either be done with 2 or 3 arguments.
08:08SagiCZ1boxed: lets say i have some collection of pairs.. and once i select the pair i need the first one..
08:08SagiCZ1once i select A pair i want the first element of the pair
08:08boxedSagiCZ1: ok, but WHY do you have a collection of pairs? why not something better like a collection of maps or a records?
08:09augustlboxed: first/rest is a pretty common pattern though
08:09augustlcar/cdr all the way
08:10boxedaugustl: sure, when it’s a list of things, but see? SagiCZ1 is clearly talking about using tuples :P
08:10SagiCZ1boxed: i have a map of transistions, where the keys are "states to move to" and their values are "conditions that have to be fulffiled for the transition" .. like this:
08:10SagiCZ1 {:water #(= % :melting)
08:10SagiCZ1 :vapor #(= % :sublimation)}
08:11augustlis there an executor/thread pool combo that will allow multiple threads running, but only a single thread per "id"? So, when I want to execute, I pass in the ID, and only one thread may run at any given time for that ID
08:11boxedyea ok, so you’re just destructuring a map? then (for [[k v] map] …) is pretty good
08:12SagiCZ1boxed: yeah i need to rework it.. its ugly.. i just realized what im doing wrong
08:14hyPiRionaugustl: Need more information: Should you block or try another work function if "id" is already in use?
08:14boxedor put in a queue?
08:18augustlhyPiRion: block
08:18augustlerr, put in a queue :)
08:20stuartsierraaugustl: Clojure agents will do that :)
08:20SagiCZ1boxed: can i break out of the "for" once i find what i need?
08:22SagiCZ1i am looking for a certain value in a map, and once i find it i need to return its key
08:23boxedthat sounds a bit backwards :P
08:23SagiCZ1boxed: i know right..
08:23SagiCZ1boxed: i know the map is backwards.. it just feels more natural when inputing it for this case..
08:24augustlstuartsierra: ah, will look into that
08:24SagiCZ1boxed: maybe i should first fix the map and then work with it as normal
08:24hyPiRionSagiCZ1: you don't break out of a for. That's not how for works.
08:25hyPiRionIt's not like Java's for loop. It's a for comprehension. Think of it as a way to use map/filter in a neat way.
08:27SagiCZ1hyPiRion: yeah i think i understood that although i keep forgetting its not like regular for.. doseq is closer to a regular for
08:27hyPiRionright
08:27SagiCZ1but doseq cant return anything.. just for sideeffects right?
08:28hyPiRionright
08:30boxedSagiCZ1: loop/recur will do it…
08:33hyPiRionif you want to get some key/value pair where you already know the value, do (first (for [[k v] :when (= v known-val)] [k v]))
08:34hyPiRionwhoops, (first (for [[k v] m :when (= v known-val)] [k v])) I meant
08:35clgvhyPiRion: I'd advise the more performant reduce-kv
08:35clgvtogether with `reduced`
08:37hyPiRionclgv: I'd advise for another data model if that query is going to happen frequently
08:40clgvhyPiRion: well, that's true. but might be some compromise...
08:41lvhclgv: huh what's a reduced
08:41lvhI know about reduce-kv
08:41clgv,(doc reduced)
08:41clojurebot"([x]); Wraps x in a way such that a reduce will terminate with the value x"
08:42lvhwhaaa
08:42clgv;)
08:42Glenjamin,(reduce (reduced 1))
08:42clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/reduce>
08:42lvhclgv: I seriously have no idea what that is
08:42lvhclgv: the source code didn't help either
08:43lvhclgv: Would you mind typing a reduce(-kv) example that uses it?
08:43Glenjamin,(reduce list (reduced 1))
08:43clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Reduced>
08:43lvhalso grimoire doesn't know about it
08:43hyPiRion,(reduce list (reduced 1) ())
08:43clojurebot#<Reduced@1c2df08: 1>
08:43clgvlvh: `reduce` will terminate if something wrapped in `reduced` is returned from the function no matter if the given collection was traversed completely
08:43hyPiRionuh
08:44clgvno must be returned from the function
08:44Glenjaminhttp://stackoverflow.com/questions/15625341/reduce-a-lazy-sequence-like-a-loop-with-a-condition-in-clojure
08:44clgv,(reduce (fn [x y] (reduced x)) 1 (range))
08:44clojurebot1
08:45Glenjaminoh, that's neat
08:45hyPiRionclgv: sure, I was just confused about the fact that the init value isn't considered a value returned by f
08:45Glenjaminlike an early return
08:45Glenjamin,(reduce list (reduced 1) '(1))
08:45clojurebot(#<Reduced@47fdc3: 1> 1)
08:45Glenjamin,(reduce second (reduced 1) '(1))
08:45clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core/second>
08:46hyPiRionclgv: the docs are ambiguous enough to not specify what should happen.
08:46clgv,(reduce (fn [x y] (cond-> y (and (even? y) (< 3 y)) reduced) (range))
08:46clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
08:46Glenjamin,(reduce #(apply second) (reduced 1) '(1))
08:46clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: sandbox/eval215/fn--216>
08:46clgv,(reduce (fn [x y] (cond-> y (and (even? y) (< 3 y)) reduced)) (range))
08:46clojurebot4
08:46lvhso, on the first call, you get (reduced 1)
08:46clgvhyPiRion: yeah, doc jira issue? ;)
08:47hyPiRionyeah, on it
08:47lvhyou get ((fn [x y] (reduced x)) 1 0) == (reduced 1)
08:47lvhthen you get... ((fn [x y] (reduced x)) (reduced 1) 1) ?
08:48clgvonly the function return values are checked for `reduced` wrappers
08:48bacon1989I was wondering how I can fix problems involving dynamic, and unbound variables
08:48clgvbacon1989: bind them? :D
08:48bacon1989I have a function that I can't compile, and it isn't accessible until runtime
08:48bacon1989it says it's unbound
08:49bacon1989I tried @(delay (foo)), but I don't think I have the right idea
08:49lvhclgv: oh
08:50lvhclgv: so reduce and reduce-kv know about reduced, and if they find that, they go "welp I'm done" and return the wrapped value?
08:50clgvlvh: that's the idea ;)
08:50lvhI'll try to write out the reduce-kv to find a key given a value in a map later :)
08:50Glenjaminthis seem reasonable? https://github.com/arrdem/grimoire/pull/56
08:51clgvbacon1989: sounds pretty weird. maybe you should describe your concrete application problem
08:52clgvGlenjamin: shouldnt such an example be executable? and I 'd definitely add a short description what the whole expression is supposed to calculate
08:52Glenjaminwhat do you mean by executable?
08:53clgvGlenjamin: well the code you posted there cannot be run in a repl
08:53Glenjaminoh, i see
08:53bacon1989clgv: it is weird, i'm using clojure-android
08:53Glenjaminheh, that's what i get for blindly copying stack overflow
08:53bacon1989the function is unbound for some reason
08:53clgvbetter make up your own example searching for an element with a specific property
08:53bacon1989I can't figure out 'why' it's not unbound, because it's clearly bound
08:53bacon1989*is unbound
08:54clgvGlenjamin: or take that one ##(reduce (fn [x y] (cond-> y (and (even? y) (< 3 y)) reduced)) (range))
08:54lazybotjava.lang.RuntimeException: Unable to resolve symbol: cond-> in this context
08:54Glenjamin,(reduce (fn [a v] (if (> 5 v) a (conj a v))) #{} (range))
08:54Glenjaminoh
08:54clgvoops. lazybot is lame nowadays...
08:54Glenjaminforgot to reduced
08:54clojureboteval service is offline
08:55hyPiRionbacon1989: try to sharp-quote it. May be that the delay captures the unbound value the var refers to
08:55bacon1989sharp quote?
08:56bacon1989`?
08:56bacon1989hmm yeah, I guess I could just deref that
08:57bacon1989you do mean like this, @`(foo)?
08:58bacon1989i can't dereference that
08:58Glenjamin,(reduce (fn [a v] (if (> 5 v) (reduced a) (conj a v))) #{} (range))
08:58clojurebot#{}
08:59Glenjaminhave i done something dumb there?
08:59hyPiRionbacon1989: #' is sharp-quote
08:59Glenjamin,(reduce (fn [x y] (cond-> y (and (even? y) (< 3 y)) reduced)) (range))
08:59clojurebot4
08:59hyPiRionbacon1989: so (delay (#'foo)) should not fail if foo is a nullary function
09:01clgvbacon1989: build a minimal failing example of your code and post it as a gist
09:03Glenjaminhere we go, updated: https://github.com/arrdem/grimoire/pull/56
09:04bacon1989clgv: it's still unbound, i'm using clojure-android, on an android product with lein-droid
09:04bacon1989maybe I should be asking about this in the official channel
09:10bacon1989looks like this though https://gist.github.com/benzap/8cf4526f413339624c92
09:10clgvGlenjamin: :D
09:10clgvGlenjamin: but I would add a comment what it does ^^
09:11Glenjaminyou mean like walking through the algorithm it implements?
09:11clgvbacon1989: where does the exception originate from?
09:12bacon1989refresh, I left a comment with the stacktrace
09:12clgvGlenjamin: no just like -> the example extracts all numbers smaller than 5 until a number >= 5 is encountered - or something similar ;)
09:12Glenjaminright, seems sensible
09:13bacon1989clgv: if I use the repl, the code works fine, but compiling doesn't work
09:13hyPiRionclgv: http://dev.clojure.org/jira/browse/CLJ-1474
09:13bacon1989i've had the same issue before regarding stubs, but I solved those by using delays
09:13bacon1989this time it's different, I can't figure out what's causing it to be unbound at compile-time
09:14clgvbacon1989: weird - does it also work in a fresh repl?
09:15bacon1989clgv: it works on a repl
09:16clgvbacon1989: also a restarted one?
09:16bacon1989idk about restarted, I just use the repl that's provided when the app starts up
09:18clgvbacon1989: I mean did you restart the repl and try?
09:18bacon1989yes
09:19bacon1989i'll try again just to make sure, but it was definitely working
09:20bacon1989which doesn't solve my issue, it's needs to be compiled into the application
09:20clgvwell if it works in the repl after restart you definitely have to ask the clojure-android guys
09:21bacon1989yeah, I just tested it, it works
09:21clgva minimal runnable project with the same error will be appreciated and speed up things I guess
09:22bacon1989do you have an android device?
09:22bacon1989i could probably throw together a simple project
09:22clgvI got no android dev env...
09:22bacon1989i'm going to post in the google group through
09:38TimMcarrdem: I see you've avoided clojuredocs' .. problem.
09:39TimMcarrdem: I'm curious why you decided to trim off leading and trailing underscores, though.
09:48gauravagarwalrclear
09:49gauravagarwalr(use '[clojure.java.shell :only [sh]])
09:49gauravagarwalr(sh "free")
09:49gauravagarwalr,(use '[clojure.java.shell :only [sh]])
09:49gauravagarwalr,(sh "free")
09:49clojurebotnil
09:49clojurebot#<SecurityException java.lang.SecurityException: denied>
09:50clgvgauravagarwalr: next try would have been "rm -rf /" ? :P
09:56bacon1989clojurebot has been locked down pretty well, there's an intersting article on all of the holes some guy found
09:56bacon1989they were able to patch it up pretty well
09:57hyPiRion$google xeqixeqi clojurebot
09:57lazybot[Breaking lazybot out of clojail - Nelson Morris] http://nelsonmorris.net/2012/09/06/breaking-lazybot-out-of-clojail.html
09:59gauravagarwalr:D
10:00gauravagarwalrIt never hurts to try! :P
10:00boxedis there a way to make everything non-lazy? this debugging with prints that are interleaved and shit is killing me
10:02gauravagarwalrboxed: If you are trying to print stuff.. then as soon as you output it to console it starts to evaluate..
10:03gauravagarwalrAren't you using lighttable? :P
10:04boxedhttps://www.refheap.com/88574
10:13stuartsierraboxed: It's much easier with a real logging framework, although non-trivial to set up.
10:18andyfCan anyone recommend a tool for creating class/interface inheritance diagrams for Clojure's Java implementation code, preferably one simple to set up, or there are documented instructions for setting it up you could send me a link for?
10:18gtrakboxed: tried the dbg macro? http://www.learningclojure.com/2010/09/clojure-macro-tutorial-part-i-getting.html
10:20stuartsierraandyf: https://github.com/stuartsierra/class-diagram
10:21andyfstuartsierra: Thanks! I'll give that a go.
10:36lvhclgv: ping, re: earlier where we talked about reduced, and map + val -> key, were you thinking something like:
10:36lvh(defn val->key [val map] (reduce-kv (fn [cur k v] (if (== v val) (reduced k) nil)) nil map))
10:37lvhseems kinda weird to me, since cur is always nil basically
10:38clgvlvh: yeah an impl via reduce-kv could look like that; better use `when?
10:38clgv`when`
10:40clgvlvh: if you have some kind of bijection there that is used often it is probably worth to main one map for each mapping direction
10:41lvhokay, so my understanding of reduced is now "fine here have your answer stop reducing"
10:41lvhmakes sense
10:41lvhI thought it'd be some crazy functional hackery
10:41clgvhm no it is not ;)
10:55lsdafjklsda
11:01trptcolinanybody got a foolproof demo proving that Atoms retry when the CAS fails? i know how it works [i’m pretty sure anywa], just having a rough time getting an actual demo showing it.
11:07Bronsatrptcolin: http://sprunge.us/EGKS?clj
11:12trptcolinBronsa: thanks, i see my mistake
11:13trptcolini was dumbly putting the sleep outside the swap fn
11:13trptcolinwhich isn’t going to work :)
11:38hcumberdalewhy is (cond-> a :x print) working >> {:x "abc} but not (cond-> a :x #(print %)) ?
11:38hcumberdale,(cond-> {:x "abc"} :x print)
11:38clojurebot{:x abc}
11:39hcumberdale,(cond-> {:x "abc"} :x #(print %))
11:39clojurebot#<sandbox$eval52$G__51__53 sandbox$eval52$G__51__53@75b962>
11:39clgvhcumberdale: becauce cond-> is a macro manipulating the execution forms
11:40hcumberdaleso I can't use # and fn there?
11:40hcumberdalehow to access "abc" then?
11:40clgvhcumberdale: in that case #(print % a) is the resulting form that is executed if :x is truthy in a
11:40arrdemyou can totally use #() in there, you just have to apply the fn represented with #() yourself.
11:40BobSchackseangrove are you looking for a fressian port to clojurescript?
11:40joegallo(#(print %))
11:41clgvhcumberdale: do you want (cond-> a :x (print %))?
11:41seangroveBobSchack: Specifically looking for an efficient way to send huge clj/cljs datastructures with tons and tons of structural sharing over the wire efficient
11:41clgvhcumberdale: or do you want to creat an anonymous function?
11:41hcumberdale(cond-> a :x (spit % somethinghere))
11:42BobSchackI've ported fressian to cljs if you are interested
11:42seangroveBobSchack: That's fantastic, I'm definitely interesting in checking it out
11:42hcumberdalewhere (:x a) is the filename
11:42seangroveI think I saw on hn that you have it 40% faster than edn?
11:42BobSchackhttps://github.com/spinningtopsofdoom/longshi
11:43BobSchackso far it uses typed arrays so you'll have that restriction
11:44BobSchackso far doing perf tests with large edn data it's about 40% faster
11:45BobSchackI'm still doing perf improvement and looking any tricks the did for transit
11:45hcumberdaleclgv: (#(...)) works!
11:46BobSchackIt's my first non toy clojure library so any feedback is welcome
11:47clgvhcumberdale: but then you could just use (cond-> a :x print)
11:48hcumberdaleclgv yes for print. But I want to call (spit (:x a) graph).
11:48seangroveBobSchack: This si great, thank you. How does the domain-aware compression work? What kidn of compression ratio do you get?
11:48hcumberdaleBasically I have that graph and I work on cli options for the output
11:49clgvhcumberdale: if the function is more complicate you probably should "defn" it anyway ;)
11:49hcumberdaleusing clojure.tools/cli I have a options map. I want to be able to create both graphml files for yed and yaml output
11:52awwaiidicfp contest today!
11:52hcumberdaleI've choosen cond-> because of it's behavior not to short circuit
11:53hcumberdaleIs there a better alternative to cond-> if I just want a not short circuit cond but not changing my forms?
11:53BobSchackseangrove to cache you can either use (write-object object cahce-flag) in the write handler or cache an individual object by calling (cache object)
11:54BobSchackFressian caching is really awesome but very poorly documented :(
11:55seangroveBobSchack: Any chance of a few code examples in the readme or examples dir?
11:56BobSchackYep working on this today with 20% time any use cases you'd like to see?
12:00ppppauli can't find david nolens blog post about using core.async to make a typeahead
12:01nullptrppppaul: http://swannodette.github.io/2013/08/17/comparative/ ?
12:02seangroveBobSchack: Not sure. Generaly usage - I'll play around with this tonight or this weekend if the examples are there
12:03ppppaulthanks nullptr
12:49mpenethuh, take! doesn't work on sliding buffers ?
12:50mpenetc.c.async map uses that internally and breaks stuff down the road I think
12:51mpenetc.c.async/map
12:51mpenetmap< even, anyway...
12:52vdmit11hi folks, how can I define a constructor for a custom type?
12:53vdmit11I mean, can I define different arities for the automatically generated constructor?
12:53bbloomvdmit11: no, just use a function
12:54mpenet,(use 'clojure.core.async)
12:54clojurebot#<FileNotFoundException java.io.FileNotFoundException: Could not locate clojure/core/async__init.class or clojure/core/async.clj on classpath: >
13:09kwladykaWhat is the most mature (the best) webframework using Clojure? I know in google is many articles about that but not actual any more.
13:29bridgethillyerkwladyka: take a look at Luminus, Pedestal, Om, and Hoplon
13:29bridgethillyerWhich one you pick depends on your needs
13:29bridgethillyerIn Clojure, it’s more a set of libraries than an entire framework
13:30bridgethillyerAlthough Pedestal could be considered a framework
13:30boxedand Reagent!
13:31johnwalkerwhat is :scope "provided"?
13:31johnwalkerhttps://github.com/swannodette/om-sync/blob/master/project.clj
13:31hiredmanhoplon seems to come with its own build system, it maybe a framework :)
13:31johnwalkeris it clojurescript only?
13:35bridgethillyerhiredman: more a worldview :)
13:36llasramjohnwalker: It's a Maven thing which means that in production the actual implementation for dependency will be provided by e.g. some sort of framework
13:37johnwalkerahh, so one of the other dependencies in the project?
13:37llasramjohnwalker: I'm not sure what the intent is there in that project.clj file though. The resulting pom.xml will have the deps marked as sscope=provided, but Leiningen expects "provided" dependencies to go in the "provided" profile
13:38llasramjohnwalker: No, but I could be mistaken
13:38llasramUsually you use it to indicate actual dependencies of the project, but which dependencies shouldn't be added to e.g. an uberjar, because they'll be provided at runtime in some other fashion
13:39llasramI don't know what it means heer
13:39llasramhere
13:39johnwalkerok, so it also works for clojure?
13:40johnwalkerer, that should have been a statement
13:40johnwalkerthanks llasram
13:40johnwalker(inc llasram)
13:40lazybot⇒ 29
13:40llasramnp... I hope actually helpful :-)
13:41johnwalkerdefinitely
13:42technomancyjohnwalker: iiuc :provided only makes sense for a project that's distributed via uberjar but not run via `java -jar ...`
13:43technomancyI don't know anything about this project, but it seems a bit fishy
13:48johnwalkertechnomancy: llasram: the plot thickens
13:51johnwalker(inc technomancy)
13:51lazybot⇒ 126
13:59kwladykabridgethillyer any good comperassion about that framework from about last 3-moths? :) I need create web app and need solutions like validation example http://laravel.com/docs/validation#available-validation-rules and relationships in DB like http://laravel.com/docs/eloquent#relationships, clever forms like http://laravel.com/docs/html#form-model-binding
14:00kwladykaAny framework or framework + some packages can give me that stable?
14:02kwladykaClojure is specific language... i am not sure how to thing about that... get simply framework and find packages or get complex framework. In other languages i am sure i want complex framework but Clojure is functional language and i am not so expirence with that.
14:03boxedthose validation rules seems like just simple functions in the standard lib… but maybe you want something like http://let-caribou.in ?
14:03boxedor rather.. that’s what you’re looking for, but it might not be the best thing!
14:03kwladykamayby in Clojure all is so simply to glue together so i can easy get simply web framework, some package for relationships and validation on database structer etc. and it will always work together stable
14:04boxedfor example: that form “bindings” thing can be done much easier and simpler in Reagent
14:04kwladykaboxed: yes, its simply but there is more things like that, it's about time of coding
14:05boxedI mean in time of coding easier and simpler too… but of course using something new takes more time
14:06kwladykaboxed: for me is always better has ready solution for example validations with most possibilites what i want then write my own
14:06boxedeh.. depends
14:06kwladykaalso the same with database relationship
14:06kwladykabut ofcourse example i always preffer my own solutions for front-end, using ready solutions always *ucks :)
14:06ToBeReplacedsilly little puzzle... what's a nice way to go from [0 1 2 3] to ([0 1 2 3] [1 2 3] [2 3] [3]) ? All i've got is (->> [0 1 2 3] (iterate next) (take-while some?))... which is close enough, but doesn't read very well
14:07boxedkwladyka: try Reagent. Really!
14:10boxed,(let [x [0 1 2 3]] (for [i (range (count x))] (drop i x)))
14:10clojurebot((0 1 2 3) (1 2 3) (2 3) (3))
14:11boxedreads pretty clearly imo
14:12ToBeReplacedboxed: not sure i agree, but subjective so ::shrug::
14:13boxed“give me the list dropping nothing, then give me the list dropping one, and so forth until the list is empty”
14:13ToBeReplacedboxed: i don't like that it requires x to be countable
14:13boxedah
14:13boxedyou want something that works for a seq of 1 2 3 too?
14:14ToBeReplacedboxed: but maybe that's a feature for readability
14:14boxedI think it can be :P
14:14ToBeReplacedboxed: i don't know what i want / don't have anything in particular i'm looking for... just realized that i didn't care for what i had and was interested in seeing other ways
14:16boxedto my mind it makes more sense to make the terminating form as explicit as possible.. “(take-while some?)” doesn’t really speak to me but “(drop i x)” is very clear
14:16kwladykaboxed reagent is javascript not "clear" Clojure? Damn... so many things to test and thing about the choice :)
14:17boxedkwladyka: it’s for ClojureScript not Clojure yea, so you run it on the client instead of javascript
14:18kwladykais it somethig similar to meteor framework?
14:20kwladykaok so i have last question :)
14:20boxedkwladyka: not really.. meteor seems to go the entire way to the DB which sounds like a horribly bad idea. Reagent is more like… angular maybe? but imo better and based on React so much much faster
14:22kwladykaClojure is functional language and i am beginner with that. Example in PHP is good to have big complex framework with everything because glues some idenpedned parts is not easy. How is it look in Clojure? Better is get complex framework or simply framework + package for validation + package for database structure etc. What do you thing about that?
14:22kwladykaor mayby packages like that doesn't exist :)
14:23boxedyou don’t need a big package for validation. Just make a simple if statement.
14:23kwladykaboxed i have to write "Reagent" in my notes to check this :)
14:23kwladykai know but the question is about something else
14:23boxedkwladyka: http://yogthos.net/blog/54-Building+Single+Page+Apps+with+Reagent
14:24kwladykahow easy and stable is glue many small element in Clojure, better then one complex framework or not?
14:24boxedputting together parts is mostly a lot easier yea
14:24TimMcToBeReplaced: ##(reverse (rest (reductions conj () (reverse (range 4)))))
14:24lazybot⇒ ((0 1 2 3) (1 2 3) (2 3) (3))
14:24TimMcNow, just to replace conj with something that starts with "re"...
14:24boxedbut it’s also early days in Clojure, so maybe there _should_ be a big framework that is a collection of good stuff
14:25technomancyboxed: iiuc that's what luminus is
14:25boxedtechnomancy: ok.. haven’t gotten that far yet :P
14:25technomancyI haven't used it either
14:25boxedkwladyka: so look at luminus too! :P
14:27kwladykaboxed, i don't know today how it should works in functional language... i know in non-functional is good to have complex solutions but only because is hard to integrate all this things. But from other side having all complex give some problems when you want something more custom... i guess the only one way to figure out what is better in Clojure is learn and try both ideas.
14:27vermais there a reason to use emacs over vim + fireplace for clojure(script) dev?
14:28technomancyverma: lots of reasons to, and lots of reasons not to
14:28boxedkwladyka: addaboy!
14:28kwladykalighttable looks good as editor
14:28kwladykai think :)
14:28kwladykabecause i am beginner but it look really good
14:28jcromart_OK so I am going to say, I really really really like Enlive for most things
14:28jcromart_but when it comes to something like forms
14:28jcromart_I am at a loss
14:28jcromart_forms are like, blech
14:28boxedkwladyka: I find that clojure seems to be nice to plug things together because of a strong culture of keeping the data itself simple with maps, sets and lists. That makes combining things much much easier than in OOP
14:28jcromart_I mean HTML forms are always kind of like that
14:29kwladykaboxed: but example in PHP i can definitly say what is better... just expirience :)
14:29jcromart_I guess not everything in my views needs to be an Envlive defsnippet
14:30kwladykaboxed: yes and this is the reason why i am thinging about try more small ements then less bigger in Clojrue. Becaouse of cluture of maps etc.
14:30vermatechnomancy, I see emacs being popular among clojure developers, wonder if that's because its a concious choice over vim or is it just because that's what they've been using before clojure
14:30moquistkwladyka: There's some good advice here (blog.getprismatic.com/software-engineering-at-prismatic/) about how to think differently in Clojure-land than in OOP-land. Note the gentle push away from frameworks and toward libraries.
14:31moquistkwladyka: I use emacs+EVIL+cider for Clojure work, but highly recommend checking out lighttable.
14:31technomancyverma: well it is a lisp virtual machine
14:32kwladykamoquist: thx, i will read that
14:32kwladykaAnybody use lighttable?
14:32vermatechnomancy, sure, but does that play a part in day to day software dev?
14:32kwladykahttp://www.lighttable.com/
14:32vermakwladyka, I've "tried it" sure
14:33technomancyverma: it does if you're using it correctly
14:33kwladykaverma and what do you think about that?
14:33vermatechnomancy, nice, tell me more, or point me to somewhere
14:33technomancyworking in programs that don't have a repl as an integral part of them is just a nightmare
14:33boxedkwladyka: yea I code clojure in it… it’s a bit rough but has some really nice things too
14:33kwladykaits really similar edior to Sublime Text 3 as in my opinion is one of the best
14:33technomancywell, programs with nontrivial interfaces
14:34vermakwladyka, vi bindings were a little iffy, so I never gave it much time, but it seemed like I could customize it a lot
14:34technomancyit's just ... you're a programmer. you should be programming your programs as you use them. that should be your natural state.
14:34technomancybut so much crap is hard-coded and impossible to modify.
14:34vermatechnomancy, :)
14:35technomancythe fact that browsers don't work this way should be a source of great shame for the entire industry
14:35technomancyhttp://technomancy.us/161
14:35technomancythis isn't specific to emacs or anything
14:36technomancysmalltalk and genera are the same way
14:37vermatechnomancy, hmm nice
14:38boxedtechnomancy: I looked into fiddling with the syntax highlighting of clojure in light table… turns out it’s all a big hairy javascript parser that’s pretty damn horrible. I just gave up
14:38boxedI wanted to add reasonable things like marking the keys in maps diffently from the values… but yea
14:39tjdis there an idiomatic way to version records with edn?
14:39GlenjaminFirefox sorta works that way, it's a shame there was that dark spell where venkman and dom inspector weren't supported well
14:39tjdlike #com.example.Product.V1 {:foo "bar"}
14:40tjdbut that feels dirty
14:41dnolen_ClojureScript 0.0-2277 released, should fix REPL issues to Google Closure Library changes
14:41dnolen_due to
14:42technomancyGlenjamin: in a way that's even worse
14:42technomancybecause there's no technical reason it sucks so bad
14:42technomancyall the parts are there to build something sensible, and no one has done it
14:43GlenjaminUI was all hackable XUL and JS, extensions can do basically anything
14:43GlenjaminNot sure how true that is anymore
14:43Jaoodtechnomancy: so is it emacs what drove to you clojure? :)
14:43technomancyJaood: absolutely
14:44Jaoodthought so by reading that post
14:44boxedwhat’s the name of that site that shows you which clojure libs are used by which projects and how popular libs are? I can never remember
14:44technomancyboxed: http://clojuresphere.com
14:45GlenjaminCross clj as well?
14:45boxedhuh, that wasn’t the one I was thinking about but that’s cool :P
15:01Bronsahiredman: ping
15:02hiredmanyo
15:02hiredmanI mean pong
15:03Bronsahiredman: hi, I'm looking at your patch&comments on CLJ-701 and you mention you're seeing some verification errors
15:03hiredmanyes, which I have had no luck solving
15:03BronsaI've been implementing loop/try hoisting on tools.emitter.jvm myself over the last couple of days & it compiles data.json fine
15:04hiredmanlucky you :)
15:04Bronsado you have any specific code you can give me that causes the error so I can help you out?
15:04hiredmanhttps://github.com/clojure/data.json/blob/master/src/test/clojure/clojure/data/json_compat_0_1_test.clj#L221
15:04hiredmanI have been meaning to do a gist or something writing up the current issue I am having
15:06hiredmanbasically, it sort of looks like operations on longs are not being emitted in such a way as to properly take in to take in to account how many local slots a long takes up
15:06hiredmanI am not 100% sure that is accurate, but it is what seems to be the case
15:08hiredmanbut I don't think the compiler at all concerns itself with that issue, defering to asm to track it internally, so how it could be a problem I have no idea
15:08Bronsahiredman: ok I've confirmed that it works w/ t.e.j, I'll look into it when I have some time
15:08Bronsahiredman: uhm, I'm pretty sure the compiler needs to deal with it actually
15:09kwladykaboxed: thx again for http://www.clojuresphere.com/ :)
15:09Bronsahiredman: for longs/doubles it needs to reserve 2 local slots
15:10hiredmanright
15:10gfrederi`so leiningen profiles
15:10hiredmanbut I haven't seen a place in the compiler where it does that
15:10gfredericksif I have a profile that adds a dependency
15:10gfredericksshould `lein with-profile +foo uberjar` actually work?
15:10hiredman(which I thought it must, for deftypes with primitives, primitive lets, etc)
15:10gfredericksor is uberjar going to undermine my efforts?
15:11hiredmanso I assumed asm's internal machinery must be doing the bookkeeping
15:14hiredmanmaybe I am just not doing the registerlocal thing correctly
15:14hiredmananyway, I spent all of yesterday pointedly not thinking about it :)
15:16Bronsahiredman: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L5213, https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L7998, https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L4296
15:16vdmit11Hi folks. I'm implementing a bunch of custom types. For instance, there are 'Action' and 'Process', a Process consists of Actions. Both types have a property called 'duration'. But the Process needs to calculate the 'duration' as a sum of all nested Actions. So I'm going to define a protocol. So there is a question: how to put such a "field" to a protocol? Is there an idiomatic way, something more handy than a getter and a setter method? Is it idiomatic to comb
15:19Bronsahiredman: + all the places where it checks to know whether to emit pop or pop2
15:20hiredmanright
15:20hiredmaninteresting
15:21hiredman(I was aware of the pop2 thing, but somehow must have missed this)
15:36gfredericksoh I see the problem
15:37gfredericksif my :dev profile includes the :foo profile, then I'm unable to add :foo to the uberjar task
15:37gfredericksi.e., it silently doesn't add it
15:39gfredericksdoes anybody know if this is a bug?
15:49llasramgfredericks: I think it's a known issue... The problem is that the :dev profile gets unmerged as part of the uberjar task
15:50llasramHmm, which. Yeah, maybe it is a bug
15:50llasramMy absence means I'm out of the loop -- jcrossley fixed some related-in-my-mind bugs right before the last release
15:52llasramThe profile unmerging stuff always goes fuzzy unless I focus my entire consciousness on it
15:52gfredericksyeah I don't have any guesses how it works
15:54gfredericksmy use case is just that I want different versions of a dependency
15:54gfredericksseems innocuous enough
15:55gfredericksand the versions actually have different group names, so I can't put a default in the main :dependencies list
15:55llasramUgh. Yeah, I hate that
15:56gfredericksso I did :profiles {:a {deps w/ a} :b {deps w/ b} :dev' {normal dev stuff} :dev [:dev' :a]}
15:57llasramLast time I fought with something like that, I ended up using with-profile aliases to entirely replace the default profile set
15:57llasramhttps://github.com/damballa/parkour/blob/master/project.clj#L39-L52
15:58mdrogalisstuartsierra: Component question. Why'd you decide to wrap up exceptions emitted from start/stop-system into the cause of another exception?
16:00stuartsierramdrogalis: They're wrapped to convey the last known state of the system before the exception was thrown, so you can use it to recover or clean up.
16:02mdrogalisstuartsierra: Hm, alright.
16:03stuartsierraIt's not necessarily sufficient: if a component's `start` method created some partial state and then threw an exception, you will not have any way to get at the partially-constructed state.
16:04stuartsierraI can't fix this: you have to write your `start` and `stop` methods carefully if you want to protect against this.
16:06jcromart_where is the appropriate channel on freenode for venting/rambling?
16:10technomancy#emacs for the latter
16:12llasramThe mission of #clojure-offtopic seems broad enough to encompass nearly anything
16:13technomancyyou can also do a private message to clojurebot
16:13mr-foobari have regexes, start and end, to define a text region. how can I extract multiple regions from a text file, functionally ?
16:13llasramtechnomancy: That seems so... extra sad though
16:14technomancyllasram: well you never know when something you say may resurface
16:16alexyakushevHi everyone. What would be the best way to get a dependency tree of namespaces for one chosen namespace? I'm thinking about clojure.tools.namespace, but not sure how to apply it
16:17stuartsierraalexyakushev: tools.namespace does have the necessary pieces...
16:17alexyakushevI suppose functions from clojure.tools.namespace.dependency should help, right?
16:18stuartsierraThat's part of it, but that's just the dependency tree data structure, not specific to namespaces.
16:19stuartsierraShortest way right now is to create a project with your namespace + tools.namespace, call `clojure.tools.namespace.repl/refresh`, then get the dependency graph from (:clojure.tools.namespace.track/deps @#'clojure.tools.namespace.repl/refresh-tracker)
16:20stuartsierraNot at all obvious, I know.
16:20alexyakushevstuartsierra: Yeah, and kinda side-effectish
16:21alexyakushevstuartsierra: Seems like I'll have to do it manually by calling read-ns-decl
16:22stuartsierratools.namespace mostly works with files, and relies on the ability to parse the `ns` declaration without evaluating it.
16:25alexyakushevCan I somehow infer a list of required namespaces in pure Clojure?
16:25alexyakushevMaybe from "mappings" or "namespaces" maps
16:33stuartsierraalexyakushev: You could get close with `ns-refers` and `ns-aliases`, but neither tells you if a namespace :require's another namespace without aliasing or referring any symbols.
16:33stuartsierrae.g. (ns foo (:require bar))
16:35alexyakushevstuartsierra: Well, I guess I'll stick to tools.namespace then
16:35stuartsierra^^ The dependency of 'foo' on 'bar' cannot be determined from runtime metadata.
16:36stuartsierraIt's tricky because Clojure doesn't really have a notion of a compilation unit larger than a single expression.
16:37stuartsierraFiles are just sequences of expressions to the compiler; `in-ns` and `require` are side-effects.
16:37technomancydepending on what it's for, it may be reasonable to say that if you alias or refer without a require, you're doing it wrong, and the tool is just not going to help you
16:37technomancyslamhound does plenty of that
16:37technomancyand some people don't like it, but I can just say "too bad; that's not what slamhound is for" and get on with life.
16:38stuartsierraI agree that using a namespace without 'require'ing it is probably a mistake, but I do sometimes :require a full name without an alias or a refer.
16:39fifosineIf I change a method in hashmap, is there a way to force all other methods to return the same type (i.e., a hashmap with the same changed method)?
16:41alexyakushevstuartsierra, technomancy: Thank you for clarification
16:42alexyakushevThe usecase actually is to get the list of all clj files in my own library, but in the "correct" order
16:42alexyakushevSo I can control if I refer anything without :require (which I don't)
16:46hoverbearI've got a "io.undertow.servlet.util.IteratorEnumeration@3b9c778e" .... How do I "unwrap" this in Clojure?
16:46stuartsierraalexyakushev: Something like this might work (-> (clojure.tools.namespace.dir/scan (clojure.tools.namespace.track/tracker) "src") :clojure.tools.namespace.track/deps clojure.tools.namespace.dependency/topo-sort)
16:48alexyakushevstuartsierra: Can I make it scan files on the classpath?
16:49stuartsierraalexyakushev: yes, use java.classpath to get a list of directories on the classpath
16:51alexyakushevstuartsierra: Well, what I meant is that I want to scan files that are in a jar
16:51stuartsierraThat's much harder.
16:51stuartsierraalexyakushev: You can expand files in the jar with java.classpath too.
16:51justin_smithalexyakushev: a jar is a zip file, open it with your favorite zip file software
16:52justin_smithunless you mean you have to do it inside clojure at runtime
16:52stuartsierraalexyakushev: What are you really trying to do?
16:54alexyakushevstuartsierra: It's complicated:). @bbatsov and @trptcolin are trying to replace clojure-complete with Compliment in Reply. There is a usecase in Reply where it has to transmit all clojure files for the underlying completion backend to the remote nREPL instance.
16:54alexyakushevstuartsierra: The order of files transmitted should be such that if evaluated one after one it will work correctly
16:55alexyakushevstuartsierra: I don't like to hardcode all of the Compliment files inside Reply, so I'm searching a way for Reply to build that list of files automatically
16:57stuartsierraalexyakushev: OK, so you want to search for *all* .clj files anywhere on the classpath then, right?
16:58alexyakushevstuartsierra: Ideally for all files that belong to "compliment/" directory in resources, but yes, I can search for all and filter them after
16:58BobSchackseangrove: I just pushed perf improvements, api improvements and an in depth caching example.
17:00stuartsierraalexyakushev: Why does 'Reply' need to know about all the namespaces in 'Compliment'?
17:00BobSchackI'll be busy during the weekend but feel free to email me any questions you have and pain points you discover and I should be able to get to them next week.
17:01alexyakushevstuartsierra: That's even more complicated. Reply supports mode when it connects to a remote nREPL instance that might not have any completion backend loaded. So in order to provide completion it transfers all the files for completion backend to that nREPL instance and loads them there.
17:06stuartsierraalexyakushev: I have to say, this all sounds excessively complicated to me. But if you really want to do it... yes, you could use java.classpath to enumerate every file on the classpath, filter them by name, then use tools.namespace.file to add each file to a dependency graph, get the topologically-sorted list, then filter again by your namespace prefix.
17:08alexyakushevstuartsierra: At this point the hardcoding solution doesn't seem that bad
17:08stuartsierraalexyakushev: yes.
17:08technomancyalexyakushev: bultitude does this
17:08technomancyoh, but you probably can't add a dep
17:09seangroveBobSchack: That's awesome, thank you
17:09mikerodwhat is a good use case for `var-get`?
17:10mikerodit looks like `deref` is the same thing for a var
17:10mikerodand it is used by it
17:10alexyakushevtechnomancy: Perhaps I could try to use builtitude, thanks
17:10mikerodif(!threadBound.get())
17:11mikerodmaybe this is the difference, but I don't see what the implications of this is
17:11mikerodSo, can `var-get` give you a different result than `deref` for some Var object?
17:11alexyakushevtechnomancy: If it's only one dependency, I can probably talk Colin into it
17:11technomancy"It's not just a Clojure lib... it's a Raynes® lib."
17:12technomancytaste the difference
17:12trptcolinalexyakushev: fwiw my principal dependency concerns are for lein users
17:13technomancybultitude is already in lein, but not on the project side
17:13trptcolinand since lein already uses bultitude (in the lein process/classloader) it should probably be fine
17:13Raynestechnomancy and I are the king of ignoring stuartsierra's objections to features and just writing our own libraries. :P
17:13stuartsierra:)
17:13technomancyRaynes: but... it's part of this complete breakfast
17:13trptcolinbtw how do people feel about this potential clojure-complete -> compliment transition?
17:14stuartsierratrptcolin: This discussion isn't filling me with confidence.
17:14trptcolinthe big win as far as i’m concerned is being able to complete available java instance methods
17:14RaynesIn all seriousness, the original reason for bultitude's existence was an issue with the other lib breaking on malformed ns lines.
17:14RaynesI don't think we communicated the issue well enough to stuartsierra so he declined a fix.
17:14RaynesIn case anyone was ever wondering.
17:15stuartsierraOr it was just my natural obtuseness. :P
17:15alexyakushevstuartsierra: Well, that mess is not about Compliment. REPLy already did the files-transaction-evaluation thing, but clojure-complete had just one file
17:15stuartsierraobtusity?
17:15RaynesBultitude is basically a leiningen-optimized version of stuartsierra's lovely library.
17:15stuartsierraobtusiveness?
17:16technomancyRaynes: didn't a lot of it come from swank?
17:16Raynestechnomancy: I don't think so?
17:16technomancyoh
17:16technomancycarry on then
17:16Raynestechnomancy: I'm pretty sure you just copied stuart's library and changed like a line of code.
17:16RaynesThen I moved it into a separate library
17:16RaynesAnd then people added features ad infinitum.
17:16stuartsierraalexyakushev: So can you fit your library in one file?
17:17alexyakushevstuartsierra: nah, that was my original gripe with clojure-complete
17:17alexyakushevWell, one of
17:18stuartsierraThen I think I give up. :)
17:20technomancyRaynes: you still want a keyboard?
17:21Raynestechnomancy: My body says yes but my bank account says next month.
17:21technomancyworks for me
17:21alexyakushevstuartsierra: You've tried though:) Anyway thank you for fruitful discussion, I now know better to accept low-hanging approaches and not over-engineer
17:21Raynestechnomancy: I'll set a reminder to send you a bag of cash on the 1st.
17:21stuartsierraalexyakushev: You're welcome. Good luck!
17:22technomancygold coins would be ok too
17:22Raynestechnomancy: To be clear, I just said "Ok google, remind me on the 1st of August to buy a keyboard from Phil Hagelberg" and my WRISTWATCH set a reminder.
17:22RaynesJust so you know how much technology I just used.
17:23technomancyI'm holding out for smart pocket watches
17:24seangrovetechnomancy: Same here, can't wait for google monocle
17:24Raynestechnomancy: The best part was that it even got the spelling of your name right.
17:24stuartsierratechnomancy: like … a phone?
17:26technomancystuartsierra: it's not the same without the gold chain
17:26technomancyfuture status http://86bb71d19d3bcb79effc-d9e6924a0395cb1b5b9f03b7640d26eb.r91.cf1.rackcdn.com/wp-content/uploads/2011/06/zelda-ocarina-of-time-money-cheat-big-and-purple-rupees-guide-screenshot.jpg
17:26technomancyheh, this one is pretty good too though http://www.funnyjunk.com/channel/legend-of-zelda/I/onkrDba
17:27pmonksI’m still waiting for smart people to be as ubiquitous as smart gadgets (present company excluded, of course!).
17:27stuartsierrahttp://www.amazon.com/FOSC-Crossbody-Wearable-Silicone-Samsung/dp/B00EVZRPNK
17:28technomancynot bad
17:31mimieux
17:45PigDudeWhat is the idiomatic way to update multiple record fields? I have been using merge
17:45PigDude(-> r (assoc :k v) (assoc :k v)) i don't like the repeated assoc
17:46Bronsa,(assoc {} :a 1 :b 2)
17:46clojurebot{:b 2, :a 1}
17:47dbaschPigDude: assoc takes multiple kvs, see the docs
17:47PigDudeoh ok, thanks dbasch
17:50_2_candy12345:D:D:D:D:D:D:D
17:54bbloomdoes anybody else consistently accidentally lose *e by causing another exception while trying to inspect *e ?
17:54perplexahaha
17:54Bronsame too
17:54perplexa+1
17:54Bronsabbloom: I learned to (def a *e) because I'm too stupid
17:55bbloomidea: if the symbol *e appears in the expression, then don't set *e... sound like it would help?
17:55bbloomcould anything horrible go wrong with that?
17:56bbloomBronsa: heh, why not (def e *e) ....
17:56ambrosebs(pst) ;=> ; No such var
17:56bbloomambrosebs: argh.
17:56bbloomi actually despise the relative nature of *1 etc too
17:57gfrederickserlang style integers would be cool
17:57Bronsahaha I actually constantly mess up *1 & friends too
17:57bbloommathematica has Out[n]
17:57bbloomwith shorthand %n
17:57bbloombut also supports arbitrary strings of %
17:57Bronsa85% of the times I (use 'clojure.pprint) and forget to replace *1 with *2 on the previous input
17:57bbloomso you get both relative and absolute
17:58gfredericksmy bg macro defs things with incrementing integers
17:58bbloomhttp://reference.wolfram.com/language/ref/Out.html
17:58gfredericksbut that's only useful for backgrounding slow things
17:59bbloomseems like %% is represented by Out[-2]
17:59bbloomthat's basically what i want
17:59bbloom(clojure.repl/in n) and (clojure.repl/out n)
17:59bbloomand (clojure.repl/err n)
18:00bbloomwith both absolute & relative
18:00gfredericksnegatives for relative?
18:00bbloomyes
18:01gfredericksshould this be nrepl client stuff or middleware stuff or regular lib stuff?
18:01bbloomi think it needs to be part of nrepl, but i'm not an expert on that stuff
18:01bbloomi also want the default history to be at least 100
18:01ambrosebsoh boo, I hope this interview gets put back up http://codequarterly.com/2011/rich-hickey/
18:02mlb-I'm setting a exception handler via Thread/setDefaultExceptionHandler (to simply call println, for now), but when I run (future (Thread/sleep 500) (/ 1 0)), I don't see any stdout. Am I missing something?
18:02gfredericksmlb-: yes
18:02gfredericksmlb-: futures will catch the exception and store it for throwing on deref
18:03gfredericksso the default exception handler doesn't factor in
18:03mlb-hmm. Okay.
18:03gfrederickstry (.start (Thread. #(...)))
18:03mlb-Is that the same for core.async?
18:04PigDudewhy does (assoc r ..) return a new record, but (dissoc r) returns PersistentArrayMap?
18:04gfredericksno the default exception handler is relevant for at least some core.async usage
18:04PigDudeis this behavior of assoc supported? the docs don't mention returning records
18:04mlb-gfredericks: okay, thanks much! =]
18:04gfredericksPigDude: a record has to have the basis keys
18:04gfredericksPigDude: so you always get records back unless you remove a basis key
18:04PigDudegfredericks: so assoc nil
18:04gfredericksmlb-: np
18:05gfredericksPigDude: not sure what you mean?
18:05PigDudegfredericks: if i want to unset a record field i need to assoc nil or otherwise create a new record, dissoc will remove the basis as you said
18:06PigDudegfredericks: is that right?
18:07gfredericksdepends on what you're trying to achieve -- I think as envisioned removing a basis key is a weird thing to do
18:07bbloom,`*1 ; ugh, forgot about that
18:07clojurebotclojure.core/*1
18:07bbloomthey aren't in clojure.repl or clojure.tools.nrepl or whatever
18:08gfrederickswell nrepl does have to bother to set them
18:08bbloomyeah
18:09gfredericksPigDude: assoc nil is probably normal, yeah
18:09gfredericksI use that with component
18:11PigDudeok, thanks gfredericks !
18:13PigDudegfredericks: and then i just wrote (reduce dissoc {:a 1 :b 2 :c 3} [:a :b]) before thinking hm ... i bet dissoc takes multiple keys too :)
18:26bmabeyI am using java.data and I want to define a multimethod that extends the functionality of the :default multimethod. How can I explicitly call the :default method so I can then adjust the results?
18:28bbloom(doc get-method) ; bmabey
18:28clojurebot"([multifn dispatch-val]); Given a multimethod and a dispatch value, returns the dispatch fn that would apply to that value, or nil if none apply and no default"
18:29bmabeybbloom: ah, thanks
18:42lxsameerhey guys, I'm totally new to clojure, is there any lib to develop android native apps using clojure ?
18:45Atlanisthere was a really useful library I'd toyed with before, i'm looking to see if i can find it again
18:45Atlanisat least, you'll want lein-droid.
18:46Atlanislxsameer: neko (https://github.com/clojure-android/neko)
18:48lxsameerAtlanis: thanks
18:57AtlanisJaood: its about the same as on any other computer (~3 seconds). way longer than i want to wait for an app to launch, but with the way android works most apps dont launch often
18:57Atlanisclojure launch time still frustrating though :(
18:57benkayso frustrating.
20:00bobby_tablesI am using the clojure.tools.analyzer.jvm namespace and the ast generation is taking FOREVER on even relatively small code samples. is anyone else running into this, or is there something that can be done to limit the analysis to speed it up? thanks!
20:03ambrosebsbobby_tables: it shouldn't be more than 10x slow afaik
20:03ambrosebsbut its faster than that in my experience
20:03bobby_tablesambrosebs: hmm...
20:03ambrosebsum, you're not printing the output are you?
20:03ambrosebsotherwise, do you have an example?
20:04bobby_tablesambrosebs: well, thanks for letting me know that you are at least having a different experience so i can see if it is something else that is going on
20:05bobby_tablespprint... ahh, right... great point... i didn't cosider that it had to analyse the layout - thanks, I will give that a try
20:05ambrosebsif you're printing it, make sure *print-length* and *print-level* are defined
20:06bobby_tablesyeeeeppp... that was it... it was nearly instantaneous without the pprint formatting
20:06ambrosebsotherwise the ast will probably crash your program
20:06bobby_tablesambrosebs: thanks a ton!
20:06bobby_tablesambrosebs: okay, I will do that
20:06ambrosebsI have this in my profiles.clj: {:user {:injections [(set! *print-level* 10) (set! *print-length* 10)]}}}
20:07ambrosebserm extra }
20:07ambrosebsstolen from Bronsa
20:07bobby_tablesambrosebs: cool... thanks
20:07bobby_tablesbronsa... and thanks to you as well...
20:07ambrosebsnp
20:13bobby_tablesambrosebs: the binding change made a ton of difference... thanks
20:14ambrosebsgreat
20:14BalvedaHas anyone used clj-pdf?
20:15BalvedaI need to format data from an excel so that I can spit out cards on a pdf for future printing;
20:16BalvedaAnd for that I need to take a bunch of vectors of maps and format the data in such a manner that I'm creating vectors and essentially... rotating the data from the initial vector
20:17Balvedaso the thing in the first row turns into the first column, etc
20:17BalvedaWhat would be a good way to do this?
20:46PigDudeis there a shortcut for (zipmap (map k coll) coll)?
20:48justin_smith(reduce (fn [m v] (assoc m v (k v))) {} coll) not a shortcut, but is an laternate option
20:49PigDudesometimes i see people do weird (apply hash-map)-type stuff where zipmap would work
20:50PigDude(apply hash-map (interleave ...) or something
20:50hyPiRion(into {} (map (juxt k identity) coll))
20:50PigDudeis there a reason for that or just to feel smart?
20:50justin_smith(inc hyPiRion)
20:50lazybot⇒ 40
20:50justin_smithyeah, I like that one best
20:50PigDudehehe
20:51PigDudeok thank you
20:51justin_smithPigDude: apply hash-map makes sense when the things you want are already alternating in one sequence
20:52justin_smithin k,v,k,v ... order
20:53justin_smithzipmap makes most sense when the source of the keys and the source of the vals are totally independent, but when they come from the same sequence (which is the majority of cases I see) it seems a bit odd to walk something twice to get one result
20:53justin_smiththough the performance implications there are not likely huge
20:54PigDudejustin_smith: yea, what surprised me was to see taking two sequences that could be (zipmap s s2) and doing (apply hash-map (interleave s s2))
20:55justin_smithyeah, that's a silly one for sure
20:55justin_smith(though I know I am guilty of worse)
20:55PigDudelike making a mess to clean it up :)
20:55PigDudeyea, core is big
21:02Raynesguys
21:02RaynesI need Chas's flowchart for whether or not to use records an stuff
21:02Raynesand*
21:03justin_smithhttp://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/
21:03justin_smithlol, as usual, I had it in my bookmarks but it was easier to find it via google
21:03Raynesthnx
21:03justin_smithnp
21:17tuft_finally the weekend is here. time for clojure programming
21:17PigDudetuft: and here i am trying to fix this bug so i can start my weekend and not think about clojure programming for 48hrs
21:17Balvedadid anyone reply? I dropped
21:19justin_smithBalveda: vectors as in the clj datatype and rotating values, or as in vectorial data in a pdf and rotating the x/y coords?
21:19tuftPigDude: hah, isn't that the way
21:19Balvedaas in the data type
21:19tuftPigDude: btw don't make me think about python for at least that long
21:19arrdemdamnit is ambrose gone already..
21:19mthvedtanger leads to hate, hate leads to object oriented frameworks
21:19arrdem(inc mthvedt)
21:20lazybot⇒ 4
21:20BalvedaBasically I'm lifting data from an excel, so I get each row as a vector with all its information
21:20justin_smith,(apply map vector [[0 1 2] [3 4 5] [6 7 8]]) Balveda
21:20clojurebot([0 3 6] [1 4 7] [2 5 8])
21:20Balvedaah
21:20Balvedainteresting
21:20Balvedathanks
21:20justin_smithnp
21:21PigDudetuft: don't make me think about python either :) too soon
21:21PigDudetuft: i am picking up sml in my free time :)
21:22justin_smithBalveda: you can even do (def transpose (partial apply map vector))
21:22justin_smiththough that may look like magic and may call for a comment explicating wtf that is doing :)
21:23Balvedawell, i think i get the transpose part
21:23Balvedabut the partial, no idea
21:24justin_smithpartial returns a function that takes some more args, and applies all preceding args to it
21:24justin_smith,(map (partial + 20) (range 5))
21:24clojurebot(20 21 22 23 24)
21:25Balvedai see
21:25justin_smithwell, that was a sloppy description, but hopefully the example helps :)
21:25PigDudeBalveda: that works because of how (map) consumes extra collections:
21:25PigDude,(map #(identity %&) [1 2 3] [4 5 6]))
21:25clojurebot((1 4) (2 5) (3 6))
21:25justin_smithPigDude: hah, using the implicit list generation of varargs, nice
21:26PigDude;)
21:27justin_smiththough I prefer (fn [& l] l) -- it's two characters shorter
21:27justin_smithor perhaps just list
21:27justin_smithheh
21:27justin_smith,(map list [1 2 3] [4 5 6])
21:27clojurebot((1 4) (2 5) (3 6))
21:27Balvedaclojure is magic sometimes.
21:28justin_smithBalveda: there are lot's of funny tricks, but if you hang around here you'll see a lot of them
21:28Balvedawhat's the deal with map though?
21:28justin_smithBalveda: it's vararg
21:28Balvedahow come the mapping rotates the vectors?
21:28vermais there a way to do a update-in style swap-in for atoms? which limits the swap to a certain key or seq of keys?
21:29justin_smithBalveda: if you map across multiple sequences, your function gets the first element of each one as args
21:29justin_smiththen, it gets the second element of each one
21:29justin_smithetc. until you get to the end of the shortest one
21:29justin_smithif all you want is to rotate columns / rows, then you make a list of all the first items, then a list of all the second items, then a list of all the third items...
21:30PigDude(swap! a
21:30BalvedaI see
21:30PigDudesorry wrong window
21:30BalvedaI'll try this out as soon as I get my setup in this thing
21:30BalvedaI have all my stuff in the linux partition
21:30justin_smithyeah, dev on linux tends to be more sane
21:30vermait'd be nice to do a (swap-in! atom [:hello :world] assoc :what "world") -> {:hello {:world {:what "world"}}}
21:31Balvedacan't play masterwork dwarf fortress on linux though.. at least not the latest version
21:31Balvedaand after a couple of hours of trying to get that to work i needed a break, heh
21:31ToBeReplaced"block and consume everything until channel is closed" -> (async/reduce (constantly nil) nil channel)? something more idiomatic?
21:31justin_smithverma: why not (swap! atom assoc-in [:hello :world :what] "world")
21:32justin_smith,(swap! (atom {}) assoc-in [:hello :world :what] "world")
21:32clojurebot{:hello {:world {:what "world"}}}
21:32vermajustin_smith, because I am going to replace the assoc with a more complex function
21:32justin_smiththen use update-in
21:32ToBeReplacedi have a case where i'm using a channel as a sentinel... thread X periodically checks if channel is closed, if it is, stops
21:32vermathat was just an example
21:33vermajustin_smith, sure, just thought there was some better way :) thanks
21:33justin_smith,(swap! (atom {}) update-in [:hello :world] #(assoc % :what "world"))
21:34clojurebot{:hello {:world {:what "world"}}}
21:34vermaoh
21:34vermajustin_smith, sweet
21:34vermajustin_smith, much better than that what I was going to do :)
21:34verma(inc justin_smith)
21:34lazybot⇒ 53
21:47drguildodoes anyone have any idea what's causing this when i run cider-jack-in? https://www.refheap.com/88607
21:48drguildoi don't have any functions called create in my project
21:49drguildoor other symbols
21:50justin_smithwhat is in C:\Users\Simon.Simon-T400\AppData\Local\Temp\form-init6118470964490798405.clj
21:51justin_smithit has an error on line 4009
21:52justin_smithsounds like either cider is broken by an update, or your install is hosed (hell, it could be both)
21:52drguildoit looks like some kind of intermediate compiled version of the code
21:53justin_smithsome transformed version of your own namespaces?
21:53drguildowhich looks pretty much like gibberish to me
21:53drguildoi guess
21:57drguildoit seems to work since i did "lein new" using a normal command prompt instead of one running inside emacs
21:57drguildo*shrug*
21:58drguildooh wait
21:58drguildoi forgot to paste the code into the buffer
22:02drguildoyeah looks like shell+cmd messed things up
22:07technomancyjustin_smith: eval-in-project writes forms to a file since windows can't handle command-line args of the length we need
22:08justin_smithtechnomancy: oh, interesting
22:09justin_smithtechnomancy: so that file will have everything cider has evaluated in it
22:10nkozothere is a way in prismatic schema to specify an specific value? this doesnt work: (schema.core/validate {:k 3} {:k 3}))
22:10technomancyjustin_smith: just the first eval-in-project call
22:10technomancywhich is usually from lein repl, not cider
22:11justin_smithahh
22:11nkozook, found it, is schema.core/eq
22:12justin_smithit's funny all the different ways windows users get hobbled because ms so extensively commited to the philosophy of "standards are for the other guy"
22:12clojurebotHuh?
22:12cespareWhen I do deftype, why can't I add an extra method not on the interface I provided? ("Can't define method not in interfaces")
22:17technomancyjustin_smith: more like "command lines are for the other guy"
22:17technomancywhere "other" here means "the 1980s"
22:17technomancyI mean, it's certified posix compliant, so...
22:19justin_smithlol
22:20justin_smithbtw, linux is not posix compliant
22:22bbloomcespare: in theory, you shouldn't need them. although i'll admit there are a few cases i've wanted a private method or two
22:22technomancyI wish I could remember the exact wording, but someone once said that Posix is to the aftermath of the unix wars as the restrictions on naval tonnage was to the aftermath of WWI.
22:23justin_smithhah
22:23bbloomstandards are overrated anyway
22:23sm0kelinux is not posix? really?
22:24p_lsm0ke: it's not certified
22:24sm0kewho all are certified?
22:25justin_smithsm0ke: irony being windows is certified (and barely if at all usable as a posix system)
22:25cesparebbloom: why shouldn't I need them?
22:25p_lPOSIX certs are outdated, these days you want SUSv3
22:25cesparebbloom: methods are the only place I can use set!, yes?
22:25p_ljustin_smith: windows posix subsystem gave about as good as OpenBSD, afaik, with better GUI and driver support ;)
22:25bbloomcespare: that's the one case where a private method would actually be useful, and i'd agree it's an oversight
22:26cesparebbloom: I'm still missing something though -- why wouldn't one expect to add any methods you want? In Java, you can define any methods that aren't on the interfaces you're implementing, right?
22:26cesparebbloom: and what's the workaround; make a protocol that has what I need?
22:27bbloomcespare: public methods that aren't part of an interface is a generally bad idea
22:28bbloomcespare: "always code to an abstraction" when working with objects
22:28cesparebbloom: okay, I wasn't aware of that. I'm not a java programmer.
22:28cesparethanks
22:28bbloomcespare: that's a controversial statement for java programmers, but not so for java programmers who write clojure on the side :-P
22:29cesparebbloom: I just wanted to implement IDeref
22:29cesparebut also have some other methods.
22:29bbloomcespare: so what other public methods do you need?
22:29bbloomcespare: just define a protocol
22:29bbloomit's that simple
22:29cespareyeah, makes sense.
22:29technomancybbloom: wait, "always code to an abstraction" is good, but private vars are bad?
22:29technomancyhow is this possible
22:31bbloomtechnomancy: i didn't say private vars were bad
22:31bbloomtechnomancy: i said i'd like private methods
22:31technomancyok, I was recalling a twitter conversation from a few days ago, but maybe I got the names mixed up
22:31bbloomi don't buy in to the idea that encapsulation has absolutely no place, only that it's significantly less useful when you have immutable data
22:32technomancyI'm glad that Clojure makes it both 0) easy to declare things as private and 1) nearly as easy to get around that declaration when you decide it's worth the risk
22:33eggsbyless reason to have private stuff when you don't carry around a bunch of mutable state
22:33bbloomtechnomancy: agreed for vars, but the situation with deftype is a little less good
22:33technomancyI wouldn't know
22:33technomancyeggsby: having the freedom to change your arglists and know you're not going to break downstream consumers is a wonderful thing
22:34technomancythere are a bunch of places in lein where we have just a complete mess because it would be a breaking change to do the thing that actually makes sense
22:34eggsbyisn't that kind of solved by versioning your api technomancy
22:34bbloomeggsby: i don't know of any decent API versioning support in any language really
22:34technomancyeggsby: there are various reasons why you would want to space out breaking changes by a year or more
22:35eggsbytechnomancy: I guess it is a litle ridiculous to think every refactor might lead to a version bump
22:35technomancygranted it's not as bad for most libs
22:35technomancyas it is with lein
22:36eggsbywhen I'm programming java I often feel the need to make things private to protect them from would-be future use
22:38eggsbywell, probably b/c every third party api is stateful and mutable...