#clojure logs

2013-01-13

00:07TimMcbbloom: Dammit, I've now spent an hour learning about Aaron Swartz. I think it's some kind of paying-of-respects thing.
00:07bbloomTimMc: it upset me too. i've written more than my fair share of spiders in my day, so it kinda hit home
00:07TimMcYeah, that too.
00:11muhooyep. scary.
00:12TimMcIt's also a good reminder to use really good OpSec when being Robin Hood. :-/
00:13ibdknoxThe whole thing is just ridiculous
00:13muhooor, when doing civil disobedience, retain a lawyer first. mlk didn't end up in a brimingham jail by surprise
00:15muhoorosa parks also didn't act alone. and when i've been to anti-war protests, some of us were deliberately planning to get arrested
00:15muhooso sad though. heartbreaking
00:15bbloomtechnomancy: what is responsible for putting pprint into scope when i run `lein nrepl`?
00:15seangroveHrm, does ohpauleez not hang out here much?
00:16bbloomseangrove: i think he was in here just yesterday
00:16xeqi$seen ohpauleez
00:16lazybotohpauleez was last seen quitting 12 hours and 37 minutes ago.
00:16seangroveAh nice
00:16seangroveWould like to see a new release of shoreleave
00:17ibdknoxFWIW: re the discussion about consistency earlier - I agree that there needs to be some. Even if the approach is compose these libs, there's almost always a standard set
00:17bbloomtechnomancy: nvmd, found it: REPL-y
00:18yogthosibdknox: the templates can definitely do that, but until one catches on it's wild west ;)
00:20ibdknoxyogthos: I don't disagree :)
00:20yogthoshehe
00:20yogthosat least standard libs situation is starting to crystalize
00:25tomojrails etc seem to have worse consistency problems to me
00:25tomojsure, if they're all rails apps and you know rails, you probably have a good idea about the basic project structure
00:26tomojif you're looking at a project written with some random awesome framework, the fact that you need to look in some file is probably only encoded in the framework's docs and/or source
00:26ibdknoxtomoj: more importantly, you know that if you want to build a website, you use rails
00:26Natyhello
00:26Naty...
00:26Natyanyone there?
00:26ibdknoxtomoj: what do you use if you come to clojure?
00:27tomojalmost all clojure apps use a single consistent mechanism for encoding where the code is
00:27tomojsure, if that's a "consistency" problem then I call equivocation
00:28tomojnot that it isn't a problem
00:29muhooi'll go for comprehensibility and flexibility over consistency
00:29headshot^^
00:29headshotpython/flask, scala/lift
00:30Natywhat?
00:30clojurebotwhat is short for ,(doc ...)
00:31muhoobotsnack!
00:33Natyi feel lost
00:33Natysorry
00:33Natyi better left this room.
00:33tmciverNaty: if you have a Clojure question, just go ahead and ask.
00:36nightflyI'm afraid I already know the answer; but is there a relatively simple way to estimate the memory usage of a complexly nested clojure data structure?
00:39muhoohmm, syme looks interesting.
00:41muhoonightfly: maybe one of the java instrumentation tools?
00:43yogthosheadshot: well technically now scala has play/lift
00:47Deece_Some very naive benchmarking seems to indicate that, for small amounts of data, lists are much faster when using the 'stack' abstraction (peek & pop) than vectors. is this accepted behaviour?
00:53muhooi dunno about accepted, but it seems unsurprising to me. lists are cons cells, linked lists, IIRC
00:56devnyogthos: I don't think there's an easy way to get people to agree either, but if we find some minor version of common ground I think everyone will be bette roff
00:56devnbetter off*
01:00Raynesdevn: Where do you live?
01:00RaynesNot because I plan to murder you in your sleep or anything, but because I'm curious.
01:10bbloomdevn: don't do it. it's a trap!
01:14yogthosrofl
01:15yogthosdevn: yeah I agree it would be nice to agree on some basic stuff that's idiomatic, I'm trying with the luminus thing :)
01:16yogthosdevn: my hope is that if I make it easy enough to use it'll catch on, and then everybody will have the same base template with the same layout
01:16yogthosdevn: it worked with noir I think
01:46tomojfrom java, how might you implement reduce for PHS in terms of PHM's kvreduce?
01:59amalloyin java, tomoj? why would you do it in java rather than clojure?
02:00tomojthe map impl of a set is not public
02:00amalloyi guess because the backing map isn't exposed
02:01tomojI think I figured it out by just creating an anonymous AFn subclass, but a problem is that PHM's kvreduce requires an initial value
02:02amalloyas should every reduce implementation in clojure.lang, i would think
02:02amalloyit's the job of clojure.core/reduce to find an initial value for it if none is supplied
02:03tomojreduce just calls coll-reduce
02:03tomojit seems you could extend CollReduce to PHS
02:04tomojbut e.g. PHM and PV seem to CollReduce over chunked seqs
02:05tomojah, and seq-reduce does a first/next if necessary
02:06tomoj&(reduce (fn [ret v]) [])
02:07lazybotclojure.lang.ArityException: Wrong number of args (0) passed to: sandbox8277$eval30159$fn
02:07tomojnever noticed that
02:09tomojactually PHM's seq is not chunked
02:16tomojwow, ~4x speedup on (reduce + (into #{} (range 1e7)))
02:17bbloomtomoj: by doing what?
02:17tomojusing the backing map's kvreduce instead of an unchunked seq reduce
02:18bbloomwhich line are you comparing that against?
02:19tomojwhich line in clojure's existing code?
02:19bbloomtomoj: oh, you're mucking with the implementation. i misunderstood
02:20tomojI'm not exactly sure where PH{M,S} get reduced, actually
02:20tomojI'm guessing it's the Iterable CollReduce impl
02:23tomojso with this patch reducing over a PHS is faster than reducing over its backing map
04:23Seba51Having a chain of functions like split message into parts, calculate something, store the parts, send a message to a broker, should I use multiple agents to pass the processing from process step to process step or is just one agent fine. The agent do not have state (I set it to nil).
04:31pepijndevosSeba51: why are you using an agent without state?
04:32pepijndevosIt seems to me that what you want is maybe a queue?
04:32Raynes$dict overengineering
04:32lazybotRaynes: verb: present participle of overengineer.
04:32Raynes$dict overengineer
04:32lazybotRaynes: verb: To make something more complicated than necessary; often implies that the complexity was added intentionally.
04:34pepijndevosRaynes: overengineer can also be a noun. It like an overlord of engineers… maybe
04:34Seba51The agent is having an action queue, isn't it? The idea is to have a chain of agent which pass around the data. If a step fail the error handler tries to find a way out. When the system crashes and reboots, the unprocessed steps are identified and send to the related agent
04:35Seba51correction: the related function is send with the data to the agent
04:35hyPiRionRaynes: I didn't think that overengineering was that. I thought it was to create an unneccesary good solution to a problem.
04:35hyPiRionThis changes everything.
04:36pepijndevoshyPiRion: I thought AbstractSingletonProxyFactoryBean was overengineering
04:36RaynesAbstractSingletonProxySuperUtilFactoryFactoryBeanFactory
04:37pepijndevosSeba51: I don't know your project, but I'd say an agent is to manage state. I fyou are using it as a wekr queue, use a work queue. Have you looked at java.util.concurrent queues?
04:38hyPiRionpepijndevos: I thought that only was ridiculous.
04:39pepijndevoshyPiRion: it's actually used: http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/transaction/interceptor/TransactionProxyFactoryBean.html
04:40Seba51I haven't considered them yet. But I still will have to manage threads because, I want to process the queue between each step with multiple instances.
04:40pepijndevosRaynes: wait, what timezone are you in?
04:41Raynespepijndevos: Central at the moment.
04:41RaynesYes, it's 3:29AM.
04:41hyPiRionpepijndevos: I know, I know. I'm just saying I thought overengineering was a very good solution to a problem, not a complex solution.
04:41pepijndevosok
04:41hyPiRionpepijndevos: Raynes is like that.
04:41RaynesFor now, anyways. I'm moving to LA in February. I'll actually have to sleep then.
04:42ejacksonRaynes has overengineered his metabolism...
04:42pepijndevosejackson: you're confusing me. Did he makt it too good, ro too complex?
04:42hyPiRionI'm like that when I can work whenever I want to as well Raynes.
04:43ejacksonits certainly complex...
04:43hyPiRionBut that's more because I synchronize with the american people, and because other people at home bothers me at normal hours.
04:43ejacksoni'm naturally that way, but it hurts me after a while
04:44ejacksonor maybe that's just the coffee that goes along with it...
07:51clj_newbHi, should lein repl write a target/lein-port file? My installation won't create that file. Leiningen 2.0.0-RC2 on Java 1.6.0_37 Java HotSpot(TM) 64-Bit Server VM, OS X 10.8.2
07:52clj_newbnevermind, after upgrading is working again, sorry
10:29tmciverAny recommendations of docs/blogs on how to get started deploying clojure/java web apps via apache server? I have little to no experience with Java servlet containers.
11:25yogthostmciver: you mean deploying on tomcat?
12:04technomancytmciver: supposedly if you just make a war file with lein-ring it's a lot like using jetty
12:12yogthostmciver: tmciver: basically yeah, if you do lein ring uberwar then you just drop it in the webapps directory under tomcat and it will pick it up, the name of the app is whatever the name of the war was
12:13yogthosif you want to run it as root, then you remove ROOT directory from webapps and rename your war to ROOT.war
12:30tmciverI'm trying to deploy to my own local server machine that's running apache. My question concerns how to get an app server like tomcat running within apache.
12:31magnarsSeems like all examples I can find for Midje are with Leiningen 1, which makes them seem outdated to me. Is it just wrong of me to think so, or do people use other test frameworks these days? Or is Rich's anti-tdd-talk getting to the community? ^^
12:33thorwilmagnars: i don't know what the market share for midje is, but i doubt it went down. maybe you are looking for examples in the wrong places
12:34rodnaph_magnars: what's this "anti-tdd" talk?
12:35magnarsthorwil: may be - I'm using my google-fu, but it might not be sufficient. All I'm trying to figure out is some best practices, and how to set it up properly.
12:37thorwilwhat's the name of the site that lists dependencies of various clojure projects?
12:37hiredmanmagnars: most people use clojure.test which ships with clojure
12:39thorwilfound it: http://clojuresphere.herokuapp.com/
12:43thorwilunfortunately, i can't find an entry for clojure.test there. but for midje, it reports "used by" 571
12:44thorwilmagnars: it's likely a good idea to only chose midje over clojure.test, if you know it does somethng you want/need that the later doesn't offer
12:44magnarsthorwil: thanks, that link is pretty nice
12:46thorwilmagnars: regarding best practices, you might want to consider that tests can serve as (addition to) documentation. in this aspect, it makes sense to write them even after manual testing on the repl
12:47magnarsthorwil: that's good input. I do enjoy using the repl to drive out implementation, so adding tests after seems like a nice workflow
12:48thorwili found myself being more rigorous when writing tests oer tyring things on the repl. that is i found issues after initial repl testing, because my tests included more cases
12:51magnarsNaming of test files: test/project-name/test/file.clj or test/project-name/file_test.clj ?
12:51magnarsjust a matter of taste?
12:52muhooRaynes: you forgot Helper !
12:53muhooAbstractSingletonProxySuperUtilFactoryFactoryBeanHelper
12:54thorwilmagnars: i like test/foo/t_baz.clj for src/foo/baz.clj
12:55thorwilmagnars: it works well with filename completion
13:05jonasenIs it a known cljs bug that one can not create a function named the same as the root namespace?
13:08erikwrjonasen, don't you just get a warning?
13:08jonasenerikwr: https://www.refheap.com/paste/8494
13:10Bodilmagnars: Re: Midje vs clojure.test, Midje is specifically tailored for a TDD workflow. If you use TDD then Midje is probably what you want. If you don't, it gets in your way, imo.
13:11erikwrjonasen, i guess i'm having trouble doing something similar. I tried to override set. nm
13:18Bodiljonasen: It's a named function, so it overrides the foo namespace with itself inside its closure. More of a known JS issue, I guess.
13:19jonasenBodil: shouldn't cljs be able to fix it with name munging?
13:20Bodiljonasen: Yeah, should be easy enough to work around. It's certainly something Cljs should deal with.
13:32djwonkhi everybody. I'm looking for guiding principles or idiomatic Clojure ways to name functions and how to namespace them… at what point is a function name too verbose?
13:33djwonki've thought about grouping namespaces in logical ways -- such as functions that update a particular kind of thing -- together. it makes it feel like i'm grouping things in similar ways that I would with OO … don't know if that is idiomatic
13:38Bodildjwonk: Just group things together in a way that makes sense to you. And you'll notice when a function name is too long when you start getting annoyed while typing it.
13:39djwonkBodil: thanks. I'm writing a Clojure version of this complicated German board game with all kinds of stuff happening. It is fitting together slowly
13:42jonasenhow do I format code on JIRA?
13:45tomoj{{code}}foo bar baz{{code}} iirc
13:45jonasentomoj: I'll try that. Thanks!
13:58palangoa question to the osx people: is the preferred jvm the bundle from apple or the one from oracle?
14:00osautthe one from apple is not updated anymore
14:00osautso the one from Oracle is probably a better choice
14:00palangoosaut: ok, thanks
14:47SgeoOh god clojure.tools.macro/macrolet uses a recursive macroexpander
14:47SgeoIt's going to be horribly broken, isn't it
14:51tomojis it not enough to (binding [clojure.lang.Compiler/LOCAL_ENV &env] (macroexpand ...)) ?
14:52Sgeotomoj, .... hmm.
14:52Sgeohmm?
14:52tomojthe &env is the problem, at least, yeah?
14:52SgeoYes, iirc (and according to my tumblr post from way back when)
14:53SgeoHm
14:55tomojwhere's your tumblr?
14:55tomojoh, duh
15:01tomojguess you can't modify &env
15:02SgeoWhat needs to happen is, I think, upon expansion of let*, fn*, and loop*, determine what the &env will be and pass that in to the single form macroexpander
15:02marcellus123I really loved the web scraper implementation in the Clojure Programming book that used agents as FSMs, seen here: http://goo.gl/aAMDi does anyone know of resources online that use that style or describe it in further detail? I'm trying to restructure some code to more closely match that style but I'm having trouble figuring out how to expand it beyond the toy-ish example
15:02SgeoIt is possible to, given a defmacro-defined macro, pass in your own &env
15:02tomojno, that's what my "guess you can't modify &env" meant
15:02tomojthe values of &env must be LocalBindings
15:02tomojwhich.. I dunno, maybe you can make those
15:02SgeoOh
15:03SgeoFake a let, grab the &env from there, use that?
15:04tomojwhy not just expand to a let* or whatever and let the compiler take care of it?
15:09Sgeohm?
15:09clojurebotbenchmarking is https://github.com/hugoduncan/criterium
15:10SgeoFun fact: macrolet allows for hygienic macros
15:10SgeoI'm not entirely sure on the details of how it works though
15:11augustlI have a list that I need to find an item on by predicate, and procude a new list with that item removed. What's a good way to do that?
15:11augustlso, I need two references - the item that was removed, and the new shorter list
15:11gfredericksaugustl: just the first one?
15:12augustlgfredericks: yes, just the first one
15:12gfredericksaugustl: and if it's not found?
15:12augustldo nothing
15:12gfredericksbut return what?
15:13augustlif it's not found I don't need the shorter version of the original list
15:13gfrederickswell we're returning [x ys] where x is the thing we found
15:14gfredericksif it's not found we can return [nil ys], or just nil
15:14gfredericksin any case you can definitely do this with loop; maybe with reduce
15:14Sgeoaugustl, filter on the complement of the predicate?
15:14augustlmaking a refheap
15:14gfredericksSgeo: he just wants to remove one
15:14Sgeooh
15:15augustlsomething like this https://www.refheap.com/paste/8499
15:15augustlwould be nice to avoid two iterations though, not that it really matters since the lists are short ;)
15:16augustlgfredericks: something like that sounds nice, yeah. [x ys] and [nil ys] that is
15:16augustlI'll write me a function :)
15:17gfredericksaugustl: it might well have to be a loop; I can't think of another way to do it
15:17gfredericksa pretty simple one though
15:18augustlgfredericks: I'm thinking "filter" and then somehow later remove the found item from the list
15:18augustlnot sure if there's a function for the latter thoug
15:18augustlh
15:19gfredericksaugustl: that involves 2 passes though, like you said
15:19gfredericksaugustl: one sec I'll write it up
15:20augustlah, I see why you suggested a loop :)
15:21gfrederickshttps://www.refheap.com/paste/8500
15:21gfredericksaugustl: ^ there's my untested first try
15:21gfredericksoh switch line 7 no [nil ys] :)
15:21augustlvery haskelly :)
15:21augustlwith the xs' and all
15:22gfredericksyay haskell
15:22augustl..in which I pretend to know haskell
15:23brehautaugustl: btw, remove p xs = filter (complement p) xs
15:23gfredericksoh no haskell!
15:23augustlbrehaut: :D
15:28augustlthanks folks, btw!
15:29augustlI should finish learn you some haskell, then I'll be able to do this low level stuff too!
15:29gfredericksyes, you can't use loop until you know monad transformers
15:31muhoo"learn you some haskell"? what is that, the chicken-fried version? or do you mean learn this http://learnyouahaskell.com/ ?
15:32gfredericksthe erlang book used the word 'some' I think
15:33muhoothat book is cute, the illustrations are like the sesame street version of haskell.
15:47tomojI've wasted so much of my life doing `M-p C-M-b M-( try C-M-f C-j (catch Exception e (pst e RET`
15:47tomoj..instead of `(pst) RET`
15:48gfrederickstomoj: best to sit there in pained regret for a while
15:57maehow does one access the 'this' instance when using gen-class
15:57mae(from inside gen class definitions)
15:58gfrederickswhen inside in instance method I think it'd be the first argument?
15:58gfredericksI thought they were instance methods by default but -main always ends up static... :/
16:00maeme too
16:00maelol
16:00maelet me try that
16:00maeoh snap
16:00maethat actually worked
16:00maeyou rock
16:01gfredericksmae: so they are instance methods by default? except for -main presumably?
16:01maegfredericks: nah just mean inside the instance method i omitted the first argument
16:23ivantomoj: maybe you can make the REPL preserve the last form in some weird *_1 and then use a macro
16:24ivanI haven't yet run into the case where I have to try/catch in the REPL like that; what's going on?
16:25ivanoh, hah, I see what you mean
16:25ivanthat sure is doing it the hard way
16:32rbxbxAre there any particularly good resources for getting up to speed with Storm other than the website & wiki?
16:32tomojbetter way to write (fn compare [x y] (cond (and (= x foo) (not= y foo)) -1 (and (not= x foo) (= y foo)) 1 :else (compare x y))) ?
16:34maeok this is driving me crazy, what does the - prefix do in a method definition
16:34maevs no -
16:35tmcivermae: do you mean (defn- ...) ?
16:35tmcivermae: or (defn -main ...)?
16:36tmciverI've only seen it used on a 'main' defn. I believe it's just a convention.
16:37hiredmandefn- makes a function marked as private in the metadata
16:38hiredmanthe gen-class stuff maps methods to function implementations by taking the method name and prepending a -
16:38hiredmanhence -main being the static main init method the jvm looks for in the main class
16:52maetmciver: i mean (defn -main ...)
16:52maeso in my case
16:52maei want to have a method which is exported to java land in AOT mode
16:53maei have the :methods declaration in gen-class
16:53gfredericksmae: what do you need this class generated for?
16:54maegfredericks: to feel to voltcompiler
16:54mae; )
16:54maeerr
16:54maefeed
16:54mae*
16:54gfrederickswhat does it require?
16:54maeit only needs to extend a class 'VoltProcedure' and then export a public method 'run'
16:55maei have VoltProcedure in the classpath
16:55mae(the jar file)
16:55maeit is not complaining about that anymore, it was earlier
16:55maeso this is the error i get now
16:55gfredericksmight be one of the simpler classgen utilities can handle that
16:55maeException in thread "main" java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword
16:55gfredericksI can't remember if any of them can do superclasses
16:56maehmm
16:56maewell i know there is proxy
16:56maebut i have to generate the static class files
16:56maein this case
16:56gfredericksoh cemerick says gen-class; nevermind.
16:57gfredericksmae: so what's going wrong?
16:59maegfredericks: well i think its just a matter of java not being happy with the interface i exported
16:59maeor maybe my failure to convert something correctly on the clojure side
16:59mae1 sec let me pastebin
17:08maegfredericks: http://hpaste.org/80714
17:12tomojhmmm https://www.refheap.com/paste/2d485033427839cafeed7236b
17:12maegfredericks: i would like to also state that i have got it to compile a class, but after adding the methods annotation to export to javaland it gives me the stack trace ipasted
17:18amalloytomoj: your particular compare function must stackoverflow a lot
17:18tomojheh
17:18amalloyanyway, you can clean it up a bit by using (= (= x foo) (= y foo)) somewhere in there
17:18tomojI added the name for clarity without thinking about it
17:19amalloy(cond (= (= x foo) (= y foo)) (compare x y), (= x foo) 1 :else -1)
17:20tomojthat's somewhat better
17:22tomojI was thinking about (l/assoc compare (l/comparing foo) -1) but that seems pretty rarely useful
17:23amalloywhat is l/?
17:24tomojmostly hypothetical
17:24augustlany suggestions for how to better write this? :) https://www.refheap.com/paste/8505
17:24augustli.e. remove the duplication
17:24augustlor whatever you measure of better might be ;)
17:25amalloyyour loop/recur should be a reduce
17:25amalloyalso, conjing a map onto a map is gross. use into instead
17:26augustlah, result is a vector
17:26amalloyin that case you've elided way too much code to get useful feedback
17:27augustlit was the map part I was curious about
17:27amalloy*shrug* use a let to avoid duplicating the common stuff, then
17:27augustlheh
17:28amalloyor, i suppose, (conj result (into {self-key (get-change-attr-value change) :attr attr-pubid} (when opposite {opposite-key (get-change-attr-value opposite)})))
17:30hyPiRion(conj result (merge {...} (if opposite {opposite-key ...}))) ?
17:31augustlseems more readable to just duplicate it
17:31hyPiRionI thought merge was more idiomatic than into when doing it on maps.
17:32cemerickgfredericks: what did I say about gen-class?
17:33augustlah, merge takes nil, nice
17:34amalloymeh. i never use merge
17:34amalloywell, that's not quite true
17:34amalloyi haven't really thought about it before, but i think i use merge when i intend for entries to be overwritten, and into when i intend only to create new entries
17:58gfrederickscemerick: your flow-chart said it was needed
18:04tomojhow bad would it have been (not proposing a change - ignore the cost of changing existing code) if (= (seq {1 2 3 4}) [2 4]) ?
18:04gfrederickstomoj: so there'd be a clojure.core/entries function for iterating over the entries?
18:05tomojwas just about to say that
18:05tomoj:)
18:05tomojs/bad/much worse/
18:05gfredericks(into m1 m2) wouldn't work
18:06gfredericksI can't think of anything serious
18:07tomojI'd replace that with (into-kv m1 m2)
18:08tomojI guess when you iterate through a map, you more often want the entries
18:08tomojbut when you map over a map...
18:23gfrederickstomoj: one thought is that the current definition is more general
18:24gfredericksi.e., I can get (vals m) from (seq m) but not the other way around
18:24gfredericksso the current version doesn't _require_ an extra function, while yours does
18:26gfrederickstomoj: it would also feel weird for (seq m) to lose so much information
18:26devni didn't know you could do: [name [& fields] & opts+specs]
18:27devnnamely the + in the name
18:27gfredericks,'foo+bar
18:27clojurebotfoo+bar
18:27gfredericks,'[+++ +-* foo*bar]
18:27clojurebot[+++ +-* foo*bar]
18:31tomojit does seem weird for seq to lose the keys
18:36technomancywhoa; I actually had a use for c.c/next
18:40prsnDoes anyone have a rough idea of how many downloads/installs clojure has? Or know where I can find out?
18:41headshothttp://cemerick.com/2012/08/06/results-of-the-2012-state-of-clojure-survey/
18:42headshotmight not be exactly what you're looking for
18:42bbloomprsn: i thought maybe teh sonatype maven server would have download stats, but apparently they are not enabled
18:43taliosyou should be able to get that information from Jason van Zyl tho, or someone else at Sonatype
18:43taliosthey've posted central stats before
18:44prsnheadshot: that's helpful, but yeah, it's hard to estimate what the response rate was
18:44prsntalios: do you know where they've posted them?
18:44talioshttp://www.sonatype.com/people/2010/12/now-available-central-download-statistics-for-oss-projects/
18:45maehow can i access the 'this' instance inside a gen-class instance method
18:45taliosahh thats on a per-project basis
18:45taliosand only for projects you control
18:46bbloomthen i guess you'd need to email the clojure mailing list and ask for that info
18:46bbloomthis, of course, assumes lein downloads clojure from there
18:56bbloomi really like the this streaming/serialization idea that i stumbled upon for fipp... i wonder if it would make sense to do a variant of it for html/xml/sgml...
18:57bbloomi guess data.xml is "lazy"
18:58bbloomah data.xml already does this
18:58bbloomstart-element, end-element etc
19:06TimMc_Oh weird, Knuth's tree traversal section refers to preorder, postorder, and endorder instead of preorder, inorder, and postorder.
19:07TimMc_I've *never* heard of symmetric traversal being called postorder before.
19:07TimMc_(This is in TAOCP.)
19:08bbloomTimMc_: yeah, i ran across something like that confusing in a paper the other day. they said "post order" but they really meant "in order", at least as i understood the terms
19:08bbloomi thought it was a typo or something
19:09TimMc_Knuth claims it makes sense because binary trees often encode trees, and the left subtree is therefore special -- but it's just insane for pre- to not be the opposite of post-.
19:10TimMc_And it doesn't help that "inorder" sounds like "endorder".
19:10bbloomi've always learned it as pre/in/post and that just seemed clear to me
19:11bbloomfor whatever little it counts for, wikipedia agrees: http://en.wikipedia.org/wiki/Tree_traversal#Depth-first_2
19:11TimMcI'm going to send Knuth an angry fax. :-P
19:11bbloomlol
19:13amalloyis he still paying for every error? "dear knuth, these terms are rubbish"
19:14bbloomi suspect this is unworthy of a hexidollar
19:15TimMcThere's a lot of good stuff in here, but I'm not enamored with the general style.
19:16TimMcEverything is so low-level as to obscure the actual algorithms.
19:18bbloomTimMc: apparently it was first published in 1968
19:18TimMcholy cats
19:19bbloomat least volume 1
19:19TimMc...but that still doesn't excuse the lack of abstract descriptions.
19:19bbloomi havent seen it, much less read it
19:19TimMcSome of this stuff is like uncommented code.
19:20TimMcbbloom: I nabbed a pirated copy to look something up (faster than going to the library), and now I'm trying to decide whether to buy it.
19:20TimMcI probably will.
19:22headshotheh, re knuth
19:28seancorfieldhmm, a friend was asking whether reading old/outdated comp sci books was worthwhile
19:29seancorfieldi'd say "yes" for knuth and a handful of others
19:29seancorfieldi was going back over some stuff for a C++ journal in the early/mid-90's... found a review i'd done of the gang of four book when it came out
19:30seancorfieldand the journal had been publishing for over a year by then and i'd been doing c++ for a few years... interesting to look back even that far (two decades!)
19:31seancorfieldi have a bunch of books from the late 70's / early 80's from when i was at university... and some of those are still good...
19:34TimMcYeah, anything not language- or machine-specific has a good chance of remaining relevant.
19:37TimMcCirca 2001 I picked up a book called the "Dictionary of Computing" for free outside a bookshop. The book was from the 80s or so but maybe 2/3 of the entries were still completely relevant.
19:38technomancyI found a book in Powell's called Travels in Computerland about a Theatre professor trying to build a database of all the performances in London from 1665-1700 and it was fascinating.
19:38brainproxyI have a dependency that's pulling in an older version of data.json and causing a problem w/ a more recent dep that's using the newer API for data.json
19:39brainproxybut ... having trouble figuring out which dep is the culprit
19:39technomancykind of this double unfamiliarity of seeing tech that's completely ancient, but at the same time seeing it from the humanities perspective
19:39technomancybrainproxy: try `lein deps :tree`
19:39brainproxytechnomancy: thanks
19:40bbloomi really wish github let me make private notes about repositories
19:40Raynesbbloom: Evernote does.
19:40Raynes;)
19:40bbloomRaynes: it recognizes github?
19:41RaynesNo, I mean you can make notes.
19:41RaynesI was being a smartass.
19:41RaynesCan you not detect smartassery?
19:41brainproxytechnomancy: okay, found it ... it's datomic-free :-/
19:41bbloomRaynes: i can, but when it comes to evernote, i wouldn't be surprised if there was like plugins for sites & github was on the list
19:41Raynestrue.
19:41bbloomRaynes: smartass.
19:41brainproxysince I can't fork that one, what are my options to have it not screw up the other library? if any
19:42TimMcbrainproxy: exclusions?
19:42TimMcOh, wait... you said it's an API mismatch.
19:42brainproxyTimMc: yeah
19:43TimMcCan classlojure help? :-/
19:43TimMcugh
19:43brainproxyso another lib is using the api that's 0.2.1+ for data.json
19:43seancorfieldbrainproxy: there's a newer version of data.json that supports both old and new APIs
19:43seancorfieldhmm, 0.2.1 should have both APIs
19:43brainproxyseancorfield: yeah, but the upstream lib is using the newer api
19:44seancorfieldexclude data.json from both libs and add 0.2.1 as a direct dependency
19:44seancorfieldboth libs should be able to use 0.2.1 - it has both old and new APIs in it
19:44brainproxyseancorfield: can I exclude it purely from project.clj?
19:44brainproxyi mean w/o hacking source for datomic-free?
19:45brainproxysorry, guess my lein fu is a bit weaker than I'd like
19:45seancorfieldyes, where you specify each dependency exclude data.json
19:45seancorfieldfor example: [clj-webdriver "0.6.0-beta2" :exclusions [org.clojure/core.cache]]
19:46seancorfieldclj-webdriver uses an older version of core.cache and my code needs a newer version
19:48ecmendenhallHi everyone, I'm back…still working through SICP in Clojure.
19:48ecmendenhallI'm up to chapter 2, which builds up rational number arithmetic using cons, car, and cdr.
19:49ecmendenhallWhat are the most idiomatic equivalents in Clojure?
19:49TimMccar = first, cdr = rest
19:49ecmendenhallfirst and second for car and cdr, I assume...
19:49amalloyvectors, maps, lists, whatever
19:50ecmendenhall(vector a b) for cons?
19:50hyPiRionconj for cons.
19:51amalloyhyPiRion: wat. that doesn't work at all
19:51TimMcecmendenhall: It really depends on what they're being used for.
19:51hyPiRion,[(conj '(2 3) 1) (conj [2 3] 1)]
19:51amalloy(conj 1 2) ;; not a good thing
19:51clojurebot[(1 2 3) [2 3 1]]
19:51seancorfieldif it's using pairs of numbers, vector with first and second might be better?
19:51hyPiRionamalloy: oh right, I was thinking without dotted lists.
19:52ecmendenhallTimMc: seancorfield: Yeah, in this case it's using pairs of numbers to do rational number arithmetic.
19:52TimMcecmendenhall: If you want to stick precisely to the semantics of cons cells: cons, first, & next.
19:52TimMcOh, just pairs? Use vectors, first, and second.
19:52TimMc&(first [5 6])
19:52lazybot⇒ 5
19:52seangrove$seen ohpauleez
19:52lazybotohpauleez was last seen quitting 1 day and 8 hours ago.
19:53TimMcamalloy: Good point about dotted pairs, if that's what you were getting at.
19:53seancorfield(vector num denom), (first rational), (second rational)
19:53brainproxyseancorfield: thanks so much, working now :D
19:54seancorfieldbrainproxy: cool...
19:54ecmendenhallCool, thanks. I'll stick to vectors for pairs for now. When I need sequences I'll switch to cons, first, and next.
19:54seancorfieldecmendenhall: although i guess you could use clojure's native ratio types... but that's kinda cheating :)
19:55seancorfield&22/7
19:55lazybot⇒ 22/7
19:55seancorfield(ratio? 22/7)
19:55amalloyif you want to avoid any possibility of confusion with clojure's builtin sequences, you could create a new Cons type that doesn't participate in any of clojure protocols
19:55seancorfield&(ratio? 22/7)
19:55lazybot⇒ true
19:56ecmendenhallseancorfield: haha, yeah. I'm trying not to cheat too much and learn a thing or two.
19:56seancorfield&(Ratio. 22 7) ;; does this work?
19:56lazybotjava.lang.IllegalArgumentException: Unable to resolve classname: Ratio
19:56seancorfield&(clojure.lang.Ratio. 22 7) ;; ??
19:56lazybotseancorfield: What are you, crazy? Of course not!
19:56lazybotjava.lang.ClassCastException: java.lang.Long cannot be cast to java.math.BigInteger
19:57seancorfield&(clojure.lang.Ratio. 22M 7M)
19:57lazybotjava.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.math.BigInteger
19:57seancorfieldbah...
19:57seancorfield&(clojure.lang.Ratio. 22N 7N)
19:57lazybotjava.lang.ClassCastException: clojure.lang.BigInt cannot be cast to java.math.BigInteger
19:57seancorfieldoh.. duh.. of course..
19:58TimMc&(class (inc' Long/MAX_VALUE))
19:58lazybot⇒ clojure.lang.BigInt
19:59ecmendenhallThe first chapter also had a section introducing orders of growth, with exercises like "double the input on this O(n^2) algorithm and see how much longer it takes."
20:00loliveirahow to make it work? (let [f (fn [x] (dec x))] (eval (read-string "(f 42)")))
20:00ecmendenhallI get orders of growth conceptually, but the results were always inconsistent using core/time to time functions
20:00ecmendenhallI suspect some of this has to do with on-the-fly compilation in the REPL?
20:01loliveira&(let [f (fn [x] (dec x))] (eval (read-string "(f 42)")))
20:01lazybotjava.lang.SecurityException: You tripped the alarm! eval is bad!
20:01ecmendenhallThe first evaluation always takes a lot longer using time. Am I on the right track with this?
20:06TimMcecmendenhall: If you want to get a better timer, I recommend hugod's "criterium".
20:06TimMclet's see...
20:06TimMc$latest hugod/criterium
20:06lazybotNo project by this name exists on clojars.
20:06TimMcWorth a try.
20:07ecmendenhallTimMc: Thanks, I'll check it out.
20:08amalloyit's probably pallet
20:08amalloy$latest criterium
20:08lazybot[criterium "0.3.1"] -- https://clojars.org/criterium
20:13arohneramalloy: do I remember correctly that you had a library that has Sets that maintain insertion order?
20:16arohneraha, https://github.com/flatland/ordered
20:31Rich_MorinHmmm - http://clojurewest.org/ is down.
20:31bbloomRich_Morin: works for me
20:32Rich_Morinback now - hiccup, I guess
20:38idlecoolhi guys. i am struggling to include a library into my project.clj by adding (require 'clojure.contrib.io)
20:39idlecoolbut `lein run` throws out "Error loading project.clj"
20:39idlecooli am using leiningen 2.
20:39idlecoolis there by anyway, i can get more discriptive errors?
20:40gtrak clojure.contrib is no longer a thing
20:40idlecooloh.
20:40gtrakwhat are you trying to do? there's probably a more appropriate library now.
20:40idlecoolthen where do i find io module?
20:40brehautalso, you dont use require in project.clj
20:40technomancyidlecool: clojure.java.io
20:41idlecooltechnomancy: works like a charm. thanks :)
20:42idlecoolgtrak: i am trying to add -javaagent to jvm-opts, and i need to know the current working directory (pwd)
20:43idlecoolbrehaut ^
20:43idlecoolbrehaut: what would be the optimal way to do this, if i not use require in project.clj
20:43idlecoolusing*
20:44gtrakidlecool: you can eval in project.clj
20:44gtrakfor lack of a better way
20:45brehautidlecool: i had assumed you were getting confused between dependancy/packages and namespace/requires
20:45idlecoolbrehaut: oh.
20:46idlecoolgtrak: eval, i am not sure how will i use eval find the current working directory
20:46technomancyidlecool: pwd is always the project root
20:46gtrakidlecool: here's an example: http://stackoverflow.com/a/12599890/244235
20:46gtraklisten to technomancy :-)
20:51tmarshThis might be me miss-reading the docs, but I can't get a JTextArea to obey a margin using Seesaw
20:52tmarsh(defn make-item [] (text :multi-line? true :wrap-lines? true :margin [5 5 5 5] :border (line-border)))
20:56idlecooltechnomancy: gtrak: relative paths works just fine. :)
21:01amalloyarohner: yep, that's the one. enjoy, or let me know if there are problems
21:14gfredericksit is surprising that = does not bother comparing hashes
21:16TimMc&(->> :a :b :c #'+)
21:16lazybot⇒ #'clojure.core/+
21:17TimMcI'd forgotten that var can "soak up" extra arguments. I'm sure I can do something heinous with that.
21:17gfredericks&(var first these symbols don't compile)
21:17lazybot⇒ #'clojure.core/first
21:17TimMc&(->> 1 2 3 #'+)
21:17lazybot⇒ #'clojure.core/+
21:17gfredericks&(var first eval System/exit)
21:17lazybotjava.lang.SecurityException: You tripped the alarm! eval is bad!
21:18TimMcheh
21:18gfredericks&(resolve (symbol "eval"))
21:18lazybotjava.lang.SecurityException: You tripped the alarm! resolve is bad!
21:19gfredericks&((ns-publics 'clojure.core) (symbol "eval"))
21:19lazybotjava.lang.SecurityException: You tripped the alarm! ns-publics is bad!
21:19TimMc&(#((var + %3) 5 6) 'need 'more 'args)
21:19lazybot⇒ 11
21:19gfredericks&(first (ns-map 'clojure.core))
21:19lazybotjava.lang.SecurityException: You tripped the alarm! ns-map is bad!
21:20gfredericks&*ns*
21:20lazybot⇒ #<Namespace sandbox8277>
21:20gfredericks&(the-ns 'clojure.core)
21:20lazybotjava.lang.SecurityException: You tripped the alarm! the-ns is bad!
21:22TimMc,(s/join \ (for [[k v] (ns-publics 'clojure.core) :let [added (:added (meta v))] :when (= added "1.4")] k))
21:22clojurebot"mapv *data-readers* filterv default-data-readers ex-info ex-data"
21:22amalloygfredericks: it's nice if (= some-huge-vector other-huge-vector) can short-circuit on the first difference instead of having to hash them
21:22amalloyis one reason that might have been done
21:23gfredericksamalloy: yeah, it's a complicated thing; you could only check if the hashes are already computed, but I can see why maybe that wasn't done
21:25technomancyso I think this is ready: https://github.com/technomancy/syme
21:26technomancy^ if you do remote work you might be interested in that
21:42TimMcHow do I go about calling a constructor that expects a primitive int?
21:43gfredericks&(Integer. ^int 7)
21:43lazybotjava.lang.IllegalArgumentException: Metadata can only be applied to IMetas
21:43gfrederickshaha of course
21:43TimMcmmm, I think my problem is elsewhere
21:43gfredericks&(let [^int x 7] (Integer. x))
21:43lazybotjava.lang.UnsupportedOperationException: Can't type hint a local with a primitive initializer
21:43tomojI want metadata for numbers in cljs
21:43gfredericksman I don't know anything about primitives in clojure :(
21:43TimMcEh, I had the wrong signature anyway.
21:43gfrederickstomoj: that's impossible right?
21:43tomojI think I have the .cljs side done, but the clojure reader won't accept it, of course :(
21:44TimMcPassing 0 worked fine.
21:44gfrederickstomoj: how do you represent it at runtime in JS?
21:44tomojas a Number object
21:44gfredericksman how do I not know about this
21:45tomojbut really, I probably don't want to put metadata on numbers anyway
21:45tomojI was thinking about units ("dimensional analysis"?)
21:45gfrederickstomoj: is there some magic method that a JS object can have such that it works with +?
21:46tomojI think it's .valueOf
21:46gfredericksoh but that has to return a number
21:46gfredericksrather than giving + arbitrary meaning
21:46gfredericksgoright
21:46gfredericksright*
21:46tomoj({valueOf: function() { return 3; }}) + 4
21:47tomoj#u/ms 1000 ?
21:47maeoh boy
21:47maehow do i do varargs
21:48gfredericksjava varargs?
21:48maei.e. call a varargs function in java with an empty arg list
21:48tomojthen a set of custom arithmetic operators :(
21:48gfredericksmae: I think on the jvm it's just an array argument
21:48maei try into-array
21:48gfrederickstomoj: let's team up on a generic arithmetic lib
21:48maebut getting null pointer exception
21:48maelol
21:48tomojyou can implement Number by returning a value in the standard units for that dimension but then you just get a normal number at the end..
21:48tomojjust like valueOf
21:48maeanyways, ill keep hackin at it
21:49gfredericksmae: you need to make sure the type of the array is correct?
21:49maeah i gotta use annotation?
21:49gfredericksmae: into-array can take a type as its first arg
21:50gfredericksmae: make-array might be slightly more natural
21:50gfredericks&(make-array Integer 0)
21:50lazybot⇒ #<Integer[] [Ljava.lang.Integer;@5def14>
21:55maehmm
21:55maewhat does the & do
21:55maeis that the lazybot command
21:55maeheh
21:55gfredericksyes
21:55amalloygfredericks: "of course", but it's actually wrong: metadata can only be applied to IObj, not IMeta
21:56gfredericksamalloy: oh the error msg you mean?
21:56amalloyyeah
21:56gfrederickswhat is IMeta?
21:58amalloy&(clojure.reflect/reflect clojure.lang.IMeta)
21:58lazybot⇒ {:bases nil, :flags #{:public :interface :abstract}, :members #{#clojure.reflect.Method{:name meta, :return-type clojure.lang.IPersistentMap, :declaring-class clojure.lang.IMeta, :parameter-types [], :exception-types [], :flags #{:public :abstract}}}}
21:59gfredericks&(clojure.reflect/reflect clojure.lang.IObj)
21:59lazybot⇒ {:bases #{clojure.lang.IMeta}, :flags #{:public :interface :abstract}, :members #{#clojure.reflect.Method{:name withMeta, :return-type clojure.lang.IObj, :declaring-class clojure.lang.IObj, :parameter-types [clojure.lang.IPersistentMap], :exception-types [], :flags #{:public :abstract}}}}
21:59gfredericksso IObj can take meta and IMeta can return it
22:07amalloyright, except that of course IObj can do both, since it extends IMeta
22:08gfredericksoh so it does
22:08amalloywouldn't be very useful to put metadata on something without being able to get it out, anyway
22:56yedigawd i hate frameworks
22:57RaynesDon't use them.
22:57RaynesThat's what I do.
22:59gtrakI hate libraries
23:00gtrakwell, anything with dependencies
23:01TimMcFrom clojure.lang.Compiler: static Symbol dummyThis = Symbol.intern(null,"dummy_this_dlskjsdfower");
23:04gtrakI kinda just want includes
23:04TimMc,(apropos 'load)
23:04clojurebot(with-loading-context *use-context-classloader* load-reader load load-string ...)
23:04TimMc,(doc load)
23:04clojurebot"([& paths]); Loads Clojure code from resources in classpath. A path is interpreted as classpath-relative if it begins with a slash or relative to the root directory for the current namespace otherwise."
23:05gtrakand each function should have its own dependency graph, that's easy to separate.
23:07yunfanhi, just found avian http://oss.readytalk.com/avian/status.html , i was wonder if it could run clojure
23:08gtrakyunfan: does it have reflection and classloaders?
23:09yunfangtrak: it do has java.lang support , i am not a java programmer you could check http://oss.readytalk.com/avian/javadoc/index.html
23:09gtrak"a useful subset of Java's features," doesn't sound promising
23:09yunfantried the paint sample app, its really cool
23:10technomancyyunfan: I tried it a while back. I think it can run a raw Clojure repl but it can't run Leiningen
23:10technomancyI think that was due to some of the aether dependencies rather than leiningen itself though
23:11yunfantechnomancy: so it means you could build a independ clojure executable app?
23:12technomancyyunfan: for some subset of Clojure
23:12gtrakmight have better luck with clojurescript
23:12yunfan:]
23:25technomancyone of the maintainer guys was pretty responsive when I was emailing him