#clojure logs

2010-08-30

00:18notsonerdysunnyHello everybody, I am trying to get a simple java code (about 10 lines in clojure ) which uses jReality ported to clojure. This is my attempt has been kind of half way successfull. The corresponding github-repo link is git://github.com/sunilnandihalli/jRealityTutorial.git
00:19notsonerdysunnyThe project is nicely set up to work with leiningen .. so simple "lein deps && lein native-deps" should get it started. after that I just execute the sexp in the emacs editor ..
00:22notsonerdysunnyWhen the code runs, it opens the ui and shows what is intended in a rather unpleasing way with the flickers and all. when I look at the terminal output it tells me that jogl.jar may not be in the class path.. I have however added it to the :native-dependencies and it does download and extract it . I do see the corresponding shared object files .. but I don't understand why it still says it...
00:22notsonerdysunny...is not finding the jogl.jar .. can Anybody help me?
00:33Raynesnotsonerdysunny: If nobody answers you here, try (if you haven't already) posting your question in the google group (linked in the channel's title). It's late for a lot of people here.
00:35ihodesRaynes: you got any experience with append-spit? i've used it without trouble in the past, but now i keep getting "Cannot change an open stream to append mode." errors.
00:36Raynesihodes: I had that exact same problem a while back. I believe it's a long-standing bug.
00:36ihodesshit. i'm using it in production code.
00:36ihodesthough it works fine there…
00:37RaynesIt may not be, but I remember having that issue a while back. I can't remember what I did about it. I think I ended up using writers directly or something.
00:37ihodesi guess i could just implement it myself…
00:37ihodesyeah
00:37ihodesFileOutputStream will do it for me.
00:38ihodeswhich is my cue to go to bed for tonight. i've learned that hacking with java in the last night does wonders for my stress levels. terrible, terrible wonders.
00:38technomancydoes anyone else get no sound on this page? http://www.youtube.com/watch?v=OONlGVGStSE
00:38ihodesconfirmed: no sound
00:38technomancycool
00:40technomancyyou never know with freaking flash
00:41technomancynot that sound would do me much good in a korean tutorial
00:45ihodesi was wondering the same thing… but yeah, flash is a bane
00:45ihodesRaynes: posted a Q re append-spit on SO
00:48Raynesihodes: Cool.
01:08notsonerdysunnythanks Raynes I think I will post it google groups.
01:50pdk(+ 76.73 350.44 49.27 34.94)
01:50pdk,(+ 76.73 350.44 49.27 34.94)
01:50clojurebot511.38
02:01_na_ka_na_hey guys .. i want to implement a function f which works over 2 function-closures f1, f2 ... but I want to keep f1, f2 private only to f (no one other than f should know of f1,f2) .. whats the way to do that?
02:04wwmorgan,(doc defn-) ; <- _na_ka_na_
02:04clojurebot"([name & decls]); same as defn, yielding non-public def"
02:04noidi_na_ka_na_, or you can define f in a letfn block
02:05noidi(letfn [(f2 [a b] (+ a b))] (def f1 [...] (f2 ...)))
02:05noidisomething like that
02:06noidior, if f is the only one using f1 and f2, you can put the letfn inside f
02:09_na_ka_na_but is it okay to put a let on top level ?
02:09_na_ka_na_what if someone reloads my ns
02:09_na_ka_na_remember that f1, f2 are closures
02:10_na_ka_na_so on reloading ns .. they shouldn't get redef ..
02:13pdkyou can put a let on the toplevel _na_ka_na_
02:14wwmorgan,(doc defonce) <- _na_ka_na. You can combine this with setting :private to true in the function's metadata to get a private var that's not redefined when the namespace is reloaded
02:14clojurebot"([name expr]); defs name to have the root value of the expr iff the named var has no root value, else expr is unevaluated"
02:14pdkthat's how you can define closures on the toplevel :p
02:15RaynesOh, so that's what defonce is for.
02:15RaynesCool.
02:16RaynesThat would have been insanely useful about 4 months ago.
02:20_na_ka_na_wwmorgan: i want to do something like ..
02:20_na_ka_na_(defn gen-closure []
02:20_na_ka_na_ (let [a (atom nil)]
02:20_na_ka_na_ [(fn [] @a) (fn [v] (reset! a v))]))
02:20_na_ka_na_(let [[f1 f2] (gen-closure)] (defn f ...))
02:20_na_ka_na_now how do i utilize defonce to define f1, f2 only once
02:25wwmorgan_na_ka_na_: I think I'd do it this way http://paste.lisp.org/display/114042
02:27_na_ka_na_wwmorgan: but then getter and setter might be utilized by other fns also in my ns .. i dont want that .. i want getter, setter to be private to f
02:27_na_ka_na_and i don't want to put f in a separate ns for this reason alone
02:29wwmorgan_na_ka_na_: Like this? http://paste.lisp.org/display/114042#1
02:30_na_ka_na_wwmorgan: exactly!! thanks
02:30wwmorganhappy to help :-)
02:31gkoWhat format would you use to store data readable by Clojure and Common Lisp?
02:32_na_ka_na_gko: data needs to be human readable ?
02:33gko_na_ka_na_: it would be something like a DSL, but actually no, as it's actually just def/setq...
02:34gko_na_ka_na_: so, before, it was simple, just (load "data.lisp")...
02:35gko_na_ka_na_: where data.lisp sets some variables (lists describing the structures of data format).
02:36_na_ka_na_gko: but how would that be readable by clojure?
02:38gko_na_ka_na_: yeah, maybe I could use just "name value" and read/eval each line...
02:39gko_na_ka_na_: without going XML or similar.
02:39_na_ka_na_gko: hmm .. that's one way .. why don't you wana go xml/json/bson way ?
02:40_na_ka_na_that way data is readable by other systems 2
02:51gko_na_ka_na_: I'm trying to avoid xml/json/bson... anyway, I guess it would have to be like this...
02:52BahmanHi all!
03:12notsonerdysunnywhat does this mean "Please note that messages from new members to this group are moderated (in order to prevent spam), so please be patient awaiting your first messages to appear." .. does somebody actually read the messages before appearing on the group?
03:14notsonerdysunnyhttp://gist.github.com/557124 is the paste of the email I sent this morning to the clojure-google-group.. (and it still has not appeared on the forum) .. can somebody help me with this?
03:24Chousukenotsonerdysunny: the moderation is only for the first message.
03:24Chousukenotsonerdysunny: it's read and approved by a moderator
03:27notsonerdysunnyChousuke: The message I posted this morning about 4 hrs ago is still not there on google groups
03:27notsonerdysunny:(
03:29kjeldahl(load-file "ants.clj") gives me "java.lang.Exception: Unable to resolve symbol: setColor in this context (ants.clj:234)". Any clues for newbie?
03:29notsonerdysunnyIt looks like I have trouble using jogl (java and opengl) I found a bunch of jogl-jars on clojars.org.. Can anybody tell me which is the right one to use? I am using linux
03:30lenwkjeldahl: what does your line 234 look like ?
03:30kjeldahl(defn fill-cell [#^Graphics g x y c]
03:30kjeldahl (doto g
03:30kjeldahl (setColor c)
03:30kjeldahl (fillRect (* x scale) (* y scale) scale scale)))
03:31Chousukekjeldahl: old style syntax. you have an old version of ants.clj
03:31Chousukea really old version :P
03:31kjeldahlOh. Thanks, I'll dig up a newer one.
03:31lenwkjeldahl: yes get a new version !
03:35kjeldahlAny pointer to the official location of ants.clj? The one in Google Clojure Group is from 2008...
03:37kjeldahlFound workable version on http://www.lisptoronto.org/past-meetings/2009-05-clojure-ants-demo
04:07LauJensenGood morning all
04:09mrBlissTop of the morning to you
04:10RaynesGood morning.
04:11hoeckgood morning
04:11RaynesLauJensen: You've got mail!
04:12LauJensenOdd
04:12Raynes-> (/ (.getRawOffset (java.util.TimeZone/getDefault)) 3600)
04:12sexpbotjava.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.util.calendar)
04:17LauJensenRaynes: has -> replaced $ ?
04:17RaynesLauJensen: Yes.
04:18LauJensenWhy? Did you start doing Groovy ?
04:19RaynesHeh, nosir. Anything that begins with the prefix ($ in this case) is a typical command. You can only do so much with commands. Before ->, when we had $( it was a normal command. That's why I needed $eval to be able to evaluate stuff that didn't start with a parenthesis.
04:19Raynes-> is a hook so it's handled differently.
04:19sexpbotjava.lang.Exception: Unable to resolve symbol: is in this context
04:19RaynesIndeed.
04:20LauJensenOk - Makes no sense to me why $( couldnt be a hook
04:22RaynesBecause anything starting with the prefix is a normal command. It doesn't make sense to make a hook look for $( which would appear to be a normal command, but would behave differently. And, It would look weird doing stuff like $('()
04:22Raynes-> '()
04:22sexpbot=> ()
04:24Raynesit*
04:24RaynesI digress. It's 3:24AM and I need to be up in a few hours. I'm off to sleep. <3
04:24LauJensenOk :) Good night
04:44LauJensenIs there something nice in contrib for download binary files? Would slurp* work?
04:45mrBlissI always use (with-open [input --inputstream-- output --file--] (copy input output)) (pseudo-clojure-code)
04:45LauJensenmrBliss: alright, that doesn't tell me much about whats in contrib though
04:45mrBlisscopy in clojure.java.io or clojure.contrib.io
04:47LauJensenslurp* only works for text, copy might do the trick
04:52LauJensenjava.net.URL isn't implemented for copy, hrmf
04:52mrBliss(-> -the-url- (URL.) (.openStream) (BufferedInputStream.)) is what I do
04:53mrBlissI've reused my download function more times than I can count
04:53LauJensenShould go into contrib - In my mind its a missing feature of the io lib
04:53mrBlissI agree
04:56LauJensen(defmethod copy [URL File] [^java.net.URL input ^File output]
04:56LauJensen (copy (-> input .openStream BufferedInputStream.) output))
04:58Chousukeheh
05:00mrBlissI didn't even know you could omit the parentheses in -> or ->>
05:00LauJensenmrBliss: Everything thats not a list gets coerced into one
05:00LauJensenThe exception being the first arg I think
05:01mrBliss(doto mrBliss (memoize ^^))
05:01LauJensenhehe
05:03mrBlissLauJensen: are you gonna make a ticket for it?
05:03LauJensenNot if you are going to :)
05:04mrBlissIf you have an account for Assembla, i'll grant you permission ;-)
05:05mrBlissI haven't got one (yet?)
05:05LauJensenYou can make one quite easily, and I don't have the time right now - If I don't forget I might follow up late this week
05:06mrBlissOk I'll do it (after I had my exam @ 1pm)
05:07mrBlissclojure or clojure.contrib? copy is present in both
05:07LauJensencontrib
05:44notsonerdysunnyHas anybody used jogl in your projects before? if so can you please help me with http://gist.github.com/557124
05:54LauJensennotsonerdysunny: It sounds like you haven't set the LIBRARY_PATH to point to your native deps (the .so files)
06:05notsonerdysunnyLauJensen: doesn't lein automatically set those paths when it is launching the swank server?
06:17LauJensenNot that I know of, but you can check it, theres an environment variable which makes lein print out all paths
06:17LauJensenI forgot what its called
06:26notsonerdysunnyI just saw your fluid-dynamics for clojure blog.. Are you a cfd-er yourself? We work in Meshing ..
06:26notsonerdysunnyLauJensen: *
06:27LauJensencfd'er ?
06:28notsonerdysunnyLauJensen: I was just wondering if you work in Computational Fluid Dynamics ..
06:28LauJensenNo no, I just like swirly things so I thought it'd be fun for the blog
06:28LauJensen:)
06:30notsonerdysunny:) but its cool you have done some benchmarking and all. I will read it..
06:31LauJensennotsonerdysunny: Yea, the blogpost is good if you want to learn about profiling, optimizing math heavy code etc. For learning Fluid Dynamics you should read Jos Stams paper instead. For a more beautiful Clojure solution, wait until I get a snapshot of the current Master branch, wherein you can pass primitives between functions. A lot of the pain in that blogpost comes from not having that ability
06:34LauJensenAlso be aware, that Zach Tellman took my code and implemented it with Penumbra, which yielded 50 FPS on an 800x600 board - yea! :)
06:34notsonerdysunnyLauJensen: I actually work in CFD .. It was nice to find something in clojure for CFD
06:35LauJensenOh really - Perhaps you should contribute version2, because in terms of Clojure code its not very idiomatic. You could make muuuch nicer abstractions without loosing the performance
06:38notsonerdysunnyit does not look like zach has his verion on the github.. or does he?
06:38LauJensenYea, he put it into the test/ demos/ section of penumbra
06:38LauJensenunder gpgpu
06:39notsonerdysunnyoh ic
06:39notsonerdysunnyLauJensen: have you used jReality? scenegraph library..
06:39notsonerdysunnydo you have any comments on it?
06:40LauJensenHaven't tried it yet
06:48notsonerdysunnyLauJensen: I tried setting LIBRARY_PATH and LD_LIBRARY_PATH to the directories that contain the shared-object files .. but it seems to behave exactly same before...
06:51LauJensenok - I don't know whats up :(
06:52fulletsnotsonerdysunny: Which OS?
06:52notsonerdysunnyLinux
06:52notsonerdysunnyubuntu 8.04
06:52notsonerdysunnyJava 1.6
06:59LauJensenI wonder if I put an embedded DB like Derby into a jar file, will the program be able to both read/write to it ?
07:01notsonerdysunnyfullets: *
07:02fulletsnotsonerdysunny: Ah, I just thought that if you were running on a Mac you'd want to set DYLD_LIBRARY_PATH instead, but alas it's not that easy :(
07:03notsonerdysunnyfullets: thanks for trying to help :)
07:05LauJensenI hate to ask this, but what are the recommended git tools for Windows?
07:23bobo_LauJensen: git bash worked ok for me
07:24bobo_but for some reason, everything is a hasle to install in windows
07:30LauJensenSo Im trying to download the JDK and I get this "Your download transaction cannot be approved, please contact Customer Service" - O_o ?
07:34bobo_yeh, someone had a great idea it appears, but people are working on it if you belive twitter
07:36LauJensen?
07:43LauJensenbobo_: ?
07:43bobo_oh, i can hardly understand myself what i wrote
07:44bobo_i saw several people had problems with downloading it
07:44bobo_some people claimed they are working to fix it
07:47LauJensenIt seems that the popular theory is that their geo-ip lookup is failing
07:47LauJensenSo, I went to download.com instead
07:52malcolmsparksDoes anyone here use Maven to release artefacts to clojars?
07:52LauJensenmalcolmsparks: cemerick does
07:52malcolmsparksI've been googling and can only see how this is done with lein or scp.
07:53malcolmsparkscan anyone show me a pom.xml with the required voodoo?
07:55manniche@LauJensen: As far as I recall, the short answer to your derby question is: yes. But only one process is allowed to access a derby db at the time.
07:55LauJensenmanniche: great - and yes, derby has zero concurrency story
07:56mannicheyeah, midly irritating in a debug scenario...
07:58LauJensenWell. It can be annoying if you're using cake, since cake stays in the background, effectively blocking access. Other than that I've never had any problems with it, neither debugging it, since it borks saying "Cant establish connection", so it can only be one thing basically
07:58LauJensenmalcolmsparks: Isn't there something in the clojure-maven project that can help you out?
07:59bobo_and there should be some scp plugins to maven?
08:06malcolmsparksLauJensen: there's nothing I can find in clojure-maven-plugin pertaining to clojars specifically - yes I can use scp (maven-exec-plugin) but then there's the job of working out all the parameters - I wondered if anyone here has gone through that effort
08:06LauJensenmalcolmsparks: There are 2 guys from this community, that I know of, who use Maven. Its not my impression that Maven is generally something which is invested a lot of time in
08:06malcolmsparksI'm happy writing a Maven plugin tailored to clojars but don't want to bother if someone already has this in progress
08:07malcolmsparksLauJensen: ok - so I assume everyone else uses leiningen? if that's the case I'll switch over
08:07LauJensenmalcolmsparks: I would check with cemeric of stuartsierra when America wakes up
08:07malcolmsparksthanks
08:07LauJensenmalcolmsparks: Most people use lein exclusively I think, I use lein and cake
08:13LauJensenAnybody know the equivalent of 'which' on Windows 7 ?
08:14bobo_cake looks realy nice
08:18LauJensenIf they can just match lein feature for feature, then it has a huge advantage in that it install rather easily on Windows
08:18bobo_looks like it can do more then lein?
08:21LauJensenRight now I think it has an edge on lein. The thing about technomancy is that when he gets going, he goes fast :)
08:22LauJensenActually I was a bit dismayed that they forked instead of worked together. But thats how it goes.
08:42LauJensenAny windows users here?
08:45LauJensenGood :)
08:46bobo_noone dares to admit it to youo
08:51LauJensenI just needed to see how some code could run
09:06BahmanHi all!
09:08solussdHi!
09:09zmilaclojure still is ill about docs, see new function http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/keep-indexed
09:29AWizzArdLauJensen: interesting to note, BitBucket moves away from EC2: http://blog.bitbucket.org/2010/08/25/bitbucket-downtime-for-a-hardware-upgrade/
09:31LauJensenAWizzArd: They just needed bigger dedicated hardware :)
09:31LauJensenDunno why they couldnt have that at EC2
09:32AWizzArdprobably could, by getting more Quadruple instances for a fantasy price
09:50amatosRather dumb question: how do I remove a value from a vector (that is how do I create a new vector without a given element in)?
09:51amatosI don't want to remove by index, I want to remove a specific element that I know is on the vector
09:55AWizzArdamatos: you will have to code your own solution for that.
09:56amatosI guess that I can do a filter then make it a vector again, just seems should be an easier way to do it
09:56amatosI would use sets if they kept insertion ordering
09:56amatosthanks
09:57LauJensen,(replace {3 5} [1 2 3 4 5])
09:57clojurebot[1 2 5 4 5]
09:57MayDaniel_amatos: http://github.com/ninjudd/ordered-set
09:57LauJensenamatos: pass replace a map where the key is the old val and the val is the new val
09:57vu3rddamatos: something like this? (into [] (remove #(= % 2) [1 2 3]))
09:57AWizzArdyou can use remove
09:57AWizzArdand call vec on it
09:58vu3rdd,(into [] (remove #(= % 2) [1 2 3]))
09:58clojurebot[1 3]
09:58LauJensenguys, why not use replace? Thats what its there for
09:58AWizzArdthere is no fn provided for this by Clojure, because vectors are not a good data structure to do that stuff
09:58amatosvu3rdd, AWizzArd, that is what I was thinking yes
09:58AWizzArdLauJensen: I think he wants to get rid of an element, not replace it
09:58amatosyes, that is true
09:58AWizzArdamatos: maybe you can use a set?
09:58amatosSets don't preserve insertion order
09:58MayDaniel_http://github.com/ninjudd/ordered-set
09:58AWizzArdone guy here implemented sets that do
09:58MayDaniel_They do.
09:59AWizzArdyes, ninjudd did that
09:59amatosMayDaniel looking at ordered-set now. thanks
09:59amatosordered set will do what I need. thanks!
10:00AWizzArdWhen chouser will be done with FingerTrees then those could be used as well :)
10:04amatosyes, that sounds great. Hopefully they will be in soon
10:04LauJensendont hold your breath, its a lot of work
10:05AWizzArdThe basics are there. But getting those beasts to be efficient and fast is the real issue.
10:05amatosyes, indeed.
10:22fliebelIs there anything for getting a sliding window from a list? so for example (sliding-window 2 (range 5)) would return [0 1] and then [1 2] and [2 3] and so one.
10:23chouser_fliebel: partition
10:24fliebelchouser: nice, didn;t know about the step thing. I suppose setting that t one gives me what I want?
10:25chouser,(partition 2 1 (range 5))
10:25clojurebot((0 1) (1 2) (2 3) (3 4))
10:26chouserif that's what you want, then yes. :-)
10:26fliebel:) thank you
10:52fliebelI solved project euler problem 11 in Clojure. Is there anyone who wants to look at my code, to see if it is good Clojure?
10:52fliebelhttp://gist.github.com/557505
10:56fliebelI havnt' done a lot of Clojure lately, but it looks okayish to me, and it works.
11:05mrBlissLauJensen: I use Clojure/Emacs/Zsh on Linux, OS X and Windows. To be somewhat productive on Windows you have to install Cygwin.
11:06ssiderisdoes defrecord allow you to define just one constructor?
11:06LauJensenmrBliss: If you must have Windows installed, it runs best when you boot from an Arch live CD :)
11:07mrBlissI use a Ubuntu VM for my coding, but I wrote a couple of programs to manage my movie/tv show collection in Clojure and all of my media is on my Windows desktop so, I have no choice.
11:08chouserssideris: defrecord defines exactly two constructors for you
11:09AWizzArdchouser: which are those?
11:09chouser"Two constructors will be defined, one taking the designated fields followed by a metadata map (nil for none) and an extension field map (nil for none), and one taking only the fields (using nil for meta and extension fields)."
11:10ssiderisso any extra constructors should be added as methods...
11:11AWizzArdchouser: thanks, I see this now too
11:11chouserssideris: you can't really do that.
11:12ssiderisah ok
11:12chouserif you want to provide ways to create instances of your record, provide them as regular clojure functions
11:12chouserthese are sometimes called "factory functions"
11:12ssiderisok thanks. sadly, I'm familiar with the concept of factories
11:13chouserI prefer to think of them as helper or convenience functions. :-)
11:14chouserfactory sounds like it sits there spewing stuff. but it's really just a pure function that takes some args and returns an object.
11:15ssideristhere is a great rant somewhere about factories and frameworks in java
11:15ssiderishere: http://discuss.joelonsoftware.com/default.asp?joel.3.219431
11:16cemerickah, the hammer-factory-factory thread
11:17karmazillaa function of raw materials to a product?
11:19ssiderischouser: the pattern where you define "factories" where arguments that are not mentioned by the caller are filled with nils looks like a prime candidate for a macro to me
11:20ssiderisif only i knew how to write them :-)
11:20chousercemerick may have written that one for you already
11:21cemerickssideris: http://cemerick.com/2010/08/02/defrecord-slot-defaults/
11:21cemerickchouser: Ironic that a macro of mine that I'm fairly uncomfortable with is in such demand. :-|
11:22ssideriscemerick: thanks, I'll try and understand it before using it
11:22ssideriswell I guess ist shows that there is a gap in the language...
11:22chousermaybe, but there's also something oddly familier or fitting about that.
11:23chouserssideris: a gap between the language and what we think we want it to be
11:23chouserwhether the gap is in the lanuguage or our thinking isn't indicated.
11:23ssiderisi thought the point of lisp was that it's programmable so it can be what you want it to be!
11:23chouserand when what's involved is rhickey's language and my thinking, I too become fairly uncomfortable
11:24chouserssideris: well, yes. but be careful what you wish for. :-)
11:25ssiderishaha, point taken
11:25fliebelchouser: would you mind explaining your implementation of project euler 11? http://clojure-euler.wikispaces.com/Problem+011
11:26ssiderisis there any way to get a bit more information out of exceptions? like a line number for example?
11:30chouser(.printStackTrace *e) will give you more information than you want.
11:30ssideristhanks
11:31fliebelchouser: Am I right to assume you used a 2D vector, instead of an 1D one, like most implementations I've seen?
11:32chouserfliebel: not sure about the others, but mine is 2D vector yes
11:33fliebelchouser: Good, the eliminates the issue where you can get results that wrap around the edges.
11:34fliebelchouser: How does this work? (partial map list)
11:34chouserfliebel: I keep things in bounds with the :while
11:35fliebelchouser: Ah, looking at the one below yours :P
11:35chouserwhere's (partial map list) ?
11:35chouseroh, sorry
11:35chouseryeah, I just saw it
11:36fliebelyours is even more magic, using a string instead of a vector...
11:36fliebelah, your splitting it up in parts of 20
11:36fliebelstarts to make sense...
11:37chouserright, to build a 2D vector
11:37fliebelI just did this one: http://gist.github.com/557505 but it's bad, because it wraps.
11:37chouserI prefer not to manually edit the input data, hence parsing the string in clojure
11:38chousermine avoids wrapping (or otherwize falling off the edge) with the :while clause in the 'for'
11:38fliebelchouser: I'm still trying to untangle the rest of the process
11:39fliebel*practicing inward-out-reading*
11:39chouser:-)
11:40chouseryx is a vector of lenght two, coordinates.
11:41chouserso reduce nth grid yx is a sneaky way of saying (nth (nth grid y) x)
11:41chouseror (get-in grid yx)
11:42fliebel*copys code over to vim to have rainbow parens*
11:42chouserso just fetching yx from the grid.
11:43chouserhuh. I guess if I used 'get' instead of 'nth' I wouldn't have needed the :while at all
11:44fliebelwhere?
11:44clojurebotwhere is your source code
11:45chouserthe nth in reduce, the :while in for
11:45chouseroh, nm. nil is no good
11:45fliebelso what is the difference?
11:45chouser,(nth [] -1)
11:45clojurebotjava.lang.IndexOutOfBoundsException
11:45chouser,(get [] -1)
11:45clojurebotnil
11:46chouserJoC has a handly little chart for this I think
11:47fliebelI'm going to translate your code to human language to make it understandable for myself… I suck at understanding Clojure code...
11:47chouserI think reading code is inherently harder than writing code, regardless of the language.
11:49fliebeltrue, but clojure has this inside-out style, which I'm not used to anymore.
11:49fliebelI *love* ->
11:50ssiderisi just don't get -> yet :-)
11:50fliebelwhat is delta-yx for?
11:50cemerickgood code shouldn't be heavily nested IMO
11:51fliebelcemerick: So how do you avoid nesting?
11:51cemerickI don't find that I need to *avoid* it. It's just a matter of avoiding the lisp equivalent of spaghetti code
11:52cemerickhrm, I am full of contradictions. :-/
11:52cemerickMy point being, if you're doing (foo (bar (baz (other-fn 5) x) y) z) q), you're not doing anyone any favors.
11:53cemerickUse -> and friends, or break out individual expressions into a series of let-bindings so as to keep things clear.
11:54chouserfliebel: http://gist.github.com/557593
11:55fliebelchouser: this is your code redone with -->?
11:55chouseryeah
11:55fliebelnice
11:55chouserand with get-in instead of reduce nth, so I don't need the :while
11:55chouser'for' essentially nests loops for each clause, right?
11:56chousersx is the starting x location, the column.
11:56fliebelI think so...
11:56fliebelyea, I see
11:56chouserfor each column, sy is the starting y location
11:56chouserfor each sx,sy starting position, delta-yx is the direction to go to find 4 in a row
11:57fliebelah
11:59fliebelso take 4 returns 4 2-length tuples of positions in the given direction
12:04fliebel*thinking out loud* what happens when the index is out of bounds… it returns 0 for that index… so you can actually have a set like '(23 0 0 0)… which doesn't really matter because it'll be low anyway…. and then you apply * to that and get the max of the whole bunch. yay!
12:05chousersounds like you got it.
12:06fliebelyea, thanks for explaining and the ->> version :)
12:06chouser:-)
12:06chouserI'm sure my original solution predates ->>
12:07fliebelAnd I for myself feel (code (like (this))) is easier to write/grow, while ->> is better for reading.
12:08Raynesfliebel: Indeed. I typically write it like the former and then change it to the latter.
12:08RaynesI don't have a habit of thinking backwards.
12:09fliebelRaynes: That is a strange thing to say, as (code (nested)) is actually more backwards than (-> nested code)
12:10fliebelTurns out I'm also full of contradictions...
12:10Raynesfliebel: Not necessarily.
12:11Raynesfliebel: If you're used to writing code that way, it's going to seem much less backwards than the opposite.
12:12fliebelokayokay, I get it… real men don't read lisp, they think lisp :P
12:12fliebel(just like real man don't eat honey, they chew bees)
12:12Raynes:)
12:14fliebelSo maybe lisp is just like towers of hanoi… *tries to come up with another stupid analogy*
12:23fliebelattacking the next problem… (15)
12:25arnorhsI'm also attacking problems
12:26fliebelarnorhs: euler problems, or 'real' ones?
12:28arnorhsreal ones
12:28arnorhsI don't do math
12:28arnorhsI do meth
12:29fliebelmethamphetamine? :P
12:29fliebel(that's what my dictionary said when I clicked on meth)
12:35mcavis there a function to split a string into chunks of length N? I don't see anything in clojure or clojure.contrib; i'll do it manually otherwise, but seems like something would be in core or contrib already
12:35mrBliss,(partition 2 "hello mcav")
12:35clojurebot((\h \e) (\l \l) (\o \space) (\m \c) (\a \v))
12:36mcavyeah, that's how i'd do it if there wasn't a string-specific function... is there any kind of performance penalty with all those seqs?
12:36mcav(as opposed to java string.substring)
12:37mrBlissmmm, you could do some small benchmarks to see if it matters
12:38mcavyeah, will do, ty
13:04fliebelchouser: did you write more of those euler solutions in Clojure?
13:31ssiderisis this the best way to go from list to vector? (apply vector l)
13:31ssiderish l is a list
13:32Chousukessideris: (vec l) is enough.
13:32ssiderisah, thanks
13:34fliebelHow do I create an integer from a char? (Integer. \1)
13:36chouser,(Character/digit \1 10)
13:36clojurebot1
13:39chouser,(read-string (str \1))
13:39clojurebot1
13:39chouser,(Integer/parseInt (str \1))
13:39clojurebot1
13:39fliebel,(Integer. (str \1))
13:39clojurebot1
13:40chouser,(Character/getNumericValue \1)
13:40clojurebot1
13:40fliebel,import this
13:40clojurebotjava.lang.Exception: Can't take value of a macro: #'clojure.core/import
13:40fliebellol
13:41ssiderishas anyone used the clj-swing macros?
13:44fliebel,(map #(new Integer (str %)) (\3 \4 \5 \6 \7))
13:44clojurebotjava.lang.ClassCastException: java.lang.Character cannot be cast to clojure.lang.IFn
13:44fliebelsame for all the other options
13:44fliebel:$ oops
13:45fliebel'
14:07chouser,(map #(Character/getNumericValue %) [\3 \4 \5 \6 \7])
14:07clojurebot(3 4 5 6 7)
14:07chouser,(map #(Character/getNumericValue %) "34567")
14:07clojurebot(3 4 5 6 7)
14:08chouser,(Integer/parseInt (apply str [\3 \4 \5 \6 \7]))
14:08clojurebot34567
14:08fliebelHow does Clojure handle octal numbers?
14:10hiredmanfliebel: very well
14:11mrBliss,(= 010 8)
14:11clojurebottrue
14:11fliebelnice
14:12mrBlissor for a arbitrary base:
14:12mrBliss,(= 10r7 7)
14:12clojurebottrue
14:13fliebel,3r120
14:13clojurebot15
14:35florianjunkerCan I use transients with transactions?
14:37chouserflorianjunker: yes, if you're careful
14:37florianjunkerchouser: What does careful mean in this context?
14:38chouserflorianjunker: changing a transient is a side-effect as far as a transaction is concerned
14:38florianjunkerSo, it needs to happen inside of an agent?
14:38chouserflorianjunker: so if you're changing a transient inside a dosync, you probably need to make sure that transient is created inside the same dosync.
14:38chouserthat's another option
14:39fliebelUgh, it's to late to attempt math...
14:40fliebel,(letfn [(multi-of [nr maxi] (take-while #(< % maxi) (iterate #(+ nr %) nr)))] (apply + (concat (multi-of 3 1000) (multi-of 5 1000))))
14:40clojurebot266333
14:40fliebel= wrong answer according to euler
14:40florianjunkerIs there any easily accessible information about the amount of memory that clojure uses for its various data structures?
14:41chouserflorianjunker: hm, not that I know of.
14:43fliebelStrange…
14:44fliebel,(letfn [(multi-of [nr maxi] (take-while #(< % maxi) (iterate #(+ nr %) nr)))] (apply + (concat (multi-of 3 10) (multi-of 5 10))))
14:44clojurebotjava.lang.Exception: Unable to resolve symbol: <  in this context
14:44fliebelhuh.. that was supposed to give 23
14:45fliebel,(letfn [(multi-of [nr maxi] (take-while #(< % maxi) (iterate #(+ nr %) nr)))](apply + (concat (multi-of 3 10) (multi-of 5 10))))
14:45clojurebot23
14:45fliebelas the example suggests
14:45fliebelsom I'm lost as to why the real thing, with 1000 is claimed to be wrong by euler
14:46fliebelah, *eurekea*
14:46fliebelgive me a set...
14:47fliebelyay
14:56scottjHow do read some input from a user? (read-line) doesn't wait for me to type anything
14:57chouserscottj: slime?
14:57scottjchouser: yeah
14:58chouserit's getting in your way. :-/ I'm not sure how to do it with slime.
14:58scottjok. with pre-lein there was an inferior lisp buffer that you could use when slime messed with stuff but I think that's gone now
15:06scottjIs there something like file-truename from elisp, where you could do (slurp (file-truename "~/foo")) for handling ~?
15:09ansso is anyone working on some xlib bindings for clojure?
15:10scottjans: going to write a wm? :)
15:10ansscottj: toying with the idea
15:11scottjans: maybe there's something in java.
15:12ansscottj: im looking into that now
15:17chouserans: http://github.com/abrooks/prion/blob/master/src/prion.clj
15:17raekhaha! http://blog.fogus.me/2010/08/30/community-standards/
15:17chouserans: hardly anything there yet, but maybe some ideas.
15:17raekimplicit self reference is the best kind of humor...
15:22LauJensenfogus: thats an instant classic :)
15:22abrooksans: I may have missed the context (chouser pointed out that I should weigh in) but I'd suggest using xcb bindings instead of xlib.
15:23ansabrooks: why xcb
15:24abrooksMaybe chouser already said that and I'm being redundant. In any case, there's example code using an older version of clj-native to call the native libxcb here: http://github.com/abrooks/prion
15:24abrooksans: xlib is a synchronous library, xcb is asynchronous. xcb is also a much more modern (albeit somewhat less featured) replacement for xlib.
15:25abrooksans: In current Xorg, the xlib interfaces are written on top of xcb.
15:25fliebelLauJensen: I went to bed yesterday, halfway your testing of Clojure for your game after the C++ Decision. Any news?
15:25abrooksans: http://xcb.freedesktop.org/
15:25scottjis there a shorter way to write (let [{:keys [a b]} amap] [a b]) ?
15:27chouserscottj: (map amap [:a :b])
15:27scottjchouser: thanks
15:27LauJensenfliebel: The news is that you were so tired, that you forgot it was Bjering who was testing :)
15:28chouserscottj: of course that's a lazy seq not a vector, but may be close enough.
15:28abrooksans: http://github.com/abrooks/prion/blob/master/src/prion.clj is currently a port of the last example on this page: http://xcb.freedesktop.org/tutorial/ (with all the XCB wrapping, some idiomatization and example all mashed together, ew.)
15:28fogusLet it be known that I do not disparage anyone their personal style -- only that I wish to point out that there is a cost associated with it
15:29fliebelLauJensen: You are right… you know the outcome? :P
15:30LauJensenfliebel: He's going with C++ since Java has a bug for which the root cause cannot be determined
15:34kotarakthe methods of reify are closures, aren't they?
15:34chouserkotarak: the whole thing is a closure, essentially.
15:35kotarakk
15:36kotarakshrinking is hairy, it seems...
15:37chouser???
15:37kotarakquickcheck style shrinking. For testing purposes. Tries to minify an counterexample for a test.
15:37chouserhm.
15:56leafwI am looking for an ide to develop clojure in--using vim at the moment. Any recommendations other than emacs?
15:56leafwto dev clj code, that is, not clj itself!
15:57kotarakleafw: vim obviously :)
15:57leafwkotarak: I am afraid I let you down on that offer in the mailing list. vim clj baffles me .I use it only for syntax coloring
15:57slyrusleafw: emacs
15:57kotarakleafw: ccw
15:58leafwby the way your memoize functions are very nice. kotarak: uder what license is that code in your webpage?
15:58LauJensenleafw: http://bestinclass.dk/index.clj/2010/03/clojure-ides-the-grand-tour-getting-started.html
15:58leafwccw sounds like counterclockwise ... eclipse?
15:58leafwLauJensen: thanks
15:59kotarakleafw: Normally I use MIT license, but since the memoize function is a product of the community I would say EPL is fine.
15:59leafwkotarak: a note to that effect in the webpage would be great :) And thanks
15:59raekEclipse – Counterclockwise, Emacs – clojure-mode, SLIME, swank-clojure, Idea – La Clojure, Netbeans – Enclojure, Textmate, Vim
16:01leafwraek: the point on IDE was, does any really work? Makes life painless? Expands all function names, knows how to go to the declarations, can tell me something is wrong (particularly with namespaces)?
16:02leafwgotta go, bbl ~ 2h
16:02kotarakI'm not sure about the last one, I think the other points are all covered (also with VC)
16:02kotarakClojure has a quite good position IDE-wise. (considering its age)
16:02raekI only have experience with emacs, so don't think I have any useful stories for you
16:02leafwkotarak: I know, I am just spoiled.
16:12scottjleafw: imo the eclipse plugin is currently the best
16:13scottjand in my experience it works better than the scala plugin!
16:25jfieldsis there a fn that takes nil and returns nil (or an empty list) or takes an element and returns that element in a list?
16:26kotarakjfields: #(when % [%]) is approximation
16:28jfieldsthx
16:28kotarakjfields: pay attention to boolean false...
16:29jfieldskotarak, yep. thanks
19:01mrSpecHello! I have problem with connection to DB "No suitable driver found for jdbc:postgresql://localhost:5432/" I've added postgresql's jdbc to CLASSPATH, what else should I do?
19:04scottjmake sure you have the right connection string
19:07arohnermrSpec: you might also need to do (. Class (forName "org.postgresql.Driver"))
19:08mrSpecI hope string is ok. I'm trying run example from http://groups.google.com/group/clojure/browse_thread/thread/176a11847601cc5a/445026a02e302837?pli=1
19:09mrSpecorg.postgresql.Driver [Thrown class java.lang.ClassNotFoundException]
19:11arohnermrSpec: that sounds like postgres isn't on your classpath. Have you restarted the clojure process since you added the jar?
19:11arohneror your classpath isn't what you think it is
19:13mrSpecok, now I've tried run it from shell, not emacs
19:13mrSpecjava.lang.ClassNotFoundException: org.postgresql.Driver (NO_SOURCE_FILE:0)
19:13mrSpechm so maybe something wrong with my classpath :S
19:16mrSpecbut there cant be anything wrong I think, $CLASSPATH contains clojure/postgresql-8.3-604.jdbc4.jar
19:21arohnermrSpec: how are you starting the clojure process?
19:21mrSpecjava -jar clojure.jar
19:22arohnermrSpec: aha! -jar ignores $CLASSPATH and -cp
19:22arohnermrSpec: start like java -cp clojure.jar:postgres.jar clojure.main
19:24mrSpecah, but unfortunately still the same problem java.lang.ClassNotFoundException: org.postgresql.Driver (NO_SOURCE_FILE:0) :/
19:25arohnermrSpec: are you sure the path to the postgres jar is correct? that really should work
19:28mrSpecah, now I see I have some problem with clojure contrib. I'll add it to classpath too.
20:00mrSpecarohner: everything works! thanks :)
20:02arnorhsheh, arohner is almost an anagram of my name :)
21:55ihodesanyone here able to give me a hand with an Elive questio?n
21:55ihodesEnlive* make that
21:59scottjihodes: just ask question
22:05ihodeswell, Enlive is html-escaping content i format with a snippet when I use emit*, but if i leave off the emit* and just print the node sequence, it shows the content formatted regularly with HTML. when I use emit* on that seq of nodes, just that content is html-escaped, whilst the rest of the template remains properly formatted
22:06ihodesah i see that when i have a list of nodes, the tags aren't in place for the content i'm adding. e.g. it considers <p> a piece of content, not a tag.
22:07ihodesso is there a function like content (from Enlive) that will keep the HTML formatting? substitute almost does it
22:09ihodestake it back, substitute doesn't do it. what i'm trying to do here is select the :body of my template, and put the result of a snippet in it. that snippet needs to take in a string of HTML and place it between its <section> tags: the problem is, it does that, but the HTML tags aren't considered as node delimiters: instead they're considered all part of the content string, and so they're escaped in the result of my template i'm spitting to
22:09ihodesfile.
22:44ihodesfound it by searching through the source: html-content
23:16pdk,(+ 76.73 49.27 34.94 350.44 60.97)
23:16clojurebot572.35
23:38technomancyis (System/getProperty "user.home") ever going to be different from (System/getenv "HOME")?
23:41technomancyalso, is it possible for that to ever be nil?
23:43bmhtechnomancy: yes. It is possible for them to differ
23:44bmhgetenv pulls the environment variable HOME.
23:44technomancybmh: so if someone's been monkeying with it?
23:44bmhIf I `export HOME=foo`, then getProperty will return the path to my homedir, while getenv returns foo
23:45bmhtechnomancy: For very small values of monkeying and someone ;-)
23:45technomancyI'll just stick with getProperty then
23:45technomancyno idea why I was checking both here... must have been late
23:47bmhtechnomancy: In a more mundane case, I believe that they can differ if you're su'ed to another user
23:47bmhHm. Looks like it's the case with fakeroot, but not with su. Your mileage may vary.