#clojure logs

2015-02-28

02:55lvhHm
02:58lvhSo, I am rebinding a dynamic var using a fixture that lives in a different namespace; that namespace then calls the original namespace back, and by the time I get there, the var is unbound again :-(
02:58lvhat first I thought it might be some threading shennanigans, but I get the same behavior with with-redefs
03:04lvhAh. Turns out I didn't know how use-fixtures works :)
03:07niacuser=> (import PiratePhrases)
03:07niacClassNotFoundException PiratePhrases java.net.URLClassLoader$1.run (URLClassLoader.java:372)
03:08niacbut there is a PiratePhrases.class
03:08niacwithout package
03:26SagiCZi am making java desktop application and i have decided to use clojure to write the gui part.. swing and javafx seem both pretty constricted where it comes to design, i would like to develop the design simliary to web pages, is it possible in clojure? maybe run it in a bundled web browser? i dont know where to start though
03:30niacis there any way to use a local java file without lein in clojure
03:33devllyou can checkout reimport here. niac https://github.com/zcaudate/vinyasa/tree/master/src/vinyasa
03:35niacdevll: thanks
03:40sveriHi, I wonder if there is an abstraction for korma that let's me insert and update many-to-many entities? It seems like korma itself does not support this usecase
03:42devllhttps://github.com/friemen/aggregate
03:43devllI am using yesql ,but aggregate might do what you want sveri
03:47sveridevll: uh, another nice library I never heard of, this looks promising, thank you
03:49devll:D
04:18noncomhi, anyone using ccw here ?
04:37EremoxHow do I set a distinct documentation string for each arity of a function?
04:39noncomEremox: i think there is no way to do that. if you look at the core clojure functions, they all just describe the arities verbally in a singal description
04:40Eremoxok to bad.
04:40noncomEremox: not really, this goes hand-in-hand with the notion that a single function must have a single responsibility and arity overload must not seriously affect the functionality of the function
04:40noncomEremox: so, ultimately, this limitation is for the greater good
04:42EremoxI understand but i think it makes the code clear. (I defined a macro.
05:33SagiCZI am trying to add a couple of clojure files to my all java project in intellij but Cursive does not recognize any symbols, what am I doing wrong?
05:34SagiCZoh i know.. i didnt set the directory as source in the project structure.. nevermind it works now
05:34cflemingSagiCZ: Do you have Clojure added as a library dependency to your module? And are your Clojure files under a source root?
05:35cflemingSagiCZ: Snap, there you go.
05:35cflemingSagiCZ: I'm planning to add a popup in the editor when you don't do that, especially for cljs
07:06SagiCZcfleming: thanks!
07:07SagiCZwhats the best way to send two state parameter to a function?
07:07SagiCZlets say i have a function that can draw something on TOP or BOTTOM
07:08SagiCZi could do something like (draw x y z true) where true would mean TOP and false would mean BOTTOM.. but i dont like that
07:08SagiCZwhat about (draw x y z :top) and (draw x y z :bottom) is that a misused keyword?
07:19raspasovSagiCZ: have two separate functions? :)
08:22devllHi, after deleting a file in my project,(refresh-all) gives FileNotFount Exception.
08:22devll*Found
08:32devlldoing remove-ns does not help.
08:32devllhow can I remove this error?
08:33devllrestarting repl will do it,but it is too costly.
08:43trisshey all. am I right in thinking there are no pre and post conditions for defmethod?
08:48Bronsatriss: you can add them to the dispatch function
08:49Bronsatriss: or even to every defmethod
08:50Bronsa,(defmulti m class)
08:50clojurebot#'sandbox/m
08:50Bronsa,(defmethod m Object [x] {:pre [(string? x)]} x)
08:50clojurebot#<MultiFn clojure.lang.MultiFn@6ea5b634>
08:50Bronsa,(m "foo")
08:50clojurebot"foo"
08:50Bronsa,(m 1)
08:50clojurebot#<AssertionError java.lang.AssertionError: Assert failed: (string? x)>
08:51trissbrilliant thanks Bronsa... doesn't look documented to me? http://clojuredocs.org/clojure.core/defmethod
08:52Bronsadunno, I read the impl
08:52trisshah. might hve o try nad ge used to that.
08:53triss^ have to try and get used to that
11:17crazydiamondHi. Can anyone suggest math/functional programming book with theory and/or exercises for development of functional way of thinking (with Clojure flavour)?
11:17subhashgocrazydiamond: I don't know about books, but 4clojure.com is a good resource for clojure exercises
11:24crazydiamondsubhashgo, thanks
11:25justin_smithcrazydiamond: have you looked at clojure for the brave and true, and clojure from the ground up?
11:34gfredericksclojure {for,from} the {brave,ground} [and] {true,up}
11:37crazydiamond_:D
11:37crazydiamond_btw, is e.g. lambda calculus useful to know for functional programming?
11:37justin_smith,(str "clojure " (rand-nth '[from for]) " the " (rand-nth '[ground brave]) (rand-nth [" and " " "]) (rand-nth '[true up]))
11:37clojurebot"clojure from the brave true"
11:38justin_smith,(str "clojure " (rand-nth '[from for]) " the " (rand-nth '[ground brave]) (rand-nth [" and " " "]) (rand-nth '[true up]))
11:38clojurebot"clojure from the ground and up"
11:38gfrederickscrazydiamond_: not in too much detail
11:38crazydiamond_an, other fields of math?
11:38crazydiamond_*and
11:38justin_smithcrazydiamond_: the lambda calculus is for fp kind of like knowing a machine language (optionally turing tape being that language) is for imperative
11:38justin_smith,(str "clojure " (rand-nth '[from for]) " the " (rand-nth '[ground brave]) (rand-nth [" and " " "]) (rand-nth '[true up]))
11:38clojurebot"clojure from the brave and up"
11:39crazydiamond_so far no matches with "for", btw
11:39justin_smith,(str "clojure " (rand-nth '[from for]) " the " (rand-nth '[ground brave]) (rand-nth [" and " " "]) (rand-nth '[true up]))
11:39clojurebot"clojure from the brave up"
11:39justin_smith,(str "clojure " (rand-nth '[from for]) " the " (rand-nth '[ground brave]) (rand-nth [" and " " "]) (rand-nth '[true up]))
11:39clojurebot"clojure for the ground up"
11:39crazydiamond_there it is
11:40justin_smithfinally - that last one is for pigs that want to learn how to program after they become sausage
11:46gfredericks(inc justin_smith)
11:46lazybot⇒ 199
11:49justin_smithhaha
12:04hyPiRion(inc justin_smith)
12:04lazybot⇒ 200
12:04hyPiRiondo I win something
12:06justin_smithyou got to be an important part of a very special moment
12:06gfredericks~200 is a number made up of only smallish primes
12:06clojurebotIk begrijp
12:07gfredericks,(* 2 2 2 5 5)
12:07clojurebot200
12:08justin_smith,(filter #(zero? (rem 200 %)) (range 1 200))
12:08clojurebot(1 2 4 5 8 ...)
12:09justin_smith,(clojure.string/join \space (filter #(zero? (rem 200 %)) (range 1 200)))
12:09clojurebot"1 2 4 5 8 10 20 25 40 50 100"
12:18TEttinger,(clojure.string/join " " (filter #(zero? (rem 200 %)) (range -200 0)))
12:18clojurebot"-200 -100 -50 -40 -25 -20 -10 -8 -5 -4 -2 -1"
12:18TEttingernice
12:19justin_smithremainder is handy that way
12:21SagiCZdoes anybody know how could i change the way seesaw button is painted? i know its JButton and in java i would extend it and overwrite the paint method, how to do that in clojure/seesaw?
12:26emaczenI need to use the for macro and for some reason this is not visible in my current namespace -- I see that it is part of clojure.core.
12:27emaczennvm I figured it out
12:28emaczenbut what does :refer all do in a require form?
12:28SagiCZit should be :refer :all
12:29nuwanda_it means you get every function in the namespace, as opposed to :refer [functions you want]
12:29SagiCZand it refers all the symbols
12:29SagiCZand yeah.. 'for' should be available everywhere
12:29emaczenSagiCZ: What's wrong with omitting :refer :all (it seemed to import the for macro)
12:29SagiCZemaczen: what was before the refer all? what namespace>
12:29SagiCZ?
12:30emaczenclojure.core
12:30SagiCZyou dont need to require clojure.core thats automatic
12:30SagiCZdelete the whole statement
12:30SagiCZ(ns my-namespace)
12:30emaczenBut I can't use the for macro otherwise
12:30SagiCZ(for [x (range 10)] x)
12:30SagiCZemaczen: unlikely
12:31SagiCZwhat editor do you use?
12:31emaczenemacs
12:31justin_smithSagiCZ: clojure.core is not referred if you use in-ns to create a namespace
12:31emaczenI'm user cider
12:31justin_smithemaczen: did you use in-ns to switch to a namespace that did not exist yet?
12:31emaczenjustin_smith: I am switching namespaces
12:31emaczenI believe that it exists
12:31justin_smithhow did you create the namespace?
12:32justin_smithI bet the ns code had an error, so the namespace was not created
12:32justin_smithjust a guess
12:32justin_smiththen when you used in-ns you created a namespace that did not have (refer-clojure)
12:32emaczenjustin_smith: It does have an error -- I am editing it...
12:32justin_smiththat's literally all you need to do to rescue your repl
12:32justin_smith(refer-clojure)
12:32justin_smithit's done implicitly by ns
12:34emaczenjustin_smith: good to know, thanks
12:34SagiCZin proxy macro how do i mimick super.method() call?
12:36gfredericks,(apropos "super")
12:36clojurebot(clojure.core/proxy-call-with-super clojure.core/proxy-super clojure.core/supers)
12:36gfredericksI'd check those first two
12:37SagiCZit has no doc.. gosh i hate core
12:38justin_smith(doc proxy-super)
12:38clojurebot"([meth & args]); Use to call a superclass method in the body of a proxy method. Note, expansion captures 'this"
12:38justin_smithSagiCZ: ?
12:40SagiCZproxy-call-with-super has no doc
12:40justin_smithit's a helper function used in implementing proxy-super
12:41SagiCZi see.. well it at least works so thats nice
12:43SagiCZi would like to use "this" in the proxy too..
12:44justin_smithSagiCZ: that's what proxy-super says - you can use "this" inside the body
12:44justin_smithas long as that is the name of the object in that scope, it will work
12:45justin_smithI don't like that it is a magic name used by the macro, but at least it's usable
12:45justin_smithyou're just required to bind to the name "
12:45SagiCZyeah.. that is super weird.. it works though
12:45justin_smiththis" in the enclosing scope
12:45justin_smithright
12:54devllwhy I can't see the full deps tree with lein?
12:54justin_smithdevll: is something missing from "lein deps :tree" ?
12:54devllI am having an issue with clj-http.
12:55justin_smithso what's wrong with the deps tree printing?
12:55devllI am using elastic search too which uses clj-http, but lein deps :tree does not show this.
12:56justin_smithdevll: if it's not in the tree, how do you know the dep is present?
12:56devllI searched for the error
12:56devllthen I got the info from github.
12:57devllI also verified from ClojureSphere
12:57justin_smithare they pulling in the dep via their declared deps, or resolving it and compiling it in when packaging?
12:57devll*it
12:59justin_smithdevll: are you talking about elastich? their handling of the clj-http dep is super weird https://github.com/clojurewerkz/elastisch/blob/master/project.clj#L21
12:59devllyes.
13:00justin_smithdevll: you can only have one version of a dep loaded. Likely clj-http is being loaded under another dep
13:00justin_smithif it's not present in the tree at all, that's seriously messed up
13:00justin_smithif you need a specific version, you should explicitly depend on that version rather than relying on transative deps
13:02devllin my case,deps tree are missing info.
13:02justin_smithcan you post your deps tree output?
13:02justin_smithnot in here, on refheap or something, of course
13:03devllok
13:03devllwait for a minute
13:05devllhttp://pastebin.com/0in6rjmQ
13:06justin_smithdevll: clj-http is right there, it's a top level dep
13:06justin_smithline 78, that's the version you have
13:08devll[clj-http "1.0.1-SNAPSHOT"]
13:08justin_smithsnapshot gets translated into a date specific version
13:08justin_smith[clj-http "1.0.1-20140913.231842-1"] is what 1.0.1-SNAPSHOT gets today
13:09justin_smiththat may change tomorrow
13:09justin_smiththat's how snapshots work
13:09devllgot it. lein deps :tree | grep -i clj-http
13:09devllthis only showed one line.
13:09devllmy bad.
13:09devllthanks
13:10justin_smithno problem
13:16SagiCZcfleming: any reason why cursive cant see my Java classes? the plugin itself can find them because it autoimported them but REPL says ClassNotFoudException when trying to load the clojure file
13:18TEttingerSagiCZ: loading a clojure file that itself imports java classes?
13:22SagiCZyes
13:23SagiCZclojure file with (:import (myPackage MyClass)
13:23SagiCZfails
13:24devllWARNING: update already refers to: #'clojure.core/update in namespace: clj-http.client, being replaced by: #'clj-http.client/update
13:25devllI am getting this warning .
13:26gfredericksdevll: hopefully newer versions of clj-http don't have that?
13:26devllwhat does this mean? how can I resolve this?
13:26devllI updated everything.
13:26devllno luck.
13:29justin_smithdevll: someone needs to update clj-http to be compatible with clojure 1.7.
13:29justin_smiththe warning doesn't mean anything is broken though
13:29justin_smithit just means they gave something the same top level name as something in clojure.core
13:29AlwaysBCodingdoes anyone know what \_ means as a character in Clojure? It’s coming from an api where a &nbsp was in a string and the string in clojure just has a weird _ character in it. When I do (seq (char-array string)) it shows up as \_ … what is that character and how could I regex it out?
13:30justin_smith,(type \_)
13:30clojurebotjava.lang.Character
13:30SagiCZAlwaysBCoding: its a clojure literal for the underscore symbol "_"
13:30justin_smithoh, that may be something different
13:30devllI cant use clj-http. it eventually throws an error.
13:30justin_smith,(int \_)
13:30clojurebot95
13:31justin_smithAlwaysBCoding: that's a normal underscore - is that copy pasted from the original?
13:31the-kennydevll: that warning isn't a big issue. It just says you import a function named 'update' which overrides the clojure function with the same name.
13:31justin_smithAlwaysBCoding: use int to find out it's numerical value, that will be unambiguous
13:31devll- Attempting to call unbound fn: #'clj-http.client/update
13:31AlwaysBCodingit shows up in emacs/cider as a yellow underscore, but if I regex on an underscore it doesn’t match
13:32godd2,(str \h \e \l \l \o)
13:32clojurebot"hello"
13:32the-kennydevll: Either import qualified [... :as http] or refer only the functions you need: [... :refer [fn1 fn2 ...]]
13:32devllI got this error too.
13:32the-kennyAlwaysBCoding: \_ is a char, not a string.
13:32justin_smithAlwaysBCoding: OK, in the context where you have that string, map int across the string
13:32the-kenny,(first "_")
13:32clojurebot\_
13:32justin_smithAlwaysBCoding: get the actual code point
13:32devllI delete all the (:use ) today.
13:32devlldeleted*
13:32AlwaysBCodingint value is 160
13:33justin_smithdevll: I think that has to do with the fact that your libs require like 80 different versions of clj-http
13:33devllI exclude all
13:33justin_smithdevll: likely the one you are providing does not define the function one of your libs needs
13:33devlld
13:33justin_smithdevll: exclude does not help when they call a function not defined in the version of the lib you pull in
13:33justin_smiththat's the problem
13:33devllI downgraded Clojure to 1.6.0
13:33devllthen it is OK.
13:33justin_smithdevll: that won't fix your probelm
13:34justin_smithreally?
13:34justin_smith...
13:34devllyes.
13:34the-kennyjustin_smith: 1.6 doesn't have clojure.core/update
13:34the-kennyonly clojure.core/update-in
13:34AlwaysBCodingthe int value of a normal underscore is 95 it seems, then what the hell is 160? wtf haha this is tripping me out
13:34justin_smiththe-kenny: his actual problem is something in his code calls clj-http/update and it does not exist
13:34godd2AlwaysBCoding the \ is used to denote a single character. So "h" and \h are pretty much the same thing, as are "_" and \_
13:34justin_smithgodd2: but not everything that prints as _ is _
13:35justin_smithAlwaysBCoding: unicode 160 is non breaking space http://www.fileformat.info/info/unicode/char/00a0/index.htm
13:35justin_smiththat's your issue
13:35justin_smith&nbsp translates to that unicode symbol
13:35lazybotjava.lang.RuntimeException: Unable to resolve symbol: nbsp in this context
13:35justin_smithlazybot: shutup
13:36AlwaysBCodingjustin_smith: awesome. how can I regex out that character from strings?
13:37justin_smithAlwaysBCoding: I'd use clojure.string/replace to replace nbsp with regular space maybe
13:38godd2does \s not match nbsp?
13:39godd2or refer to it by its unicode \u00a0
13:39AlwaysBCodingjustim_smith: how though? like it doesn’t match &nbsp or anything
13:39justin_smithAlwaysBCoding: looks like godd2 is on the right track there
13:39AlwaysBCodingok got it. It looks like it matches if you do '\xa0'
13:39the-kennydoesn't clojure.string/replace also work on char/char replacements? Just specify nbsp as second arg, space as third.
13:40AlwaysBCodinggodd2: \u00a0 works also, awesome
13:40godd2coolio
13:43justin_smith /me loves it when a plan comes together.
13:44justin_smithgreat work, team!
13:46godd2(synergize [:team_member1 :team_member_2 :team_member_3 :team_member_4])
14:12erik``why does
14:12slipset,(+)
14:12clojurebot0
14:12slipsetbut not
14:12slipset,(-)
14:12clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core/->
14:13justin_smith,(/ 2)
14:13clojurebot1/2
14:13slipsetand one could expect
14:13godd2slipset subtraction doesnt have a left-associative identity
14:13slipsetah!
14:14justin_smithgodd2: well, it won't until we invent anti-zero
14:14slipsetSo then there might be a (good) reason why
14:14slipset,(max)
14:14clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core/max>
14:15justin_smith,(min)
14:15clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core/min>
14:15justin_smith,(*)
14:15clojurebot1
14:15slipsetone could imagine (max) return something very small :)
14:16godd2slipset think about what reduce does
14:16slipsetgodd2, that's actually what I'm trying to think about
14:16slipset(reduce max [1 23 8 2 ])
14:17justin_smith,(max Double/NEGATIVE_INFINITY)
14:17clojurebot-Infinity
14:17hyPiRion,(reduce max []) ;; ???
14:17lazybothyPiRion: Oh, absolutely.
14:17clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core/max>
14:17slipset(reduce and [])
14:17slipset,(reduce and [])
14:17clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/and, compiling:(NO_SOURCE_PATH:0:0)>
14:17slipsetd'oh!
14:18slipset,(and)
14:18clojurebottrue
14:18hyPiRionand is a monoid though
14:18godd2the identity of addition is 0, so reducing [1 2 3] is (+ (+ (+ 0 1) 2 ) 3), but for subtraction, (- 1 2) doesnt equal (- (- 0 1) 2)
14:18slipset,(or)
14:18clojurebotnil
14:18hyPiRionmax and min aren't
14:18justin_smithgodd2: right, which is why I suggested we need anti-0
14:18slipsethyPirion: max and min aren't monoids, or aren't monoids in Clojure?
14:19slipsetI only do crud
14:19godd2justin_smith but then we'd have to prove uniquness and that all just too much hassle
14:19justin_smithgodd2: why prove something when you can axiomize it?
14:19justin_smith"the value that is the left-associative identity for subtraction"
14:20justin_smithdone, it's unique
14:20hyPiRionslipset: They could be monoids for floating point values, but not for any other numeric type
14:20godd2justin_smith I think you may run into a contradiction from commutativity.
14:20hyPiRionWell, I mean, they *could* be for any type, but I'm not sure if it makes sense
14:21justin_smithgodd2: oh god
14:21justin_smithright
14:21slipsethyPirion: the question sortof arises from one of @ctfords tweets this evening.
14:21slipsethe had a function somewhat like
14:21justin_smithgodd2: hrm, wait - no - it would be similar to i I think
14:21godd2justin_smith you might be right, I'm just speculating
14:21justin_smithgodd2: it introduces a new kind of "complex number" anti-zero+n
14:21slipset(defn f [l] (->> :foo (max)))
14:22slipset(defn f [l] (->> l :foo (max)))
14:22slipsetit should be
14:22godd2justin_smith and the anti-identity matrix
14:22slipsetwhich fails when the list he passes in is empty
14:22justin_smithright, right
14:22slipsetsorry, my brain is not on
14:22slipset(defn f [l] (->> l (map :foo) (max)))
14:23hyPiRionslipset: I think you forgot a reduce or apply there
14:23justin_smithyeah, definitely forgot an apply
14:23hyPiRion(->> l (map :foo) (reduce max))
14:23slipsethyPirion: you're right
14:23slipset(defn f [l] (->> l (map :foo) (apply max)))
14:23slipsetbut this fails when the list is empty
14:23slipsetsince max is not a monoid
14:23slipsetbut
14:24slipset(defn f [l] (->> l (map :foo) (reduce 0 max)))
14:24slipsetworks
14:24slipsetas would wrapping the whole thing in a (if ...)
14:24hyPiRionslipset: sure, but that assumes the lowest value in the list is 0
14:24justin_smithslipset: that works if at least one arg is positive
14:25slipsetwhich I guess is a pre-condition to this function
14:25justin_smithslipset: use Double/NEGATIVE_INFINITY instead maybe?
14:25justin_smithor just not provide an anitial value and let reduce use the first value as the inditial
14:25hyPiRionActually, I just retract my statement about max/min being monoids. They simply can't be.
14:25hyPiRion,(max Double/NaN Double/POSITIVE_INFINITY)
14:25clojurebotNaN
14:25slipsetjustin_smith: sure, in the general case, but in this specific case, 0 is known to be the smallest possible value
14:26hyPiRion,(= Double/NaN Double/NaN)
14:26clojurebotfalse
14:26justin_smithslipset: why not use the general solution?
14:27slipsetjustin_smith: I guess if it were my code, I'd wrap the thing in a (if (seq l) ... 0)
14:27emaczenWhat is the difference between atoms and agents? All I can tell is that they both are asynchronous.
14:28justin_smithemaczen: agents don't retry, for one
14:28justin_smithand they have a queue, rather than speculative execution
14:29emaczenSo an agent seems more like the traditional asynchronous execution that I would think of.
14:29slipsetwould it be correct to say that you send someting off to an agent to happen at some time, whereas a change to an atom happens quite immediatly?
14:29justin_smithemaczen: if you know contention will be low (the normal case) an atom will be faster. If you know it will be high (or if retries would be disasterous) agents are definitely better.
14:30justin_smithslipset: change to an atom happens when it is done with the computation you use, plus all relevant retries (if any)
14:30slipsetjustin_smith: and while updating an atom you block, right?
14:31emaczenjustin_smith: can you define or point me to contention?
14:31slipsetwhereas updating an agent is non blocking.
14:31slipset?
14:31justin_smithemaczen: two overlapping updates to the same atom
14:31justin_smithsomething else changed it while you were using it
14:32emaczenjustin_smith: cool!
14:32justin_smithswap! will restart with the new value, if any change happened after it started and before it commited
14:32justin_smithwhich is why swap! + side effects is bad news
14:37justin_smithemaczen: oh, another big difference is that if you get an exception when doing a swap! on an atom, you get it in your calling context, but an exception on a send or send-off to an agent will be handled by the agent's exception handler (or via explicit calls to agent-error and restart-agent later)
14:39emaczenIs retrying by the atom the major difference? It makes sense to me to use agents over atoms when contention is high due to the retrying.
14:39justin_smithatoms have less coordination overhead, and you can deal with exceptions / get the result transperently in the calling context
14:56gfredericksemaczen: I think switching to agents due to contention only makes sense if the contention is due to the update function being slow
14:56gfredericksthreads still have to contend to get stuff into the agent's queue
14:57justin_smithgfredericks: isn't it a decent sized queue though? and queue insertion should't be a wide target for contention
14:58gfredericksI wasn't referring to queue size just the coordinated operation
14:58justin_smithaha, yeah
14:58gfrederickswhat do they use some kind of j.u.c.QueueThinger?
15:00justin_smithgfredericks: https://github.com/clojure/clojure/blob/clojure-1.6.0/src/jvm/clojure/lang/Agent.java#L24
15:00gfredericksan AtomicReference to an ActionQueue
15:00justin_smithyup
15:01gfrederickswhat on earth is line 40 about?
15:01gfredericksis that an initial value for an instance variable?
15:01emaczendoc isn't working in the "user" namespace for me, what is going on?
15:01justin_smithemaczen: (use 'clojure.repl)
15:02gfredericksemaczen: dunno that's complicated, I recommend using lein-shorthand and not investigating further :)
15:02justin_smithemaczen: likely lein added clojure.repl to your "main ns", whichever that is
15:02emaczenuse is the same as require right?
15:03justin_smithgfredericks: it's declaring an instance field on Agent, with some misleading indentation
15:04justin_smithemaczen: kind of, it's the same as (require 'foo :refer :all)
15:04emaczenI'm looking for a function like common-lisps make-list or make-array where you can specify the number of entries to be in the sequence and the initial argument.
15:04justin_smithemaczen: checkout conj.io
15:04emaczenjustin_smith: Ok, so you can pick a subset of the stuff that you want to import
15:04emaczenwhat is conj.io?
15:05gfredericksjustin_smith: I didn't think instance fields could have initial values set at the top level
15:05gfrederickslike
15:05gfrederickswhat does that even?
15:05justin_smithemaczen: a cheatsheet of useful clojure functions
15:05gfredericksI'm gonna go write some java code to try this out.
15:05justin_smithgfredericks: ahh, good point
15:06emaczenjustin_smith: is conj.io as website or something?
15:06justin_smithemaczen: anyway, the function you want is on conj.io, and is called repeatedly
15:06justin_smithemaczen: yes
15:06emaczenI'm googling it, and not finding anything
15:06justin_smithhttp://conj.io
15:06justin_smith,(repeatedly 3 :a)
15:06justin_smitherr
15:06clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Wrong number of args passed to keyword: :a>
15:06justin_smithsorry
15:06justin_smith,(repeat 3 :a)
15:06clojurebot(:a :a :a)
15:06justin_smithmuch better
15:07justin_smithemaczen: http://conj.io/store/v0/org.clojure/clojure/1.7.0-alpha4/clj/clojure.core/repeat/
15:08justin_smithemaczen: anyway, most of the interesting functions in clojure are on that page (http://conj.io aka grimoire), and it is updated pretty regularly
15:08emaczensweet! Thanks for the resource
15:09emaczenCan you get a vector instead of a list from repeat?
15:09gfredericksjustin_smith: looks like java lets you do it and just runs the expression every time you initialize something
15:09justin_smithgfredericks: so it's like constructor code that is not inside the constructor
15:09TEttingeremaczen, sure
15:10TEttinger,(vec (repeat 5 "whee"))
15:10clojurebot["whee" "whee" "whee" "whee" "whee"]
15:10TEttingersorry, didn't realize that nick was in use
15:10emaczenhah okay thanks TEttinger -- I thought it might have been a keyword argument to repeat
15:10TEttingerthat's rare in clojure, usually things return seqs
15:10gfredericksjustin_smith: yep I believe so.
15:11gfredericksI'll check whether it runs before or after constructor.
15:11gfredericksruns before
15:11gfredericksTIL about java.
15:11justin_smith~java
15:11clojurebotjava is a mutable basket case
15:11justin_smith~clojure
15:11clojurebotclojure is the bestest programming language available.
15:11gfredericks~a mutable basket case
15:11clojurebotexcusez-moi
15:24justin_smith~java
15:24clojurebotjava is nuts
15:24justin_smithmore of that mental illness theme, I see
15:24justin_smith~nuts
15:24clojurebotexcusez-moi
15:25justin_smithfrom a pm: 12:24 <clojurebot> ☕
15:29crazydiamondHi. Is there "loop version" of walk/postwalk?
15:29TEttinger(identity justin_smith)
15:29lazybotjustin_smith has karma 200.
15:29TEttingergasp!
15:29TEttingeryou reached it justin_smith!
15:29justin_smithI couldn't have done it without the help of all the little people
15:29TEttingerhaha
15:29justin_smithmeaning the leprechauns who help me answer clojure questions
15:30justin_smithit's a great day in fake internet points for me, to be sure
15:31justin_smithlet's just hope technomancy doesn't figure out I was stealing his points while he wasn't looking
15:31justin_smith(identity technomancy)
15:31lazybottechnomancy has karma 162.
15:33justin_smithwoah, does anyone else see a "run code snippet" button on this? http://stackoverflow.com/questions/28786376/how-can-i-use-a-unsigned-64-bits-variables-in-bits-operations-in-clojure
15:34gfredericksyep
15:34justin_smithI have never seen that feature before
15:34gfredericksI clicked it and it just printed the code
15:34justin_smithit appears to be totally broken
15:34gfredericksunformatted
15:34justin_smithbut it looks like a new feature
15:35justin_smithperhaps it will even work soon, that would be cool
15:35gfredericksmaybe it assumes all code is a language wherewithin everything evaluates to itself
15:35gfredericksor rather itself without newlines and in a variable-width font
15:36justin_smithreminds me of this messed up language I tried once called html
15:37kryftHmm, I tried to set :friend/redirect-on-auth? to false, but I still seem to get redirection upon successful login
15:38TEttingerjustin_smith: gfredericks: it looks like that code snippet doesn't have highlighting, maybe they didn't set the language
15:38justin_smithaha, I will edit it!
15:38kryftIf I have (:require [cemerick.friend :as friend]), then :friend/redirect-on-auth? should be the same symbol as ::redirect-on-auth? in the cemerick.friend ns, right?
15:38justin_smithTEttinger: oh, I reloaded, someone else set the language
15:39Bronsakryft: ::friend/redirect-on-auth
15:39justin_smithTEttinger: maybe it was a java related feature? (or chess or bitboard...)
15:39TEttingerhaha
15:39kryftBronsa: ...ah, thanks
15:39justin_smithTEttinger: ahh! the button was there because it had been set as lang-html http://stackoverflow.com/posts/28786376/revisions
15:39kryftSo :friend/redirect-on-auth would be ::my-current-ns/friend/redirect-on-auth :P
15:39justin_smithand they switched it to java which is way silly
15:40Bronsakryft: no :friend/redirect-on-auth is just :friend/redirect-on-auth
15:41kryftBronsa: Ok, I'd better reread the docs on that, thanks :)
16:54lvhis there a shorthand for "apply, except for macros"?
16:55lvhE.g. if I have a list [1 2 3 4], I want to be able to easily do (are [whatever] some-expr ~@that-list) in a test
16:55lvhexcept without the ~@ I guess
16:56justin_smithlvh: I think it would need to be another macro
16:57lvhjustin_smith: Indeed it would; I was hoping that'd be a macro someone already wrote ;)
16:57justin_smithactually, it may be hard to do without eval...
16:57arohnerlvh: there's apply-macro floating around
16:58justin_smithhttps://github.com/clojure/clojure-contrib/blob/73accf597eafb8dfcb642702a3b98b057bbdbbdf/src/main/clojure/clojure/contrib/apply_macro.clj#L34
16:58arohnerlvh: I'm on slow internets right now, you'll have to google for it. It was in old contrib, not sure if it got re-released
16:58justin_smithlike I thought, eval :(
16:58lvharohner: Found it; thanks :)
16:58arohnerlvh: but I'd be cautious about using it. It's not really idiomatic
16:58arohnerand ~@ works just fine in most cases
16:58justin_smith"This is evil. Don't ever use it. It makes a macro behave like a function. Seriously, how messed up is that?"
16:58lvhheh
16:58arohner`(are [whatever] some-expr ~@that-list)
16:59lvhYeah :-)
16:59lvhI might also just use is and give up on are's magic
17:00lvhmaybe that's slightly suboptimal because I'll get pretty terrible error message out when a test fails
17:13hq1hi, noob here. I'm having trouble getting cljfmt to work. `lein cljfmt check src/foo/core.clj` works, but I'm having classpath issues when running `lein repl` and trying to (require `cljfmt.core) throws FileNotFoundException. My lein version is 2.5.1. Profile: https://gist.github.com/aerosol/2b2da25ec3bf72f21d59
17:15hq1Running `lein classpath` doesn't include any of the cljfmt packages. Is that supposed to be handled automatically or do I need some extra configuration?
17:16arohnerhq1: that's a lein profile issue
17:17hq1as in, the profile is misconfigured?
17:17arohnerif you try to require at runtime, it needs to be in the standard deps. I'm assuming cljfmt, when loaded as a plugin, puts itself in the :dev profile
17:18hq1oh ok, let me look that up
17:20arohnerhq1: :plugins are code that is loaded into the lein process. :dependencies are loaded into your app's process. Some plugins add dependencies.
17:21arohnerhq1: lein-cljfmt is the lein plugin. [cljfmt "0.1.7"]. is the runtime code. I bet lein-cljfmt adds cljfmt as a dependency. If you don't go through that path, cljfmt doesn't get loaded, and you can't require from repl
17:22arohnerso the way to fix it is just add [cljfmt "0.1.7"] as a dependency. You probably want to put it in your :dev profile, like {:profiles {:dev {:dependencies [[cljfmt "0.1.7"]]...
17:22hq1thanks arohner
17:24emaczencan someone here help me with cider? #clojure-emacs is very quiet
17:24hq1arohner: brilliant, it works as expected now.
17:24arohner~ask
17:25clojurebotThe Ask To Ask protocol wastes more bandwidth than any version of the Ask protocol, so just ask your question.
17:25emaczenwhen I start a cider-repl, I am now seening warnings
17:25emaczen1) WARNING: CIDER requires nREPL 0.2.7 to work properly
17:25emaczen2) WARNING: The following required nREPL ops are not supported:
17:25emaczenapropos classpath complete eldoc format-code format-edn info
17:25emaczen inspect-start inspect-refresh inspect-pop inspect-push inspect-reset
17:25emaczen macroexpand ns-list ns-vars resource stacktrace toggle-trace-var
17:25emaczen toggle-trace-ns undef
17:25emaczenPlease, install (or update) cider-nrepl 0.9.0-SNAPSHOT and restart
17:25emaczen CIDER
17:26emaczenWARNING: CIDER's version (0.9.0-snapshot) does not match
17:26emaczen cider-nrepl's version (not installed)
17:26scottjuh oh
17:26emaczenAll I did was install cider via MELPA
17:26justin_smithemaczen: what it is saying is that your clojure process needs a cider-nrepl dep to work properly with cider
17:27justin_smithemaczen: the two halves are distributed and installed separately, but their versions must match
17:27emaczenjustin_smith: where do I get this nrepl plugin?
17:27justin_smithusually it will be installed via a plugin in profiles.clj
17:27emaczenjustin_smith: can I put it in project.clj?
17:27justin_smithemaczen: declare a dep for cider-nrepl with the version string it asks for under the dev profile
17:28justin_smithit's better off in ~/.lein/profiles.clj unless you only plan to use cider with one project
17:29arohneremaczen: putting it in project.clj is good if you're planning on starting nrepl at runtime, i.e. in production. Otherwise put it in profiles
17:30emaczenthanks guys!
17:33emaczenSo I am still getting some warning messages that aren't clear to me
17:34emaczenWARNING: CIDER requires nREPL 0.2.7 to work properly
17:34emaczen{:user {:plugins [[cider/cider-nrepl "0.8.2"]]}} -- I put this in profiles.clj
17:34justin_smithwhy did you pick that version?
17:34justin_smiththe error message told you exactly the version it wanted
17:35emaczenThat's the version which is in Melpa
17:35emaczen cider 0.8.2 installed Clojure Integrated Development Environment and REPL
17:35justin_smithemaczen: something's fucky
17:35justin_smithyour cider thinks it is 0.9.0-SNAPSHOT
17:36justin_smithand that's the version of cider-nrepl it is asking for
17:36emaczenwhat is the difference between the two warnings:
17:36emaczenWARNING: CIDER requires nREPL 0.2.7 to work properly
17:36emaczenWARNING: CIDER's version (0.9.0-snapshot) does not match cider-nrepl's version (0.8.2)
17:36emaczenI also get the 0.9.0-SNAPSHOT warning
17:36arohneremaczen: I bet you have multiple cider.el's loaded in emacs
17:36justin_smithnrepl is a dep that cider-nrepl needs
17:36emaczenarohner: That's probably valid -- I'll remove them and then restart emeacs
17:37justin_smiththe version of nrepl, and the version of cider-nrepl, are both not usable by your version of cider
17:37justin_smith~cider
17:37clojurebotcider is Try #clojure-emacs for more help with Cider
17:37justin_smith~cider
17:37clojurebotcider is Cider is unstable and broken right now, most things don't work. Use the last stable version of nrepl.el for now.
17:39emaczenarohner: AMAZING! It works! FINALLY!
17:40arohneremaczen: great!
17:40emaczenarohner: Now I will play with company-mode and the extra jazz :)
17:40emaczenis there a recommended way to reload your .emacs file?
17:41emaczenI either M-x eval-buffer or M-x load-file [.emacs]
17:41arohnernot that I know of. The bigger problem is there isn't a convenient way to unload the effects of an old file
17:42emaczenYeah ...
17:42justin_smithif only we had component.el
17:42justin_smithhaha
17:49gfrederickshas anybody written clojure.el yet?
17:51emaczenwhat do you guys use for clojure completion?
17:51gfrederickssomething terrible
17:54scottjgfredericks: have you seen dash.el?
17:55gfredericksyeah
17:59avshalomemaczen: company
18:00emaczenavshalom: do you know of a way to rebind the up and down arrow keys for selection of a completion in the scroll bar?
18:01avshalomemaczen: not sure how to do that. are you talking about company mode?
18:18emaczenavshalom: I figured it out if you want the code
18:19chipf0rkHi, could anyone familiar with cider/cider-nrepl help me out? I've upgraded cider in emacs to the latest version and the cider-nrepl version in my profiles.clj is 0.9.0-SNAPSHOT, but cider seems to think it's both 0.9.0snapshot and 0.8.1 at the same time...
18:20emaczenchipf0rk: I might have just had this problem
18:20chipf0rkWARNING: CIDER's version (0.8.1) does not match cider-nrepl's version (0.9.0)-snapshot) - yet it says "CIDER 0.9.0snapshot" one line above
18:20emaczenYou may have multiple versions of cider loaded into emacs
18:20emaczenI just rebooted
18:20emaczenand it was fine
18:20chipf0rkrebooted or restarted emacs?
18:20chipf0rkbecause I've tried the latter
18:20emaczenrestarted emacs
18:21emaczenthe lateset in elpa is 0.8.2 for me
18:23chipf0rkhold up, `killall emacs` might've done the trick
18:23chipf0rksigh
18:23clojurebotExcuse me?
18:25chipf0rk"CIDER 0.9.0snapshot (package: 20150228.1306)" btw
18:25chipf0rkso 0.9.0snapshot seems to be in my package repos
18:26emaczenit has to match what is in profiles.clj
18:26chipf0rkI'm aware of that
18:26emaczenwhy not use 0.8.2
18:27chipf0rkgood question - mainly because I saw that I had emacs upgrade to 0.9.0
18:27chipf0rkhow do I downgrade a package?
18:27maveneaglehi guys, I was trying to understand the reducers in clojure. Just wanted to know if i understand it correctly.. when i create a reducer for map and reduce it, the specific collection (vec, list et all) will reduce itself "sequentially"? but the same reducer if i try to fold it will use the fork/join approach to parallelise the reduction?
18:27chipf0rkto a specific version
18:27ZardozSo ~/.lein/profiles.clj has the right plugin version?
18:27chipf0rkwelp it has 0.9.0-SNAPSHOT atm
18:27emaczenSo 20150228 in my *packages* buffer is from melpa
18:28emaczenUsually there is a melpa archive and a marmalade archive
18:28emaczenthe marmalade archive lists the version and the latest for cider was 0.8.2
18:28emaczenunless it changed in the last 30 minutes
18:29chipf0rki'm reinstalling the cider package I guess
18:29ZardozCan confirm, mine is "20150228"
18:34arohnermaveneagle: I don't think reducers specify an order. in fact I think they explicitly don't
18:34arohnermaveneagle: though transducers are explicitly fold-left
18:34chipf0rkwell that's interesting, it installed the same version, now that warning's gone
18:35chipf0rkhowever it now tells me it needs nrepl 0.2.7
18:35arohnermaveneagle: there's also https://github.com/aphyr/tesser
18:35ZardozOh yeah, that's annoying
18:36ZardozMake sure your profiles.clj looks like this:
18:36Zardoz{:user {:plugins [[cider/cider-nrepl "0.9.0-SNAPSHOT"]]
18:36Zardoz :dependencies [[org.clojure/tools.nrepl "0.2.7"]]}}
18:36emaczenchipf0rk: I had the exact same errors before but the restart just worked for me
18:36chipf0rkdoesn't for me sadly :(
18:36chipf0rkhold on I can specify deps in profiles.clj? oh
18:37emaczenCan anyone link me to a resource about OO design and clojure? I'm seeing a lot about just using values and datastructures (I like the idea of just using a map everywhere but I want to see the other options as well)
18:39maveneaglearohner: thanks, will have a look at it
18:39chipf0rkZardoz: Seems to have done the trick. Thanks a bunch!
18:39ZardozYou're welcome =D
18:40ZardozI ran into the same thing last week
18:47justin_smithemaczen: regarding when to use maps etc. http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/
18:47justin_smithemaczen: you won't be let down by that flowchart
18:49justin_smithemaczen: regarding OO, OO in clojure is mostly about keeping things modular by definining functions that work on interfaces / protocols, and then extending those interfaces / protocols to the types you need (starting with the persistent datatypes like map, vector, list, set etc.)
18:50justin_smithalso see multimethods, and derive, between those you can do some interesting OO things
18:50emaczenjustim_smith: cool, I am somewhat familiar with multi-methods but not derive
18:50justin_smithemaczen: multimethods respect the heirarchies created via derive for dispatch
18:51justin_smithfinally, information hiding isn't as important when your data is not mutable
18:53emaczenjustin_smith: What can you tell me about lazy evaluation?
18:53justin_smithwhat about it?
18:53emaczenI think I have a good question that will clarify my understanding thus far for you.
18:55emaczenIf I have a nested map expression, in common-lisp it must finish evaluating the nested map expression before the outer-expression can be evaluated
18:55justin_smithemaczen: clojure lazy-sequences are always evaluated in order
18:56justin_smithbut they are not always realized
18:56emaczenI thought in Clojure, the outer sequence would begin to be evaluated as soon as the inner one had "returned" an element
18:57justin_smithemaczen: it really depends. I'm putting together an example.
18:59justin_smithcontrived example:
18:59justin_smith,,(let [counter (atom 0)] (nth (map (fn [i] (map #(swap! counter + %) (take 3 (repeat 1)))) (iterate inc 0)) 1000))
18:59clojurebot(1 2 3)
19:00justin_smithemaczen: notice that I get the 1000th element from the outer map
19:00justin_smithbut the inner map is the first of the inner maps to be realized
19:00justin_smiththe rest, being lazy, have not been generated yet, because they were not accessed
19:06emaczenjustin_smith: I don't know enough clojure yet to follow it to a tee -- but what I think you are getting at is that the nested-maps will only evaluate till they get the 1000th item. Is that right?
19:07justin_smithemaczen: (iterate inc 0) gets the integers starting with 0
19:07justin_smith,(iterate inc 0)
19:07clojurebot(0 1 2 3 4 ...)
19:08justin_smithactually - let me simplify it, one moment
19:10justin_smith,(let [counter (atom 0)] (last (repeatedly 1000 (fn [] (map #(swap! counter + %) (repeat 3 1))))))
19:10clojurebot(1 2 3)
19:10justin_smiththat's equivalent, and hopefully easier to read
19:10justin_smithso, it's a lazy seq of evaluating that function 1000 times
19:10justin_smithand we are just taking the last item and returning it
19:11justin_smiththe item is generated by mapping an increment of the atom across [1 1 1]
19:11justin_smithin fact I should have written [1 1 1] instead of (repeat 3 1)
19:12justin_smithwhat's to be noted, is that for each realized element of that 1000 item sequence, the atom is incremented 3 times
19:12maveneagleI was watching Rich hickey's talk on reducers, I just want to understand how this line performs efficient compared to the old map & reduce -> (time (reduce + (r/map inc (r/filter even? v))))
19:12justin_smithbut you see at the end, it only got incremented 3 times total, even though we got to the 1000th item
19:12maveneaglei do understand fold is optimsed due to fork join
19:13emaczenwhat is the %?
19:14justin_smithemaczen: oh, that's a shortcut for anonymous functions
19:14justin_smith,'#(+ % %)
19:14clojurebot(fn* [p1__54#] (+ p1__54# p1__54#))
19:14emaczenit looks like a placeholder
19:14justin_smithit just means "first argument"
19:16emaczenso why aren't all the elements "realized"
19:16justin_smithemaczen: they are lazy, and were not accessed
19:16justin_smithwhich is why typically you really want referentially transperent functions generating lazy sequences
19:17justin_smithI intentionally made a contrived, non-transperent function (closing over the mutable atom) to demonstrate the behavior
19:18emaczenYeah, I would think the values would be 2998 2999 3000
19:18emaczenIf you count from 1
19:19emaczenWhich you aren't so subtract 1 from what I wrote above
19:19justin_smiththe first swap! returns 1
19:19justin_smithso it does count from 1
19:19emaczenoh ha
19:19justin_smithswap! returns the new value, and you added 1
19:20justin_smithwell, not you, but anyway
19:20emaczenCan you tell me what happends under the hood? A contrived example is just telling me that the first portion of the list is not evaluated?
19:20justin_smithunder the hood a lazy seq is a thunk
19:21emaczenthunk?
19:21justin_smitha function of no arguments returning the next element of the list
19:21justin_smithor, actually, returning a next element, followed by a "rest" that is a thunk
19:21justin_smithwhich is in turn the same
19:21justin_smithuntil one of them has an empty rest
19:25emaczenjustim_smith: It would probably be very educational to play with a thunk -- I've done this before in scheme. I'll have to look into it again but more in depth
19:26justin_smithemaczen: thunks are just how lazy-seqs are implemented
19:26justin_smithtypically you don't need to use them directly
19:26justin_smiththough we have delay, for doing similar things with explicit deref
19:26emaczenI just remember using "force" or something in scheme
19:26emaczenTo actually get the next element
19:31emaczenjustin_smith: Isn't the implementation of lazy sequences a starting value and a function to get you the next element?
19:31justin_smitha function that gets you next element and next function
19:31emaczenAnd when you actually want to get the next value, you just apply this function with the current value?
19:31justin_smithbecause that first function can only give you the first element
19:32justin_smithno
19:32justin_smithyou get a new lazy-seq at each step
19:32justin_smithor nil (empty)
19:46maveneaglewhy is the second line faster than the second line here (https://gist.github.com/anonymous/19702a4efdac2cedae97) I understand why the 3rd line is faster though
19:47maveneagle* second line faster than first line
19:47justin_smithmaveneagle: lazy-seqs have an overhead that r/map and r/filter do not
19:48maveneaglejustin_smith: ahh.. thanks! forgot about that
19:48justin_smithmaveneagle: as I was just describing to emaczen, the thunk created for each item
19:48justin_smithmaveneagle: r/map does not need to create that for each element
19:49bbloomgfredericks: i think i solved my irc time traveling problem
19:50justin_smithmaveneagle: for more info, you would likely find it informative to look at transducers. They solve a similar performance problem in a more generalized way.
19:50gfredericksbbloom: omg omg omg
19:50bbloomgfredericks: solution was to switch ISPs by moving across the country
19:50gfredericksbbloom: oh right of course
19:50gfredericksobvious in hindsight
19:50maveneaglejustin_smith: sure, I am gonna watch rich's talk on transducers
19:50justin_smithmaveneagle: whereas reducers specialize map, filter, etc. for reduce, transducers generalize them to be efficiently used for any source / sink of data generally
19:51bbloomgfredericks: if i start time traveling again, you let me know so that i can move back before i test another solution. we want to be scientific about this
19:52gfredericksbbloom: I bet if you had called the IRC call center they would've made you try that before anything else
19:52justin_smithbbloom: my guess was that you were in a weird spot in respect to the infrastructure of the Internet that would cause you to be separated in multi-jump netsplits from most of us
19:52bbloomi always refuse to unplug it and plug it back in again
19:53gfredericks~bbloom is in a weird spot in respect to the infrastructure of the Internet
19:53clojurebotA nod, you know, is as good as a wink to a blind horse.
19:53ennSo Clojure Autodoc, Marginalia, and Codox all generate fairly fancy multi-column layouts for the documention. Can anyone recomment a tool that generates something more basic?
19:54emaczenin core.match, can a pattern be a predicate? I'm pretty sure I've seen this functionality in elisp's pcase.
19:55bbloomemaczen: https://github.com/clojure/core.match/wiki/Basic-usage#guards
19:58crazydiamondHi. Are there data structure processing algorithms that require state by definition? I have solved my idea with a bit of imperative code, but not sure that I can turn it into pure functional
19:59justin_smithcrazydiamond: there is a proof that any mutation can be refactored into extra args / return values that are threaded through the code
19:59justin_smiththis is very easy to do with loop
19:59clojurebotRoger.
19:59justin_smithclojurebot: I wasn't talking to you
19:59clojurebotCool story bro.
19:59crazydiamondjustin_smith, interesting
20:00justin_smithcrazydiamond: of course where this gets tricky is if you had multiple mutations within one loop
20:00justin_smiththen you need to refactor things so there is one threading of the updated values from top to bottom
20:00crazydiamondso, my example: I have DS like this [[1] [[1]]]. I want to take out common parts [1]
20:01crazydiamondthere's it solved in imperative way with Python: 4
20:01crazydiamond[(0, 1), (1, [0]), (2, [1]), (3, [2]), (4, [1, 3])]
20:01crazydiamondi.e. 4 is list (say, vector) with 1 and 3:
20:01crazydiamond[0_] [2_]]
20:02justin_smithI have no idea what any of this means, sorry
20:03crazydiamondwell... imagine (clojure.walk/postwalk f some-data-structure)
20:03crazydiamondwhere (defn f [x] (do (println x) x)))
20:03crazydiamondi.e. prints and returns the value
20:04bbloomcrazydiamond: if you need state over a traversal, idiomatic clojure is to simply use mutable state
20:04crazydiamondand I want to gather that values instead of returning them
20:04bbloomcrazydiamond: unless you need something more advanced, like the ability to backtrack or go down multiple traversal paths in a non-standard order or something
20:04bbloomcrazydiamond: however, if you are interested in how you'd do this more functionally just b/c, then may i suggest looking at zippers
20:05gfredericks~zippers |are| the lenses of monads
20:05clojurebotc'est bon!
20:06crazydiamondwell, traversal, when I visit each node-by-node
20:06crazydiamondi.e. next node knows about what happened when visiting all previous
20:07crazydiamondin typical traversal it knows only about it's parents
20:07crazydiamondnot siblings
20:07justin_smithcrazydiamond: what about just using tree-seq
20:07crazydiamondI should check that out
20:08justin_smithand having a reduce over the tree-seq that carries the state you care about in the accumulator
20:08bbloomcrazydiamond: do you care about the context of the tree? ie parents/siblings, or do you only care about the state threaded through the traversal?
20:08bbloomif just the state, yeah tree-seq is what you want
20:08bbloomif actual parents/children/etc, then look at zippers
20:08crazydiamondstate, yes
20:08bbloomin both cases, it's just a "left fold"
20:08crazydiamondhow to say that...
20:09bbloomthe idea is to flatten the traversal of the tree in to something like a list, then reduce over the list + some state
20:09crazydiamondI have structure with huge amount of repeating parts
20:09crazydiamondI want to achieve the same goal what "let" is for
20:09crazydiamondsay that
20:10emaczenis there a flat-map function in clojure?
20:10emaczenIn CL I did reduce #'append
20:10justin_smithemaczen: apply concat
20:10crazydiamond[[1] [[1]]] become (let [a [1]] [a [a]])
20:10emaczenI'd rather use something like flat-map though
20:10justin_smithor mapcat
20:10bbloom,(reduce (fn [acc x] (update-in acc [x] (fnil inc 0))) {} (tree-seq vector? seq [[1] [1 [1] [1]]]))
20:10clojurebot{[1 [1] [1]] 1, 1 4, [1] 3, [[1] [1 [1] [1]]] 1}
20:10bbloomcrazydiamond: something like that ^^
20:11justin_smith,(frequencies (tree-seq vector? seq [[1] [1 [1] [1]]])))
20:11clojurebot{[[1] [1 [1] [1]]] 1, [1] 3, 1 4, [1 [1] [1]] 1}
20:11justin_smith:)
20:11bbloomjustin_smith: yes, but that won't teach him how to use reduce to emulate state
20:11bbloom:-P
20:12justin_smithof course
20:12crazydiamonduhm, that's exciting anyway
20:12crazydiamondthanks!
20:12crazydiamondUncle Bob was talking "with state monad you may have state when you haven't"
20:12crazydiamondso this must be the case
20:12justin_smithcrazydiamond: bbloom: I finally realized that weird vector of numbers and vectors above was probably just "frequencies" over subtrees
20:13justin_smithcrazydiamond: the one where I was just like "wait, I don't even know what that is supposed to be"
20:13emaczenIs there a mutable version of map like forEach?
20:13bbloom,(reduce (fn [acc x] (update-in acc [x] (fnil inc 0))) {} (tree-seq vector? seq [[:x] [:x [:x] [:x]]])) ; clearer
20:13clojurebot{[:x [:x] [:x]] 1, :x 4, [:x] 3, [[:x] [:x [:x] [:x]]] 1}
20:13justin_smithdoseq
20:13emaczenehh nvm
20:13bbloomemaczen: in clojure 1.7 there will be run!, but yeah, doseq is what you have to use otherwise
20:14emaczenwhat is run!
20:14bbloom,*clojure-version*
20:14clojurebot{:interim true, :major 1, :minor 7, :incremental 0, :qualifier "master"}
20:14bbloom,(run! prn [1 2 3])
20:14clojurebot1\n2\n3\n
20:14bbloom,(doc run!)
20:14clojurebot"([proc coll]); Runs the supplied procedure (via reduce), for purposes of side effects, on successive items in the collection. Returns nil"
20:23emaczenhow do you refer to a function without the (fn [x] ...)
20:23emaczensorry let me restate
20:24emaczenInstead of (fn [x] (some-function(x)))
20:24emaczenCan you do #'some-function?
20:24Bronsaemaczen: assuming you mean (fn [x] (some-function x)), that's equivalent to some-function
20:25timvisheremaczen: what are you trying to achieve?
20:25Bronsaemaczen: and more or less equivalent to #'some-function too if you don't take into account var redefinition
20:25timvishergiven your nick, are you thinking that passing a function to another one requires special quoting like it does in elisp?
20:25emaczenI got it -- in common-lisp often you will write (mapcar #'some-function some-list)
20:25emaczenIn clj you can just write the function
20:25timvisheryeah, in clojure that's just (map func ...)
20:26timvisheryep
20:26Bronsaemaczen: #' in clojure doesn't mean what it means in cl
20:26emaczenI was trying all of these weird # combos
20:26timvisheremaczen: glad you're sorted out :)
20:26justin_smithbut funny enough it will sometimes look like it is
20:27justin_smith,(map #'inc (range))
20:27clojurebot(1 2 3 4 5 ...)
20:31emaczenthanks for all the help today guys -- getting spun-up on Clojure from common-lisp is really fun!
20:32justin_smithEmpperi: I think it'll grow on you as well
20:36vasdatomic is really cool
20:43crazydiamondcan "loop"s be nested?
20:44justin_smithyes
20:44justin_smiththe recur will work going to the innermost loop in the context
20:45crazydiamondis there "depth" function with signature like tree-seq's one? :D
20:49gfrederickswhat would it return?
20:50gfredericksthe depth of the input?
20:50crazydiamondyes
20:50crazydiamondI have written one, though (but simpler one)
20:51crazydiamondhttp://dpaste.com/1MENVQ7
20:53gfredericks,(defn tree-depth [branch? children root] (let [walk (fn walk [node] (if (branch? node) (inc (reduce max (map walk (children node)))) 0))] (walk root)))
20:53clojurebot#'sandbox/tree-depth
20:53gfredericks,(tree-depth 4)
20:53clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox/tree-depth>
20:53gfredericks,(tree-depth coll? seq 4)
20:53clojurebot0
20:53gfredericks,(tree-depth coll? seq [4])
20:53clojurebot1
20:53gfredericks,(tree-depth coll? seq [4 [1]])
20:53clojurebot2
20:53gfredericks,(tree-depth coll? seq [4 [[4] 1]])
20:53clojurebot3
20:54gfrederickssomethinglikethat
20:54gfredericksI think it crashes on an empty collection so good luck
20:54crazydiamondcool, thanks
20:56gfredericksI don't know what an empty collection means in terms of depth anyhow
20:56crazydiamondeither +1 or +0 :D
20:56gfredericksyeah one of those
21:03arohnerwhen using #'proxy, is there a way to proxy the constructor?
21:10crazydiamond,(defn tree-depth-check-empty [branch? children empty root] (let [walk (fn walk [node] (if (branch? node) (let [children (children node)] (if (empty? children) empty (inc (reduce max (map walk children))))) 0))] (walk root)))
21:10clojurebot#'sandbox/tree-depth-check-empty
21:10crazydiamond,(tree-depth-check empty coll? seq 4)
21:10clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: tree-depth-check in this context, compiling:(NO_SOURCE_PATH:0:0)>
21:10crazydiamond,(tree-depth-check-empty coll? seq 4 0)
21:11clojurebot0
21:11crazydiamond,(tree-depth-check-empty coll? seq 4 1)
21:11clojurebot0
21:11crazydiamond,(tree-depth-check-empty coll? seq [4] 1)
21:11clojurebot0
21:11crazydiamond,(tree-depth-check-empty coll? seq 0 [4])
21:11clojurebot1
21:11arrdemo/
21:11crazydiamondLOL
21:11crazydiamondso many arguments so easy to mess up
21:50mistaBIZWow its deep
22:03devllhi, I deployed a clojar from the latest source,but I am getting this error
22:03devllCaused by: java.lang.IllegalArgumentException: Can't define method not in interfaces: with_meta, compiling:(clj_http/headers.clj:105:1)
22:04devllcode is here. https://github.com/dakrone/clj-http/blob/master/src/clj_http/headers.clj#L120
22:05devllhow can I resolve this?
22:06arrdemdevll: what's the full stack trace and what else are you using/doing?
22:06arrdemdevll: just that isn't enough to go on besides telling you to open an issue on the clj-http bugtracker.
22:06arrdemand even that may not be in order depending on what you're up to..
22:08devllthis is a known issue for long
22:09devllclj-http 1.0.1 does not support clojure 1.7
22:09devllwhich is the latest version for clj-http
22:10arrdemhttps://raw.githubusercontent.com/dakrone/clj-http/1.0.1/project.clj
22:10devllhttp://pastebin.com/1Ld4D8Q7
22:10devllfull trace here
22:11arrdemclj-http 1.0.1 doesn't depend on any version of Clojure. In fact it explicitly excludes any specific version of clojure from its transitive deps. You're probably trying to use 1.7-alphaN which doesn't work.
22:12devllyes.
22:14arrdemwhat are we on... alpha4 right now?
22:14arrdemdoesn't look like there's a matching issue on jira..
22:14devllcompability fix has been merged into clj-http master.
22:14devllthere is but closed
22:15devllalpha5
22:16arrdemdevll: what commit fixes this? I'm not seeing one but still looking.
22:17devllhttps://github.com/dakrone/clj-http/commit/ccd4f10ce9fc748a882b27d57408145cb3e3b057
22:17arrdemthat shouldn't fix the issue you posted a stacktrace for...
22:18devllit fixes another issue
22:18arrdemright.
22:18arrdembut not the one you seem to care about.
22:18ennI'd like to find a way to figure out whether a certain function is anywhere on the call stack. I thought I'd be able to do this by examining the JVM stacktrace, but I've run into a wall.
22:19ennIf I have a function: (def foo [] (map bar some-sequence)), and I look at the stacktrace (with (.. Thread currentThreat getStackTrace)) from within bar, foo doesn't appear anywhere, because by the time the sequence is realized foo has already completed.
22:20devllusing clj-http 1.0.1 causes "update" related issue. using the latest build throws the error above
22:20arrdemdevll: my gut is that you've found a bug in the alpha and should probably report it.
22:20devllOK
22:20ennSo I guess what I'd like is a way to get the "logical" call stack. Does such a thing exist?
22:21devllI am downgrading to 1.6.0
22:21arrdemenn: no, Clojure keeps no "logical" call stack.
22:21devllfor this though
22:21devllor my online app will not work.
22:21ennarrdem: well, shoot. OK, thank you.
22:21arrdemenn: so you're hitting an issue with lazy evaluation.
22:22devllthanks arrdem as well
22:22ennyeah
22:22arrdemenn: if you _really_ want to see foo in your stack, try mapv (which is strict) or use doall
22:22arrdem$grim clojure.core/doall
22:22lazybothttp://grimoire.arrdem.com/1.6.0/clojure.core/doall
22:22arrdem$grim clojure.core/mapv
22:22lazybothttp://grimoire.arrdem.com/1.6.0/clojure.core/mapv
22:23ennarrdem: unfortunately this is in the context of instrumenting arbitrary code, so I can't really banish lazy sequences altogether
22:25ennI guess plan B is, alter-var-root on the function I'm looking for (foo) so that it dynamically binds some flag, which I can then check for in bar
22:26arrdemenn: I guess that could work..
22:26arrdemI think dynalint and some other tools do some similar var introspection hackery to build a logical call stack.
22:26arrdemtracer...? it's been a long time since I used it last.
22:27arrdemhttps://github.com/xumingming/tracer
22:27arrdemhttps://github.com/clojure/tools.trace
22:28arrdemI'm pretty sure both of those do var poisoning akin to what you're after... as does technomancy/radagast
22:28amalloyenn: dynamically binding a flag will have exactly the same problem
22:29amalloyfoo has finished by the time you realize the results of map, so of course the flag will no longer be dynamically bound either
22:29ennamalloy: yeah, I just discovered that. Damn.
22:31ennWhat I'm trying to do is implement something like tools.trace, with an option to only trace function bar when it is called down-stack of foo. (This is a shameless copy of the :wherein option to SBCL's trace, http://www.sbcl.org/manual/#Function-Tracing.)
22:31ennBut it sounds like this is not possible in the general case in Clojure.
22:31clojurebot'Sea, mhuise.
22:31gfredericksoh because of laziness?
22:31ennYeah
22:32gfredericksmaybe if you modified the lazy-seq macro, but that sounds sooper hairy
22:32gfredericksi.e., it could save your dynamic bindings before executing the thunk
22:32gfredericksor something I mean youseewhatimsayin
22:33gfredericksI think modifying the lazyseq macro like that might be damn near impossible though w/o forking clojure
22:34ennyeah, I'd be worried about things breaking
22:53arrdemI assume that the string "RELEASE" as a lein version specifier refers the latest release?
22:54arrdemJust trying to grok how this works https://github.com/lshift/cloverage/blob/master/lein-cloverage/src/leiningen/cloverage.clj#L9
23:02WonkyWombatHi all, I'm a Clojure-N00b and get it power in using the JVM platform but can Clojure operate on it's own in a desktop or server, *not* using the JVM for delivery?
23:03gfredericksnot clojure the jvm language, no
23:04WonkyWombatgfredericks: right, does Clojure have access to libs or frameworks for TCP/IP-systems frameworks?
23:05gfredericksonly inasmuch as Java does
23:05gfredericksfor questions like that you can consider Clojure to be just a java library
23:05WonkyWombatgfredericks: that puts it into perspective
23:06WonkyWombatSo it may not be the best choice for writing a tool that can almost forensically examines, reports and backups a web site/application?
23:08WonkyWombatgfredericks: thanks for the candour, I'll read further on Java's ability for networking
23:08gfredericksnp
23:08juggernotWonkyWombat: it might be since that seems like a long running process
23:09juggernotis there a particular reason you want to avoid Java/JVM?
23:09WonkyWombatjuggernot: Have this perhaps incorrect view that Java is second rate with networking compared to Python etc
23:11juggernotoh i see... well there's always the ClojureScript on nodejs route if you dont have any qualms about nodejs
23:12WonkyWombatjuggernot: k, aware but have not read up
23:47WonkyWombatDid we have a net split or something? Awful lot of In/Out