#clojure logs

2008-12-28

00:07kabnyi see
00:12kabnywhat doe sit mean to write (. hmm some) as opposed to (.some hmm)?
00:16dreishThe latter turns into the former at macro expansion time. They're equivalent.
00:36kabnywhat would be best suitable for a GUI, agents or refs?
00:52kabnywhat would be best suitable for a GUI, agents or refs?
01:00kabnyanyone using contrib.sql?
01:02kabnyhow do you refer to a database since with-connection returns nil?
01:22chrisdoneclojurebot: help
01:22clojurebotmacro help is http://clojure-log.n01se.net/macro.html
01:22chrisdoneclojurebot: source
01:22clojurebotTitim gan �ir� ort.
01:22chrisdonemmkay
01:22chrisdoneclojurebot: commands
01:22clojurebotIt's greek to me.
01:29chrisdoneclojurebot: eval (+ 1 1)
01:29clojurebotGabh mo leithsc�al?
01:37eric-at-home,(+ 1 1)
01:37clojurebot2
01:37eric-at-homekabny: I am using contrib.sql.
01:38eric-at-homeoh, kabny already left :-(
09:50Lau_of_DKZzzzz
09:51RayneszzzzZ
11:34vseguiphi all
11:35danlarkinvseguip: howdy
11:35vseguipI'm new to clojure
11:35vseguipI've been plating with it for some univerity assignment
11:36vseguipI've been trying to optimize my algorithims with some hints as per http://clojure.org/java_interop
11:36vseguiphowever I'm getting very different timings
11:36vseguipfrom those in the page
11:37vseguipfor intance
11:37vseguipde foo2 function
11:38mibuhow much different is it?
11:38vseguipan order of magnitude
11:38vseguip(time (foo2 100000))
11:38vseguip"Elapsed time: 0.908077 msecs"
11:38vseguip100000
11:38danlarkinwell you've got a different computer from the one on which this computer was compiled
11:39vseguipI have a string ina Java array
11:39mibuthat's well under a msec. doesn't mean anything.
11:39vseguipyep
11:39vseguipbut for instance
11:39vseguipI would have thought that this would be faster
11:40vseguip(time (clojure.core/amap *dicc* i ret (aget ret i)))
11:40mibudifferent computer, different java version, background programs all can affect the speed.
11:40vseguip"Elapsed time: 18.029456 msecs"
11:41vseguip(count *dicc*)
11:41vseguip13189
11:41vseguipI realize that
11:41vseguipbut 20 ms to traverse a Java array seems weird
11:42vseguipwith only 13189 positions
11:42vseguipwould that be normal?
11:43mibuvseguip: it could
11:44vseguip(fairly new machine Intel(R) Core(TM)2 Duo CPU T7250 @ 2.00GHz with 4gb ram, java 6, ubuntu)
11:44vseguip(clojure-svn rev 1162)
11:49danlarkinvseguip: whip up a reproducible test and I'll tell you how fast it is on my machine
11:50vseguip(def *arry* (into-array (range 10000)))
11:50vseguip(time (clojure.core/amap *arry* i ret (aget ret i)))
11:51vseguipI'm doing it in 2 steps
11:51vseguipso as to only time
11:51vseguipamap
11:51vseguipnot the array conversion
11:51danlarkin10ms for me
11:52vogelrn3ms here
11:52vseguip13ms
11:52vseguip for me
11:53vseguipvogelrn: what is your setup?
11:54vogelrnuhhh core 2 duo E6600, 2gb ram, java 6, ubuntu
11:57vseguipsimiilar to mine
11:57vseguipwht clojure version?
12:01vogelrnwhoops, I forgot, I haven't updated in a while, been on my laptop recently, let me update and see if it gets slower (I'm on 1147)
12:04vogelrnnope, still the same speed
12:04vogelrnwell, updating to latest that is
12:07arbscht_3.5ms - core2 duo E6750, 2G, openjdk 1.6.0, debian, clojure rv 1185
12:10vseguipmm
12:10vseguipI'm using sun6-java
12:10vogelrnso am I
12:11RaynesDownloading the JDK on dialup is no fun :|
12:11danlarkinJava(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284)
12:11Lau_of_DKJust wanted to make sure that everyones aware that clojure-mode has been forked and it now being worked upon from http://github.com/technomancy/clojure-mode/tree/master
12:12arbscht_Lau_of_DK: fantastic
12:12vseguipvogelrn: using server jvm?
12:12vogelrnthe default is client, no? I haven't added the flag myself
12:13vseguipyep
12:13vseguipdefualt is clinet
12:13vseguipusing it from emacs/command line/repl?
12:13vogelrnemacs
12:14vseguipme too
12:15vseguipclojure trunk I guess?
12:16mibuanyone knows if there is a splice or flatten function in the contrib?
12:16vseguipflatten
12:16vseguipis there
12:17mibuwhere?
12:17vseguipin clojure.contrib.seq-utils
12:17mibuthanks
12:18vogelrnI mean, you might try updating to the latest revision, it's slightly possible that it got worse in 1162 and then better again afterwards, if unlikely :P
12:19vseguipaccording to svn up
12:19vseguiplatest revision in 1162
12:20vseguip:-|
12:20vogelrnit got changed
12:20vogelrnhttp://clojure.googlecode.com/svn/trunk clojure
12:21vseguip:-o
12:22vseguipOTOH is there a way to "realize" a lazy seq recurisively other then printing it?
12:23mibuvseguip: dorun or doall
12:24vseguipit doesn't seem to do it recursively
12:24mibuvseguip: what do you mean recursively?
12:25vseguiplet's suppose you have a lazy seqs of lazy seqs
12:25vseguipI would like it to realize the top level lazy seq
12:25vseguipand then the inner lazy seqs
12:25vseguipetc
12:26vseguipI think I will do a simple func to do this
12:26mibuagain, you can use doall or dorun. just map them (map doall some-seq)
12:27vseguipmibu: yup but it would be nice to have a recurive function to do this
12:27vseguipwill try and ree
12:27vseguipand reachback
12:36vseguip(defn realize [xs]
12:36vseguip (if (seq? xs)
12:36vseguip (doall (map realize xs))
12:36vseguip xs))
12:36vseguipseems to work
12:40mibuvseguip: do you happen to know if there is also splice somewhere?
12:44vseguipwhat does splice do?
12:45vseguipare you operating on strings, seqs, vecs ?
12:46kotarakFor vecs there is subvec.
12:46kotarakFor seq: (take n (drop m s))
12:50vseguipsame speed
12:51vseguip:(
12:54chrisnwhat is the most efficient way to go from a sequence to a typed array?
12:56vseguipchrisn: not sure but (into-array)
12:56vseguipseems the way
12:56chrisnthanks, I will check that out.
12:56chrisnLooking into the api more, I need it to go into java.nio Buffer of some sort
12:58chrisnIs there a typeof operator?
12:59kotarakchrisn: (class ...)
12:59kotarakOr better: (instance? TheClass the-thing)
13:00chrisnawesome
13:00danlarkinalso isa?
13:01kotarakdanlarkin: I think isa? is more for the hierarchy stuff.
13:01danlarkin(doc isa?)
13:01clojurebotReturns true if (= child parent), or child is directly or indirectly derived from parent, either via a Java type inheritance relationship or a relationship established via derive. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to the global hierarchy; arglists ([child parent] [h child parent])
13:02kotarak(isa? TheClass (class the-thing)). instance? is shorter.
13:02danlarkininstance? checks only direct inheritance, isa? does full inheritance trees
13:03kotarak? What is a full inheritance tree?
13:05danlarkinsay C inherits from B which inherits from A
13:05danlarkinand a is an instance of A
13:06danlarkin(instance? C c) is true, (isa? c C) is true, (instance? A c) is false, (isa? c A) is true
13:06danlarkinright?
13:07kotarakObviously not:
13:07kotarak1:1 user=> (isa? "string" String)
13:07kotarakfalse
13:07kotarak1:2 user=> (isa? (class "string") String)
13:07kotaraktrue
13:07kotarak1:3 user=> (instance? Object "string")
13:07kotaraktrue
13:07kotarak1:4 user=> (instance? String "string")
13:07kotaraktrue
13:08danlarkinHm, guess I was mistaken... not the first time!
13:10mibuI have this unexplained error when I use a macro. Everything works just fine as long as I don't you the macro in a function.
13:11mibu ; permutations without repetitions (r choices from n)
13:11mibu(defmacro permutations [n r]
13:11mibu (let [locals (take r (repeatedly gensym))
13:11mibu for-range (apply concat (for [i (range r)] [(nth locals i) `(range ~n)]))]
13:11mibu `(for [~@for-range :when (= ~r (count (distinct [~@locals])))] [~@locals])))
13:11mibu; permutate a vector without repetitions (r choices from vector v)
13:11mibu(defn permutate [v r]
13:11mibu (let [perms (permutations (count v) r)
13:11mibu map-perm (fn [perm] (map #(nth v %) perm))]
13:11mibu (map map-perm perms)))
13:11mibu(lisppaste don't work)
13:12mibu(permutate [10 20 30 40 50] 3)) spits java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.Number (NO_SOURCE_FILE:229)
13:13mibuanyone has any idea what's going on?
13:13arbscht_mibu: use paste.lisp.org please
13:13mibuarbscht_: it doesn't work.
13:14mibuarbscht_: some kind of netsplit. lisppaste8 isn't in the channel (at least over here)
13:14arbscht_you can paste it and broadcast the url manually :)
13:15mibuarbscht_: how do I get the url?
13:16chrisnhow do I use a static function as a first class function?
13:16arbscht_mibu: when you make a paste, it will create a page at some url, which you will be redirected to
13:17mibuchrisn: #(.lowercase %)
13:17chrisnstatic, not member
13:18chrisnBut that would work. I was trying to avoid wrapping in another function
13:18chrisnseems pointless
13:18Chousukeyou have to wrap java methods.
13:18chrisneven static functions?
13:18Chousukesince they're not first class functions.
13:18Chousukeeven them.
13:18mibuarbscht_: nope, it sent me to a blank with the same url of the submit
13:19arbscht_mibu: fine, use some other paste service then. it makes code much easier to read and copy :)
13:21mibuhttp://pastebin.com/md89a240
13:22mibuanyone with a suggestion? I'm busting my head with this for hours now.
13:23Chousukegah I hate that pastebin
13:23Chousukethe colour scheme is horrible
13:23Rayneswww.codepad.org
13:24RaynesHas a Scheme setting.
13:24mibuhttp://codepad.org/jbDEzu1x
13:24Chousukewhy is your permutations a macro?
13:25mibuchousuke: how would you have written it?
13:25Chousukeas a function?
13:25Chousukeis there a reason that it is a macro?
13:25mibuchousuke: yeah, how? I'm using a variable number of locals in the for range.
13:26mibu(for [x1 (range 6) x2 (range 6) x3 (range 6)] ...) for [6 3] ; (for [x1 (range 6) x2 (range 6)] ..) for [6 2]
13:27Chousukehmm.
13:27mibubtw: if you guys know of a better permutations implementation, I'm all ears.
13:29mibuoutside of a function, it just works. I don't understand why when I call it, it spits this error. I tried tracing it to the Java code, but to no avail.
13:33chrisn(permutations (count [1 2 3]) 4)
13:33chrisnnil
13:33chrisn(I think you are double evaluating something
13:34mibuif I don't call it from inside the function, it works. If I fix r, it works. If I expand it by hand and eval it, it works.
13:34mibuchrisn: (permutations [1 2 3 4] 3). what you called is not a vector and has too small of an r.
13:35mibuchrisn: I meant an r that is too large - r should be <= (count v)
13:36chrisnyeah, I just tried with a valid r and it was fine
13:36chrisnTrying to check out the macroexpand code
13:36mibuchrisn: you managed to run it without an error from a function?
13:36chrisnhell no
13:36chrisnjust typing it into my repl
13:36mibuoh :-(
13:38chrisnuser> (def v [1 2 3])
13:38chrisn#'user/v
13:38chrisnuser> (def r 2)
13:38chrisn#'user/r
13:38chrisnuser> (permutations (count v) r)
13:38chrisnThat doesn't work
13:38chrisnSo you can break it just by using symbols in any sense, not just in a function
13:39chrisnbreaks macroexpand, too
13:39chrisnweird
13:39Chousukemibu: I think the problem is with your n
13:39mibuI figured it has something to do with r. Use a fix r, and it works.
13:39Chousukeinstead of the evaled value of (count v), an actual "(count v)" is passed
13:40kotarakmacros cannot depend on runtime information.
13:40kotarak(count v) is runtime info
13:40kotarakChousuke is right. The macro sees the form (count v) and not the value.
13:40mibuchousuke: doesn't ~n eval it?
13:41Chousukeno, ~n expands to (count v)
13:41chrisnThe error is in r
13:42mibuha...
13:42chrisnnope
13:42chrisnwrong
13:42mibuthat's one hell of a gotcha.
13:42chrisnhmm...
13:42chrisnwhoa
13:43mibukotarak: you said it's runtime info, how so?
13:43mibuchousuke: wouldn't a (count v) still eval correctly in the context of the father function?
13:43kotarakmibu: ok, the argument applies, but to the other parameter.
13:44chrisnonly if the arguments were known at compile time.
13:44chrisnIn your function, they are symbols, not compile time constants
13:44Chousukehm, no wait
13:44kotarakmibu: you get r as a function parameter, but use it in your macro.
13:44kotarakbut the macro sees r and not the parameter value
13:44chrisnright. The compiler would have to generate infinitely many functions for this to work.
13:44mibukotarak: wait wait, I'm not following. r is not bound to what permutate sets it to be?
13:45kotarakYup.
13:45kotarakThe compiler doesn't know that at compile time.
13:45mibukotarak: I fail to see how it's a problem
13:46kotarak(let [r 5] (permutations (count v) r)) The macro sees the symbol r, not the value 5.
13:46mibuoh, I get it. It's not the evaluated r. How do I bypass this?
13:47kotarakYou can't, I presume.
13:47chrisnEither your arguments are known at compile time *or* you write a function as Chousuke suggested.
13:47mibukotarak: is there something more elegant than (eval r)?
13:47mibuchrisn: it wouldn't be easy to write a function like that.
13:47Chousukemibu: add (println r) to the top of your macro to see the problem
13:48Chousukemibu: when called directly, you get "3" printed, but when you call from a function, it prints "r"
13:48chrisnI didn't say anything about easy or hard. You don't have other options, mibu.
13:48kotarakmibu: (eval r) also doesn't work.
13:48mibuchousuke: I got the problem now. Now, I'm trying to understand what is the proper way to fix it, and how to properly write macros in the future.
13:49kotarakmibu: macros may only depend on information known at compile time. A function parameter is not known at compile time.
13:49kotarakmibu: you have to find a different algorithm, which doesn't use for.
13:50chrisnmibu, you are missing the point. Macros are compile time code. They can't work if they can only be expanded at run time. Your macro is fine. Its the use case.
13:50mibukotarak: you're right.
13:50mibukotarak: but it was such a nice idea. ;-)
13:50kotarakmibu: there are a lot of nice ideas. ;) Have lots of those myself. ;)
13:51mibuwell, this mistake was well worth the lesson it taught me about macros.
13:56mibuanyway, thanks for your help guys.
13:59kabnyI think people overuse macros in lisp
14:00danlarkinkabny: I agree
14:00kabnyso often I see examples of macros where a function would d an be much cleaner and simpler
14:00kotarakIf you don't need to control evaluation, you don't need a macro.
14:00ChousukeI wonder what's wrong with my aquamacs
14:01Chousukeit always opens two windows at startup
14:01Chousukeit's annoying
14:01danlarkinChousuke: *scratch*?
14:02Chousukeyes. twice.
14:02danlarkingotta delete that sheeeaaaat
14:02danlarkinhaven't figured out how to make it not open aside from deleting it
14:02Chousukewhoops
14:03Chousukewiped my config
14:03Chousukegood thing it's backed up in git :P
14:04Chousukedanlarkin: and I don't mind it opening *scratch* but why does it open it twice?
14:04Chousukeand in different windows.
14:04Chousukeif I wipe my config it works normally :/
14:04danlarkinwell I've figured it out then, a problem with your config!
14:05Chousukeyes, but WHAT.
14:06mibuemacs is a conspiracy to keep programmers occupied with their config files. ;-)
14:08ivanindeed
14:09ivananyone have basic clojure syntax highlighting for IDEA 8?
14:10mibuivan, if you want something really basic you can use highlighting of other lisp formats.
14:11danlarkinivan: there's an IDEA plugin... somewhere
14:11ivanthe generic syntax highlighter that doesn't really work?
14:12danlarkincan't say, I haven't tried it
14:12kabnywhen doing GUIs what is most appropriate, agents or refs?
14:14mibukabny: it really depends, but if you must have a general answer then agents. GUI is mostly asynchronous.
14:17Chousukeah, hm
14:18chrisnmibu: http://pastebin.com/m10ecab20
14:19mibuchrisn: thanks!
14:20chrisnI forgot contains_dups
14:20chrisnBut it is stupid
14:20chrisn(defn contains_dups [seq]
14:20chrisn (< (count (distinct seq)) (count seq)))
14:23chrisnIt would be way more efficient to catch duplicates in the for statement
14:24chrisnAnd my order is different than yours
14:24chrisnBut the result is the same
14:24chrisnAlso, if I knew recur that would be a better solution
14:24Chousukefor some reason, (setq 'viper-mode t) is causing it
14:25mibuchousuke: the double *scratch*?
14:25Chousukeyeah
14:26mibuchrisn: what I like about my version is that with a simple for that *declares* what needs to be the result, you finish the task.
14:26chrisnyour version is definitely ideal.
14:27chrisnbut in reality for expands into a bunch of recur statements, so I am damn close to the implementation
14:27mibuI started solving problems in projecteuler yesterday with clojure and discovered how powerful for is. it's almost like cheating.
14:27chrisnI had a buddy working through that in factor
14:27kotarakmibu: there is also clojure-euler.wikispaces.com
14:27chrisnHave you taken a look at the haskell solutions?
14:28mibukotarak: it's really bad you told me about this. now I might look there ;-)
14:28kotarakmibu: share your solutions. :)
14:29kotarakmibu: but be warned! SPOILER!
14:29mibukotarak: I will
14:31vogelrnheh, what do you think, is using primes from clojure.contrib.lazy-seqs cheating? :P
14:31mibuvogelrn: there is primes in contrib?
14:31vogelrnyeah, and fib
14:32vogelrnconsidering one of the problems is
14:32vogelrnget the 10001st prime or something
14:32mibucrap, I did not know that.
14:32mibuI consider whatever comes with the standard language is fair game. contrib is pretty much standard, isn't it?
14:32mibubut writing primes or fib is not hard and even fun.
14:33vogelrnyeah I mean I was half-joking, both prime and fib are pretty easy to write
14:33vogelrnit's just that the whole point of certain problems is to write fib and primes, heh
14:33danlarkinthere's a nice example of fib using a memoize function and atoms
14:34danlarkinhere it is, http://clojure.org/atoms
14:35mibumemoize is part of the core now, right?
14:40vogelrnlooks like it
14:43kabnyI'm doing a GUI app that will play mp3s and sometimes at the same time update a database or take input in a textfield from the user. should I use agents then? since it is asynchronous.
14:44kabnywhy is fib and prime in seq-utils or lazy-seqs and not in math?
14:45kabnyisnt there some java lib like numerical java that has fib and prime anyway?
14:45vogelrnpossibly, but not lazily
14:47vogelrnand I don't think there's one built into java, it might be 3rd party (could be wrong though)
15:16eldokthe more clojure I code the more I like it.
15:16kotarak:)
15:17chrisnmibu: did you check out lazy-seq permutations?
15:17chrisnIt isn't exactly what you want, but I would start from there.
15:18chrisnmuch better than what I wrote.
15:29kabnyis an undergraduate 4 years, then waht is graduate? how long have you actually been to uni when you have a PhD? 10years!!!!!!!!!!!!???????????
15:30Hundepends.
15:33kabnyanyone use contrib/sql? how do I create a db? (sql/with-connection db) ?
15:33kabnyafter havin done:
15:33kabny(require '[clojure.contrib.sql :as sql])
15:33kabny(def db {:classname "org.apache.derby.jdbc.EmbeddedDriver"
15:33kabny :subprotocol "derby"
15:33kabny :subname "C:/clojure/progs/pod/podcasts.db"
15:33kabny :create true})
15:33kabnythen the with-connection call returns nil. ok so how do I refer to it later?
15:36Chousukekabny: with-connection doesn't make a connection; it creates a context. You're supposed to put your code inside the with-connection call.
15:39Chousukekabny: according to the docs, your database will be accessible in the *db* var within the with-connection call
15:41kabnywhere are the docs?
15:41Chousukeer, source :)
15:42kabnyah because lisp code is its own documentation :)
15:43Chousuke(doc with-connection) may be useful
15:43clojurebotExcuse me?
15:45Chousukekabny: apparently though you're not supposed to care about the existence of *db*
15:46kabnybut what does that mean within the with-connection call?
15:46kabnyso I should do (with-connection db-spec action) ? where action could be the create-table function?
15:46Chousukeyeah
15:47Chousukelike with-open
15:48Chousuke(with-open [file (open-file)] (do-something file) (do-something-else file))
15:48Chousukewith- is a naming convention for macros like that.
15:50kabnyok thanks
16:08kabny:subname "/tmp/clojure.contrib.sql.test.db"
16:08kabnyis that where the db will be stored?
16:08kabnyand how do I specify a name for the db?
16:09kabnyscgilardi, is he the same name here?
16:09kabnydid tom hickey maintain JScheme before after Norvig?
16:14rhickeykabny: no, Tim Hickey, not related
16:15kabnyok
16:31kabnygod I just keep loving clojure more and more
16:32kabnythe contrib sql is so easy to use once i got it(which didnt take to long)! so small yet so more pleasant than working directly with jdbc.
16:39kabnyis there any plans for a html-parsing-library? basically I need to extract some stuff from a big amount of html-pages, I resort to Java then? any wish for a clojure-html-parsing-lib?
16:39kotarakkabny: there is some xml stuff in clojure and contrib. Maybe this helps?
16:50chrisnAn interesting problem would be an API that is more difficult that jdbc
16:50chrisnodbc I guess
17:08kabnyhow do you host a webapp? I know Google appengine lets you host for free but then you have to use Python(which is fine btw). Is it good? What are the alternatives? are their good ones that let you pay a monthly fee? or is the normal thing to have your own server?
17:10laurikabny:you can read about one possibility here: http://ericlavigne.wordpress.com/2008/12/18/compojure-on-a-slicehost-vps/
17:15danlarkinjavascript snowflakes
17:15danlarkinwhat year is it?
17:16ericlavignedanlarkin: They'll be gone in a few days. Just celebrating Christmas :-)
17:16danlarkinthey are distracting my eyes :(
17:17ericlavigneOkay, I'll turn off the snowflakes.
17:17danlarkinhuzzah!
17:17kotarakericlavigne: maybe they can be restricted to the area without text?
17:19ericlavignekotarak: That would be a huge improvement, but I didn't create the theme.
17:19ericlavigneThere's also a new article on setting up PostgreSQL for use with Clojure.
17:20ericlavignehttp://ericlavigne.wordpress.com/2008/12/28/using-postgresql-with-compojure/
17:27kabnythanks eric, very cool
17:28darkdescendantGot a question on Java UI: How can I clear out all my Java UI within clojure without taking down clojure itself? I.e. if I create a JFrame and show it, how do I destroy it cleanly?
17:29ericlavignekabny: You're welcome. I wanted to write a Compojure application anyway, and seeing that others are enjoying the articles really helps my motivation.
17:30darkdescendantIs it as simple as (def <my frame> nil)?
17:31ericlavignedarkdescendant: There is a "dispose" method on JFrame.
17:33ericlavigneYou can also setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE) so it will dispose itself when a user hits the close button or the X.
17:33darkdescendantThanx!
17:35darkdescendant(My Java/Swin exp is poor at best)
17:35ericlavignedarkdescendant: I would prefer to have less Java/Swing experience. I program Java by day and escape to Lisp at night.
17:36kotarakericlavigne: sneak in a clojure.jar. ;)
17:37ericlavignekotarak: The thought has crossed my mind, but my boss wants the code to be all Java because Java programmers are easier to hire.
17:38ericlavigneHe apparently hasn't noticed how often you end up with Lisp and Haskell programmers when you look for Java programmers.
17:38darkdescendantI program C/C++ by day. :-)
17:38ericlavignedarkdescendant: Now I feel better :-P
17:38kotarakI "program" Excel. At least it's functional...
17:39darkdescendantHey, at least basing it on Java means I can create an x-plat UI for my app. It also means I can pick my OS platform (to an extent). I have a Macbook and I run Linux and Windows under VMWare. I can easily do clojure an any of those (and in fact I setup my Linux box with it).
17:39darkdescendantkotarak: I feel your pain. -)
17:42kotarakdarkdescendant: Oh. Not necessary painful. Excel is actually quite powerful. And it simply awesome for exploratory data analysis, eg. with pivot tables. But maintaining a spreadsheet with some calculations.... *ugh*
17:42Chousukethere was one guy who did a 3d cube in excel
17:43ChousukeI though that was the epitome of pointlessness.
17:43Chousukethought*
17:43darkdescendantSpace Invaders in Excel.
17:43darkdescendantI heard someone make the point that as soon as you can write a game on something, it ceases being an app and becomes an OS.
17:44Chousuke:p
17:57chrisnthere is/was a weird flight simulator in excel
17:57chrisnIt was written in c though
18:10chrisngiven a sequence like ((1 2) (1 3) (1 4)) how do I lazily create (1 2 1 3 1 4)?
18:10chrisn(apply concat seq) isn't very lazy
18:10chrisnI don't think
18:10ericlavignechrisn: I think there's a function called flatten.
18:10ericlavigne,(flatten '((1 2) (1 3) (1 4)))
18:10clojurebotjava.lang.Exception: Unable to resolve symbol: flatten in this context (NO_SOURCE_FILE:0)
18:11kotarak(interpose (ffirst s) (map second s))
18:11ericlavignemaybe flatten is in clojure-contrib
18:12danlarkinit is, in seq-utils I believe
18:13chrisnfound it, thanks
18:14chrisnIt appears to do a complete flatten using tree-seq, but only return items that aren't sequences
18:18Chousukehm
18:18kabnyjavadoc in contrib, is it for auto-generating documentation of clojure-files?
18:18ChousukeI'm experimenting with my own clojurebot
18:18kabnywe need such a program...
18:18Chousukeand it's not letting me run any code...
18:18ChousukeI wonder what's wrong.
18:19Chousukeit keeps complaining about classloaders
18:19Chousuke,(System/getProperty "java.home")
18:19clojurebotjava.security.AccessControlException: access denied (java.util.PropertyPermission java.home read) (NO_SOURCE_FILE:0)
18:19Chousukehmm
18:20Chousukeso it *should* allow some stuff.
18:22Chousuke... my policy file is somehow screwed up I guess
18:23Chousukeit's a simple grant-all file though
18:34kabnyanyone use tagsoup? i cant find the documentation: http://home.ccil.org/~cowan/XML/tagsoup/#warning
18:34kabnyis htmlparser good?
18:45kabnyhtmlparser seems good
18:46ericlavignekabny: what are you working on?
18:47kabnyrecommender/aggregator thingie
18:47kabnywebapp/cellphone app
18:47kabnygonna do for android in Java and the webapp in Clojure+compojure
19:22kabnywhat does protected constructor mean? god some Java-libs are so deeply nested(but better too much documentation that none at all I guess).
19:24gnuvince_What's a good intro book on Java without the usual "a variable is a memory cell where you can put a value" newbie stuff?
19:25drewrgnuvince_: I thought "Thinking In Java" was OK, but it does have its share of newbie-friendly stuff.
19:27emacsenSo the DC Clojure study group is still looking for project ideas if anyone has any. Something generally useful but not full time projects
19:30kabnyif: (URL. site) works then why doesnt: (HttpURLConnection. (URL. site))
19:30kabnyjava.lang.IllegalArgumentException: No matching ctor found
19:30kabnywhen
19:30kabnyprotected HttpURLConnection(URL u)
19:30kabny Constructor for the HttpURLConnection.
19:30kabnyhttp://java.sun.com/j2se/1.4.2/docs/api/java/net/HttpURLConnection.html
19:31rhickeykabny: it's protected
19:32danlarkinkabny: there's an openConnection method on URL I think?
20:37kabny<i><a href="http://media.libsyn.com/media/seradio/seradio-episode119-DSLsInPracticeWithJPTolvanen.mp3&quot; rel="nofollow">Download MP3</a></i>
20:37kabnywhat does nofollow mean? dont link?
20:38kabnyor wait it is for googles spider
20:40Chouserkabny: it's meant for google and other spiders to indicate no enorsement of the quality of the link
20:52kabnywhy doesnt (doc multimethods return the args passed)?
20:58Chouserkabny: by default defmulti doesn't add arglist or doc metadata
20:58Chouserbut you can provide either or both:
20:58Chouser(defmulti #^{:doc "does foo stuff" :arglists '([bar & more])} foo class)
20:59kabnyhow can I convert a string to a regexp?
21:00kabny"mp3" to #"mp3"
21:00Chouser(doc re-pattern)
21:00clojurebotReturns an instance of java.util.regex.Pattern, for use, e.g. in re-matcher.; arglists ([s])
21:09eldoki added the metadata but it still doesnt show up when doing (doc f)
21:09eldokwhats the char I have to add when asking for metadata nyway?
21:12eldok(defn scanl
21:12eldok #^{:doc
21:12eldokthat is the correct place for meta right?
21:13Chousereldok: not like that. you can put a plain string there instead #^{...} and it'll work.
21:14alphazerognuvince_: http://www.mindview.net/Books/TIJ/
21:14Chousereldok: or just leave off the #^ prefix
21:15Chousereldok: those are features of 'defn'. To use the more general #^{...} format, put that before the name of the var you're defining.
21:16Chouserkabny, eldok: http://paste.lisp.org/display/72759
22:39achim_phi all! is anybody aware of a bytecode inspection/disassembly tool that doesn't choke on clojure bytecode?
22:40achim_pi just tried to package a clj hello world for android, which gave me a bytecode related error
22:42achim_phttp://pastie.org/348098 - now i'd like to see what's happening at bytecode offset 0000003a ...
22:48eldokachim_p: sorry I can't help you but really cool you try to get Clojure going n Android. I'm writing a webapp/Android app using Clojure/Java. Would really like to write everything in Clojure.
22:49eldokachim_p: since you are doing such stuff I suppose you are aware that Android use its own VM, the Dalvik VM. could that be related to the error?
22:51achim_peldok: it doesn't even get that far, it fails while building. the "dexer" doesn't seem to like ns_public's bytecode
22:54eldokdexer?
22:55eldokare you running it on a real phone or on the emulator?
23:02achim_peldok: dx, the tool that generates dex files. i'm on an emulator, but i don't think that's emulator-specific ... i don't know much about android though
23:02achim_phttp://code.google.com/intl/de-DE/android/reference/othertools.html
23:08eldokso you use Clojure's compile then dx to convert to Android bytecode?
23:09achim_pyep
23:11eldokso probably it is the clojure-generated code that is incompatible with Dalvik bytecode?
23:11achim_pso it seems
23:11eldokrhickey: where is compile?
23:13danlarkinIIRC there is a vestigial class loader related issue with the android VM
23:13eldokvestigial?
23:13danlarkinthat may have been dealt with by now, though
23:14danlarkinI'm often wrong about these things I pull from the back of my brain
23:14eldokA rudimentary or degenerate, usually nonfunctioning, structure that is the remnant of an organ or part that was fully developed or functioning in a preceding generation or an earlier stage of development.
23:15achim_pthat's the error message: local variable type mismatch: attempt to set or access a value of type java.lang.Object using a local variable of type boolean. This is symptomatic of .class transformation tools that ignore local variable information.
23:15achim_pdoesn't look classloader-related
23:16danlarkinI was going for the, "having become functionless in the course of evolution"
23:17rhickeyI saw this when I first tried dx from the Android SDK - looking at it now. It is a bytecode thing, not related to classloaders - the dx verifier chokes on something the Java verifier doesn't
23:17danlarkinwrong again! my record continues
23:21gnuvinceI asked a question earlier today, but I've been having problems with my Internet connection all day since then, so I haven't caught an answer (if there were one): what book would you suggest to somebody who wants to quickly get up to speed on Java?
23:22zakwilsonhttp://per.bothner.com/blog/2008/AndroidHelloScheme/ <-- somebody just got Kawa working on Android.
23:22eldok(defn hash
23:22eldok "Returns the hash code of its argument"
23:22eldok [x] (. clojure.lang.Util (hash x)))
23:23eldokcan someone explain that to me?
23:23eldokrhickey: where is compile in the src of Clojure?
23:23gnuvinceeldok: this calls the .hash() method of clojure.lang.Util with an argument x.
23:24rhickeyeldok: clojure.lang.Compiler
23:26eldokah so it refers to another method hash
23:29eldokhmm so it is not the compile.java but the:
23:29eldokpublic static Object compile(Reader rdr, String sourcePath, String sourceName) throws Exception{
23:29eldokin Compiler.java ?