2009-07-02
| 00:00 | Chouser | http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html |
| 00:01 | Chouser | Under "Special constructs (non-capturing)" that lists various pieces that can be included in the regex pattern (which is what #"" is) |
| 00:01 | Chouser | for the flags you can see your options include each of idmsux |
| 00:02 | Chouser | Under "Field Summary" you can see a list of english-named flags, including DOTALL |
| 00:02 | Chouser | click on any of those to find out what flag letter to use, for example (?s) |
| 00:03 | newbie_ | thanks you |
| 00:04 | newbie_ | *thank |
| 00:06 | Chouser | np |
| 00:22 | newbie_ | 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:31 | jackdempsey | newbie_: just learning clojure myself but if you're going to do that a lot you could create a function and use some destructuring |
| 00:31 | jackdempsey | ,(defstruct atest :t1 :t2) |
| 00:32 | jackdempsey | ,(def avector [1 2]) |
| 00:32 | jackdempsey | (defn make-atest [{t1 t2}] (struct atest t1 t2)) |
| 00:32 | jackdempsey | oops |
| 00:32 | jackdempsey | ,(defn make-atest [{t1 t2}] (struct atest t1 t2)) |
| 00:32 | jackdempsey | ,(make-atest avector) |
| 00:32 | jackdempsey | although i'm sure there's better ways, etc :-) |
| 00:33 | jackdempsey | can use (first avector) and (second avector) too fwiw |
| 00:33 | Paul___ | IF I understand what you are asking, |
| 00:33 | Paul___ | you can simply use apply. |
| 00:33 | Paul___ | In other words, if you have your struct as given, |
| 00:33 | Paul___ | you can do (apply atest [1 2]) |
| 00:33 | Paul___ | woops |
| 00:34 | Paul___ | I meant, (apply struct atest [1 2]) |
| 00:34 | Paul___ | Does that answer your question, newbie, or did I misunderstand ? |
| 00:34 | newbie_ | thank you both that is what i need |
| 00:34 | jackdempsey | yea i think you got it.....basically looking for a way to unroll a sequence into individual args |
| 00:35 | jackdempsey | nice, i have to remind myself of apply......used to *args from ruby |
| 00:35 | Paul___ | Yeah, it's a similar use to *args ... |
| 00:35 | Paul___ | BRB. |
| 00:36 | pmooser | Ok, back. |
| 00:53 | jackdempsey | so a question of style |
| 00:53 | jackdempsey | there're obviously a lot of java libraries out there |
| 00:53 | jackdempsey | and working with java in clojure seems pretty simple and easy |
| 00:53 | jackdempsey | do people find themselves writing wrappers to java libs often? |
| 00:54 | grrrt | not for simple stuff |
| 00:54 | jackdempsey | i'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:54 | grrrt | but in my clojure SWT experiments, I can replace +/- 10 lines of java with 1 line of clojure |
| 00:54 | jackdempsey | nice |
| 00:55 | grrrt | I'm still doing things like (.open myWindow) |
| 00:55 | jackdempsey | so 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:55 | jackdempsey | gotcha |
| 00:55 | grrrt | that's what I'm doing - it might still be foolish though :) |
| 00:56 | grrrt | Some things in java are truly hideous, like anonymous inner classes |
| 00:57 | grrrt | I define functions for that, so I don't have to use (proxy ....) all the time |
| 00:58 | grrrt | one drawback of wrapping could be that it might be difficult to still provide access to the "raw" java objects you're wrapping... |
| 01:02 | jackdempsey | yeah |
| 01:03 | jackdempsey | i mean i'm still really early to this, so i think i'll just go with something, and see how it feels |
| 01:10 | Chouser | the general recommendation is to not wrap too early. |
| 01:10 | Chouser | go ahead and use whatever java lib you need directly. |
| 01:10 | Chouser | But if you start to see patterns or ways you could make your clojure code clearer with some wrappers, then go for it. |
| 01:10 | Chouser | just no (defn parse-int [s] (Integer/parseInt s)) please |
| 01:11 | grrrt | no you don't really gain anything with that |
| 01:12 | Chouser | wait, am I still awake!? |
| 01:24 | Knekk | anyone 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:07 | netmage0606 | Hello |
| 02:09 | netmage0606 | If 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:10 | grrrt | as far as I know, there is no java API for javaFX |
| 02:10 | grrrt | you have to program in JavaFX script (or whatever it's called) |
| 02:11 | grrrt | there was a thread about this on the clojure google group not that long ago I think |
| 02:13 | netmage0606 | grrrt: Thanks. I will look for this thread. |
| 02:41 | Lau_of_DK | Morning guys |
| 04:26 | duncanm | what's the right way to use the clojure.contrib.http.agent lib? |
| 04:29 | duncanm | ah, i got it |
| 08:45 | AWizzArd | Compiling (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:46 | AWizzArd | The ones without alpha: did they change since the last 1.0? Or are basically all the changes in the alphas? |
| 08:47 | Chouser | I would assume the alpha and non-alpha are identical |
| 08:48 | Chouser | yeah, they're the same |
| 08:48 | Chouser | it's just that one set has the version number so you'll know, the other left it out -- just to be shorter? |
| 08:49 | frodef | when a java method calls for "byte[]", how do I make a buffer like that? |
| 08:49 | Chouser | frodef: (into-array Byte/TYPE (map byte [1 2 3])) |
| 08:50 | Chouser | or make-array |
| 08:50 | frodef | Chouser: thanks.. how is that different from (make-array java.lang.Byte 100) which doesn't seem to work? |
| 08:51 | Chouser | frodef: it's the difference between an array of Byte and an array of byte |
| 08:52 | frodef | fascinating.. |
| 08:52 | rhickey | anyone want to take a crack at chunked 'for'? |
| 08:52 | Chouser | Byte is an instance of a subclass of Object |
| 08:53 | Chouser | frodef: 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:54 | frodef | Chouser: right, but it looks to me that the into-array thing returns an array of Byte? I get #<Byte[] [Ljava.lang.Byte;@5a71c3> |
| 08:54 | Chouser | (make-array Byte/TYPE 0) ==> #<byte[] [B@359ecd80> |
| 08:55 | Chouser | (make-array Byte 0) ==> #<Byte[] [Ljava.lang.Byte;@319c0bd6> |
| 08:56 | frodef | Chouser: oh right, I missed the Byte/TYPE part, sorry.. it works fine. thanks! |
| 09:26 | AWizzArd | Chouser: thanks for the alpha info |
| 09:27 | jweiss_ | 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:27 | dnolen | http://clojure.org |
| 09:28 | jweiss_ | dnolen: uh, yeah |
| 09:28 | dnolen | look at the part on reader |
| 09:28 | dnolen | the reader |
| 09:28 | AWizzArd | I think that code is written in Java. |
| 09:30 | jweiss_ | dnolen: ah ok that's what i was looking for thanks |
| 09:31 | dnolen | np |
| 09:40 | Jetien | hi! is there a more elegant way to check if a vector v contains a given element x than this?: (some #(== %1 x) v) |
| 09:42 | Chouser | (some #{x} v) |
| 09:44 | Jetien | thanks chouser |
| 10:14 | Jetien | i 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:15 | Jetien | my 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:16 | Chouser | hm. Well, there's .indexOf |
| 10:17 | Chouser | (defn subvec-starting-with [v x] (subvec v (.indexOf v x))) |
| 10:17 | Jetien | oh :) |
| 10:17 | Jetien | thanks |
| 10:18 | Jetien | i forgot that there's a java part to all collections |
| 10:18 | Chouser | :-) |
| 10:18 | Chouser | you rarely need it. |
| 10:18 | Chouser | that is, most of the useful operations are pulled out into clojure.core functions |
| 10:19 | Chouser | but some of the linear-search ones are not, I guess because they're discouraged? |
| 10:19 | Chouser | your vector doesn't happen to be in sorted order, does it? |
| 10:19 | Chouser | any sorted order? |
| 10:19 | Jetien | no, it's an arbitrary sequence of integers |
| 10:20 | Jetien | and the order is important |
| 10:20 | Chouser | yeah, this seems the most sensible way I can think of. |
| 10:21 | Chouser | similarly .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:22 | Jetien | so a clojure vector implements java.util.Vector ? |
| 10:22 | Chouser | but in this case a vector seems really right -- you care about order and you want to use subvec. |
| 10:22 | Chouser | (instance? java.util.Vector [1 2 3]) ==> false |
| 10:22 | duck1123 | is there a public javadoc for the java part of clojure hosted anywhere? |
| 10:23 | Jetien | chouser: so how did you know you could invoke indexOf ? |
| 10:23 | Chouser | duck1123: 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:24 | Chouser | Jetien: You can use (supers (class [1 2 3])) to see what it implements, but I just used clojure.contrib.repl-utils/show |
| 10:24 | Chouser | (show [1 2 3]) lists all the methods you can get at. |
| 10:24 | Jetien | thanks |
| 10:48 | jackdempsey | can't seem to run that show |
| 10:48 | jackdempsey | am i missing something obvious? |
| 10:48 | jackdempsey | java.lang.Exception: Unable to resolve symbol: show in this context (NO_SOURCE_FILE:42) |
| 10:48 | jackdempsey | user=> (show [1 2 3]) |
| 10:49 | cgrand | jackdempsey: show is in clojure.contrib.repl-utils |
| 10:49 | jackdempsey | hm yeah, i guess its not loading anymore |
| 10:50 | jackdempsey | k brb |
| 10:50 | Chouser | (use '[clojure.contrib.repl-utils :only [show javadoc source]]) |
| 10:55 | jackdempsey | thx Chouser somethings not right with jars/paths/etc |
| 10:55 | jackdempsey | ah the fun |
| 11:03 | jackdempsey | yea 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:04 | jackdempsey | clojure-contrib is still in svn right? |
| 11:04 | jackdempsey | just the main clojure on github? |
| 11:08 | achim | jackdempsey: both are on github |
| 11:08 | jackdempsey | oh ok, i guess i missed contrib |
| 11:08 | jackdempsey | jeez |
| 11:08 | jackdempsey | duh |
| 11:08 | jackdempsey | hadn't shown up in a search, strange |
| 11:09 | achim | the current clojure contrib won't work with clojure 1.0, i believe |
| 11:09 | achim | here's the last tree before test reorganization: http://github.com/richhickey/clojure-contrib/tree/3073f0dc0614cb8c95f2debd0b7e6a75c1736ece |
| 11:11 | jackdempsey | oh |
| 11:11 | jackdempsey | hehe |
| 11:11 | jackdempsey | yeah i'm going in circles |
| 11:11 | jackdempsey | downloaded both sources, built clojure then clojure-contrib specifying the location of the clojure.jar |
| 11:11 | jackdempsey | load them up in classpath, startup the repl, and its still not finding show |
| 11:11 | jackdempsey | will check out that tree, thanks achim |
| 11:13 | Chouser | jackdempsey: are you getting an error when you run that 'use' line? |
| 11:13 | jackdempsey | yeah, its not finding it, so something simple but bad is happening :-) |
| 11:13 | jackdempsey | java.io.FileNotFoundException: Could not locate clojure/contrib/repl_utils__init.class or clojure/contrib/repl_utils.clj on classpath: (NO_SOURCE_FILE:0) |
| 11:14 | jackdempsey | let 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:15 | Chouser | if you're not getting errors when you build, that's probably not the issue. |
| 11:15 | jackdempsey | hmm, yeah the builds seem ok |
| 11:15 | jackdempsey | slim isn't necssary right? |
| 11:16 | jackdempsey | thats only if you don't want the compiled clojure code |
| 11:16 | Chouser | then it's more likely your classpath when you start java |
| 11:17 | achim | jackdempsey: how do you start the REPL? |
| 11:17 | jackdempsey | pasting |
| 11:18 | Knekk | any idea about this error while compiling the contrib jar? |
| 11:18 | Knekk | [java] java.io.FileNotFoundException: Could not locate clojure/walk__init.class or clojure/walk.clj on classpath: (dataflow.clj:17) |
| 11:19 | jackdempsey | achim: http://gist.github.com/139520 |
| 11:19 | achim | Knekk: compiling with clojure 1.0? |
| 11:19 | jackdempsey | i'm wondering if the clojure.lang.Repl is old huh |
| 11:19 | Knekk | compiling against clojure from May04, using -Dclojure.jar |
| 11:19 | Knekk | achim: yes, from here http://code.google.com/p/clojure/downloads/list |
| 11:19 | Knekk | on OSX |
| 11:19 | achim | Knekk: the current contrib doesn't work with 1.0 anymore :-( |
| 11:20 | Knekk | achim: I got http://github.com/richhickey/clojure-contrib/tree/3073f0dc0614cb8c95f2debd0b7e6a75c1736ece |
| 11:20 | Knekk | achim: isn't that the last working version to 1.0? |
| 11:20 | jackdempsey | some tags would be helpful |
| 11:21 | achim | i thought it was ... |
| 11:21 | Knekk | a nice bundled release with contrib would be nice too :) |
| 11:22 | jackdempsey | yep, so much to do, so little time :-) |
| 11:22 | achim | jackdempsey: does it work if you just call "java -cp path/to/clojure.jar:path/to/clojure-contrib.jar clojure.main" ? |
| 11:23 | jackdempsey | thats a negative ghostrider |
| 11:23 | jackdempsey | Clojure 1.1.0-alpha-SNAPSHOT |
| 11:23 | jackdempsey | user=> (show [1 2 3]) |
| 11:23 | jackdempsey | java.lang.Exception: Unable to resolve symbol: show in this context (NO_SOURCE_FILE:1) |
| 11:23 | jackdempsey | hmm |
| 11:24 | jackdempsey | (use '[clojure.contrib.repl-utils :only [show javadoc source]]) returns a nil tho |
| 11:24 | Chouser | that's good! |
| 11:24 | jackdempsey | ah |
| 11:24 | jackdempsey | yep |
| 11:24 | jackdempsey | and now show works |
| 11:24 | jackdempsey | so, hm, excuse me but wtf :-D a bit confused |
| 11:24 | jackdempsey | so its just not loading repl-utils at the start? |
| 11:25 | jackdempsey | i guess that would make sense, huh |
| 11:25 | jackdempsey | man, that is so useful btw |
| 11:29 | jackdempsey | k, 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:29 | jackdempsey | but, 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:31 | lisppaste8 | Chouser pasted "my current clj launch script" at http://paste.lisp.org/display/82905 |
| 11:31 | Chouser | wait, are you on linux? |
| 11:32 | jackdempsey | nope os x |
| 11:32 | Chouser | ah, well ... not sure how well that will do then. |
| 11:33 | jackdempsey | ok well, its a similar beast though |
| 11:33 | jackdempsey | i think my load script is ok for now |
| 11:33 | jackdempsey | unless |
| 11:33 | jackdempsey | does this loadup the repl-utils for you |
| 11:33 | Chouser | anyway, I have a $HOME/.clojure directory where I put a repl-init.clj where I set *print-level* and (use repl-utils) etc. |
| 11:33 | jackdempsey | ahh |
| 11:33 | jackdempsey | i see |
| 11:33 | Knekk | where do I get a contrib version that will compile against 1.0? |
| 11:33 | jackdempsey | any chance you can pastie that? |
| 11:34 | jackdempsey | Knekk: did you try that http://github.com/richhickey/clojure-contrib/tree/3073f0dc0614cb8c95f2debd0b7e6a75c1736ece |
| 11:34 | Chouser | that part is just the -i repl-init.clj part, followed by optional -e or -i's |
| 11:34 | jackdempsey | i believe i have that working against edge of clojure |
| 11:34 | Chouser | er, -r's |
| 11:34 | jackdempsey | yeah, didn't realize thats where you set those things up |
| 11:34 | jackdempsey | i think thats all i need now |
| 11:35 | kotarak | Knekk: everything before the walk, template, test-is move should work against 1.0 |
| 11:36 | achim | re: rlwrap: is there a way to have multiline history? |
| 11:36 | achim | i'd ditch emacs right away |
| 11:37 | Chouser | achim: I dunno -- I use a keyboard shortcut to merge pastes into a single line before dropping them into rlwrap |
| 11:37 | achim | Chouser: that's clever! |
| 11:38 | Knekk | Thanks, 3073f0dc0614cb8c95f2debd0b7e6a75c1736ece compiles |
| 11:38 | jackdempsey | cool |
| 11:39 | Knekk | now vimclojure compiles as well. Awesome |
| 11:39 | Chouser | achim: it actually does a bunch of other stuff too: http://agriffis.n01se.net/skel.hg/index.cgi/file/d59d4656cbec/bin/eatpaste |
| 11:39 | kotarak | Knekk: 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:40 | Knekk | kotarak: do updates get announced in here? |
| 11:41 | jackdempsey | Chouser: nice. out of curiousity, would you mind pasting your repl-init.clj file? |
| 11:41 | kotarak | Knekk: no. Releases are announced via the group and twitter |
| 11:41 | kotarak | Knekk: But commits go unnoticed (unless you follow it on bitbucket) |
| 11:43 | Knekk | thanks |
| 11:43 | Knekk | back from the office in a few. |
| 11:44 | achim | Chouser: that's useful, thanks! |
| 11:54 | kotarak | How can I get continuous updates of a JTextField |
| 11:54 | kotarak | ? |
| 11:54 | kotarak | ie. w/o the user hitting enter? |
| 11:59 | jackdempsey | Chouser: amazing, your clj script works for me. thx! |
| 11:59 | Chouser | jackdempsey: oh, great. you figured out the .clojure/cp-1.0 stuff? |
| 12:00 | jackdempsey | yeah i had a couple things to change, but now the use i have in repl-init correctly loads up show and friends |
| 12:00 | jackdempsey | are there any other useful things to loadup/set that i may not know of? you mentioned *print-level* i think? |
| 12:00 | achim | ah, rlwrap has some multi-line support: you can specify a line break substitute, like rlwrap -m " #_| " ... |
| 12:00 | Chouser | well, good. I haven't put it up anywhere because it keeps changing and/or break. :-/ |
| 12:01 | achim | hitting ctrl-^ then lets you edit a multi-line expansion of the current expression |
| 12:01 | Chouser | jackdempsey: I'll paste my .repl-init in a minute -- found a bug in 'add-break-thread!' |
| 12:01 | jackdempsey | oh ok cool, thx |
| 12:01 | Chouser | achim: oh! cool. |
| 12:03 | achim | that's good enough for me |
| 12:09 | jackdempsey | heh |
| 12:11 | lisppaste8 | Chouser pasted "repl-init.clj" at http://paste.lisp.org/display/82906 |
| 12:15 | Chouser | (e) is experimental for me... not yet sure if I like it. |
| 12:30 | jackdempsey | ok cool, thanks man |
| 12:31 | stuartsierra | Chouser: yes, it's experimental. :) |
| 12:33 | Chouser | stuartsierra: 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:34 | Chouser | I'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:34 | Chouser | that ordering caused me confusion for a long time at the beginning, and still slows me down at times now. |
| 12:39 | stuartsierra | So the "root" cause should come first? |
| 12:53 | dysinger_ | http://groups.google.com/group/clojure/t/55e55941bd05c5b5 :) |
| 12:55 | jackdempsey | hehe, nice |
| 12:55 | jackdempsey | nice stuart |
| 12:56 | jackdempsey | Chouser: 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:56 | Knekk | so the recommended approach to multidimensional arrays of mutable data in Clojure is to instantiate as Java arrays? |
| 12:58 | texodus | Anyone in here know their licensing well enough to answer a few simple questions? |
| 12:59 | drewr | texodus: |
| 12:59 | drewr | Just ask; it'll start the conversation. |
| 12:59 | texodus | fair enough |
| 12:59 | texodus | clojure is epl |
| 12:59 | texodus | does that mean I can't distribute if my clojure project relies on gpl libs? |
| 13:00 | drewr | Perhaps, but that wouldn't be a restriction of Clojure's license. |
| 13:01 | drewr | You can bundle Clojure programs without dependencies and tell people to go get them if that's a problem. |
| 13:01 | texodus | true, but that's a pain for none-technical users |
| 13:02 | drewr | What non-technical user cares about Clojure? :-) |
| 13:02 | drewr | I would think programming in Lisp on the JVM automatically elevates you to technical status. At least that's why I'm here. |
| 13:03 | stuartsierra | texodus: you can distribute Clojure however you want. |
| 13:04 | drewr | texodus: Are you referring to the compatibility section of http://en.wikipedia.org/wiki/Eclipse_Public_License? |
| 13:04 | drewr | That does make it sound ominous. |
| 13:06 | stuartsierra | License terms don't matter until somebody sues you. If you're worried, distribute your app in two packages -- one for each license. |
| 13:08 | technomancy | stuartsierra: spoken like someone who works with lawyers. =) |
| 13:10 | stuartsierra | technomancy: yes. |
| 13:20 | Chouser | jackdempsey: thanks! |
| 13:20 | jackdempsey | no, ty! :-) |
| 13:20 | Chouser | jackdempsey: so you'll be handling support requests related to the clj script. ;-) |
| 13:20 | jackdempsey | hehe, yep, i'll be happy to help where i can :-D |
| 13:21 | technomancy | what's this about a clj script? |
| 13:25 | Chouser | technomancy: http://jackndempsey.blogspot.com/2009/07/opening-your-mind-with-clojure.html |
| 13:27 | technomancy | what's the rationale for not having a shell script in clojure itself? just that nobody has gotten around to it? |
| 13:27 | technomancy | or to get people comfortable with the fact that they need editor integration? =) |
| 13:28 | Chouser | not sure. I suppose there's some question as to what exactly such a script ought to do. |
| 13:28 | Chouser | there 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:28 | Chouser | not to mention the various platforms |
| 13:31 | technomancy | I guess the OS-specific ext_dirs etc are tricky. |
| 13:36 | Lau_of_DK | Good evening gents |
| 13:37 | technomancy | wow, I stick my head out on the mailing list, and I get a flood of patches. |
| 13:37 | technomancy | that's awesome. |
| 13:40 | Lau_of_DK | patches for...? |
| 13:41 | Chousuke | ll |
| 13:42 | technomancy | Lau_of_DK: for clojure-mode and swank |
| 13:42 | Lau_of_DK | Ok - I had some NASTY trouble with Slime the other day - Will you consider taking that on ? |
| 13:43 | jackdempsey | hehe |
| 13:43 | technomancy | no, today I only accept patches |
| 13:43 | technomancy | nah; just ask. =) |
| 13:44 | Lau_of_DK | :( |
| 14:01 | texodus | ah, two licenses, that does sound like a good idea |
| 14:01 | texodus | I dont anticipate being sued, but potentially harassed |
| 14:02 | texodus | and I'd like to distribute in a binary form so people without programming experience can use it |
| 14:02 | texodus | 'binary' |
| 14:02 | texodus | thanks for the advice, all |
| 15:03 | Chouser | pop quiz, Q1: what does (assoc [] 0 1) return? |
| 15:03 | Chouser | pop quiz, Q2: what does (assoc nil 0 1) return? |
| 15:12 | dysinger | I'd rather make my own special purpose shell scripts than have "standard" one - it's just java |
| 15:12 | dysinger | but - for example - the macports version of clojure comes with bin/clj |
| 15:13 | dysinger | (referring to 10:30am conversation) |
| 15:15 | kotarak | Chouser: ad 1: hmm... throws? ad 2: nil? geez, where do you get these questions from? |
| 15:16 | kotarak | ok |
| 15:16 | Chouser | kotarak: :-) |
| 15:17 | Chouser | kotarak: thanks for playing, we have a nice parting gift for you. |
| 15:17 | kencausey | So those answers were corect? |
| 15:17 | kotarak | The "Trostpreis" |
| 15:17 | kotarak | no |
| 15:17 | drewr | [1] & {0 1} respectively |
| 15:17 | drewr | Interesting. |
| 15:17 | kencausey | oh, I guess 'parting' should imply that |
| 15:18 | kotarak | A nice flower. :) |
| 15:19 | kotarak | The first is not so far fetched, but somehow ugly (special case). I don't like the second. |
| 15:20 | Chouser | right, 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:20 | unlink | What's the best way to say (zero? (truncating-division n k)) |
| 15:21 | kotarak | I would probably avoid both cases, although the first might have some nice applications. (less special treatment) |
| 15:22 | Chouser | (assoc nil 0 1) is perhaps like the corollary to (conj nil 1) |
| 15:22 | kotarak | hmm... |
| 15:22 | kotarak | I don't like either.... |
| 15:22 | Chouser | in each case 'nil' is a bit too vague, so Clojure could either throw something or pick a "reasonable" meaning for nil |
| 15:24 | kotarak | I 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:50 | slurms | hello |
| 15:50 | Chouser | hi |
| 15:51 | Chouser | kotarak: do you'd prefer an exception over the current default behavior? or you have something else in mind? |
| 15:52 | kotarak | I 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:52 | unlink | Is there a way I can do this with reduce? http://paste.pocoo.org/show/126386/ |
| 15:54 | Chouser | unlink: *whew*, an easy one: yes you can. |
| 15:54 | unlink | yeah |
| 15:54 | unlink | I just noticed |
| 15:55 | unlink | although the condescending attitude is not appreciated |
| 15:55 | Chouser | oh. well, "how" may not be so easy to answer. :-) |
| 15:55 | Chouser | unlink: I'm sorry, I mean it to be funny, no condescending. I'll stop talking now. |
| 15:55 | unlink | oh, my apologies |
| 15:57 | Chouser | unlink: 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:59 | unlink | thanks |
| 16:08 | dysinger | So everybody in here has full time clojure work ? :) |
| 16:08 | Chouser | hm, I appear to be headed toward (last ... (iterate ...)) rather than reduce |
| 16:09 | unlink | Chouser: or just (/ log(n) log(1024)) |
| 16:09 | technomancy | dysinger: /me raises his hand |
| 16:09 | Chouser | unlink: heh. oh. :-) |
| 16:10 | dysinger | technomancy: also raising hand |
| 16:10 | kotarak | not full time, but I snuck some Clojure, hehe. |
| 16:10 | Chouser | I've checked in a little bit of clojure at my full time job... |
| 16:10 | kotarak | snuck in some Clojure, I meant.. |
| 16:10 | Chouser | :-) |
| 16:10 | kotarak | :) |
| 16:11 | kotarak | pure self-defense against corporate IT |
| 16:11 | Chouser | and then hosted a 3-hour con call walking my team though it. |
| 16:11 | unlink | :( |
| 16:11 | unlink | well good for clojure |
| 16:11 | unlink | bad for business |
| 16:11 | Chouser | unlink: so you have a solution you like, or you want me to keep poking at it. |
| 16:12 | unlink | you can if you like |
| 16:12 | unlink | I'm actually just doing it for fun anyway, my final solution will be in python |
| 16:12 | unlink | I can't afford to give that 3 hour conference call. |
| 16:12 | Chouser | usually 3 hours of training is much more expensive. |
| 16:13 | kotarak | luckily my boss looks in the other direction... "As long as the job gets done..." |
| 16:13 | kotarak | Waiting for corporate IT means doing steps backwards. :( |
| 16:14 | unlink | What's the right way to go from java.lang.Double -> java.lang.Integer? |
| 16:14 | unlink | specifically, the ceiling of the double |
| 16:16 | Chouser | probably (int (Math/ceil x)) |
| 16:16 | unlink | Isn't that unchecked? |
| 16:17 | Chouser | (int (Math/ceil 1e100)) ==> 2147483647 so I think you're safe |
| 16:17 | Chouser | unless you want an exception, I suppose. |
| 16:18 | unlink | I want a BigInteger |
| 16:18 | unlink | (am I asking for too much?) |
| 16:20 | Chouser | I don't know Java math very well. I don't see any BigInteger methods that take Doubles |
| 16:20 | Chouser | or any Double methods that return BigIntegers |
| 16:21 | Chouser | I imagine you could route it through a String, but that smells bad. |
| 16:25 | Chouser | (.toBigIntegerExact (BigDecimal. (Math/ceil 1e23))) ==> 99999999999999991611392 |
| 16:25 | Chouser | :-/ |
| 16:25 | Chouser | but I guess that's the Double's fault |
| 16:26 | unlink | lawl |
| 16:55 | jkantz | ,(if (Boolean. "false") 1 2) |
| 16:56 | jkantz | no clojurebot? |
| 16:57 | kotarak | on vacation |
| 16:57 | jkantz | is the above really supposed to return 2? |
| 16:57 | jkantz | that's what clj 1.0 is doing |
| 16:57 | unlink | supposed to? I don't know. I do know what it does. |
| 16:58 | jkantz | gah, I mean it returns 1 |
| 16:58 | jkantz | in clojure 1.0 |
| 16:58 | kotarak | (Boolean. "true") returns true, (Boolean. "something else") false => hence the above is correct. |
| 16:58 | kotarak | Oh. 1 is wrong, no? |
| 16:59 | unlink | *some other string |
| 16:59 | jkantz | yeah, it seems there is only one false value |
| 16:59 | unlink | Not surprisingly, (Boolean. true) returns true |
| 16:59 | jkantz | (false? (Boolean. "False")) |
| 16:59 | jkantz | => false |
| 16:59 | technomancy | triple negative? |
| 17:00 | jkantz | (true? (Boolean. "true") => false |
| 17:00 | unlink | hold your horses |
| 17:00 | unlink | new Boolean is almost always the wrong thing to use |
| 17:00 | unlink | user=> (false? (Boolean/valueOf "false")) |
| 17:00 | unlink | true |
| 17:02 | unlink | rtfm |
| 17:03 | unlink | Note: 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:03 | unlink | i.e. it will return one of the interned values true and false |
| 17:04 | unlink | like, the same ones that the java compiler emits when it sees the literals "true" and "false" |
| 17:05 | jkantz | ok. yeah, reading through docs. but it what situation is the new constructor used? why is it even there? |
| 17:05 | unlink | If you need a new Boolean instance. |
| 17:05 | unlink | I can't think of any reason other than completeness' sake. I've never used it. |
| 17:11 | slurms | I 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:12 | grrrt | that's a bitwise or I think |
| 17:13 | slurms | (new StyledText *shell* SWT/V_SCROLL) will work, when you only use one. BUt I'm looking to use two scroll bars here. |
| 17:13 | kotarak | (bit-or SWT/V_SCROLL SWT/H_SCROLL) or something like that, or simply (+ SWT/V_SCROLL SWT/H_SCROLL), not tested, though. |
| 17:13 | slurms | hmm |
| 17:13 | grrrt | I've used + which works with SWT |
| 17:13 | kotarak | bitwise or is in this case equivalent to +, I think |
| 17:14 | grrrt | but bit-or is closer (well identical) to the | operator |
| 17:14 | slurms | oh, cause SWT/H_SCROLL is returning a number value (binary) ? |
| 17:14 | grrrt | yes |
| 17:14 | slurms | ah, ok |
| 17:14 | kotarak | For Boolean. issue: I think similar considerations apply to Integer. ... |
| 17:15 | slurms | hah.. worked |
| 17:15 | slurms | thank you so much. |
| 17:16 | slurms | FOO/MY_BAR can return whatever though right? I have to look up the docs or introspect to find out, right? |
| 17:17 | ozzilee | kotarak: I've got another issue with ClojureQL. Every query I attempt says "java.sql.SQLException: Operation not allowed after ResultSet closed". |
| 17:17 | kotarak | slurms: To be on save side, yes. Whenever the docs say FOO | BAR, it's numbers, which should work with +. |
| 17:17 | slurms | great. Thanks :) |
| 17:18 | ozzilee | The user I'm using has only SELECT privileges on the db, but that should be enough for (raw "SELECT * FROM foo"), yes? |
| 17:18 | kotarak | ozzilee, you have to realise the resultsetset-seq with doall before leaving the run form. |
| 17:18 | kotarak | Yes. should work. I think laziness gets in the way here. |
| 17:19 | grrrt | kotarak, slurms: there is a small gotcha with using + though |
| 17:19 | kotarak | Try: (run *conn-info* (doall (query * foo))) |
| 17:19 | grrrt | binary 00000111 | 00000001 = 00000111 |
| 17:19 | grrrt | but 00000111 + 00000001 = 00001000 |
| 17:19 | kotarak | ozzilee: or (with-connection [conn *conn-info*] (doall (execute-sql (query * foo) conn))) |
| 17:20 | kotarak | grrrt: this will not happen for such constants. |
| 17:20 | grrrt | true, because they're all 2, 4, 8 etc etc |
| 17:20 | kotarak | grrrt: such constants have the form 00001 | 00010 .... |
| 17:20 | kotarak | grrrt: that's why I said: "in this case" |
| 17:24 | ozzilee | (run *conn-info* (doall (query * foo))) gives me the same error. with-connection works. |
| 17:25 | ozzilee | kotarak: 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:25 | kotarak | -.- run needs an overhaul... |
| 17:26 | kotarak | ozzilee: you mean the compile error? |
| 17:27 | kotarak | Or the raw? |
| 17:28 | ozzilee | kotarak: The raw. Lao's post doesn't use raw, but query has the same effect. |
| 17:29 | kotarak | ozzilee: you can try the same doall with with-connection and the raw. Or (run [*conn-info* results] (raw "SELECT * FROM foo") (doall results)). |
| 17:29 | kotarak | Lau BTW, not Lao ;) |
| 17:33 | ozzilee | kotarak: Ah, ok. That works. Thanks. Not sure where I got Lao from either... |
| 17:34 | kotarak | ozzilee: beware changes in JOIN and run syntax... But the possibilities are interesting. |
| 17:37 | ozzilee | kotarak: Indeed, it looks like it's going to be pretty powerful. |
| 17:38 | kotarak | ozzilee: 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:43 | ozzilee | kotarak: I imagine I'm going to try pushing it pretty hard, so I'll let you know what I hit my head against :-) |
| 17:44 | kotarak | ozzilee: 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:44 | kotarak | The code is not very well tested at the moment. |
| 17:45 | ozzilee | cut my fingers? |
| 17:45 | kotarak | hit your head against something, loads of rough edges. |
| 17:47 | ozzilee | kotarak: Ah, okay, gotcha :-) Yeah, I suppose we'll find out. |
| 17:47 | ozzilee | Is there a NOT NULL predicate? |
| 17:48 | kotarak | geez... NOT is missing.... Does foo <> NULL also work? (I'm not a SQL guru...) |
| 17:50 | ozzilee | kotarak: No, foo <> NULL doesn't work (on mysql, anyway). |
| 17:50 | kotarak | Ok. Will look into NOT. |
| 17:51 | ozzilee | "foo = NULL" doesn't work either. Needs to be "foo IS NULL". |
| 17:53 | ozzilee | Hahahaha. It is a bit... different. |
| 17:53 | technomancy | I think the word you're looking for is horrible |
| 17:55 | ozzilee | Nah, 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:56 | ozzilee | I mostly run into problems with the implementations, as opposed to the language. Performance, mostly. |
| 18:01 | kotarak | I hate the manyfold differences in syntax of the different implementations. I'm not sure on which basis they claim to something called "SQL"... |
| 18:01 | ozzilee | Well, I've got a query working at least. Time to head out for the day, thanks for the help kotarak. |
| 18:01 | kotarak | ozzilee: np |
| 18:01 | kotarak | be sure to file bug reports on github, thanks |
| 18:01 | ozzilee | kotarak: Will do. |
| 18:02 | ozzilee | btw, have you check out SQLAlchemy (Python)? It has some of the same ideas, namely the queries as higher-order functions. |
| 18:02 | ozzilee | *checked |
| 18:02 | kotarak | ozzilee: no, but will do. |
| 18:03 | ozzilee | kotarak: Cool. Later. |
| 18:04 | kotarak | cu |
| 19:44 | Anniepoo | 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:49 | emacsen | Is there a simple way to turn a vector of chars into a string? |
| 19:50 | texodus | (apply str [\a \b \c]) |
| 19:50 | emacsen | texodus, wow... that was easy :) |
| 19:50 | texodus | ,(apply str [\a \b \c]) |
| 19:51 | texodus | hrm, not good with clojurebot apparently |
| 19:51 | emacsen | works for me tho |
| 19:53 | cp2 | clojurebot is mia |
| 20:04 | texodus | poor guy - I hope he's ok :) |
| 20:06 | Anniepoo | anybody in the bay area, the Clojure meetup starts at 5:45 at Runa |
| 20:13 | emacsen | Okay, one more dumb question. remove is great, but is there a way to do remove only on the first match? |
| 20:13 | emacsen | so you don't remove all the instances of the match, just the first |
| 20:22 | texodus | not aware of one |
| 20:23 | texodus | (defn remove-first [col i] (if (= (first col) i) (rest col) (cons (first col) (remove-first (rest col) i)))) |
| 20:24 | texodus | though there's prolly a better way |
| 20:26 | emacsen | yeah... what we need is a filter-first |
| 20:26 | emacsen | but thanks |
| 20:26 | emacsen | (I just read how remove works, it uses filter) |
| 20:33 | Knekk_ | What are the normal uses for (constantly x) ? |
| 20:36 | Knekk_ | It always returns the first-ever value it was invoked with? |
| 20:36 | Knekk_ | user=> (def f (constantly x)) |
| 20:36 | Knekk_ | #'user/f |
| 20:36 | Knekk_ | user=> (f 1 2 34 5 6) |
| 20:36 | Knekk_ | 1 |
| 20:36 | Knekk_ | user=> (f 2 ) |
| 20:36 | Knekk_ | 1 |
| 20:37 | Knekk_ | oh I did (def x 1) |
| 20:38 | Knekk_ | ok, I get it |
| 21:27 | texodus | emacsen. 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:31 | emacsen | texodus, thanks |
| 22:02 | Chouser | has anyone compiled contrib's clojure-1.0-compatible branch? It's just completely failing for me |
| 22:02 | Chouser | java.lang.NoSuchMethodError: clojure.lang.Namespace.importClass(Ljava/lang/Class;)Ljava/lang/Class; |
| 22:04 | jackdempsey | hmm |
| 22:04 | jackdempsey | seems to work for me |
| 22:05 | jackdempsey | git checkout origin/clojure-1.0-compatible |
| 22:05 | jackdempsey | ant -Dclojure.jar=../clojure/clojure.jar |
| 22:05 | jackdempsey | compiles fine |
| 22:05 | jackdempsey | (and the clojure dir is up to date) |
| 22:05 | duck1123 | does rich have the 1.0 branch, or is it somewhere else |
| 22:05 | duck1123 | I just fetched and i'm not seeing it |
| 22:06 | jackdempsey | not as a remote? |
| 22:06 | jackdempsey | jack@localhost ~/git/clojure-contrib comp $ gb -a |
| 22:06 | jackdempsey | ... |
| 22:06 | jackdempsey | remotes/origin/clojure-1.0-compatible |
| 22:06 | jackdempsey | and thats from rich |
| 22:06 | jackdempsey | ( finally something i have half a clue about...) |
| 22:08 | Chouser | jackdempsey: hmph, I think that's exactly what I'm doing. |
| 22:08 | jackdempsey | hmmm |
| 22:09 | duck1123 | Chouser: did you clean? |
| 22:14 | Chouser | ah, my 1.0 branch wasn't up to date. |
| 22:26 | Chouser | oh, nope, still fails :-P |
| 22:33 | Chouser | ok, git's just toying with me. I've got it now |
| 23:04 | gstamp | I 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:05 | Chouser | gstamp: sorry, I've got a reply started, but not done yet |
| 23:07 | Chouser | maybe the best way to understand how it works is to realize that a lazy seq mutates internally |
| 23:07 | gstamp | lol. was that you're blog? I guess I can wait :-) |
| 23:07 | Chouser | :-) |
| 23:08 | Chouser | each step of a lazy seq starts as a closure that knows how to compute a cons cell (first and rest) |
| 23:09 | Chouser | when you ask for either, that closure is called |
| 23:10 | Chouser | but then the closure is thrown away and its return value is cached instead |
| 23:14 | Chouser | so as long as you refer only to parts of the seq that have realized, nothing has to recurse at that point. |
| 23:16 | Chouser | and that's what happens with 'fibs' -- each element is computed only from earlier elements -- all the way back to the [0 1] constants. |
| 23:16 | Chouser | oh |
| 23:16 | Chouser | gone |
| 23:16 | Chouser | :-P |
| 23:17 | liebke | add-break-thread works again, woot!!! :) |
| 23:18 | Chouser | liebke: nobody told me it was broken! |
| 23:18 | Chouser | though I apparently I didn't notice either. :-P |
| 23:18 | liebke | my bad, I should have told you :) |
| 23:18 | liebke | I missed it |
| 23:21 | menSan | nn all |
| 23:31 | gstamp | Blasted http://webchat.freenode.net/ hung on me. |
| 23:31 | Chouser | gstamp: http://blog.n01se.net/?p=33#comment-1230 |
| 23:32 | Chouser | gstamp: does that make any sense? |
| 23:32 | gstamp | Thank you for that. I think I understand |
| 23:33 | gstamp | I'll just keep looking at it for another hour to make sure. It's a beautiful piece of code. |
| 23:34 | Chouser | it is, though it does not perform very well |
| 23:36 | gstamp | Hopefully future versions of clojure can optimize that inconvience truth away. |
| 23:37 | unlink | speaking of optimizations, #^Object should be implicit for all parameters w/o type annotations |
| 23:38 | Chouser | unlink: would that help something? |
| 23:39 | unlink | .toString & friends by default use reflection |
| 23:39 | unlink | e.g. (fn [x] (.toString x)) |
| 23:41 | unlink | getClass, hashCode too |
| 23:46 | Chouser | unlink: hm! |
| 23:48 | unlink | It's not often a function gets passed a non-Object in clojure ;) |