#clojure logs

2014-05-11

02:49servocan you perform a function on destructuring? something akin to (let [[(keyword x) (keyword y)] ["foo" "bar"]])
04:16sveriHi, I have trouble with js interop, I am trying to initialize a tokenfield for an input but dont succeed, I always get "object is not a function error" whenever I type in the input field (the autocomplete gets initialized, so the error must be somewhere inside the #js object I guess), this is the js code I want to convert to cljs code: http://pastebin.com/cxd1P8hc
04:19hiredmanI don't think #js is recursive
04:20sverihiredman: you mean I should try it like this: :autocomplete #js {:source...?
04:22sveriah, this seems to be working, at least it tries to connect to the server
04:22sverithank you very much
05:19klokbaskehi there! trying to build a project with a dependency on a jar. Normally I specify dependencies in my project.clj, but I'm not sure what to do with this one
05:19klokbaskeHow do I find out what to specify in the dependencies list?
05:56ptcekklokbaske: you mean you have a jar file that is not in a repository (such as clojars?) if this is the case, add it to your own local repo; this may help: https://github.com/kumarshantanu/lein-localrepo
06:00martinklepschanyone experience with upserting documents into elasticsearch using elastisch by clojurewerkz? I'm uncertain if I should build a bulk upsert query on my own or use the native document/upsert function; more here: https://groups.google.com/forum/#!topic/clojure-elasticsearch/bZ7owwef1fo
06:03klokbaskeptcek: I think it's in a repo - at least I found a pom.xml referencing it:
06:03klokbaskehttp://jvstwrapper.cvs.sourceforge.net/jvstwrapper/jvst_examples/dist/pom.xml?view=markup
06:03klokbaskebut i'll look into your link, thanks :-)
07:26mi6x3mCan a lazy seq be built with loop recur?
08:12yotsovhttp://arstechnica.com/science/2014/05/scientific-computings-future-can-any-coding-language-top-a-1950s-behemoth/ this article gives me the impression that a clojure that can interop with fortran (a clojure that compiles to fortran maybe) could have its users
08:13yotsovit seems to be big selling point for julia in academia
08:27mi6x3mHello, I wrote this function as a solution to problem #30 on 4clojure: http://pastebin.com/V4d8nHMT. Can someone provide me some hints if this is a good / idiomatic solution?
08:28mi6x3mthe task as to compress a sequence, i.e. remove consecutive duplicates
08:33Glenjaminmi6x3m: seems broadly sensible
08:34Glenjamini don' think remove-run needs to be extracted
08:35mi6x3mGlenjamin: yeah, I did it just for prototyping
08:35Glenjaminand you generally are supposed to use (seq) instead of empty?
08:35mi6x3mGlenjamin: ah, why is that?
08:35Glenjamini have no idea tbh
08:35Glenjaminits just something i see often
08:35Glenjamin"seq is idiomatic"
08:36Glenjamini assume there's a reason
08:36mi6x3myeah I heard it yesterday as well
08:36mi6x3mbut empty? is just "(not (seq coll))"
08:37Glenjaminyou can collapse your if and let down into and if-let
08:37Glenjamin,(if-let [[h & t] (seq [])] :t :f)
08:37clojurebot:f
08:37Glenjamin,(if-let [[h & t] (seq [1])] :t :f)
08:37clojurebot:t
08:37mi6x3mah, yes, thanks, if-let yeah of course
08:39mi6x3mwow, Glenjamin, thanks so much
08:39Glenjamin,((fn compress [coll] (if-let [[h & t] (seq coll)] (cons h (lazy-seq (compress (drop-while #(= h %) t)))))) [1 1 2 2 3])
08:39clojurebot(1 2 3)
09:29agarmananyone use timbre logging library?
09:36gyimi do
09:38agarmangyim how's it working out? to me, it looks like it involves a lot of logging code added to all the functions
09:39gyimwhat do you mean?
09:39gyimin our app we have a few custom appenders, but only a few lines long
09:40agarmanyeah I started writing a kafka appender
09:40gyimoh i see... i am simply logging to file / console
09:40Glenjaminagarman: are you concerned about littering all your functions with logging code?
09:41agarmanI kinda want to be able to add profiling to namespaces, without messing with the fns in the namespace, AFAIK timbre requires you to wrap fns with pspy to profile
09:42Glenjaminyou can do defnp
09:42agarmanGlenjamin exactly...most of the application is pure, occasionally I want to profile...tools.trace is good in a repl
09:42Glenjaminsomething like this perhaps? https://github.com/MichaelDrogalis/dire#pre-hooks
09:42agarmanbut I want something that works well with logging to a db
09:43agarmanI'd looked at that last week. And surprisingly forgot about it, because Michael & I were talking about a lot of stuff
09:45agarman_network fun
09:45agarman_thanks for the reminder of dire...
09:49shiranaihitoIntelliJ IDEA forgot what Java looks like again.. does anyone remember how to fix this? -i've tried "invalidating caches", and even deleted Library/Caches/<etc> .. but no luck
09:50justin_smithforgot what java looks like?
09:50justin_smithsome kind of cursive bug?
09:51shiranaihitoit's a bug in IDEA, pops up every now and then.. now i'm switching from Java 7 to 8, and it went wonky again
09:51shiranaihitonow it says "java.lang.String" is an unrecognized symbol or something, paints all std java classes in red.. :P
09:51justin_smithwoah
09:52shiranaihitoyeah :P
09:52shiranaihitothis is really annoying
09:52justin_smithbtw the new syntaxes for first class methods in 8 are cool
09:52shiranaihitocompletely prevents you from doing anything, but pops up so rarely that you don't remember how to fix it :P
09:52justin_smithSystem.out::println
09:52shiranaihitoyeah, Java 8 is pretty sweet
09:52justin_smithfirst class
09:53shiranaihitooh? i didn't remember about that
09:53shiranaihitothe new lambdas are great too
09:53justin_smithSysem.out::println = (s) -> System.out.println(s)
09:54justin_smithmakes sense, really
09:56shiranaihito:P
09:59justin_smithshiranaihito: http://stackoverflow.com/a/5905931/2258453 see comment from pastafarian
09:59shiranaihitoi had overlooked one "project language level" -setting btw .. now it's back to normal :p
09:59justin_smithoh, OK
10:00shiranaihitothanks for the tip anyway! :)
10:00justin_smithI am a total luddite using emacs (learning java 8 as my first java, as a resume / portfolio building thing)
10:01shiranaihito:P
10:01justin_smithI am excited to try things like Stream.reduce()
10:01shiranaihitowell, i couldn't live without JetBrain's IDEs myself
10:01shiranaihitothe best tool for the job and all.. :P
10:02shiranaihitommm
10:02justin_smithright - I just don't think about using another env
10:02shiranaihitowell, at least Java jobs are plentiful
10:02shiranaihitoand Java 8 is a really great update.. makes the language much more palatable for snobs too :P
10:02justin_smithright, that's the idea - my clojure job layed me off and hired a java guy :/
10:03shiranaihitowow :/ .. how did that happen?
10:03shiranaihitodid they decide to ditch clojure?
10:03justin_smithwe moved up to bigger clients, and with that success they get more clients that dictate backend
10:03justin_smithor have existing codebases
10:03justin_smithetc.
10:03shiranaihitoah
10:03shiranaihitoyeah, well.. even Python jobs are really rare
10:04justin_smithand everyone's like "your setup looks nice, but I wouldn't be able to find clojure devs ten years from now"
10:04shiranaihitoi've got a Java background, actually, but learned to be comfortable with Python too.. now i'm getting used to Clojure
10:04shiranaihitoClojure might be everywhere in ten years though :P
10:05justin_smithas a self-educated coder, I am coming into this all backward, scheme/ocaml/lisp to clojure to java...
10:05shiranaihito:P
10:05justin_smithshiranaihito: well, if it was me talking to the clients I would try to tell them that
10:05shiranaihitothat's certainly an unusual progression :P
10:05shiranaihitowell, it's understandable they feel that way _now_.. but they sure as hell don't know anything about what the world will be like in 10 years
10:06shiranaihito(no one does)
10:06shiranaihitobut yeah.. it's just business
10:06shiranaihitonothing personal
10:06justin_smithshiranaihito: that they will find java devs in 10 years, given the pace of acedemia and the current cs curriculum, is a safe bet
10:06shiranaihitothe people giving up their money for a company's services kind of dictate what the company does :p
10:07justin_smithshiranaihito: right, it was a layoff, not a firing, I'm collecting unemployment for a minute and building my resume
10:07shiranaihitoyeah
10:07justin_smithexactly
10:07shiranaihitostart your own business btw, it's the best thing you can do for your financial independence/well-being
10:07justin_smithI'll consider it
10:07teslanickand for some people, the worst thing you can do for your sanity. :)
10:07shiranaihitoit's really difficult, of course, but everything worth doing is.. :P
10:08shiranaihitoteslanick: :P
10:08shiranaihitofreelancing/contracting is a step in the right direction
10:08justin_smithshiranaihito: you use the :P emoticon so much, I am picturing you as a pug that learned to type
10:08Glenjaminmost decent jobs i see these days are "perm only"
10:08shiranaihitodo pugs tend to be particularly smiley? :P
10:09teslanickOr: http://imgur.com/BCxVZ2p
10:09Glenjaminno-one around here wants to hire contractors for interesting stuff
10:09justin_smithshiranaihito: their tongues are always hanging out
10:09shiranaihitoGlenjamin: yeah, lots of companies want "commitment".. but you may be able to negotiate a contract position anyway - you can agree to a long contract too, etc
10:10Glenjaminyeah, its odd that "salaray" is equated with "commitment"
10:10shiranaihitoGlenjamin: well, they're just thinking about an employee as a "long-term investmen" kind of deal
10:10Glenjaminright, they think the relationship is asymmetrical
10:11Glenjaminthey believe that I owe them something beyond the work i produce for the salary i'd get
10:11shiranaihitoan employee willl take some time to become productive, to get used to how the business operates, to become knowledgeable in their systems and products etc
10:11Glenjaminwhereas in practice i find that we're at least even
10:11shiranaihitofrom a business perspective, it's a "loss" to have to start over with a new guy
10:11shiranaihitommm
10:11Glenjaminunless that guy is sufficiently experienced to hit the ground running, and improve their systems for the better
10:12shiranaihitoi don't think they feel "entitled" to anything from you outside of your work arrangement
10:12Glenjaminevery job i've left, i left them in better shape than when i started
10:12shiranaihito.. if they do, they've got issues
10:12Glenjaminnot purely through my own work, but i certainly contributed
10:12shiranaihitobut what i just explained is certainly a factor
10:13Glenjaminthat "long term investment" thinking is an entitlement though
10:13shiranaihitoit's just a business consideration - switching employees incurs costs to them
10:13Glenjaminyes, but when you hire a permanent employee, you give them ~3 months notice
10:13Glenjaminyou don't own them forever
10:13shiranaihitonope, it's just a business consideration :P .. we might not like it, but it's just them pursuing their personal gain, just like we all pursue ours
10:13Glenjaminoh, certainly
10:14shiranaihito"own them forever"?
10:15Glenjaminbasically, there's no rule that says contractors switch more
10:15shiranaihitoofc not, but they feel like a salaried employee is a "safer bet"
10:15shiranaihitoand/or they just don't think things through, etc
10:15Glenjaminyeah - thats the bit i'm disappointed in
10:15shiranaihitoyep, but that's something you can work around by negotiating etc
10:15teslanickWell, most employees aren't maintaining a client list or a pipeline.
10:16Glenjaminmost decent employees could find another tech job in < 1 month in the current climate
10:16shiranaihitoyeah
10:16Glenjaminespecially if they're willing to move
10:16shiranaihitoyou in the US?
10:16teslanickIt's true
10:16Glenjamini'm in the UK
10:16shiranaihitook, Finland here
10:17teslanick(US here)
10:17shiranaihitok
10:17shiranaihitowe're kind of fortunate to be developers anyway
10:18shiranaihitobut people don't exactly appreciate things they take for granted :P
10:18shiranaihito(myself included!)
10:18shiranaihitoanyway, freelancing --> business is the way to go :P
10:19shiranaihitoor just straight to starting a business :P
10:19shiranaihitofreelancing/contracting gives you a pretty sweet pay raise too
10:20Glenjaminif i had an idea, i'd be all over a business
10:20teslanickIn the US, most of that raise gets plowed into buying health insurance.
10:20shiranaihitoin finland, contracting gets you roughly double what you'd get as your gross salary
10:21shiranaihitoGlenjamin: same here.. :P i'm back to square one, and somewhat paralyzed by the fear of implementing "a solution in search of a problem"
10:21shiranaihitoteslanick: yeah, obamacare is immensely destructive
10:22teslanickThat's not really fair: health insurance is expensive in the U.S., especially if you want it to actually cover anything.
10:22shiranaihitoteslanick: what kind of "insurance" is something that you're basically forced to buy? :P
10:22teslanickThe ACA just makes it mandatory to buy that expensive insurance. (lame)
10:22shiranaihitowhat do you think it does to prices when you're forced to buy something?
10:23shiranaihitoyep
10:23shiranaihito"mandatory" being the operative word there
10:23teslanickAt this point, nobody knows what's going to happen. The market here is so dysfunctional
10:23shiranaihitoimagine the government forcing you to buy McDonald's burgers :P
10:23shiranaihitoseem familiar somehow? :P
10:24shiranaihitoyep
10:25teslanickEveryone can have an opinion about it and they're all equally valid, because the legislation is thousands of pages long and nobody knows which parts are actually practical or not.
10:25shiranaihitowhat would happen to the price of a Big Mac if everyone was forced to buy them?
10:26shiranaihitoyeah well, the legislation is an incomprehensible mess, but that's not exactly an accident
10:26Glenjaminmy understanding was that it's more akin to forcing everyone to buy a burger
10:26Glenjaminbut the individual is free to choose which one
10:26shiranaihito:P
10:27Glenjaminanyway, we have nationalised healthcare here paid for by taxes, a system i much prefer
10:27shiranaihitook, imagine there are five massive burger chains, and everyone is forced to keep buying burgers from one of them.. what happens to the prices?
10:27shiranaihito(the forced "customers" are spread roughly evenly among the five chains ofc)
10:28Glenjaminif "one of them" means "any one of them", prices would go down
10:28shiranaihitoGlenjamin: yeah, and there you're forced to "buy" NHS' services :p
10:29Glenjaminboth the price and service levels are regulated, meaning: if i get hit by a bus, they'll fix me up
10:29Glenjaminanyway, this is very OT for a clojure room :)
10:29nathan7go compute why the world sucks, y'all
10:31shiranaihitowell, the point was that if you're forced to pay for something, you're not a customer in any real sense of the word -- being a customer implies choosing something and voluntarily paying for it
10:31shiranaihitoand if you're forced to buy X, then its producer has no incentive to maintain/improve quality, or to lower costs
10:32shiranaihito(and this applies to all public services btw :p)
10:34teslanickAlthough evidence suggests that "open" markets for purchasing health care and insurance raises real costs faster than government-provided health care.
10:35Glenjaminalso, if you have no money, you die - which is what public services guard against
10:35teslanickThe United States spends 17% of GDP on health care, vs. 10% in Canada and the UK. Both countries have better health care outcomes in the general case.
10:46shiranaihitoMcDonald's forcing you to buy its burgers would be outrageous and clearly immoral, but the government forcing you to pay for health care, insurance, or aircraft carriers and military bases all over the world is.. perfectly fine? :p
10:52teslanickDepends on your moral priors, like anything.
10:53justin_smithshiranaihito: not to mention police, and roads, and the internet
10:54shiranaihitowell, coercion is immoral regardless of what supposedly good "outcome" someone thinks he'll achieve by doing it.. for example, i'm not allowed to force you to eat carrots even if they're good for you
10:56justin_smithallowed by whom? we coerce for the public good all the time, and every human society in the history of ever has as well
10:57justin_smithfor example we coerce people not to claim goods that are already previously claimed, AKA property law
10:58shiranaihitothat's true, but we all know that coercion is immoral on an individual level
10:58shiranaihitowell, you can't defend your property before someone tries to take it :)
12:00whilois it necessary that one cannot use <! in for-comprehensions (inside a go-block)?
12:06Glenjaminwhilo: i suspect it's because for is lazy
12:06Glenjamintry doseq instead
12:06whiloGlenjamin: yes, well i need all results. i also tried to put it into doall
12:07Glenjamin,(doc doseq)
12:07clojurebot"([seq-exprs & body]); Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by \"for\". Does not retain the head of the sequence. Returns nil."
12:08whiloyes, but i need the return value, i have used doseq before
12:08whiloit just turned out i need some boilerplate wrapping, first returning channels in the for-comprehension and then using async/merge, async/into etc
12:09Glenjaminoh, sorry - for some reason i thought doseq returned the result
12:10whilosince the for comprehension is actually compiled by the go-macro (contrary to closures), i thought it could be transformed into synchronous code
12:10whilowas just wondering, if it was possible
12:11Glenjamini would have assumed that was possible
12:11coventrywhilo: Can you give an example of a for comprehension which doesn't work, or a citation for it? Hadn't heard of that limitation.
12:14whilocoventry: (go (println (for [i [1 2 3]] (<! (go i)))))
12:17whilo,(go (println (for [i [1 2 3]] (<! (go i)))))
12:17clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: go in this context, compiling:(NO_SOURCE_PATH:0:0)>
12:18coventrywhilo: Interesting. Thanks.
12:32coventry(def d (go (for [i [1 2 3]] (println (<! c))))) ; <- Fails with "<! used not in (go ...) block" if you (take! d println)
12:35coventryIt looks like the go macro doesn't walk into for loops. I wonder why.
12:35seangroveLaziness/
12:35seangrove?
12:41coventryMaybe because for wraps its body in a fn.
12:41Anderkenthm, is anyone else having issues with loading core.async using lein try?
12:42coventrywhilo, seangrove: Yeah, I think that's why. (def d (go (for [i [1 2 3]] (go (println (<! c)))))) kind of works.
12:46Bronsacoventry: I think it's becasue the body is wrapped in a fn, yes
12:46whiloseangrove: right, but i was wondering whether the laziness could be transparent in this case, so the go macro can transform its body into a state-machine (which is lazy)
12:46whilook, makes sense
12:47seangrovewhilo: Yeah, part of the drawback to having it as a library and not a core language (or runtime?) feature, I think
12:49whiloyes. wrapping in async/boilerplate is verbose, yet still readable with the threading macros. i was just wondering whether in this case it could resolve the for-comprehension, because it knows all the code (while closures in general can be compiled outside of the go macro)
12:49Anderkentwith core.async, is there a way of synchronously getting a value from a channel if available, or returning nil immediately if not?
12:51Anderkenthm nevermind maybe i don't need that after all
12:54coventryIs there anything in the for macro which stops it from being expressed as a set of loop/recurs?
12:56coventryOh, maybe the lazy-seq? In which case maybe laziness is the blocker, in a way.
13:00coventrywhilo: To make that work, the go macro would have to be able to tell when a for loop is being passed out as a value, and somehow re-institute standard laziness in that case.
13:00whiloyes, i picture it is not trivial
13:00whiloprobably a for< or sth. would make sense
13:01whiloin the core.async api
13:02whiloor just for, because you wouldn't pass in a channel per se
13:26seangrovebbloom: How would you express the requirements for 2 and 3 here? https://dl.dropboxusercontent.com/u/412963/screenshots/layout_strategies.jpg
13:26seangroveI'm wondering if I need to introduce ideas like {:strategy :expand :width 230 :height :remaining}, etc.
13:27seangroveOr {:strategy :fixed :width 230 :height (fn [state] (- (:window-height state) 50)) }
13:32Anderkentugh, core.async channels aren't IObjs? :/
13:37amalloyAnderkent: i'm not sure how you would make use of IObj. if you (with-meta some-channel m), does the resulting channel read-through or write-through from the original channel? neither? both? do they somehow share messages, or does the new one steal all the messages?
13:37Anderkentwell, is that any different than just having two references to the same channel?
13:38amalloywell yeah. two references to the same channel are identical?
13:39Anderkenthm, why is that important?
13:40AnderkentI don't see the difference bwteen two reads from 'identical?' chans, and two reads from '=' chans
13:42Anderkentoh, I see your point, I was thinking in terms of the interface, you were talking about the implementation
13:47mi6x3mIs there a function to remove a prefix from a sequence
13:47mi6x3mif I know some sequence is a prefix of another?
13:48opqdonutwell you can always do (take (count prefix) the-sequence)
13:48opqdonuterr sorry
13:48mi6x3mdrop
13:48mi6x3myes
13:48opqdonuts/take/drop/
13:48opqdonutbut I haven't really seen anything that would remove a prefix using equality checking
13:49opqdonut(of course it's pretty straightforward to implement)
13:51amalloymi6x3m: i think https://github.com/flatland/useful/blob/develop/src/flatland/useful/seq.clj#L244 is that function
13:52mi6x3mamalloy: right, this one yes :)
14:12whiloseangrove: is this an application you build?
14:14seangrovewhilo: ?
14:14whiloseangrove: the screenshot you linked
14:15seangrovewhilo: Oh, sorry. It's kandan/Omchaya/my goto app to rebuild when testing out ideas
14:24visof,(str "http:\/\/hello.com")
14:24clojurebot#<RuntimeException java.lang.RuntimeException: Unsupported escape character: \/>
14:25visofif i have string like this, how can i remove \ from it?
14:28mi6x3mclojure how do you get an empty sequence?
14:28technomancy,(doc empty)
14:28clojurebot"([coll]); Returns an empty collection of the same category as coll, or nil"
14:29mi6x3mvisof: with filter?
14:29amalloymi6x3m: () is empty. do you want something else?
14:29dnolen_,(.replace "http:\/\/hello.com" "\" "")
14:29clojurebot#<RuntimeException java.lang.RuntimeException: Unsupported escape character: \/>
14:30mi6x3mamalloy: well, yeah, I was just confused with myself
14:30Glenjamin,(.replace "http:\\/\\/hello.com" "\\" "")
14:30clojurebot"http://hello.com&quot;
14:30dnolen_visof: ^
14:31Glenjaminis there a heredoc/raw-string type thing in clojure?
14:31dnolen_Glenjamin: there is not
14:31amalloyguys, "http:\/\/hello.com" is not even a legal string. shouldn't we figure out what his actual input is before trying to turn it into his desired output?
14:31visof,(.replace "http:\/\/hello.com" "\\" "")
14:31clojurebot#<RuntimeException java.lang.RuntimeException: Unsupported escape character: \/>
14:32Glenjaminvisof: where are you getting the string from?
14:32mi6x3mamalloy: so if I want to make a function which returns an empty sequence for an incoming nil argument I can just return '() ?
14:32mi6x3mand this would be idiomatic
14:33mi6x3mfor you see, I want to always return a sequence, but it will sometimes be empty
14:33amalloymi6x3m: i wouldn't worry about it. returning nil would be fine in almost all circumstances, or if you're returning a lazy seq it will naturally be empty
14:34mi6x3mamalloy: let me show you what I work on
14:34mi6x3mand explain the scenario
14:38whiloseangrove: do you rebuild it in clojurescript? for fun? i happen to build a prototype messaging app as well in cljs
14:38mi6x3mamalloy: so I wrote this http://pastebin.com/BcKqfQGm as a solution to https://www.4clojure.com/problem/32
14:38seangrovewhilo: Yeah, I've rebuilt it a few times in cljs now :)
14:38mi6x3mi wanted an efficient solution so I use lazy sequences
14:38whiloseangrove: is it mobile-friendly? could you use it for messaging on a phone?
14:38mi6x3mI used your suggestion and wrapped everything in lazy-seq
14:39seangrovewhilo: Yeah, it's mobile-responsive
14:39whilook
14:39seangroveThere's no backend for it right now, it's just a frontend
14:39whilois your version open-source?
14:39whilooh, ok. yes i build it for my backend
14:39whiloor better we build it for it
14:39Glenjaminseangrove: personally, i prefered the keyword version
14:39Glenjaminfelt a bit more declarative
14:39whiloranek: as well
14:40seangroveGlenjamin: keyword version?
14:40Glenjamin:remaining vs (fn)
14:41seangroveGlenjamin: Ah, ok. It's tricky, I don't want to accidentally walk into making a half-baked syntax
14:42Glenjaminhrm, i see what you mean - i guess functions to begin with and common patterns could always become keywords later
14:43seangroveGlenjamin: That's what I'm thinking as well
14:44whiloseangrove: got it: https://github.com/sgrove/omchaya
14:45ImperialCity_Gis there a irc channel for seesaw library?
14:51whiloseangrove: looks cool, will have a look at it. is it very coupled to the original rails backend?
14:54seangrovewhilo: Yeah, it has no concept of the rails part other than the single API namespace
14:54whilook, good
14:54phuuhey #clojure. i want to represent a tree where every node has a value. i'm using lists at the moment, where the first element is the value — '(0 (1) (2 (3 (4)))) — but navigating with zippers seems weird because you have to skip the first child every time. what am I missing? is there an idiomatic way?
14:57seangrovephuu: Use hashmaps to represent the tree?
14:57seangrove{:value X :children [{:value Y :children []}]}
14:58seangrovephuu: https://www.youtube.com/watch?v=YgvJqWiyMRY Dendrology
14:58dbaschphuu: and look at tree-seq
14:58dbasch,(doc tree-seq)
14:58clojurebot"([branch? children root]); Returns a lazy sequence of the nodes in a tree, via a depth-first walk. branch? must be a fn of one arg that returns true if passed a node that can have children (but may not). children must be a fn of one arg that returns a sequence of the children. Will only be called on nodes for which branch? returns true. Root is the root node of the tree."
14:59phuuseangrove: will check out that talk, thanks. i believe I need to use zipper because i'm need to keep a reference into the tree, and to make changes to it – is there another way where I could use a map?
15:07seangrovephuu: Sorry, I haven't used Zippers in awhile, I know that the api isn't immediately straightforward though, so I feel for you
15:08amalloyi think you can use maps with value/children nodes as seangrove suggests, and build a zipper that knows about that structure
15:09mi6x3mwhat the hell is going on here:
15:09mi6x3m,(= ((fn [coll n] (apply interleave (take n (repeat coll)))) [4 5 6] 1) '(4 5 6))
15:09clojurebottrue
15:09phuuseangrove amalloy: ah, ok. i'm really just interested in if there's a canonical way to store & manipulate a tree where every node has a value. i'm considering adding metadata to the node to store the value and using seq-zip
15:09mi6x3mthis doesn't work on 1.4
15:09amalloyphuu: that sounds like the grossest thing imaginable. use maps
15:10seangrovephuu: Metadata is pretty cool, but you'll have less pain in the long-run if you use maps
15:10seangrovephuu: amalloy is specifically concerned about people getting killed over the metadata on any given node, hence his aversion.
15:11amalloyis metadata like blood diamonds? i'm not sure i understand the concern you're alleging i have
15:12seangroveamalloy: Well, we kill people over metadata.
15:12phuuhah, ok! i can imagine grosser things ;) but yeah, ok. i'll try building a {:value x :left y :right z} zipper
15:12amalloyphuu: it'll be easier to support a list of children rather than just left/right
15:12amalloybut if you want to limit to exactly two it's not completely wrong to use left/right
15:12phuuamalloy: yeah, i thought so, but I want to enforce 2
15:12phuuyeah exactly
15:14phuu(-> tree :left :right :left}
15:17coventryI need a clojure.walk/prewalk which won't blow the stack on very deep trees. Is there such a thing already?
15:28visof,(.replace "http:\\/\\/hello.com" "\\" "")
15:28clojurebot"http://hello.com&quot;
15:31phuuseangrove: thanks for pointing me to this talk, it's brilliant
15:32seangrovephuu: I agree it's good - it's bbloom's talk
15:32Jaoodlink?
15:33Jaoodoh sqw it
15:33Jaoodsaw
15:34lxsameerhey guys, how can i install clojure using lein
15:45rpaulolxsameer: lein includes clojure already. you can start the clojure repl with lein repl. is this what you wanted?
15:45dissipateis core.contracts abandonware? hasn't been updated in 10 months: https://github.com/clojure/core.contracts
15:46ImperialCity_Glxsameer: with lein just create a project with 'lein new' ... when you are ready to run the project type 'lein run' and the first time it will download clojure before running it
15:47lxsameerImperialCity_G: rpaulo thanks, I'm a totally newbie
15:47dissipateImperialCity_G, but in order to do 'lein run' your project has to have a '-main', no?
15:48ImperialCity_Gdissipate: doesnt lein new do that for you already
15:48ImperialCity_Git gives you core.clj with a -main in it
15:48dissipateImperialCity_G, i don't think it did for my project. maybe i'm mistaken.
15:48rpaulolein new might not create a main
15:48ImperialCity_Gdissipate: maybe it was a recent addition
15:50ImperialCity_Gi just typed 'lein new app test', 'cd test', 'lein run' and i got a hello world
15:50ImperialCity_Gim using lein version 2.1.3
15:58Glenjaminis there a (not) version of == ?
15:58Glenjamini've got (if-not (and (== a b) (== c d)) and it seems a bit convoluted
15:58coventry(doc not=)
15:58clojurebot"([x] [x y] [x y & more]); Same as (not (= obj1 obj2))"
15:59coventryOh, ==. Sorry, don't know.
16:00Glenjaminon an unscientific test, that doesn't appear to be any slower
16:00Glenjaminso not= it is, cheers
16:01Glenjamini wonder why it wasn't called !=
16:08Glenjamin,(persistent! {})
16:08clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.ITransientCollection>
16:08Glenjaminhrm, i get a missing stack trace doing that in my repl :s
16:09coventry,(persistent! (transient {}))
16:09clojurebot{}
16:09Glenjaminoh, i know it's wrong
16:10Glenjaminbut it took me ages to find the bug because the stack trace was missing
16:10expezhttps://www.refheap.com/85346 <- most of this code is lifted from http://swannodette.github.io/2013/11/07/clojurescript-101/, what's wrong here?
16:10amalloyGlenjamin: it's pretty unusual to have a use case for == where = isn't just as good
16:11Glenjaminthe fact that == was just for numerics led me to an incorrect assumption about perf
16:11Glenjaminclearly i need to measure more :)
16:11seangrove,(source =)
16:11clojurebotSource not found\n
16:12amalloyexpez: you're calling (<! x), where x is not a channel but a lazy sequence
16:12amalloyin this case, it's clear that that's on line 16
16:13expezamalloy: thanks, that makes sense
16:15coventryexpez: You might want to use (alts!)
16:24seangroveDatascript is *slow*. Wonderful to play with, but GC activity goes through the roof querying against ~1000 facts
16:28Glenjamindo you think that's a fundamental property of it, or just because it's new and hasn't been heavily optimised yet?
20:34seangroveGlenjamin: Bit of both. Reducers are going to be critical for it
22:47lordB8ron http://clojure.org/, url for the clr is out of date. Anyway to update it for https://github.com/clojure/clojure-clr?
22:48lordB8ror is intentionally pointing to that git?