#clojure logs

2009-01-04

00:00chrisnWhere can I post a quote like lisppaste?
00:00chrisnI have an awesome one from the one of the devs working on CUDA compilers.
00:01danlarkinchrisn: http://paste.lisp.org/new?
00:02chrisnA quote by a human. Not lisp code.
00:03hiredmanbash.org? qdb.us?
00:03danlarkinnothing's stopping you from pasting a human quote on lisppaste
00:03chrisnhttp://paste.lisp.org/display/73041
00:03chrisnI did
00:03Chouserhttp://paste.lisp.org/display/73041
00:03Chousersorry
00:03chrisnheh
00:04Chouserwrong globally-bound keystroke. :-)
00:05chrisnThat, btw, in no way reflects NVIDIA's position on the subject.
00:05chrisnthe functional language guys number in the very few.
00:05chrisnCUDA will be imperative for the forseeable future.
00:05danlarkinthat quote reminds me a lot of a TA I had in college
00:06hiredmanthat quote sounds like a haskell guy to me
00:06chrisnyeah, it is definitely more haskell than lisp
00:07chrisnBelieve me, I would take anything but C and C++ after doing it for as long as I have.
00:07chrisnbut graphics are *always* C/C++
00:07chrisnI actually program in C sometimes
00:07chrisnreal C
00:08TDSmithIt's hard toget around C for some things
00:09hiredman"I write in C because using pointer arithmetic lets people know that you're virile" -- Matthew Garrett
00:09TDSmithWell- I'm pretty damned virile, you know.
00:10ChouserA bunch of my friends have been working on OS's since college. They're aware high-level languages may be useful to some people, but they don't really trust anything higher than C.
00:10TDSmithI put fertilizer on my balls every night before I go to sleep.
00:10chrisnwtf does trust have to do with anything?
00:11chrisnyou understand what the compiler is doing, read the assembly if you have to.
00:11chrisnI have a few friends the same way and I just don't understand them.
00:11Chouserchrisn: right, that's why they trust C. Garbage collectors scare them, for example.
00:12chrisnI see "trust" as an excuse for not learning anything new.
00:12chrisnPeople use that same argument to not use c++
00:12chrisnnot just gc's languages.
00:12TDSmithmeh- it's not that simp[le
00:12ChouserI think it's mostly a matter of the problems you've had to solve. It only takes a couple of web-apps to realize you want your language to be helping out *a lot*.
00:12chrisnOr a couple cases of RSI
00:12hiredmanchrisn: trust and STL
00:13karmazillaMS Singularity is mostly written in a dialect of C#, managed and all, because it is easier to trust -- reliability and security wise :)
00:13chrisntrust and std::vector
00:13chrisnI don't know the entire STL
00:13karmazilla... than C and asm
00:13Chouserbut if you spend your time trying to track down why one particular load profile causes a network connection to take 2 milliseconds instead of 1 (or whatever), you really want to get down close to the metal.
00:13hiredmanI think llvm could really be the foot in the door for higher level languages in the lower levels of the OS
00:13chrisnSingularity was a damn cool project.
00:13TDSmithI'm not very familiar with MS singularity but...
00:14chrisnI read their paper
00:14TDSmithAre we talking about the singularity here?
00:14karmazillaa research OS Microsoft did
00:14TDSmithAh, I see...
00:14hiredmanif people start using an llvm based c compiler, so llvm is installed anyway
00:14hiredmanmight as well use it
00:15TDSmithSo they dno't mean an intelligence hat replicates so fast that it quickly saturates the potential for compuytation avaliable in it's environs?
00:15karmazilladoes that even make sense?
00:16chrisnllvm is interesting, I haven't quite got my head around it yet.
00:16TDSmithIT does, actually...
00:16TDSmithSort of...
00:16TDSmithI'm skeptical, but...
00:16chrisnIn some sense, you could give C an eval statement.
00:16chrisnwhich is a hardcore concept
00:17TDSmithIt is really odd that people would reference the "singularity" if they didn't mean it...
00:18karmazillajust reread your question and I think you might be confusing it with Vista :p
00:19TDSmithBut, tha said, I've always thought that Singularitarianism was religion for atheists.
00:19TDSmithhmm..
00:20TDSmithVista is not the singularity. I am almost sure of that.
00:25TDSmithHmm.. clojure changes fast..
00:25ericlavigneTDSmith: Vista rapidly saturates the available computational power in whatever computer it is installed on.
00:25ericlavignethough not in a particularly productive manner
00:26ericlavigneapparently it is constantly making backups
00:26TDSmitheric: hmm
00:26TDSmithYou're right...
00:26TDSmithWow, what a letdown.. Vista was the singularity, I guess...
00:28TDSmithI have to admit..
00:29TDSmithI'm a bit suprised that the answer to life the universe and everything is a Micorosoft API...
00:34karmazillait is for cases like that, that reality distortion fields exist
02:03nibbsis it possible to have regexp that refer back ?
02:03hiredmanah
02:04hiredmana back reference?
02:04hiredmanlike with \1 ?
02:04hiredmanjava regexs use $1 instead of \1
02:05nibbshttp://hpaste.org/13597
02:05nibbsyes
02:06nibbswhats up with lissppaste? it submits but then it is just blank...
02:06Raynespaste.pocoo.org
02:06RaynesThey have clojure highlighting.
02:06hiredmanso does gist
02:07Chouserit's useful to have a single place to find pastes discussed here. Rich has requested we use lisppaste
02:08hiredman(.replaceAll "123rd" "(\\d+)rd" "$1RD")
02:08arbscht_how long until clj-paste.net? :)
02:13gnuvinceI'd rather we submit a Clojure syntax file for lisppaste than move to another place
02:14gnuvinceEspecially considering that we got a bot for that.
02:15nibbscan i destructure-bind in a fn ?
02:15nibbs(fn [[a b c] xs] b)
02:15nibbsdoesnt work like that but smehow?
02:16hiredmandestructuring almost anywhere binding is done
02:16hiredmaner
02:16hiredmanworks
02:16hiredmanthe fn you pasted will work
02:17nibbsnope
02:17hiredmanuser=> ((fn [[a b c] xs] b) [:a :b :c] :d)
02:17hiredman:b
02:17hiredmanYep.
02:17nibbshttp://paste.pocoo.org/show/97863/
02:17nibbsduh
02:17hiredmanYou are doing it work then
02:18nibbsnoh
02:18hiredmanread the exception
02:18nibbsjava.lang.IllegalArgumentException: Wrong number of args passed to: user$a (NO_SOURCE_FILE:0)
02:18hiredmanso you are doing it wrong
02:18hiredmanand that is exactly what you are doing wrong
02:19nibbswhy do you pass the :d outisde?
02:19nibbsah wait
02:19hiredman(fn [[a b c] xs] b) is a function that takes 2 args
02:19nibbsi see lol
02:24herdrickquestion: is there already something like member defined in clojure?
02:24herdrickI used 'some' to make one: http://paste.pocoo.org/show/97864/
02:25herdrickis that in canonical style?
02:25hiredmanugh
02:25hiredmanI wish clojurebot was up
02:25gnuvinceherdrick: the "usual" way people do it is with a one-element set: (defn member? [e coll] (some #{e} coll))
02:27herdrickah, so sets are executable like hash-maps cool, thanks
02:28herdrickthat is, thanks @gnuvince ;)
02:28gnuvinceI wonder if this function should be included in core.clj, because it's asked weekly.
02:28nibbs(.replaceAll "hohejoj" "(\\d+)o\\d" "$1d") -> "hohejoj" but should be "hej"
02:28gnuvinceI think I actually answered it here a couple nights ago.
02:28nibbsI mad emy own member? as a multimethod
02:29nibbshttp://paste.pocoo.org/show/97866/
02:29nibbsobv using some seems easier :)
02:30nibbsis some lazy?
02:30gnuvincenibbs: for maps, you can use contains?
02:30gnuvinceuser=> (contains? {:a 1, :b 2} :a)
02:30gnuvincetrue
02:30gnuvinceuser=> (contains? {:a 1, :b 2} :c)
02:30gnuvincefalse
02:31hiredmannibbs: fix your regex
02:31nibbsah
02:32gnuvincenibbs: contains? also has the advantage of being O(1)
02:34nibbsok
02:34nibbsyeah my contains for maps is very dumb
02:35hiredmancontains works on sets
02:41nibbsdoes nil and false always evaluate to the same?
02:42hiredmanuser=> (nil? false)
02:42hiredmanfalse
02:42lambdanil is just null, and false is a Boolean
02:43hiredmantrue and false are just there for java interop
02:44nibbsk
02:44hiredmanactually false is a boolean
02:44nibbs(.replaceAll "hohejoj"
02:44nibbs "(\\[bcdfghjklmnpqrstvwxz])o\\$1"
02:44nibbs "$1d")
02:44nibbsi still dont get it
02:45nibbsit should match bob hoh but not hoj or lob etc
02:45hiredman...
02:45hiredmanI suggest you read up on java regexs
02:46nibbs(.replaceAll "123rd" "([bcdfghjklmnpqrstvwxz])" "$1o$1")
02:47nibbsworks hello -> "hohelollolo"
02:47nibbsuser=>
02:50nibbsbut the other wat hohelollolo -> hello i cant get right
02:50nibbsin python
02:50nibbs"([%s])o\1" % "bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXYZ")
03:00nibbs(.replaceAll "hohejoj" "[bcdfghjklmnpqrstvwxz]o$1" "$1")
03:00nibbswhy doesnt that work`?
03:01nibbsor actually im a little surprised it does work in python�
03:03nibbsok i need parens
03:03nibbsnow I see how
03:03nibbs(.replaceAll "hohejoj" "([bcdfghjklmnpqrstvwxz])o$1" "$1")
03:03nibbsbut it still doesnt work
03:18nibbs(re-find #"([bcdfghjklmnpqrstvwxz])o$1" "bob")
03:18nibbsnil
03:18nibbswhy`?
03:18nibbsthat SHOULD work
03:18nibbsit refers back to the paren
03:19karmazilla(.replaceAll "hohejoj" "([bcdfghjklmnpqrstvwxz])o\\1" "$1")
03:22nibbsthanks
03:58nibbswhen using namespace my user.clj is not available. should I require it? but it doesnt have a namespace. should it have a namespace?
03:58nibbsor I should use load-file?
04:10nibbsdestructuring seems tio slow down a simple function by almost doubling the execution time
04:10nibbs http://paste.pocoo.org/show/97872/
04:47karmazillanibbs: destructering binding expands into invocations of nth and nthrest, which are O(n) for things that do not support index lookup
04:52nibbswhat is the name of a html-tag that outputs text but not in a textarea and not as a link
04:52nibbsjust as plain text
05:15nibbswho created compojure?
05:16nibbsit would be nice to know who to ask about things?
05:16nibbsisnt there a function to supply a vector of html-tags?
05:19kotaraknibbs: there is a compojure google group, IIRC
05:20kotarakthen there is Google. Searching a bit might help.
05:51nibbshow do I write a string to a file?
06:23nibbswhen using namespace my user.clj is not available. should I require it? but it doesnt have a namespace. should it have a namespace? or should I use load-file then?
06:25nibbsif I want the eq of method X throws IOException {...} how do I do?
06:25nibbsdo I have to rethrow the error or just doing nothing has the same effect?
06:46nibbsanyone familiar with the sql/insert-rows?
06:47nibbsit takes a vectors as inserts but if I have a vector of vectors, how do I do?
06:52StartsWithKnibbs: docs say that insert-row takes & rows, so it should be ok to send vector of vectors
07:35nibbs(defn insert-rows-reviews [colls]
07:35nibbs (dorun
07:35nibbs (for [row colls]
07:35nibbs (sql/insert-rows :reviews row))))
07:35nibbsi had to do that
07:35nibbs(defn insert-rows-reviews3 [colls]
07:35nibbs (sql/insert-rows :reviews colls))
07:35nibbs fails
07:36kotarakUse doseq instead of dorun + for
07:36kotarak(doseq [row colls] (sql/insert-rows :reviews row))
07:38kotaraknibbs: you should use apply: (apply sql/insert-rows :reviews colls)
07:44nibbsI have to say "big thank you" to whoever created contrib.sql, i dont think database stuff have ever been that simple
08:09nibbscan I not pass :2 a s a name to a table?
08:09nibbsbut it can be named "2"?
08:10kotarak:2 is not a valid keyword, I suppose.
08:10kotarakI must start with a alphabetic character, eg. :x2
08:11kotaraknibbs: you can pass a string (create-table "2" ...)
08:13nibbsi try but it doesnt work
08:13kotarakwhat did you try, and what doesn't work
08:15nibbsi fixed it now
08:28nibbswhat a weirdo error
08:28nibbs"movie 1" is a valid table-name right?
08:30nibbsdoesnt work
08:30nibbs"hello" works "hello 12" doesnt work as table-name, that sucks
08:30nibbsis it the parsing in contrib/sql perhaps?
08:31kotarakI personally would avoid Whitespace in table names. I suppose you have to to quote it in the SQL statement, which contrib.sql doesn't do.
08:32nibbsah yeah i jsut skip the whitspace duh
08:42nibbsshould a 300kB file with one statement per row take a looooong time to insert into derby?
08:56nibbsI have filename on the form "mv_0000001" and it is always 7 digits so 12 would be "mv_0000012" not "mv_00000012"
08:56nibbsis there some nice trick for this?
08:56kotarakformat maybe
08:56kotarak(doc format)
08:56kotarakhmmm... no clojurebot
08:57nibbslike in python filename = 'C:/users/saftarn/desktop/NetFlixDataSet/training_set/mv_%07d'
08:57nibbs return filename % filmnbr + '.txt'
08:57kotarakas I said: format
08:57nibbsah
09:10drewrkotarak: user> (class :23)
09:10drewrclojure.lang.Keyword
09:11kotarakOh. Ok.
11:46mmcgranai saw the recent change adding metadata support to namespaces: http://code.google.com/p/clojure/source/detail?r=1193 - could this be used to add a docstring to a namespace?
11:48Chouser(alter-meta! (find-ns 'user) assoc :doc "The default namespace")
11:49Chouserbut print-doc doesn't know how to deal with it.
11:50mmcgranainteresting. i really like how doc strings for vars are structured in the metadata and was thinking it would be nice to do something similar for namespace-level docs instead of putting such documentation in comments at the top of files.
11:51mmcgranadocs-in-meta for namespaces would also make programatically generated docs more viable
11:52Chouserah, here it is (kinda) working: http://paste.lisp.org/display/73059
11:58ChouserIt'd be trivial to wrap that in a function that used *ns* and call it at the top of a file.
11:59mmcgranayeah, i'm trying to paste an example of that now, but the paster is hanging...
11:59Chouseror even patch clojure.core slightly to allow (ns foo-ns (:doc "blah blah"))
11:59mmcgranahttp://pastie.org/352274
11:59Chousermmcgrana: sometimes the bot acts up and you have to choose None instead of #clojure, and then paste the link here yourself.
12:00mmcgranao ok, ill do that
12:00mmcgranahttp://paste.lisp.org/display/73064
12:01Chouseryep, I'd have no argument with that.
12:01Chouserof course the (doc clojure.zip) bit wouldn't work unless clojure.zip had already been loaded such as via require
12:01nibbsI LOVE CLOJURE, IT HAS EVEN MADE ME ABANDON PYTHON AS MY FIRST CHOICE OF LANGUAGE
12:02Chousernibbs: welcome. :-)
12:02mmcgranaright, like it doesn't work on vars from unloaded namespaces
12:05mmcgranaSo a patch might look like: 1) add support for :doc in ns macro, perhaps via lower-level, seperate function to add adocstring to an arbitrary namespace, 2) update doc/print-doc to handle namespace case
12:07mmcgranai'd be happy to give that a shot
12:09mmcgranathough Rich mentioned that he isn't interested in unsolicited patches - should I post the idea to the list first?
12:18Chousermmcgrana: yeah, that's generally wise
12:19Chouserlet people help refine the idea a bit before posting a patch.
12:19Chouserthough I do think the process needs some refinement.
12:19mmcgranawhich process is that?
12:19Chouseror I should say "would benefit from" more than "needs"
12:20mmcgranai.e. the RFC/patch process or the namespace doc process?
12:20Chouserthe process of producing incorporating (or not) patches.
12:21mmcgranai agree
12:22Chouserthe community can say "no" to an idea or a patch (unless of course overridden by Rich), but only Rich can say "yes". This is as it should be, but there are several patches that have gotten a general thumbs-up from the community but no ruling at all from the BDFL
12:23Chouserthey are in a sort of patch limbo until he rules. Maybe these should be posted to the google code issues page so that they're not lost in the avalanche of google group postings.
12:23Chouser...but I'm not sure that's exactly how rhickey_ means the issues page to be used.
12:30danlarkinguess who's been added? http://www.angelfire.com/tx4/cus/people/
12:31nibbswould it be possible to write some sort of decorator-macro that would add a println-statement of a variable for each time inside a loop?
12:31nibbsso I didnt have to clutter the function with an option or something...
12:33nibbs parsing and inserting an 8MB file is eating up my computers processor and memory
12:33nibbsis that normal?
12:34mmcgranaChouser: thanks for your thoughts, I'll post on the ns doc idea later today
13:38nibbsis it not possible to insert nil into a integer-field in sql?
13:38nibbswhat do you do if you dont have a value to pass?
13:38nibbs(like a NULL field when parsing a file)
13:40pdNULLs are fine in integer columns
13:43nibbshmm but nil?
13:43nibbsand the NULL symol doesnt exist in clojure?
13:48Chousukewhat?
13:49Chousukewhatever you're using to put the data into the database *should* map nil to the SQL NULL
13:49Chousukebut there's no way to have an actual clojure nil in there :/
13:53nibbsthere are 2 things I really want from clojure
13:53nibbs1. always show on what row the error happened in the CLOJURE-file, not what javafile.
13:54nibbs2. a way to break a computation without killing the REPL completely
14:00dreish1. I think there's a REPL that does that. I saw some messages about it on the Google group, but I don't remember where.
14:00dreish2. I don't know whether that exists, but I'd like it too.
14:20nibbs{:movieid 17770, :releaseyear 2003, :name Alien Hunter}
14:20nibbs(str "select movieid from titles WHERE name = " moviename) <- works
14:20nibbsbtw [:name "VARCHAR(32)" "NOT NULL"]
14:21nibbs(str "select movieid from titles WHERE name = " moviename) <- doesnt work
14:21nibbswhy?
14:21nibbsisnt string = varchar as far as contrib.sql is concerned?
14:28Chousernibbs: it's not doing any object translation for you. You'll need to quote it yourself or even better use a prepared statement.
14:39dreishDoes anyone understand how to use PersistentQueue?
14:40Chousersure, what's the problem?
14:40dreishI guess the interface looks simple enough, but I'm having a hard time figuring out whether the old items will get GCd.
14:41dreishMy first idea was to use a vector and keep calling subvec as I consumed items, but then I saw in the implementation subvec keeps the original vector, so my queue would grow to infinity.
14:41dreishThen I saw PersistentQueue, but I can't figure out how it avoids the problem.
14:42Chouseronce you use 'pop', the item you've popped off is no longer referenced by the PQ, so it's free to be GC'ed as long as nothing else has it.
14:44dreishIt looks to me like r, the PersistentVector in PQ, only gets truncated (to null) when it becomes empty.
14:44dreishSo if, by policy, my queue always had at least one item in it, the vector would keep growing forever.
14:45ChouserPQ.pop() always does a 'rest' which frees up the head of the seq
14:45dreishSure, for the seq f, but what about the vector, r?
14:47Chouserah, I think I see your concern. If you conj a lot onto the PQ, it will hold a large vector.
14:47Chouserif you pop all but the last item of that vector, it will stil (via the seq f) hold the whole vector.
14:47dreishRight, which never appears to get trimmed in any way.
14:47dreish(Except when empty.) Right.
14:48dreishMy program might actually not have the problem of never emptying the queue, though. I probably need to think that through a little more. :)
14:49dreishIt could be a matter of, by the time the program has run long enough that I'd care about the size of the vector, it has almost surely run long enough to be empty at least once.
14:49dreishBut dealing with finite computers and long-running programs, "almost surely" always leaves me a little uncomfortable.
14:49Chouserok, I had thought that f and r never refered to the same vector, but now I'm not sure.
14:51Chouserno, I think that's right.
14:51dreishIf it could just say something like, if we only care about 5% of the vector, and the vector has more than 640 items, pop should make a copy of the remainder, not keep the whole thing.
14:51Chouserf and r never point to the same vector, so I think this is not a problem.
14:52dreishOkay, in that case I don't understand the relationship between f and r.
14:52Chouserstarting from empyt, pushing a, b, c, d will give you a PQ of (a)[b c d]
14:52Chouserthis is seq f = (a) and vector r = [b c d]
14:52dreishok
14:53Chouserpop once, f1 is null so you get (b c d)null
14:53Chousernow push e f g: (b c d)[e f g]
14:54dreishAh!
14:54dreishThat's brilliant.
14:54dreishThanks.
14:54Chouser:-) np
14:54Chouserit's this kind of thing that (for me at least) builds trust in the whole of Clojure
14:57dreishYes.
15:00Chouserso the worst it can get is if you push a lot into the vector and then pop all but the last
15:00Chouserit's still carrying the whole of the large vector at that point.
15:00dreishRight, and then just sit there. Not exactly the worst-case I was thinking of.
15:01dreishAs long as the queue keeps moving, it won't be much bigger than length*2.
15:01nibbs"select name from titles WHERE movieid = \"Fighter\"", doesnt work, how should I do?
15:02dreishnibbs: I think you're at roughly the same point I was yesterday when I decided not to use contrib.sql.
15:04nibbsbut I like it
15:04nibbsit makes sql so easy
15:05nibbsexcept for that :)
15:05dreishIt's got some nice ideas. It could probably be very good, with some work.
15:06nibbswait ok that doesnt work because it shouldnt
15:06Chouserthere's working being done on sql api
15:06nibbsisee the error
15:06nibbsyeah Lau_of_DK has soem cool stuff going
15:06nibbson
15:12Nafainibbs: What's he working on?
15:13nibbshigher-order-functions for sql-statements
15:13nibbscheck it on github
15:13nibbsclojurebot: sql?
15:14nibbshttp://github.com/Lau-of-DK/clojureql/tree/master
15:16Chouserdreish: you're not Jason Wolfe, are you?
15:16nibbsdreish: you use jdbc directly?
15:16dreishLast time I checked, I was Dan Reish.
15:17Chouserdreish: ok. Someone named Jason Wolfe has been talking on the group about subvec's and queues.
15:18dreishnibbs: Yeah, that's what I'm doing. I'm writing a special-purpose persistence framework, and I'll target my app to that, so if contrib.sql gets irresistibly good, I can swap it in with hopefully not too much rewriting.
15:18nibbsthumbs up for Lau_of_DK for humour:
15:18nibbshttp://hpaste.org/13613
15:19nibbshttp://github.com/Lau-of-DK/clojureql/tree/master/src/dk/bestinclass/clojureql/demo.clj
15:19dreishChouser: Same guy that found an interesting hashCode contract violation. I wasn't able to figure out what it was about, but I didn't dig too deeply. I did note that a Java array's hashCode is based on its identity, not its contents.
15:23nibbs(str "select movieid from titles WHERE name = " "'" moviename "'")
15:23nibbsworks ^^
15:24Chousukebut is vulnerable to SQL injection :p
15:25dreishReminds me of my favorite movie about a character named Robert'); DROP TABLES movies; --.
15:25pdI've just run (add-classpath "file://path/to/clojureql/src") in a slime repl, but can't require dk.bestinclass.clojureql
15:26pdIs that not how to modify the classpath in slime?
15:26Chousukeyou forgot the trailing slash?
15:27pdThank you =)
15:51nibbshow can I get a list of all tables in a db?
15:53ivan\dt
15:56hoecknibbs: thats database dependend :(
15:56hoecknibbs: but you could try java.sql.DatabaseMetadata/getTables
15:57hoecknibbs: but not all jdbc drivers support metadata
16:05nibbsok
16:05nibbshttp://java.sun.com/j2se/1.4.2/docs/api/java/sql/DatabaseMetaData.html
16:05nibbsno constructor
16:06hoeckthe java.sql.Connection has a getMetaData method
16:07nibbsok but when using
16:07nibbssql
16:07nibbscontrib.sql
16:08nibbshow can I refer to it?
16:10hoeckcontrib.sql has a connection function, so (with-connection db (resultset-seq (.getTables (.getMetaData (connection))))) should work
16:11hoeckif you have an older contrib revision, connection may be in the internal namespace, so internal/connection
16:38nibbs(str "select count(grade) from " movieid "where grade = " val)
16:38nibbswhats wrong with thayt?
16:40dudleyfnibbs: movieid "where
16:40dudleyfYou probably want a space after that quote
16:42nibbsyes thanks
16:44nibbs(defn get-tables []
16:44nibbs (sql/with-connection db
16:44nibbs (resultset-seq (.getTables (.getMetaData (connection))))))
16:44nibbs;
16:44nibbsjava.lang.Exception: Unable to resolve symbol: connection in this context (db.clj:194)
16:53Lau_of_DKnibbs: Which lib are you using ?
16:57nibbscontrib.sql
16:57nibbsbut what is connection?
16:57nibbssome variable i can refer to?
16:58Lau_of_DKnibbs: Dunno, but consider using ClojureQL instead
16:58Lau_of_DK:)
16:58Lau_of_DKThen you could do (sql/run (query grade moviedb (= grade ~val))) to get that query
17:01nibbswill rich add sum to core? i know it is just (reduce + coll) but still...
17:01Lau_of_DKYou probably answered your own question :) I dont think he will do that to save one character
17:04nibbs5
17:04nibbsit is used so often...
17:05Lau_of_DKYou can argue before Rich - I'd hate to see Clojure become bloated with a gazillion little helpers
17:05ChousukeI wonder if (apply + coll) is better than reduce
17:05Chousukeless calls to +
17:05Chousukeer, fewer
17:05dreish+ uses reduce internally, so apply is better because it requires less typing.
17:06Chousukeah.
17:06Chousukenibbs: sum is trivial to define yourself if you need it a lot
17:06nibbsyes ofc
17:06nibbsjust sayan yo
17:07nibbsdo you have your user.clj ina namespace?
17:07nibbsdo i have t import it then?
17:07nibbsto use it from the repl i mean
17:07Lau_of_DKnibbs: You can always fork Clojure, call it Nibjure, and include that func :)
17:08Chousukeor send it to contrib
17:08nibbslol
17:08Lau_of_DKAnyway nibbs, for your SQL needs, check out ClojureQL, its phenominal, and the guys who made it really did a good job :)
17:12nibbsyes I checked it out before
17:12nibbsyou have anice sense of humour, i liked the best in class example
17:13Lau_of_DKbestinclass example? You mean the demos ?
17:13nibbsyes
17:13Lau_of_DKGood, Im glad you liked it :)
17:47nibbsif passing NULL to sql should it be a string "NULL" or nil?
17:53Chousukewhat are you using to communicate with SQL?
17:55Chousukeif you're using (str "select from foo bar where " whatever ...) and just sending those to the database, your NULLs will be strings :/
17:55Chousukebut that approach is flawed anyway. Did you take a look at contrib.sql?
17:55Chousukeor clojureql
18:03emacsenquote of the day goes to someone on the dc clojure study group list who wrote a little java gui app and someone else converted it into clj:
18:03emacsen"Your code was 184 lines, and my Java code was 420 lines, and my JRuby
18:03emacsencode was 402 lines!"
18:06duck1123it's really too bad that =~ isn't a valid symbol. It would be great if it could be a shorthand for re-find
18:07Chousukeooh, excellent.
18:08Chousukegot the latest slime and clojure-swank working
18:08Chousukeapparently it's now necessarily to manually enable the fancy slime repl.
18:09duck1123yeah, it was kinda annoying getting it to work, but there is a thread that explains what to do.
18:09emacsenduck1123, yeah- you could add a reader macro at the source level and see if it'd be accepted into the language...
18:22pjb3Here's the swing app that emacsen was referring to: http://github.com/pjb3/converter/tree/master/converter.clj
18:22pjb3The converter function needs to be broken down into smaller parts
18:23pjb3But I was just doing this as a straight port of the Java version
18:23pjb3and I need to set up a lot of objects in the let statement to be able use them as closure in the various functions
18:24pjb3To mimic the instance variables from the Java version
18:24Chousukesomething's wrong with the indentation of the to-f function :/
18:25pjb3yeah, there is, doesn't look that way in emacs though
18:26nibbsis it possible to run several JVMs in emacs?
18:28Chousukepjb3: all the actions look really similar :/
18:29pjb3Yeah, I could create make-action function to clean that up a little
18:30pjb3They are all slightly different
18:31Chousukemaybe even a macro
18:41aperotteI just found a very nice new numerical java library. In case anyone else is interested, it's here http://www.ujmp.org/
18:58nibbsaperotte: thanks, it leads to some good other libs too!
19:02ehirdWhat's the defacto clojure tutorial
19:02ehird?
19:02Chousukeis there such a thing :/
19:03Chousukethe wikibooks are pretty bad.
19:03aperottenibbs: no problem ... I've been looking for something exactly like this, it seems to be pretty fantastic
19:07aperotteehird: I think the best right now are the screencasts at http://clojure.blip.tv/
19:08ehirdew :\
19:08durkai recommend watching the screencasts with a repl open
19:09aperotteehird: there are also a few blogs that are essentially tutorials
19:09Chousukethe videos are really good though.
19:10aperotteehird: for example, http://writingcoding.blogspot.com/ has a series of articles that are interesting (though some of the code might be broken now because of the more recent changes in clojure)
19:10ehirdah
19:27holmak.msg NickServ identify inaktive/00
19:37duck1123looks like holmak gets to change his password
19:37holmakhaha, already done
19:37holmaki feel terribly dumb
19:38duck1123that's why, if I ever do type it manually, I always switch to the server window
19:38duck1123just in case
19:38holmaki usually do - as you can see, this time i messed up
19:41ehirdholmak: i tried ghosting you :D
19:42holmakI think I successfully resecured my identity. I seriously doubt my nick carries any weight anywhere anyway ;D
19:43duck1123I wish OAuth/OpenID worked with IRC
19:50doublefreeyow... for the record :-) I spent more than a few hours determining why (. gl glVertexPointer 3 GL/GL_FLOAT 0 0) fails ("No matching method found") ... one valid signature is [int int int long] and later I discover (by stepping through Reflector.java (invokeMatchingMethod)) that my invocation supplied [int int int int]. my fix was: (. gl glVertexPointer 3 GL/GL_FLOAT 0 (long 0)). this mixup was frustrating, but being able to
19:56Chouseryou were cut off at "but being able to"
19:56doublefreeoh... but being able to step through Clojure with a debugger was key! I bet if I had realized that 'no matching method' could mean 'no matching arguments' I could have saved some time.
19:57dreishIt was a good story up to that point, though. Why spoil it?
19:57doublefreedreish: I aim to please ;p
20:07duck1123so what do you guys think? Is it worth including a new jar just to get the dateTime formatting I want, or should I try to do it myself?
20:07Chouserbleh. You really can't get the Java format stuff to do what you want?
20:08duck1123all I want is a date formatted according to the xsd:dateTime spec
20:09duck1123I'm close, but not quite right. I can always take the string and run it through a replacement fn to fix it, but that seems wrong
20:09duck1123I've found other libraries that do what I'm looking for, but it seems a waste of a dependency
20:10sohailduck1123, in Java, there is no such thing as too many dependencies
20:11Chouserduck1123: looks like others have done it: http://www.objectdefinitions.com/odblog/2007/converting-java-dates-to-xml-schema-datetime-with-timezone/
20:20nibbsaperotte: if you are into machine learning dont forget libsvm, it is veyr easy to isntall and use
20:29xelapondHi everyone
20:30xelapondI'm a hard-core python and c++ programmer, and I have dabbled in a little scheme, but 'ive never done java
20:30xelapondDo I have to know Java to learn Clojure?
20:32durkano, but it will help with the java interop
20:32xelapondyeah, thats the part I was really excited about
20:33durkai mean, you're going to need to read a lot of javadocs
20:33xelapondok
20:33durkaand they expect a superficial knowledge of java at least
20:33durkabut if you know c++ that's almost enough
20:33xelapondok
20:33xelapondI assume there is a java tutorial?
20:34durkatons of them
20:34xelapondok, Ill do that first:)
20:34xelapondthanks
20:34xelapondI assume I could probably learn both at the same time, right?
20:34xelapondif I don't need to know one to learn the other
20:34ericlavignexelapond: you can learn either of them first, or learn both at once
20:35xelapondericlavigne: ok, thanks:)
20:37ChouserI'd start with clojure. it's more fun. when you're dealing with some java lib and realize you need to know what a final method is, or can't understand the example (because its written in Java), then go learn a little java.
20:39xelapondhm
20:39xelapondis the syntax of clojure any different from Scheme(aside from different names?)
20:39ericlavignexelapond: It's very close.
20:40xelapondok
20:40xelapondI guess ill learn Clojure first, it should be pretty quick
20:40ericlavignexelapond: http://clojure.org/getting_started
20:40xelapondyep, I'm already there:)
21:12durkahow does contrib.seq-utils/group-by work?
21:12durka(group-by class [1 2 "three" :four])
21:12durkajava.lang.ClassCastException: java.lang.Class (repl-1:154)
21:14durkai guess it expects strings?
21:14durka(group-by (comp #(.toString %) class) [1 2 "three" :four])
21:14durka{"class clojure.lang.Keyword" [:four], "class java.lang.Integer" [1 2], "class java.lang.String" ["three"]}
21:17kotarakdurka: the keys must be comparable since it is a sorted-map. How do you sort classes? I suppose group-by could also return a hash-map? That would solve this.
21:17drewrGood heavens, Volkmann is like half the msgs.
21:17durkaoh, that makes sense
21:55duck1123does anyone know of a good example of sorting a seq of maps based on certain values
21:57gnuvince"certain" values?
21:57gnuvinceLike a few of them?
21:58gnuvinceCause you can do it pretty easily:
21:58gnuvinceuser=> (sort #(compare (:a %1) (:a %2)) [{:a 2}, {:a 1}])
21:58gnuvince({:a 1} {:a 2})
21:58duck1123like a particular value, perhaps using another if they match
21:58hiredman,(sort-by :a '({:a "foo"}{:a "bar"}))
21:58clojurebot({:a "bar"} {:a "foo"})
21:59hiredman(doc sort-by)
21:59clojurebotReturns a sorted sequence of the items in coll, where the sort order is determined by comparing (keyfn item). If no comparator is supplied, uses compare. comparator must implement java.util.Comparator.; arglists ([keyfn coll] [keyfn comp coll])
21:59duck1123thanks hiredman I didn't realize keywords would work in that case
22:00hiredmanclojurebot: I missed you
22:00gnuvinceOops, I forgot about sort-by
22:00gnuvinceGood call hiredman
22:00duck1123and sort-by didn't work with syntax similar to what gnuvince posted
22:01chessguyso...what's up with clojure? i've heard the name a couple times lately, but never looked into it
22:02chessguysuntax looks like a cross between lisp and perl or something
22:02hiredmanclojurebot: clojure?
22:02clojurebotclojure is the bestest programming language available.
22:03hiredmanthe comparison to perl hurts
22:03chessguywow, that's clever
22:03chessguyhiredman, don't take it personally, it's a very ignorance-based comment
22:03duck1123clojure is about as compact as perl, yet still readable
22:04chessguyimpure, though, right? (as opposed to haskell)
22:05durkamore or less
22:05durkathe ability to call arbitrary Java is a pretty big impurity
22:06duck1123chessguy, clojure is fully compatible with java libraries, which ruins any purity. But it turns out to not that big of a problem
22:07chessguyerr, how is it any less of a "problem" than, say, java, or c#?
22:07hiredmanbecause you can just use it when you need it and avoid it the rest of the time
22:08duck1123well, you can get a lot done without dropping into java interop
22:08chessguyoh, by "it" you mean java-compatibility, not impurity
22:08duck1123I don't have enough experience with other functional languages to really say on this issue
22:09chessguyok, so more like a cross between java and lisp then
22:10duck1123exactly. It's a lisp based on the jvm
22:11chessguyinteresting...
22:11hiredmanthere are videos online with rhickey giving an intro to clojure
22:11hiredmanclojurebot: blip.tv?
22:11duck1123and since it was designed from the start to have that compatability, it's a really nice fit
22:12hiredmanhmmm
22:12chessguyi take it though that it's still pretty much a toy, not much real-world testing
22:12duck1123if only more java library designers had kept clojure in mind when they designed their api's
22:13duck1123there are a few companies that are using it full time
22:13duck1123still a very young language, but there's nothing stopping people from using it in production
22:13chessguyi don't even see any serious examples on the site, though i could be missing something
22:13duck1123except for maybe the difficulty in finding lisp programmers
22:15chessguyhaha, all the dice.com searches for "clojure" return results with the word "closure" in it
22:16hiredmanugh
22:16hiredmansomething broke fact look ups in clojurebot
22:16hiredmanbut at least oc and the sandbox still works
22:16hiredmandoc
22:20chessguyi'd prefer a haskell job any day :)
22:20durkaclojurebot: latest?
22:20clojurebotlatest is 1195
22:21durkaclojurebot: clojure?
22:21clojurebotclojure > scheme
22:21duck1123I used to very much prefer static typing. Ruby started to bring me around, clojure brought me the rest of the way
22:21durkaclojurebot: blip.tv?
22:21chessguyduck1123, oh? how so?
22:21durkamaybe it's something about facts with dots in them?
22:22durkaclojurebot: blip.tv is http://clojure.blip.tv/
22:22clojurebotAck. Ack.
22:22duck1123it's fun to take some java code, erase all the type declarations, move some parens, and watch the line count just drop
22:22durkaclojurebot: blip.tv?
22:22clojurebotblip.tv is http://clojure.blip.tv/
22:22hiredmangrr
22:22durkawoof
22:22duck1123so long as the compiler knows what type it is, I don't feel the need to type it out
22:23durkaclojurebot: doesnotexist?
22:23chessguywell that's more about type inference than static typing
22:23hiredmanhmmm
22:23durkaare the "i don't know" messages broken?
22:23hiredmanthat must be it
22:23chessguyclojurebot, foobar?
22:24durkacan i ask an agent whether it's done without awaiting it?
22:26cmvkkhmm i have a similar question. what if i want to run a series of n functions concurrently, but wait until they are all done before continuing?
22:27durkacmvkk: start them all in separate agents and call await
22:27cmvkkor better, what if i want to run a series of n functions for each i in (range 50000), but they all need to be done with i before going on to i+1?
22:27durkaawait takes any agents as you awnt
22:27cmvkkhmm
22:28cmvkki didn't know that existed.
22:28durkawant*
22:28durkathat second one is harder...
22:28cmvkkthe second one is the same problem anyway. just send all the agents, then await before looping.
22:28durkaunless it isn't
22:28durkayeah
22:28durkaalso, i think the answer to my question is await-for
22:29cmvkki see both now. thanks a lot.
22:29cmvkki still kind of wonder if it's worth the overhead if the functions in question are very fast
22:30cmvkkgiven this scenario, is there a significant overhead vs. just calling them sequentially?
22:30cmvkkhmm, maybe that question is difficult to answer in general...
22:31durkai think you would just need to benchmark a specific circumstance
22:32cmvkki think so too. which means to me the answer is 'flip a coin and get on with it'.
22:36chessguywow, this blip.tv thing has been going for like 15 minutes, and he still hasn't moved from "why" to "what"?
22:37durkawell, it's a long video
22:37durkabut worth iut
22:37durkait
22:47durkahow do agent validators work?
22:51chessguyare clojure vectors random-access, or o(n)?
22:51Chouserchessguy: constant-time lookups by index
22:51chessguycool
22:51Chouserchessguy: roughly contant-time append
22:52chessguyby which you mean log n ? :)
22:52Chouserwell, the lookup by index is O(log-base-32)
22:52durkai think "roughly" refers to the structure-sharing Magic
22:53chessguyok
22:54ChouserI shouldn't have said roughly. the constant factor on append probably flustuates a bit.
22:55Chouserdurka: what don't you understand about validators?
22:56durkajust that i can't seem to make them work
22:56durkafor one thing, the set-validator function is gone?
22:56dhaya(doc set-validator!)
22:56clojurebotexcusez-moi
22:57Chouserclojurebot's a bit behind the times, but dhaya's right.
22:57durkathat gives me the same trouble as .setValidator
22:57durka(set-validator! test-agent #(true))
22:57durkajava.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong number of args passed to: user$eval--3848$fn (repl-217:121)
23:01Chouser(def a (ref 2 :validator even?))
23:01Chouser(dosync (alter a inc)) ==> error
23:02Chouser(dosync (alter a + 2)) ==> 4
23:02durkaoh
23:02durkawell ok
23:02durkai was trying to give an agent a validator
23:03Chouser(def a (agent 2 :validator even?))
23:03hiredmanggrrrr
23:03Chouser(send a inc), @a ==> Agent has errors
23:04Chouser(clear-agent-errors a), (send a + 2), @a ==> 4
23:05durkainteresting
23:06durkanot entirely sure what i was doing wrong
23:06durkai guess it was a problem with the #() syntax
23:08ChouserCould be. #() functions take as many args as you mention. by not including %, your #() took zero args and it should have taken 1
23:09cmvkkit's too bad that's the case.
23:09cmvkki keep thinking if i want to set a particular value to an agent, i have to do like (send agent (fn [x] 0))
23:10durkai wrote a useful function
23:10durka(defn ignore [f] (fn [& args] (f)))
23:11Chouser(send agt (constantly 0))
23:12cmvkkahaaa
23:12cmvkkthanks
23:19Chouserdurka: you want add-watcher
23:20durkayeah
23:21durkai only decided to try validators because i had the same trouble as i did before with validators, which turned out to be a problem with #()
23:21durkaalso, clojure.org is out of date, lists add-watch instead of add-watcher
23:22Chouserclojure.org attempts to document the latest release
23:22Chouserit's still a bit out of date with that, but not as much.
23:24durkaoh right
23:24durkanobody care about the return value of a watcher, right?
23:25Chouserhm, I believe that's correct.
23:34durkathat's impressive
23:34durkai think clojure used seven hours of cpu time in twenty minutes
23:37hiredmanclojurebot: nonexistant?
23:37clojurebotexcusez-moi
23:38durkaclojurebot: blip.tv?
23:38clojurebotblip.tv is http://clojure.blip.tv/