#clojure logs

2009-07-02

00:00Chouserhttp://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html
00:01ChouserUnder "Special constructs (non-capturing)" that lists various pieces that can be included in the regex pattern (which is what #"" is)
00:01Chouserfor the flags you can see your options include each of idmsux
00:02ChouserUnder "Field Summary" you can see a list of english-named flags, including DOTALL
00:02Chouserclick on any of those to find out what flag letter to use, for example (?s)
00:03newbie_thanks you
00:04newbie_*thank
00:06Chousernp
00:22newbie_if i have a struct like the following (defstruct atest :t1 :t2) and a vector [ 1 2 ] is there another way to convert this in to a struct then to call (nth vec 1) (nth vec 2)?
00:31jackdempseynewbie_: just learning clojure myself but if you're going to do that a lot you could create a function and use some destructuring
00:31jackdempsey,(defstruct atest :t1 :t2)
00:32jackdempsey,(def avector [1 2])
00:32jackdempsey(defn make-atest [{t1 t2}] (struct atest t1 t2))
00:32jackdempseyoops
00:32jackdempsey,(defn make-atest [{t1 t2}] (struct atest t1 t2))
00:32jackdempsey,(make-atest avector)
00:32jackdempseyalthough i'm sure there's better ways, etc :-)
00:33jackdempseycan use (first avector) and (second avector) too fwiw
00:33Paul___IF I understand what you are asking,
00:33Paul___you can simply use apply.
00:33Paul___In other words, if you have your struct as given,
00:33Paul___you can do (apply atest [1 2])
00:33Paul___woops
00:34Paul___I meant, (apply struct atest [1 2])
00:34Paul___Does that answer your question, newbie, or did I misunderstand ?
00:34newbie_thank you both that is what i need
00:34jackdempseyyea i think you got it.....basically looking for a way to unroll a sequence into individual args
00:35jackdempseynice, i have to remind myself of apply......used to *args from ruby
00:35Paul___Yeah, it's a similar use to *args ...
00:35Paul___BRB.
00:36pmooserOk, back.
00:53jackdempseyso a question of style
00:53jackdempseythere're obviously a lot of java libraries out there
00:53jackdempseyand working with java in clojure seems pretty simple and easy
00:53jackdempseydo people find themselves writing wrappers to java libs often?
00:54grrrtnot for simple stuff
00:54jackdempseyi'm looking to do some NLP stuff with clojure, and will probably make use of a bunch of java libs......but would prefer to code more like i'm in clojure
00:54grrrtbut in my clojure SWT experiments, I can replace +/- 10 lines of java with 1 line of clojure
00:54jackdempseynice
00:55grrrtI'm still doing things like (.open myWindow)
00:55jackdempseyso people wouldn't think it foolish to write some wrappers, or macros even i guess, to streamline what consumers of the lib might want ot do
00:55jackdempseygotcha
00:55grrrtthat's what I'm doing - it might still be foolish though :)
00:56grrrtSome things in java are truly hideous, like anonymous inner classes
00:57grrrtI define functions for that, so I don't have to use (proxy ....) all the time
00:58grrrtone drawback of wrapping could be that it might be difficult to still provide access to the "raw" java objects you're wrapping...
01:02jackdempseyyeah
01:03jackdempseyi mean i'm still really early to this, so i think i'll just go with something, and see how it feels
01:10Chouserthe general recommendation is to not wrap too early.
01:10Chousergo ahead and use whatever java lib you need directly.
01:10ChouserBut if you start to see patterns or ways you could make your clojure code clearer with some wrappers, then go for it.
01:10Chouserjust no (defn parse-int [s] (Integer/parseInt s)) please
01:11grrrtno you don't really gain anything with that
01:12Chouserwait, am I still awake!?
01:24Knekkanyone know offhand how to solve this for compiling vimclojure on OSX ? /Users/jorgeb/CLOJURE/vimclojure-2.1.1/build.xml:66: java.lang.ClassNotFoundException: clojure.contrib.pprint.PrettyWriter (pprint.clj:14)
02:07netmage0606Hello
02:09netmage0606If I understood it right then you can have access to all Java Libs with Clojure. So, there should be a way to program JavaFX with Clojure. Is there someone who tried this? Or are there some technical reasons which makes it for today impossible to program JavaFX in Clojure?
02:10grrrtas far as I know, there is no java API for javaFX
02:10grrrtyou have to program in JavaFX script (or whatever it's called)
02:11grrrtthere was a thread about this on the clojure google group not that long ago I think
02:13netmage0606grrrt: Thanks. I will look for this thread.
02:41Lau_of_DKMorning guys
04:26duncanmwhat's the right way to use the clojure.contrib.http.agent lib?
04:29duncanmah, i got it
08:45AWizzArdCompiling (via ant) a freshly cloned Clojure repo now results in 6 files: clojure, slim and sources, and those three again but with an "alpha" extension.
08:46AWizzArdThe ones without alpha: did they change since the last 1.0? Or are basically all the changes in the alphas?
08:47ChouserI would assume the alpha and non-alpha are identical
08:48Chouseryeah, they're the same
08:48Chouserit's just that one set has the version number so you'll know, the other left it out -- just to be shorter?
08:49frodefwhen a java method calls for "byte[]", how do I make a buffer like that?
08:49Chouserfrodef: (into-array Byte/TYPE (map byte [1 2 3]))
08:50Chouseror make-array
08:50frodefChouser: thanks.. how is that different from (make-array java.lang.Byte 100) which doesn't seem to work?
08:51Chouserfrodef: it's the difference between an array of Byte and an array of byte
08:52frodeffascinating..
08:52rhickeyanyone want to take a crack at chunked 'for'?
08:52ChouserByte is an instance of a subclass of Object
08:53Chouserfrodef: byte is a primitive type, handled specially by the JVM. It's not an Object at all, doesn't have any methods of its own, take up exactly one real byte in memory, etc.
08:54frodefChouser: right, but it looks to me that the into-array thing returns an array of Byte? I get #<Byte[] [Ljava.lang.Byte;@5a71c3>
08:54Chouser(make-array Byte/TYPE 0) ==> #<byte[] [B@359ecd80>
08:55Chouser(make-array Byte 0) ==> #<Byte[] [Ljava.lang.Byte;@319c0bd6>
08:56frodefChouser: oh right, I missed the Byte/TYPE part, sorry.. it works fine. thanks!
09:26AWizzArdChouser: thanks for the alpha info
09:27jweiss_can someone tell me a good resource to learn how to *read* clojure? I can look up function names, but I have no idea what some symbols mean, like #, #^, etc.
09:27dnolenhttp://clojure.org
09:28jweiss_dnolen: uh, yeah
09:28dnolenlook at the part on reader
09:28dnolenthe reader
09:28AWizzArdI think that code is written in Java.
09:30jweiss_dnolen: ah ok that's what i was looking for thanks
09:31dnolennp
09:40Jetienhi! is there a more elegant way to check if a vector v contains a given element x than this?: (some #(== %1 x) v)
09:42Chouser(some #{x} v)
09:44Jetienthanks chouser
10:14Jetieni can' figure out how to solve this: for a given vector and element x i need the subvector of v starting with the first occurrence of x and all remaining elements
10:15Jetienmy idea was using subvec but there doesn't seem to exist a function that yields the index of the first occurrence of an element in an vector
10:16Chouserhm. Well, there's .indexOf
10:17Chouser(defn subvec-starting-with [v x] (subvec v (.indexOf v x)))
10:17Jetienoh :)
10:17Jetienthanks
10:18Jetieni forgot that there's a java part to all collections
10:18Chouser:-)
10:18Chouseryou rarely need it.
10:18Chouserthat is, most of the useful operations are pulled out into clojure.core functions
10:19Chouserbut some of the linear-search ones are not, I guess because they're discouraged?
10:19Chouseryour vector doesn't happen to be in sorted order, does it?
10:19Chouserany sorted order?
10:19Jetienno, it's an arbitrary sequence of integers
10:20Jetienand the order is important
10:20Chouseryeah, this seems the most sensible way I can think of.
10:21Chousersimilarly .contains is not exposed via a function, because vectors are a poor fit if you're going to be doing that kind of thing -- sets are better.
10:22Jetienso a clojure vector implements java.util.Vector ?
10:22Chouserbut in this case a vector seems really right -- you care about order and you want to use subvec.
10:22Chouser(instance? java.util.Vector [1 2 3]) ==> false
10:22duck1123is there a public javadoc for the java part of clojure hosted anywhere?
10:23Jetienchouser: so how did you know you could invoke indexOf ?
10:23Chouserduck1123: not that I know of. Writing javadocs is on the todo, but I suppose when c-in-c is done that becomes a bit moot, or at least different...
10:24ChouserJetien: You can use (supers (class [1 2 3])) to see what it implements, but I just used clojure.contrib.repl-utils/show
10:24Chouser(show [1 2 3]) lists all the methods you can get at.
10:24Jetienthanks
10:48jackdempseycan't seem to run that show
10:48jackdempseyam i missing something obvious?
10:48jackdempseyjava.lang.Exception: Unable to resolve symbol: show in this context (NO_SOURCE_FILE:42)
10:48jackdempseyuser=> (show [1 2 3])
10:49cgrandjackdempsey: show is in clojure.contrib.repl-utils
10:49jackdempseyhm yeah, i guess its not loading anymore
10:50jackdempseyk brb
10:50Chouser(use '[clojure.contrib.repl-utils :only [show javadoc source]])
10:55jackdempseythx Chouser somethings not right with jars/paths/etc
10:55jackdempseyah the fun
11:03jackdempseyyea i think when i updated to 1.0.0- contrib needed updating as well......and now i just have to figure out where to get what from to build. good experience tho
11:04jackdempseyclojure-contrib is still in svn right?
11:04jackdempseyjust the main clojure on github?
11:08achimjackdempsey: both are on github
11:08jackdempseyoh ok, i guess i missed contrib
11:08jackdempseyjeez
11:08jackdempseyduh
11:08jackdempseyhadn't shown up in a search, strange
11:09achimthe current clojure contrib won't work with clojure 1.0, i believe
11:09achimhere's the last tree before test reorganization: http://github.com/richhickey/clojure-contrib/tree/3073f0dc0614cb8c95f2debd0b7e6a75c1736ece
11:11jackdempseyoh
11:11jackdempseyhehe
11:11jackdempseyyeah i'm going in circles
11:11jackdempseydownloaded both sources, built clojure then clojure-contrib specifying the location of the clojure.jar
11:11jackdempseyload them up in classpath, startup the repl, and its still not finding show
11:11jackdempseywill check out that tree, thanks achim
11:13Chouserjackdempsey: are you getting an error when you run that 'use' line?
11:13jackdempseyyeah, its not finding it, so something simple but bad is happening :-)
11:13jackdempseyjava.io.FileNotFoundException: Could not locate clojure/contrib/repl_utils__init.class or clojure/contrib/repl_utils.clj on classpath: (NO_SOURCE_FILE:0)
11:14jackdempseylet me start fresh one more time, and will paste my commands.....still new to ant and very possible i've completely missed something basic here, but i did have this working at one point. brb
11:15Chouserif you're not getting errors when you build, that's probably not the issue.
11:15jackdempseyhmm, yeah the builds seem ok
11:15jackdempseyslim isn't necssary right?
11:16jackdempseythats only if you don't want the compiled clojure code
11:16Chouserthen it's more likely your classpath when you start java
11:17achimjackdempsey: how do you start the REPL?
11:17jackdempseypasting
11:18Knekkany idea about this error while compiling the contrib jar?
11:18Knekk [java] java.io.FileNotFoundException: Could not locate clojure/walk__init.class or clojure/walk.clj on classpath: (dataflow.clj:17)
11:19jackdempseyachim: http://gist.github.com/139520
11:19achimKnekk: compiling with clojure 1.0?
11:19jackdempseyi'm wondering if the clojure.lang.Repl is old huh
11:19Knekkcompiling against clojure from May04, using -Dclojure.jar
11:19Knekkachim: yes, from here http://code.google.com/p/clojure/downloads/list
11:19Knekkon OSX
11:19achimKnekk: the current contrib doesn't work with 1.0 anymore :-(
11:20Knekkachim: I got http://github.com/richhickey/clojure-contrib/tree/3073f0dc0614cb8c95f2debd0b7e6a75c1736ece
11:20Knekkachim: isn't that the last working version to 1.0?
11:20jackdempseysome tags would be helpful
11:21achimi thought it was ...
11:21Knekka nice bundled release with contrib would be nice too :)
11:22jackdempseyyep, so much to do, so little time :-)
11:22achimjackdempsey: does it work if you just call "java -cp path/to/clojure.jar:path/to/clojure-contrib.jar clojure.main" ?
11:23jackdempseythats a negative ghostrider
11:23jackdempseyClojure 1.1.0-alpha-SNAPSHOT
11:23jackdempseyuser=> (show [1 2 3])
11:23jackdempseyjava.lang.Exception: Unable to resolve symbol: show in this context (NO_SOURCE_FILE:1)
11:23jackdempseyhmm
11:24jackdempsey(use '[clojure.contrib.repl-utils :only [show javadoc source]]) returns a nil tho
11:24Chouserthat's good!
11:24jackdempseyah
11:24jackdempseyyep
11:24jackdempseyand now show works
11:24jackdempseyso, hm, excuse me but wtf :-D a bit confused
11:24jackdempseyso its just not loading repl-utils at the start?
11:25jackdempseyi guess that would make sense, huh
11:25jackdempseyman, that is so useful btw
11:29jackdempseyk, so i was putting clojure-contrib in the path, but not actually loading it......now its loading, so i can just type the use line and things are good
11:29jackdempseybut, i'm guessing you all don't type out that use everytime you want to use show....so where should things like that go to load it up for you automaticaly?
11:31lisppaste8Chouser pasted "my current clj launch script" at http://paste.lisp.org/display/82905
11:31Chouserwait, are you on linux?
11:32jackdempseynope os x
11:32Chouserah, well ... not sure how well that will do then.
11:33jackdempseyok well, its a similar beast though
11:33jackdempseyi think my load script is ok for now
11:33jackdempseyunless
11:33jackdempseydoes this loadup the repl-utils for you
11:33Chouseranyway, I have a $HOME/.clojure directory where I put a repl-init.clj where I set *print-level* and (use repl-utils) etc.
11:33jackdempseyahh
11:33jackdempseyi see
11:33Knekkwhere do I get a contrib version that will compile against 1.0?
11:33jackdempseyany chance you can pastie that?
11:34jackdempseyKnekk: did you try that http://github.com/richhickey/clojure-contrib/tree/3073f0dc0614cb8c95f2debd0b7e6a75c1736ece
11:34Chouserthat part is just the -i repl-init.clj part, followed by optional -e or -i's
11:34jackdempseyi believe i have that working against edge of clojure
11:34Chouserer, -r's
11:34jackdempseyyeah, didn't realize thats where you set those things up
11:34jackdempseyi think thats all i need now
11:35kotarakKnekk: everything before the walk, template, test-is move should work against 1.0
11:36achimre: rlwrap: is there a way to have multiline history?
11:36achimi'd ditch emacs right away
11:37Chouserachim: I dunno -- I use a keyboard shortcut to merge pastes into a single line before dropping them into rlwrap
11:37achimChouser: that's clever!
11:38KnekkThanks, 3073f0dc0614cb8c95f2debd0b7e6a75c1736ece compiles
11:38jackdempseycool
11:39Knekknow vimclojure compiles as well. Awesome
11:39Chouserachim: it actually does a bunch of other stuff too: http://agriffis.n01se.net/skel.hg/index.cgi/file/d59d4656cbec/bin/eatpaste
11:39kotarakKnekk: VC is in sync with 1.0 at the moment. Have to incorporate the latest changes in HEAD in the bleeding-edge branch, eg. the stacktrace move.
11:40Knekkkotarak: do updates get announced in here?
11:41jackdempseyChouser: nice. out of curiousity, would you mind pasting your repl-init.clj file?
11:41kotarakKnekk: no. Releases are announced via the group and twitter
11:41kotarakKnekk: But commits go unnoticed (unless you follow it on bitbucket)
11:43Knekkthanks
11:43Knekkback from the office in a few.
11:44achimChouser: that's useful, thanks!
11:54kotarakHow can I get continuous updates of a JTextField
11:54kotarak?
11:54kotarakie. w/o the user hitting enter?
11:59jackdempseyChouser: amazing, your clj script works for me. thx!
11:59Chouserjackdempsey: oh, great. you figured out the .clojure/cp-1.0 stuff?
12:00jackdempseyyeah i had a couple things to change, but now the use i have in repl-init correctly loads up show and friends
12:00jackdempseyare there any other useful things to loadup/set that i may not know of? you mentioned *print-level* i think?
12:00achimah, rlwrap has some multi-line support: you can specify a line break substitute, like rlwrap -m " #_| " ...
12:00Chouserwell, good. I haven't put it up anywhere because it keeps changing and/or break. :-/
12:01achimhitting ctrl-^ then lets you edit a multi-line expansion of the current expression
12:01Chouserjackdempsey: I'll paste my .repl-init in a minute -- found a bug in 'add-break-thread!'
12:01jackdempseyoh ok cool, thx
12:01Chouserachim: oh! cool.
12:03achimthat's good enough for me
12:09jackdempseyheh
12:11lisppaste8Chouser pasted "repl-init.clj" at http://paste.lisp.org/display/82906
12:15Chouser(e) is experimental for me... not yet sure if I like it.
12:30jackdempseyok cool, thanks man
12:31stuartsierraChouser: yes, it's experimental. :)
12:33Chouserstuartsierra: fwiw, it seems to me that most of the times I find it insufficient it's because I need more than the one cause that's printed.
12:34ChouserI've been wondering lately if it would help to print the whole trace in order rather than having each cause in the reverse order of the frames
12:34Chouserthat ordering caused me confusion for a long time at the beginning, and still slows me down at times now.
12:39stuartsierraSo the "root" cause should come first?
12:53dysinger_http://groups.google.com/group/clojure/t/55e55941bd05c5b5 :)
12:55jackdempseyhehe, nice
12:55jackdempseynice stuart
12:56jackdempseyChouser: thx again for the help, i tried to document all of it so others don't have to bug you the same way :-) http://jackndempsey.blogspot.com/2009/07/opening-your-mind-with-clojure.html
12:56Knekkso the recommended approach to multidimensional arrays of mutable data in Clojure is to instantiate as Java arrays?
12:58texodusAnyone in here know their licensing well enough to answer a few simple questions?
12:59drewrtexodus:
12:59drewrJust ask; it'll start the conversation.
12:59texodusfair enough
12:59texodusclojure is epl
12:59texodusdoes that mean I can't distribute if my clojure project relies on gpl libs?
13:00drewrPerhaps, but that wouldn't be a restriction of Clojure's license.
13:01drewrYou can bundle Clojure programs without dependencies and tell people to go get them if that's a problem.
13:01texodustrue, but that's a pain for none-technical users
13:02drewrWhat non-technical user cares about Clojure? :-)
13:02drewrI would think programming in Lisp on the JVM automatically elevates you to technical status. At least that's why I'm here.
13:03stuartsierratexodus: you can distribute Clojure however you want.
13:04drewrtexodus: Are you referring to the compatibility section of http://en.wikipedia.org/wiki/Eclipse_Public_License?
13:04drewrThat does make it sound ominous.
13:06stuartsierraLicense terms don't matter until somebody sues you. If you're worried, distribute your app in two packages -- one for each license.
13:08technomancystuartsierra: spoken like someone who works with lawyers. =)
13:10stuartsierratechnomancy: yes.
13:20Chouserjackdempsey: thanks!
13:20jackdempseyno, ty! :-)
13:20Chouserjackdempsey: so you'll be handling support requests related to the clj script. ;-)
13:20jackdempseyhehe, yep, i'll be happy to help where i can :-D
13:21technomancywhat's this about a clj script?
13:25Chousertechnomancy: http://jackndempsey.blogspot.com/2009/07/opening-your-mind-with-clojure.html
13:27technomancywhat's the rationale for not having a shell script in clojure itself? just that nobody has gotten around to it?
13:27technomancyor to get people comfortable with the fact that they need editor integration? =)
13:28Chousernot sure. I suppose there's some question as to what exactly such a script ought to do.
13:28Chouserthere were several such scripts shared in a g.group thread a while ago, and I was surprised by the variety of functionality they provided.
13:28Chousernot to mention the various platforms
13:31technomancyI guess the OS-specific ext_dirs etc are tricky.
13:36Lau_of_DKGood evening gents
13:37technomancywow, I stick my head out on the mailing list, and I get a flood of patches.
13:37technomancythat's awesome.
13:40Lau_of_DKpatches for...?
13:41Chousukell
13:42technomancyLau_of_DK: for clojure-mode and swank
13:42Lau_of_DKOk - I had some NASTY trouble with Slime the other day - Will you consider taking that on ?
13:43jackdempseyhehe
13:43technomancyno, today I only accept patches
13:43technomancynah; just ask. =)
13:44Lau_of_DK:(
14:01texodusah, two licenses, that does sound like a good idea
14:01texodusI dont anticipate being sued, but potentially harassed
14:02texodusand I'd like to distribute in a binary form so people without programming experience can use it
14:02texodus'binary'
14:02texodusthanks for the advice, all
15:03Chouserpop quiz, Q1: what does (assoc [] 0 1) return?
15:03Chouserpop quiz, Q2: what does (assoc nil 0 1) return?
15:12dysingerI'd rather make my own special purpose shell scripts than have "standard" one - it's just java
15:12dysingerbut - for example - the macports version of clojure comes with bin/clj
15:13dysinger(referring to 10:30am conversation)
15:15kotarakChouser: ad 1: hmm... throws? ad 2: nil? geez, where do you get these questions from?
15:16kotarakok
15:16Chouserkotarak: :-)
15:17Chouserkotarak: thanks for playing, we have a nice parting gift for you.
15:17kencauseySo those answers were corect?
15:17kotarakThe "Trostpreis"
15:17kotarakno
15:17drewr[1] & {0 1} respectively
15:17drewrInteresting.
15:17kencauseyoh, I guess 'parting' should imply that
15:18kotarakA nice flower. :)
15:19kotarakThe first is not so far fetched, but somehow ugly (special case). I don't like the second.
15:20Chouserright, so you're allowed to assoc into a vector at any existing index or at one index past the end which acts like conj
15:20unlinkWhat's the best way to say (zero? (truncating-division n k))
15:21kotarakI would probably avoid both cases, although the first might have some nice applications. (less special treatment)
15:22Chouser(assoc nil 0 1) is perhaps like the corollary to (conj nil 1)
15:22kotarakhmm...
15:22kotarakI don't like either....
15:22Chouserin each case 'nil' is a bit too vague, so Clojure could either throw something or pick a "reasonable" meaning for nil
15:24kotarakI think there is a difference between eg. nil and {}. So (assoc nil some thing) and (assoc {} some thing) means also something different to me.
15:50slurmshello
15:50Chouserhi
15:51Chouserkotarak: do you'd prefer an exception over the current default behavior? or you have something else in mind?
15:52kotarakI would probably prefer an exception. How can assoc or conj decide, what to do on nil? assoc and conj don't act on sequences, but on collections. I think passing nil is an error.
15:52unlinkIs there a way I can do this with reduce? http://paste.pocoo.org/show/126386/
15:54Chouserunlink: *whew*, an easy one: yes you can.
15:54unlinkyeah
15:54unlinkI just noticed
15:55unlinkalthough the condescending attitude is not appreciated
15:55Chouseroh. well, "how" may not be so easy to answer. :-)
15:55Chouserunlink: I'm sorry, I mean it to be funny, no condescending. I'll stop talking now.
15:55unlinkoh, my apologies
15:57Chouserunlink: I certainly did not mean to suggest the conversion to reduce would be easy. I'd be happy to help if you need any.
15:59unlinkthanks
16:08dysingerSo everybody in here has full time clojure work ? :)
16:08Chouserhm, I appear to be headed toward (last ... (iterate ...)) rather than reduce
16:09unlinkChouser: or just (/ log(n) log(1024))
16:09technomancydysinger: /me raises his hand
16:09Chouserunlink: heh. oh. :-)
16:10dysingertechnomancy: also raising hand
16:10kotaraknot full time, but I snuck some Clojure, hehe.
16:10ChouserI've checked in a little bit of clojure at my full time job...
16:10kotaraksnuck in some Clojure, I meant..
16:10Chouser:-)
16:10kotarak:)
16:11kotarakpure self-defense against corporate IT
16:11Chouserand then hosted a 3-hour con call walking my team though it.
16:11unlink:(
16:11unlinkwell good for clojure
16:11unlinkbad for business
16:11Chouserunlink: so you have a solution you like, or you want me to keep poking at it.
16:12unlinkyou can if you like
16:12unlinkI'm actually just doing it for fun anyway, my final solution will be in python
16:12unlinkI can't afford to give that 3 hour conference call.
16:12Chouserusually 3 hours of training is much more expensive.
16:13kotarakluckily my boss looks in the other direction... "As long as the job gets done..."
16:13kotarakWaiting for corporate IT means doing steps backwards. :(
16:14unlinkWhat's the right way to go from java.lang.Double -> java.lang.Integer?
16:14unlinkspecifically, the ceiling of the double
16:16Chouserprobably (int (Math/ceil x))
16:16unlinkIsn't that unchecked?
16:17Chouser(int (Math/ceil 1e100)) ==> 2147483647 so I think you're safe
16:17Chouserunless you want an exception, I suppose.
16:18unlinkI want a BigInteger
16:18unlink(am I asking for too much?)
16:20ChouserI don't know Java math very well. I don't see any BigInteger methods that take Doubles
16:20Chouseror any Double methods that return BigIntegers
16:21ChouserI imagine you could route it through a String, but that smells bad.
16:25Chouser(.toBigIntegerExact (BigDecimal. (Math/ceil 1e23))) ==> 99999999999999991611392
16:25Chouser:-/
16:25Chouserbut I guess that's the Double's fault
16:26unlinklawl
16:55jkantz,(if (Boolean. "false") 1 2)
16:56jkantzno clojurebot?
16:57kotarakon vacation
16:57jkantzis the above really supposed to return 2?
16:57jkantzthat's what clj 1.0 is doing
16:57unlinksupposed to? I don't know. I do know what it does.
16:58jkantzgah, I mean it returns 1
16:58jkantzin clojure 1.0
16:58kotarak(Boolean. "true") returns true, (Boolean. "something else") false => hence the above is correct.
16:58kotarakOh. 1 is wrong, no?
16:59unlink*some other string
16:59jkantzyeah, it seems there is only one false value
16:59unlinkNot surprisingly, (Boolean. true) returns true
16:59jkantz(false? (Boolean. "False"))
16:59jkantz=> false
16:59technomancytriple negative?
17:00jkantz(true? (Boolean. "true") => false
17:00unlinkhold your horses
17:00unlinknew Boolean is almost always the wrong thing to use
17:00unlinkuser=> (false? (Boolean/valueOf "false"))
17:00unlinktrue
17:02unlinkrtfm
17:03unlinkNote: It is rarely appropriate to use this constructor. Unless a new instance is required, the static factory valueOf(boolean) is generally a better choice. It is likely to yield significantly better space and time performance.
17:03unlinki.e. it will return one of the interned values true and false
17:04unlinklike, the same ones that the java compiler emits when it sees the literals "true" and "false"
17:05jkantzok. yeah, reading through docs. but it what situation is the new constructor used? why is it even there?
17:05unlinkIf you need a new Boolean instance.
17:05unlinkI can't think of any reason other than completeness' sake. I've never used it.
17:11slurmsI have some example java code that looks something like new StyledText( shell, SWT/V_SCROLL | SWT/H_SCROLL) My problem is, I don't even know what that pipe is doing there. In the SWT docs I have some constructors have two or three of those. How do I emulate that in Clojure?
17:12grrrtthat's a bitwise or I think
17:13slurms(new StyledText *shell* SWT/V_SCROLL) will work, when you only use one. BUt I'm looking to use two scroll bars here.
17:13kotarak(bit-or SWT/V_SCROLL SWT/H_SCROLL) or something like that, or simply (+ SWT/V_SCROLL SWT/H_SCROLL), not tested, though.
17:13slurmshmm
17:13grrrtI've used + which works with SWT
17:13kotarakbitwise or is in this case equivalent to +, I think
17:14grrrtbut bit-or is closer (well identical) to the | operator
17:14slurmsoh, cause SWT/H_SCROLL is returning a number value (binary) ?
17:14grrrtyes
17:14slurmsah, ok
17:14kotarakFor Boolean. issue: I think similar considerations apply to Integer. ...
17:15slurmshah.. worked
17:15slurmsthank you so much.
17:16slurmsFOO/MY_BAR can return whatever though right? I have to look up the docs or introspect to find out, right?
17:17ozzileekotarak: I've got another issue with ClojureQL. Every query I attempt says "java.sql.SQLException: Operation not allowed after ResultSet closed".
17:17kotarakslurms: To be on save side, yes. Whenever the docs say FOO | BAR, it's numbers, which should work with +.
17:17slurmsgreat. Thanks :)
17:18ozzileeThe user I'm using has only SELECT privileges on the db, but that should be enough for (raw "SELECT * FROM foo"), yes?
17:18kotarakozzilee, you have to realise the resultsetset-seq with doall before leaving the run form.
17:18kotarakYes. should work. I think laziness gets in the way here.
17:19grrrtkotarak, slurms: there is a small gotcha with using + though
17:19kotarakTry: (run *conn-info* (doall (query * foo)))
17:19grrrtbinary 00000111 | 00000001 = 00000111
17:19grrrtbut 00000111 + 00000001 = 00001000
17:19kotarakozzilee: or (with-connection [conn *conn-info*] (doall (execute-sql (query * foo) conn)))
17:20kotarakgrrrt: this will not happen for such constants.
17:20grrrttrue, because they're all 2, 4, 8 etc etc
17:20kotarakgrrrt: such constants have the form 00001 | 00010 ....
17:20kotarakgrrrt: that's why I said: "in this case"
17:24ozzilee(run *conn-info* (doall (query * foo))) gives me the same error. with-connection works.
17:25ozzileekotarak: The first thing I posted was directly from Lao's post on the group, so either the post is wrong or something got broken.
17:25kotarak-.- run needs an overhaul...
17:26kotarakozzilee: you mean the compile error?
17:27kotarakOr the raw?
17:28ozzileekotarak: The raw. Lao's post doesn't use raw, but query has the same effect.
17:29kotarakozzilee: you can try the same doall with with-connection and the raw. Or (run [*conn-info* results] (raw "SELECT * FROM foo") (doall results)).
17:29kotarakLau BTW, not Lao ;)
17:33ozzileekotarak: Ah, ok. That works. Thanks. Not sure where I got Lao from either...
17:34kotarakozzilee: beware changes in JOIN and run syntax... But the possibilities are interesting.
17:37ozzileekotarak: Indeed, it looks like it's going to be pretty powerful.
17:38kotarakozzilee: although, it's probably not an option if you need to go for the last tweak... It provides some abstraction. That comes with a cost. But FULL JOIN with Derby (which doesn't support it) is nice! :)
17:43ozzileekotarak: I imagine I'm going to try pushing it pretty hard, so I'll let you know what I hit my head against :-)
17:44kotarakozzilee: hehe, maybe the list were you didn't cut your fingers is shorter. ;) But that's good. I'd like to see some (more or less) real world examples, which we can test.
17:44kotarakThe code is not very well tested at the moment.
17:45ozzileecut my fingers?
17:45kotarakhit your head against something, loads of rough edges.
17:47ozzileekotarak: Ah, okay, gotcha :-) Yeah, I suppose we'll find out.
17:47ozzileeIs there a NOT NULL predicate?
17:48kotarakgeez... NOT is missing.... Does foo <> NULL also work? (I'm not a SQL guru...)
17:50ozzileekotarak: No, foo <> NULL doesn't work (on mysql, anyway).
17:50kotarakOk. Will look into NOT.
17:51ozzilee"foo = NULL" doesn't work either. Needs to be "foo IS NULL".
17:53ozzileeHahahaha. It is a bit... different.
17:53technomancyI think the word you're looking for is horrible
17:55ozzileeNah, it's not so bad. It gets a bit difficult once you get up to a certain amount of complexity, but most things do.
17:56ozzileeI mostly run into problems with the implementations, as opposed to the language. Performance, mostly.
18:01kotarakI hate the manyfold differences in syntax of the different implementations. I'm not sure on which basis they claim to something called "SQL"...
18:01ozzileeWell, I've got a query working at least. Time to head out for the day, thanks for the help kotarak.
18:01kotarakozzilee: np
18:01kotarakbe sure to file bug reports on github, thanks
18:01ozzileekotarak: Will do.
18:02ozzileebtw, have you check out SQLAlchemy (Python)? It has some of the same ideas, namely the queries as higher-order functions.
18:02ozzilee*checked
18:02kotarakozzilee: no, but will do.
18:03ozzileekotarak: Cool. Later.
18:04kotarakcu
19:44Anniepoo I just got bit by trying to assemble a Swing GUI using map to go through the form. The map, of course, didn't actually execute because it's lazy. Is there a non lazy version of map?
19:49emacsenIs there a simple way to turn a vector of chars into a string?
19:50texodus(apply str [\a \b \c])
19:50emacsentexodus, wow... that was easy :)
19:50texodus,(apply str [\a \b \c])
19:51texodushrm, not good with clojurebot apparently
19:51emacsenworks for me tho
19:53cp2clojurebot is mia
20:04texoduspoor guy - I hope he's ok :)
20:06Anniepooanybody in the bay area, the Clojure meetup starts at 5:45 at Runa
20:13emacsenOkay, one more dumb question. remove is great, but is there a way to do remove only on the first match?
20:13emacsenso you don't remove all the instances of the match, just the first
20:22texodusnot aware of one
20:23texodus(defn remove-first [col i] (if (= (first col) i) (rest col) (cons (first col) (remove-first (rest col) i))))
20:24texodusthough there's prolly a better way
20:26emacsenyeah... what we need is a filter-first
20:26emacsenbut thanks
20:26emacsen(I just read how remove works, it uses filter)
20:33Knekk_What are the normal uses for (constantly x) ?
20:36Knekk_It always returns the first-ever value it was invoked with?
20:36Knekk_user=> (def f (constantly x))
20:36Knekk_#'user/f
20:36Knekk_user=> (f 1 2 34 5 6)
20:36Knekk_1
20:36Knekk_user=> (f 2 )
20:36Knekk_1
20:37Knekk_oh I did (def x 1)
20:38Knekk_ok, I get it
21:27texodusemacsen. if you look at the code for take-while, it works the same way, so I guess that is pretyt much the best way to do it
21:31emacsentexodus, thanks
22:02Chouserhas anyone compiled contrib's clojure-1.0-compatible branch? It's just completely failing for me
22:02Chouserjava.lang.NoSuchMethodError: clojure.lang.Namespace.importClass(Ljava/lang/Class;)Ljava/lang/Class;
22:04jackdempseyhmm
22:04jackdempseyseems to work for me
22:05jackdempseygit checkout origin/clojure-1.0-compatible
22:05jackdempseyant -Dclojure.jar=../clojure/clojure.jar
22:05jackdempseycompiles fine
22:05jackdempsey(and the clojure dir is up to date)
22:05duck1123does rich have the 1.0 branch, or is it somewhere else
22:05duck1123I just fetched and i'm not seeing it
22:06jackdempseynot as a remote?
22:06jackdempseyjack@localhost ~/git/clojure-contrib comp $ gb -a
22:06jackdempsey...
22:06jackdempsey remotes/origin/clojure-1.0-compatible
22:06jackdempseyand thats from rich
22:06jackdempsey( finally something i have half a clue about...)
22:08Chouserjackdempsey: hmph, I think that's exactly what I'm doing.
22:08jackdempseyhmmm
22:09duck1123Chouser: did you clean?
22:14Chouserah, my 1.0 branch wasn't up to date.
22:26Chouseroh, nope, still fails :-P
22:33Chouserok, git's just toying with me. I've got it now
23:04gstampI saw this on a blog... (def fibs (lazy-cat [0 1] (map + fibs (rest fibs)))) ... and i'm not sure how it works. How can fibs refer to itself in that way?
23:05Chousergstamp: sorry, I've got a reply started, but not done yet
23:07Chousermaybe the best way to understand how it works is to realize that a lazy seq mutates internally
23:07gstamplol. was that you're blog? I guess I can wait :-)
23:07Chouser:-)
23:08Chousereach step of a lazy seq starts as a closure that knows how to compute a cons cell (first and rest)
23:09Chouserwhen you ask for either, that closure is called
23:10Chouserbut then the closure is thrown away and its return value is cached instead
23:14Chouserso as long as you refer only to parts of the seq that have realized, nothing has to recurse at that point.
23:16Chouserand that's what happens with 'fibs' -- each element is computed only from earlier elements -- all the way back to the [0 1] constants.
23:16Chouseroh
23:16Chousergone
23:16Chouser:-P
23:17liebkeadd-break-thread works again, woot!!! :)
23:18Chouserliebke: nobody told me it was broken!
23:18Chouserthough I apparently I didn't notice either. :-P
23:18liebkemy bad, I should have told you :)
23:18liebkeI missed it
23:21menSannn all
23:31gstampBlasted http://webchat.freenode.net/ hung on me.
23:31Chousergstamp: http://blog.n01se.net/?p=33#comment-1230
23:32Chousergstamp: does that make any sense?
23:32gstampThank you for that. I think I understand
23:33gstampI'll just keep looking at it for another hour to make sure. It's a beautiful piece of code.
23:34Chouserit is, though it does not perform very well
23:36gstampHopefully future versions of clojure can optimize that inconvience truth away.
23:37unlinkspeaking of optimizations, #^Object should be implicit for all parameters w/o type annotations
23:38Chouserunlink: would that help something?
23:39unlink.toString & friends by default use reflection
23:39unlinke.g. (fn [x] (.toString x))
23:41unlinkgetClass, hashCode too
23:46Chouserunlink: hm!
23:48unlinkIt's not often a function gets passed a non-Object in clojure ;)