#clojure logs

2010-06-24

00:16alexykwhat's the status of 1.2?
00:17technomancyalexyk: probably not right around the corner given that the prim stuff is targeted for it.
00:17alexykprime?
00:17clojurebotprimetime is <lowlycoder> i'm not convined clojure is ready for primetime until i see facebook apps in clojure
00:18technomancyalexyk: improved primitive support
00:18alexykahh
00:18alexykthat would kick haskell's ass
00:19alexyktechnomancy: what about contrib compatibility with 1.1? was it solved?
00:19technomancyalexyk: I think it's pretty much solved. it's much, much better than it was right after the contrib changes first landed.
00:21RaynesI noticed that a couple of days ago. All library writers: stop targeting specific versions unless the specific version is 1.2 and uses 1.2-only features. Don't think I wont hunt you down and kill you.
00:21Raynes:D
00:24technomancyI wonder if Clojure is going to keep a reputation of "it's not as mature for web work as ruby" just because its web frameworks are so simple, and thus people don't have a lot of incentive to create a million different web-centric libraries, etc.
00:25BlackfootWhere did you see that?
00:27technomancyBlackfoot: it's just that you can get a lot done with simple request/response functions plus middleware implemented as function composition. there's not a lot of room for superfluous "oh, I'm going to implement actions as methods on classes vs a DSL", etc.
00:27technomancyin Clojure, the right answer to "How should I represent X?" is almost always "as a function."
00:28Blackfootoh, I can see that. and I like the simple sinatra model. I'm more curious where you heard the sentiment that it is not as mature
00:28alexykwhat about node.js? it scared rubyfolk into fits of optimization of their whole stack
00:29alexykhttp://nodejs.org/
00:29technomancywell right now it's obviously not as mature since Rails has been around since 2005-ish and I don't think anyone's had anything deployed with Compojure for much over a year.
00:29alexyklooks like clojure in disguise to me
00:29alexyksince javascript is
00:30duck1123clojure on the web is not as mature. (not the same as not as capable)
00:30Blackfootnodejs is also a cool model. They almost did the same thing for IO as clojure did for state management
00:30technomancyyeah, I'm not making a judgement call--just saying that's how it's perceived.
00:31alexykthey monitor directories apparently and see if they change using OS. I wonder how JVM jives with that.
00:31cemerickI'm not sure there's much of a comparison to be made -- so much of the rails world's attention has always been on deployment and ops issues that the jvm web stuffs have had down pat for 10 years.
00:31alexykcemerick: but, nothing as good-sounding as Capistrano! :)
00:31alexykmakes you want to travel
00:32technomancyalexyk: not so sure about that... nothing beats Vlad the Deployer.
00:32cemerickmm, they're certainly good at marketing :-)
00:32lancepantztechnomancy: i was just about to say the same
00:32alexykDHH went to business school and it shows
00:33alexykhe gave an excellent talk at AMZN about it around the hight of the hype
00:33alexykof course nothing in AMZN can be run on it
00:33alexyk...as it runs on perl! :)
00:35alexykso why is clojure so fast? it's right there with haskell and ocaml in speed. something smells fishy!
00:36cemerick...and the stellar data structures
02:34alexykhow do I translate this into Clojure: Map<String,Object> userData = mapper.readValue(new File("user.json"), Map.class);
02:34alexyk(from http://wiki.fasterxml.com/JacksonInFiveMinutes)
02:36lancepantzis mapper part of the jackson api?
02:42alexyklancepantz: it's described by the jackson's author :)
02:43alexykand has always been; I think about this: let's use it to slurp a Java map very quickly out of json, then convert that to clojure
02:43alexyk's map
02:43alexykbetter yet, teach it to extract the clojure's map directly, if possible
03:16scottjalexyk: I might be missing something here..what about that code is hard to translate to java?
03:18alexykscottj: me too -- it's late and is not obvious to me now :)
03:19scottjdoes this work? (.readValue mapper (File. "user.json") Map)
03:20alexykscottj: it assumes you give types to Map, from which Jackson extracts the schema... is Map a stand-in for Map.class?
03:22scottjalexyk: not sure, (class String) says java.lang.Class so I figured Map in clojure was same as Map.class in java
03:26scottjalexyk: what's the language mechanism that lets the thing being assigned look at the type it's being assigned to?
03:26alexykscottj: reflection?
03:29TheBusbyWhat's the best way to determine the most frequently occuring element in a list?
03:29TheBusby,(first (reverse (sort-by val (frequencies [1 2 2 3 3 3 9]))))
03:29clojurebot[3 3]
03:29TheBusbythat works, but because you need to use "reverse" it has to run back across the entire list...
03:30scottjalexyk: hmm, I didn't know reflection could do that.
03:30alexykscottj: I'm not sure what you mean then. Jackson has ways to match but you have to pass the type in, per link.
03:35hiredman,(first (sort-by (comp - val) (frequencies [1 2 2 3 3 3 9])))
03:35clojurebot[3 3]
03:36serp_,#{1 1}
03:36clojurebotDuplicate key: 1
03:36serp_how so?
03:36serp_I would expect => #{1}
03:37hiredman#{1 1} is considered a bug, since sets can't have duplicate keys, so most likely the programmer made a mistake
03:39serp_I guess practically that makes sense
03:40scottjthere are some other weird behavior with hash/set literals that don't apply to the non-literal versions and also have that answer: don't do it
03:41TheBusbyhiredman: thank you!
03:42hiredmanwork has been done to try and address the oddness with literals, the exception you get from that set is a result of some of that work
03:43serp_it would not be odd if the set just dropped duplicate members... that's what should be expected
03:47Blackfoothttp://groups.google.com/group/clojure/browse_thread/thread/9c394897f6c0498e/d06f21c0eb49016b?lnk=gst&amp;q=hash+literal+oddity#d06f21c0eb49016b
03:47serp_,(clojure.set/union #{1} #{1})
03:47clojurebot#{1}
03:47serp_^ here duplicates are silently dropped
03:48Blackfootit's probably a similar issue
03:49hiredmanthe argument is a #{1 1} literal set is plainly a bug/typo since sets cannot claim duplicates, so why would you do that unless it was a mistake?
03:50serp_that's almost like saying that typos in string literals should be forbidden. why make typos if it's not a mistake?
03:52serp_sets come from mathematics, where the usual convention is that duplicates make no difference
03:52hiredmanserp_: that argument is ridiculous
03:52serp_it's a bit extreme, but I think it illustrates my point
03:52hiredmanno
03:53scottjBlackfoot: I was thinking of hickey's response in the thread linked at the bottom of the one you pasted, about it being inefficient to check literals for duplicates. but isn't that happening here?
03:53hiredmanit's not extreme, it's completely wrong headed
03:55Chousukescottj: why would you accept silly input when you can just throw an error and get the programmer to check it out?
03:55Blackfootscottj: i'm not sure of the details, but you might be right
03:55Chousukescottj: I mean, in 100% of the cases the programmer didn't intend to type two equivalent items :P
03:56Blackfootit may not spend the time condensing the keys, it just puts it into the data structure which throws the error
03:57Blackfooti think the logic is: if you specify a literal set, a valid set does not have duplicate keys
03:57Blackfootjust like if you specify a literal string with an non-existant escape sequence
03:58serp_hiredman: I think the language itself shouldn't forbid something that is not necessarily wrong. you could use a lint tool for that
03:58Chousukebut it is wrong
03:58greghsounds like a compile warning might be appropriate
03:58hiredman,(let [x′ 1] #{x′ 1})
03:58clojurebotjava.lang.IllegalArgumentException: Duplicate key: 1
03:58hiredmanserp_: I care less and less what you think
03:59Chousukea literal set with two equivalent items makes no sense at all.
03:59Chousukeyou can write some math that has one, but people will think you're weird :P
04:00Chousuke(or they will be puzzled and think maybe you meant something else)
04:00scottjChousuke: I'm not saying you shouldn't check literals, just that rhickey said once he didn't want to check them because it would slow things down so I'm wondering if that check is happening at a different level here
04:00Chousukeit only slows down the compiler as far as I know.
04:01Chousukeand not by any noticeable amount.
04:01scottjbtw, what other languages have literal syntax for sets?
04:01greghpascal :)
04:01Chousukeyou can still conj duplicates to sets, remember
04:02Chousuke,(conj 1 #{1}); I hope I got the arg order right :P
04:02clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IPersistentCollection
04:02Chousukedamn
04:02ChousukeI always get that wrong.
04:02Chousuke,(conj #{1} 1)
04:02clojurebot#{1}
04:02hiredmanChousuke: :( how do you get that wrong
04:02hiredmanit's conj man
04:02Chousukehiredman: I dunno, somehow.
04:03Chousukehiredman: I keep thinking of cons :P
04:04hiredmancons works on seqs and has the same argment order as if you where constructing the seq from just cons calls (cons 1 (cons 2 nil)) and conj works on everything and has the opposite order
04:05Chousukeyeah, I know, but it still manages to confuse me :P
04:05scottjone way to think about it is conj has the order it would if it were a method. an add method would be on the collection, not the item
04:12AWizzArdIs there a way to get a specific function object of a class which extends a Protocoll? Let's say we have the fn 'foo' and extend String and FileInputStream with it. Now is there a way to get the one foo for Strings?
04:13AWizzArd(get-protocoll-fn 'foo String) ==> callable fn
04:18Licenser$(doc cons)
04:18sexpbot=> ------------------------- clojure.core/cons ([x seq]) Returns a new seq where x is the first element and seq is the rest. nil
04:20ChousukeAWizzArd: there probably is, but I doubt it's a public API
04:21ChousukeAWizzArd: you might want to check out the implementation of extend etc.
07:39LauJensenHi guys - Contrib has been broken for 8 days, whats going on ? The console output looks a little funny
07:55Licenserout of curiosity, on the euqal branch, how is the state of compairoson operators, are they working on primitives too? aka being faste when i compare 2 longs?
08:07kib2Hi
08:09Licenserhi kib2
08:10kib2Licenser: are you the one how wrote a syntax highlighter ? (sorry, I went here once only).
08:10LicenserYap, I am the one :)
08:11kib2Licenser: cool :) Can you give mine a try ? It's a very little script (the first one I've made with Clojure)
08:12Licensersure I'll gladly look over it
08:12kib2http://kib2.free.fr/Clojure/prism_v.01.zip
08:12kib2Thanks, just unzip, and launch 'prism.clj'
08:12kib2the result will be 'prism.html'
08:14Licenserfirst hint def is for global variables if you need local ones use let
08:15kib2Licenser: witch one ?
08:15Licenserprism clj line 88
08:16kib2Licenser: oh yes, I forgot this one; thanks
08:16Licenser:)
08:16Licenserit looks very procedural ^^
08:17kib2it's certainly not idiomatic Clojure code
08:17kib2indeed :)
08:17kib2I only used recur once...shame on me !
08:17Licenser:P
08:18Licenserbut you use a definition very close to what I use, you might want to have a look at clj-highlight for some ides how to do things less procedural
08:18kib2yes, I saw you were using the same sort of rules.
08:20kib2but there's a problem : suppose you want to highlight "defn" keyword, then ie "my-defn" will also be highlighted
08:20Licenseralso use [] instead of '()
08:20kib2ie a vector ?
08:20Licenserno since I use a set for keywrds not a regexp
08:20Licenseryap
08:20kib2you don't use regexps at all ?
08:21kib2or a mix of the two ?
08:21Licenserwell I take a multi step aproach
08:22kib2good...can you tell me more about it ?
08:22Licenserregexps to tokenize and then something I call 'manglers' that go over the tokens and alter them in some way i.e. by making some idents to keywords depending weather they are part of a keyword list or not
08:22Licenserthis allows you to do funky stuff with your highlighter by applying multiple mangers and things like that
08:23kib2cool :)
08:23Licenseryou can toss all kinds of things on them and it does not get much slower thanks to everything being a lazy seq
08:23Licenseralso I don#t use regexp directly but matcher functions
08:24Licenserthat way you can also match against other things, for example for clojure nubmers (since they can be quite complex) I use a sepcial function that generates the regexp on the fly if they are needed
08:24kib2I'm using matchers too because I needed start and ends pos of the tokens
08:25Licenseryea I found javas regexp library horrible :(
08:26AWizzArdWhy that?
08:26Licenserbecause it is very hard to tokenzie with it AWizzArd it has no good suport for that
08:26Licenserat least none I found
08:26AWizzArdI mean, it would be nice of course if there were a Clojure fn to report that kind of data.
08:26AWizzArdBut the java API offers that kind of information.
08:26LicenserAWizzArd: but you can only search for 'the next match' not 'what of this matches first'
08:27kib2A nice PEG library should be nicer
08:27kib2but I don't know if there's already one for Clojure
08:27Licenserso you can't use the fast regexp functions since if you go with an index you can't use ^ since ^ matches not the start from the index but the start of the string. and if you don't have ^ it matches any match with the string not only if ti starts
08:28Licenserthere is no function to say 'does the string at position X matches regexp R'
08:28Licenserand the fast libraries don't have support for certain cases like the one I'd love ot use since it is claimed to be the fastes does not support ^ at all :(
08:30kib2If I was clever enough; i would write REBOL's "parse" function...but I'm not.
08:31Licenserkib2: I wrote a pretty fast function for it but it's not perfect
08:31Licenserit abuses the fact that java treats substrings w/o copying
08:32kib2Licenser: where is it ?
08:33Licenserin clj-highlight
08:33Licenserit rests at github feel free to take a look, fork or do wahtever you feel like :)
08:33kib2thanks, nicce to you
08:39Licenseralso if you've a question or an idea for it jet give me a ping about it
08:44kib2no problem, I just have to study what you've done ;, it will certainly take me some time to understand how things work internally.
08:44Licenserno worries
09:14kib2I have to go; see you guys.
09:16Licensersomeone around who likes optimisation?
09:27Licenserhmm getting closer :P
10:37LicenserSo I have tried to write a really really fast benchmark for clojure, but I fail, http://github.com/Licenser/clj-shootout/blob/master/fannkuchen/src/profile/fannkuchen.clj is what I got and I don#t see much more way to optimize sadly :(
10:39Licenserhttp://grab.by/57el is what the profiler says eevar2 yes I sayed profiler
10:43eevar2awesome
10:46cemerickdanlucraft1: ping
10:46danlucraftcemerick: hey
10:46cemerickthanks for the moz info -- I'm waiting for my vm to boot so I can try it in windows. But: where do you actually use the moz view?
10:47danlucraftcemerick: inside any Swt layout
10:47danlucraft?
10:48danlucraftcemerick: is that what you meant?
10:48cemerickdanlucraft: oh, all the editors are web views?
10:48danlucraftcemerick: oh, you mean in Redcar?
10:48cemerickyeah
10:48danlucraftright
10:48danlucraftin that case, there are a few places its used
10:48danlucraftI'm trying to use the web view instead of dialogs
10:49danlucraftcemerick: heh, not written that yet
10:49danlucrafttry Plugins/Plugin Manager
10:49danlucraftor open a directory, select multiple files and right click and choose "Bulk Rename"
10:50cemerickdanlucraft: I get errors for both of those: NameError: uninitialized constant Redcar::ApplicationSWT::HtmlTab::LocationListener::URI
10:51danlucrafthmm
10:51danlucraftthat's weird. have you installed from the gem?
10:51cemerickyup
10:52cemerickOS X 10.5.8-ish, ruby 1.8.6
10:52cemerickoh, it's jruby, nevermind :-)
11:00Licenserrhickey: you're around and have a minute?
11:31AWizzArdWhat is the difference between a definline and a macro?
11:31AWizzArdAre not both expanded during macroexpansion time?
11:33chouserthey are expanded at roughly the same time, but things defined by definline can be used as a function
11:34hoeckAWizzArd: definline is experimental, defmacro not :P
11:37chouseroh. wow.
11:38chouserI refuse to think about how long it took me to find that typo in my map keywords
11:40arohneris anyone using sonatype nexus to proxy clojars?
11:40arohnerit's correctly proxying some jars, but not others and I can't figure out why
11:42cemerickarohner: yes
11:42cemerickwhich jars isn't it picking up?
11:43arohnerring-core, ring-devel, ring-jetty-adapter, org.clojars.arohner/hiccup, sandbar
11:43cemerickhave you tried reindexing from scratch?
11:43arohnerno
11:44arohnercemerick: is that right click and select ReIndex?
11:44cemerickarohner: yeah, and expire cache too, just for kicks
11:46arohnercemerick: still no luck. I have clojars set up as a proxy, snapshot repository, with a url http://clojars.org/repo/
11:47cemerickarohner: it can't be done that quick -- dropping indexes takes a bit, look at the scheduled tasks panel
11:49arohnercemerick: I did another expire and reindex, and there are no scheduled tasks listed
11:49arohnerhrm...
11:49cemerickarohner: which versions of those artifacts are you trying to use?
11:49cemerickif you're trying to use release versions, nexus won't expose those through a snapshot proxy repo
11:50arohnercemerick: so do I add clojars twice at the same url?
11:50cemerick(clojars hosting snapshots and releases out of the same repo is fairly broken)
11:50cemerickarohner: yes, one snapshot proxy repo, one release proxy repo
11:50cemerickarohner: and you can set up a group to merge the two for internal use if you want
11:51cemerickwe have one group repo that merges ~20 upstream repos that we proxy
11:51cemerickmakes pom configuration very pleasant :-)
11:51arohnercemerick: what is the difference between snapshot and release? I've heard there's a difference, but can't find any detail on what it means
11:53cemerickarohner: Google is your friend ;-)
11:53cemerickhttp://docs.codehaus.org/display/MAVENUSER/Maven+Concepts+Repositories
11:53cemerickhttp://mojo.codehaus.org/versions-maven-plugin/version-rules.html
11:54chouserI love (def ^:private foo ...)
11:54AWizzArdI always do (d/defvar- foo ... "docstring), where d is clojure.contrib.def :as d
11:55arohnercemerick: that first article I'd seen, and it just says release repos hold releases, and snapshot repos hold snapshots. I'm wondering why there's a technical restriction for something that seems like it should be policy / convention
11:56arohnercemerick: adding a second clojars repo worked, thank you
11:56cemerickbah, I didn't meant to paste that second link -- informative, but irrelevant here
11:58cemerickarohner: I don't know the implementation details, but the point of snapshots is that they're meant to reflect a state of flux, and that the associated artifacts are transient -- i.e. it's typical for snapshot repos to get flushed periodically.
11:58cemerickIf everyone had their own policy/convention around handling artifacts from builds of HEAD, then we'd be in some degree of trouble.
12:00cemerickstuff like this is why e.g. using shas as version numbers and intermixing snapshot and release versions is unfortunate
12:01hiredman,(doc alter-var-root)
12:01clojurebotDENIED
12:01hiredmanclojurebot: you suck
12:01clojurebotNo entiendo
12:01cemerickarohner: http://www.maestrodev.com/node/133
12:02cemerickThe 'better builds with maven' book is excellent, BTW.
12:02arohnercemerick: I'll look into that, thanks
12:23ivenkys_the clojurebot is so polite .. :-)
12:32Lajlaivenkys, I wish to consume your vital life essence.
13:25triyoRWH introduces Applicative parsing examples. Does newer parsec versions have built-in support for applicative parsing or do I have to use the ApplicativeParsec.hs from RWH?
13:25triyoahh crap wrong channel :)
13:25mmarczyktriyo: you might want to ask on #haskell ;-)
13:25mmarczyk:-)
13:25mmarczykI'd look into attoparsec though
13:26mmarczykand similar new Parsec-like packages
13:26triyommarczyk: thanks
13:26mmarczyknp
13:47Blackfoothas anyone use clj-native with compiled classes?
13:48edbondis it possible to run swank using ~/clojure-contrib/launchers/bash/clj-env-dir ?
13:48Blackfooti'm getting an error "No matching method found: defineClass for class sun.misc.Launcher$AppClassLoader" when compiled, but none when I just use it in pure clojure
13:50edbondparedit question: how to remove ) ? I know comment trick but there should be right way to do this.
13:51arohneredbond: I just highlight the ) and kill it
13:53edbondarohner: no, paredit doesn't remove parentesis
13:54edbondI can comment it and remove, this is the only way.
13:54edbondarohner: what keys do you use?
13:54RaynesC-u backspace
13:54arohneredbond: I highlight the paren and M-w
13:55RaynesYou don't even have to do the highlight stuff.
13:55RaynesJust put the cursor in front of the paren you want to remove, and C-u backspace
13:55edbondRaynes: thanks!
13:55RaynesBut highlighting works too.
13:56RaynesFor me, anyway.
13:57edbondarohner: thanks, this works too. but I had to press Ctrl-w
14:01canderaI've knocked out a quick definition of something that computes the Cartesian cross product of multiple sequences. But as always when I write Clojure, I have to assume someone else can do it in less code. Anyone care to take a look? http://gist.github.com/451734
14:06AWizzArdcandera: did you look at clojure.contrib.combinatorics?
14:07canderaObviously not. :)
14:07AWizzArdk
14:07canderaBut say I wanted to do it without contrib.
14:07candera(I'll look at c.c.combinatorics now.)
14:09mcavi'm new to clojure too; is there a reason to use apply instead of recur in that context?
14:09chousercandera: yours looks pretty tight!
14:11chouserapply would unpack its last arg (more) into the next call's b & more
14:11canderachouser: thanks. The one in c.c.combinatorics is far more verbose. Not sure I understand why. Might be they're dealing with some corner case I'm ignoring (empty seqs, perhaps?)
14:11mcavah, i see
14:15chouserexcept ... I thought recur with varargs wanted the vararg passed as a seq
14:16chouserah, it does. so recur would in fact be better there -- faster, and no thread to the heap.
14:16chouser(defn cartes4 [a b & more] (let [so-far (for [x a y b] [x y])] (if more (recur so-far (first more) (next more)) (map flatten so-far))))
14:19canderachouser: Any comments on this, then? http://gist.github.com/451734 (I just added destructuring)
14:20chousercandera: that's what I just wrote!
14:21canderachouser: I just destructured more a little bit. Sorry if I was unclear - was asking if by doing so I was screwing anything up over explicit (first more) and (next more)
14:21chouserno, I mean I forked your gist, fixed it up with recur and destructuring -- and then you pasted the same thing
14:22canderaOh, I didn't see the fork. Was just looking at what you pasted into this channel.
14:22chouserhere's what I had written but not yet posted: http://gist.github.com/451752
14:23canderachouser: OK, got it now. Sorry for the confusion. I just moved house yesterday, so that's my current excuse for being so slow. Tomorrow I'll have to think of a different excuse. :)
14:24canderaAnyway, thanks again for the eyeball.
14:28bobo_,(contains? ["1" "2"] "1")
14:29clojurebotfalse
14:29bobo_why is that?
14:29bobo_,(contains? [1 2] 1)
14:29clojurebottrue
14:30noidi,(contains? [5 6] 1)
14:30clojurebottrue
14:30noidi,(doc contains?)
14:30clojurebot"([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'."
14:31noidibobo_, the vector does not contain an element at the index "1", but does at the index 1
14:31bobo_ah
14:31bobo_,(contains? [4 5] 1)
14:31clojurebottrue
14:31bobo_,(contains? [4 5] 4)
14:31clojurebotfalse
14:31bobo_i see!
14:31bobo_thnx
14:31lpetitbobo_: this is a search "by key". Keys of a vector are its indices
14:32chouserif you want a collection of things keyed on their value, try a set
14:33chouser,(contains? #{"1" "2"} "2")
14:33clojurebottrue
14:33qbgcontains? returns true when get can succeed.
14:33bobo_yes that did indeed work alot nicer
14:33lpetitbobo_: if contains? were to try to match vector values, the algorithm would be o(n), looking each value after the other (which a set does not, 'cause it indexes its values, as chouser demonstrated)
14:34bobo_indeed
14:34bobo_http://en.wikibooks.org/wiki/Clojure_Programming/FAQ#Why_doesn.27t_contains.3F_do_what_I_expect_on_vectors_and_lists that explained it nicely
14:35pinebaronam I completely off base with this? I'm pretty new to lisp/clojure. http://paste.ideaslabs.com/show/fK7WyBka84
14:36noidibtw. which is better if you're starting with a seq, converting to a seq and using contains?, or searching linearly with some ?
14:36noidiI'd guess the latter, since the conversion to set probably has to walk the whole seq?
14:36noidior are sets lazy too_
14:38chouserif you really want it to be a seq and are going to leave it as a seq (not convert it to a set and keep using it as a set), then yes just search the seq linearly
14:38chouserwhich you can do a couple of ways:
14:38chouser,(some #{"1"} (list "1" "2"))
14:38clojurebot"1"
14:38chouser(.contains (list "1" "2") "1")
14:38chouser,(.contains (list "1" "2") "1")
14:38clojurebottrue
14:44lpetitpinebaron: sorry to say probably yes
14:46lpetitpinebaron: a function with no argument= bad smell, a def inside a function body = bad smell.
14:48noidimaybe you want something like this? (defn draw [angle] (really-draw-things) (recur (+ angle (/ PI 25))))
14:49lpetitpinebaron: I guess what you want must be based on cycle
14:49noidiand of course you need an exit condition
14:49lpetit,(doc cycle)
14:49clojurebot"([coll]); Returns a lazy (infinite!) sequence of repetitions of the items in coll."
14:49lpetit,(cycle (range PI (/ PI 25)))
14:49clojurebotjava.lang.Exception: Unable to resolve symbol: PI in this context
14:49lpetit,(cycle (range Math/PI (/ Math/PI 25)))
14:49clojurebot()
14:50lpetit,Math/PI
14:50clojurebot3.141592653589793
14:51lpetit,(cycle (range 0 Math/PI (/ Math/PI 25)))
14:51clojurebotExecution Timed Out
14:51lpetit,(take 15 (cycle (range 0 Math/PI (/ Math/PI 25))))
14:51clojurebot(0 0.12566370614359174 0.25132741228718347 0.3769911184307752 0.5026548245743669 0.6283185307179586 0.7539822368615503 0.879645943005142 1.0053096491487337 1.1309733552923253 1.256637061435917 1.3823007675795087 1.5079644737231004 1.633628179866692 1.7592918860102837)
14:55marcolzguys, I'm trying to use contrib.sql/insert-values, but I get an Exception that is a java.io.NotSerializableException. How can I debug it? Is there any way for printing the actual generated SQL?
15:01briancarpermarcolz: The generated SQL is just "INSERT INTO table (col1,col2,col3) VALUES (?,?,?)". I think the serializing is done in Java.
15:04marcolzbriancarper: Thanks Brian. I was just wondering if perhaps the SQL had some values badly quoted or anything. It would be nice to be able to debug it... the backtrace I'm getting is really useless.
15:05briancarperYeah, I don't think quoting is an issue. But if your data types don't match your DB column types, Java will try to convert them itself, and it becomes confused easily.
15:47arohnertechnomancy: does lein support username / passwords on maven repos?
15:47arohnertechnomancy: I tried adding to ~/.m2/repository/settings.xml and it doesn't appear to work
15:51cschreinerlooking for a good css-library to use with compojure
15:53chouserhuh. jvisualvm just completely fell over trying to profile some code using the prim branch. yourkit worked fine.
15:54DeusExPikachuhi
15:55bobo_cschreiner: http://github.com/programble/csslj i havent used it but still. its a css-library =)
15:55programble:O
15:55programblesomeone heard of me
15:56cschreinerbobo_: not quite what I had in mind :)
15:56programblewell wtf is "css-libarary" mean?
15:56DeusExPikachuquestion, if reify is used in a function, and that function is called repeatedly, is a new anonymous class generated each time or is there some sort of caching or compiling going on?
15:56bobo_programble: :-)
15:57programblecschreiner: what does css-library mean?
15:57cschreinerprogramble: good question
15:57programblecschreiner: ... so answer it
15:57arohnerDeusExPikachu: reify creates a new class each time it's evaluated, I believe
15:58bobo_its easier to know what you dont want, then what you want
16:00cschreinerbobo_: indeed
16:00programblebut
16:00programblewhat do you want
16:00bobo_:-)
16:01programblewtf is "css-library"
16:01programblethe interbutts doesn't even know what that means
16:01cschreinerprogramble: by all means, I like your solution, but please, keep your tone light
16:01programblewell, why can't you just answer?
16:02programblei mean, you want us to find you one of these "css-libraries", but won't actually tell us what you want
16:02cschreinerprogramble: because I have to think through what I want
16:02programblecsslj is in the same style as hiccup, and will be integrated with hiccup sometime in the future
16:02cschreinerok
16:03programblewhenever weavejester gets around to it i guess...
16:03chouserDeusExPikachu: no. Just like 'fn', 'reify' creates a class when the form is compiled. multiple calls at runtime create instances of that class.
16:06Licenserhmm is rhickey around?
16:06djpowellshould i create a issues for that laundry list of clojure.java.sh patches I posted a while back? nobody objected to them.
16:07chouserdjpowell: did you implement any of them already?
16:08djpowellyeah, i posted patches for them all as attachments to my mail
16:08chouserok, I thought so.
16:08chouserman, I wish I had time to do all the things I want to.
16:08bhenrychouser: don't we all.
16:08chouserI ought to read through your code
16:10djpowellhttp://groups.google.com/group/clojure-dev/browse_thread/thread/b4a4d6eca3fd9b9d/1ebd2916345b88d9
16:10chouserdjpowell: I think Halloway has proposed changes for it too.
16:10djpowellok
16:10djpowelli've been using sh a bit for calling graphviz. graphviz rocks.
16:10chousergraphviz does rock. except... it's about 80% of what I want. That last 20% is a pain.
16:10djpowellyeah
16:11chouserheh, it's entirely possible I wrote sh originally to call graphviz.
16:11djpowellthe html stuff isn't very flexible I found today
16:11djpowelland i can never get clusters to work properly (and sometimes they seem to crash graphviz)
16:12djpowellI might try using the csv output, and rendering it myself using javascript divs or something
16:12chouserheh, yep. very possible. http://github.com/Chouser/clojure-classes/blob/master/src/net/n01se/clojure_classes.clj uses shell-out
16:15djpowellactually, it sounds like clojure.core/slurp should probably use clojure.java.io too
16:16djpowellbyte at a time copying is bad
16:16DeusExPikachuchouser: sweet thanks, that's what I expected, so using reify can be very efficient
16:17chouseryes
16:18djpowellit is similar to anoymous inner classes in java
16:24DeusExPikachuis there any good articles on clojure double dispatch using protocols (not multimethods) via the visitor pattern or whatever? I feel like that after single dispatch on type, double dispatch on type is the next common use case for multimethods. I somewhat recall rich talking about in on the internet somewhere (including discussing adding/not-adding language support) but I can't seem to find it.
16:47alexyklancepantz: what do I supplu for jiraph :load function if I want to get raw bytes to use later?
16:50alexyklancepantz: I guess identity?
17:00alexykI need to define two vars in repl from a pair returned by a function; here's what I do now: (let [[a b] (load-graph "tokyo/dreps.clb" "tokyo/dments.clb")] (def dreps a) (def dments b)) -- is there a better way?
17:04chouseralexyk: not that I can think of
17:04alexyk:)
17:20programblecschreiner: ever figure it out?
17:21cschreinerprogramble: yeah, I went for the include-css
17:21cschreinertrad. style
17:22programblethat... is not a css-library
17:22cschreineryou don't say
17:36patrkrisdoes anybody know why I get a ClassNotFoundException on invoking `lein nailgun`? I'm brandonw's lein-nailgun plugin
17:36patrkristhe class not found is clojure/main
17:38mmarczykLicenser: nice effort to research numerics in Clojure, thanks for posting that
17:38mmarczykpatrkris: have you changed the Clojure jar recently?
17:39patrkrismmarczyk: Nope. I'm just using the jar leiningen downloads for me
17:39patrkrisperhaps I should wipe the clojure.jar from my maven repository and have lein download it again
17:39mmarczykwell, have you recently run lein deps or sth?
17:39zakwilsonI am having a problem with Google Groups where it seems to get stuck in some sort of redirect loop on Chrome. Anyone else?
17:40mmarczykI think nailgun needs to be compiled with the clojure.jar you're using... not quite sure though -- just a hunch
17:40dakronezakwilson: yea, having the same problem with firefox
17:40mmarczykzakwilson: yup, delete groups.google.com & googlegroups.com cookies
17:41mmarczykzakwilson: it should solve it for a while... no guarantee that it won't come back though :-/
17:42idrophi, I'm new to clojure and FP, & trying to Find the sum of all the even-valued terms in a Fibonacci sequence which do not exceed four million. I have a fn for lazy seq of fibo, but trying to apply following filter to this seq:
17:42idrop(defn myfilter[] (filter (comp #(< % 4000000) even?) (fibo)))
17:42zakwilsonmmarczyk: clearing the cookie fixed it. Thanks.
17:43mmarczykgood, though as I said, the problem seems to recur occasionally for whatever reason
17:44mmarczykidrop: you could also take every third term
17:44idropand i think the even? predicate is returning a list of boolean, which can't be evaluated by the next-left predicate.. guess i has thought comp was the intersection of predicates
17:44mmarczykcomp is function composition
17:45eevaridrop: you're applying your filter to every element in the infinite list?
17:45mmarczykyou could use, say, #(and (< % 4000000) even?)
17:45mmarczykor (filter even? (take-while #(< % 4000000) (fibo)))
17:46idropooooh, 'and' .. that makes sense
17:46mmarczyk:-)
17:51tomojneed to add a point there
17:51tomoj(even? %) I mean
17:52mmarczykhm? where?
17:53mmarczykthere's no point to wrapping even? in #(even? %), if that's what you mean
17:54tomoj#(and (< % 4000000) (even? %)) I mean
17:54mmarczykah, um, ouch :-P
17:54tomoj#(and (< % 4000000) even?) is the same as #(< % 4000000)
17:54eevartesting for size in the filter is kindof awkward, tho. when do you stop?
17:55mmarczykyup, silly me, thanks
17:55tomojyeah, won't work anyway :)
17:56mmarczyktrue. one problem here was "how to compose predicates", the other was "why take-while should be used" ;-)
17:56tomswhello
17:57tomojso clojure in uncle bob's keynote I hear :D. wonder how many will come because of that
17:57mmarczykyeah, I tried scanning the video to find the mention, but somehow couldn't
17:58tomswis there a way to create an anonymous class that implements an arbitrary set of methods?
17:58tomswi thought of (proxy [Object] [] (method1 [args] ...)) but I can't call method1 on the result
17:59mmarczyktomsw: nope, if you need arbitrary methods -- possibly specific to your class -- you'll need gen-class
17:59mmarczykproxy can only implement methods of the superclass + interfaces
18:00idropgot it now, thanks for your help
18:00mmarczykwhat I really loved about that keynote -- Uncle Bob's -- though, was how he insisted that everybody needs to flush their reading queues and read SICP as their very next book :-D
18:01tomojnice
18:01tomswmmarczyk: how do I get from creating a namespace that creates a class to an instance of that class?
18:01mmarczykidrop: happy Eulering (I guess?) :-)
18:01cemerickyeah, who'd have ever thought Uncle Bob would be the highest-profile clojure proponent
18:01tomojI can hear all the rubyists grumbling about parentheses
18:01mmarczykcemerick: that's a lol-inspiring way of putting it :-)
18:02mmarczyktomoj: through the constructor ;-)
18:02idropmmarczyk: indeed :)
18:02mmarczykouch, I mean, tomsw
18:03tomswmmarczyk: ouch indeed
18:04Licensermmarczyk: you#re welcome :)
18:04Licenserand thak you for noticing
18:04mmarczykLicenser: how could I not :-)
18:08Licenserwell it was spammy? :P
18:08tomswmmarczyk: ok but it's not dynamic in the sense that it will only generate classfiles that can be loaded by another java instance - I can't just inject a new class into the current environment
18:09mmarczykLicenser: not my meaning at all ;-)
18:09mmarczyktomsw: true
18:10mmarczyktomsw: why would you want to inject an entirely new class -- as opposed to a subclass of a preexisting class overriding some methods or perhaps a class implementing some interfaces?
18:12tomswmmarczyk: in this case it's because I'm trying to do as much as possible on the repl without compiling anything :)
18:12mmarczykwell, that won't be possible at this time
18:12mmarczyknote that if you use :gen-class, you can replace methods dynamically
18:13tomswok. time to stop pretending this is javascript
18:13mmarczykonly addition / removal of methods needs to happen ahead-of-time
18:13mmarczyk:-)
18:14Licensermmarczyk: but it seems we still have a long way to go :)
18:15mmarczykheh, reading "Let Over Lambda" now... funny how a good part of the introduction is devoted to the magnificence of Paul Graham's "On Lisp" :-)
18:15tomojoh god the intro...
18:15cemerickit's an easy thing to do
18:15tomojbest part is that it ends with "your humble author" :D
18:15mmarczykLicenser: and it is a *long* way indeed, with some downcasting maybe ;-)
18:16mmarczyktomoj: really? bwahahaha :-D
18:18tomswI liked the auto-quoting macros and the pandoric macros, but "humble" is just wrong
18:21cemericktechnomancy: 322 looks like it's in the bag from here :-)
18:40arohnertechnomancy: it looks like lein plugins can't effectively hook deps, because the first time you run lein deps, your plugin isn't installed
18:43alexykoh, the hookery of it
19:46Blackfootfor clj-native, i'm trying to get the root DynamicClassLoader. But when compiling with SWT, the whole chain from baseLoader does not contain an instance of that class
20:29bortrebGood evening everyone
20:29bortrebI've been using clojure.contrib.shell-out to write some simple scripts, but it always waits for the command to finish before printing the results. Is there some way to make it print to the terminal as the shell command generates text? (I'm using it to automate calls to rsync that take ~15 mins and want to see the progress)
20:30bortrebmaybe using binding to *out* or somethign?
20:31chouserbortreb: not yet. you can mimic its implementation in your own code.
20:33bortrebso I'd have to rsync each file independently and print those results as they complete instead of issuing one command?
20:33bortrebfor example?
20:36chouserbortreb: I just mean you could write your own sh fn that prints stdout as it goes or something.
23:12alexyklancepantz: pingy
23:18rshi have a deeply nested object that consists of a map with a key that is a vector of maps, which in turn have a key that are a vector of maps. I want to remove a map from the inner vector.. would a zipper help me here? will anything?
23:21tomojyou have descended into hell
23:21tomojonly satan can help you now
23:22tomojI would be interested to hear what this map represents :)
23:27mmarczykrsh: a zipper would do fine, though you might need to supply your own branch? & children functions to clojure.zip/zipper
23:28rshthanks
23:28mmarczykdepending on what you want to do, you might also have use for clojure.walk
23:29tomojhow would you zip it?
23:29tomojonly descend into keys?
23:29mmarczykI mean, do you want to pop each of the inner vectors or something more complex than that?
23:30rshI need to pop if a key on the map equals something
23:31rshthe only examples of zippers I have seen use nesting of the same kind of data structure
23:32mmarczyktomoj: ah, depends... the general zipper concept would do just fine, but it involves a one-off implementation; clojure.zip might need to be coerced to do the job
23:32mmarczykHuet's paper describes zippers on heterogeneous trees
23:32mmarczykI mean, tree-like structures where nodes might have different types
23:32mmarczykand that's in a statically typed language
23:33mmarczykyou could treat map keys as accessors for fields in ADTs and reuse some concepts
23:34mmarczykum, one question though
23:34mmarczykis the outermost map involved in determining what to remove from the innermost vectors?
23:34rshnope
23:35rshfound the paper, I will have a look at it
23:35mmarczykok, so maybe just write a function to look at an inner map
23:35mmarczykcheck if the vector inside it needs to be popped
23:35mmarczykif so, return a version of the map with the vector popped
23:36mmarczykcall this function foo; then apply this to the outer map:
23:36mmarczyk(partial update-in [...] (partial map foo))
23:36mmarczykhm, overengineered this one :-P
23:37mmarczyk(update-in outer-map [...] (partial map foo))
23:37mmarczykargh
23:37mmarczyk(update-in outer-map [...] (partial foo
23:37mmarczyk... <- here goes the outer vector key
23:38mmarczyksorry for the confusion, I suddenly realise that this is probably my bedtime... but this should probably do fine with no zipping
23:38rshyes, I like the path you were suggesting at the end
23:41mmarczykhope it works out fine -- going off to bed now :-)
23:41rshgood night