#clojure logs

2010-11-14

00:20pppaul$fortune
00:20sexpbotYou will yawn in 5 seconds.
00:20pppaul$fortune
00:20sexpbotYou will yawn in 5 seconds.
00:20pppaul$8ball is $fortune broke?
00:20sexpbotpppaul: Concentrate and ask again.
00:21johndeo$fortune
00:21sexpbotone day sexpbot will have a large fortune database
00:22pppauli gave it some cookies
00:22pppaulwhat gives
00:23pppaul$fortunecookie
00:23pppaul$fortune cookie
00:23sexpbotYou will yawn in 5 seconds.
00:23pppaulhmph
00:23johndeo$fortune
00:23sexpbotYou will yawn in 5 seconds.
00:48johndeo##(assoc-in nil [:a :b :c] 1)
00:48sexpbot⟹ {:a {:b {:c 1}}}
00:49johndeo##(assoc-in nil [:a :b :c] :foo)
00:49sexpbot⟹ {:a {:b {:c :foo}}}
00:49johndeoCan anyone tell me how to read the :foo out of there?
00:51johndeo({:a {:b {:c :foo}}} :b)
00:51johndeo##({:a {:b {:c :foo}}} :b)
00:51sexpbot⟹ nil
00:53johndeo##({:a {:b {:c :foo}}} :a)
00:53sexpbot⟹ {:b {:c :foo}}
00:56amalloyjohndeo: ##(get-in {:a {:b {:c :foo}}} [:a :b :c])
00:56sexpbot⟹ :foo
00:57sproustAnybody know what happened to with-out-writer?
00:58sproust(Porting some code to the bleeding edge, lots of stuff moved.)
01:01johndeo##(def deephash (assoc-in nil [:a :b :c :d] '(:a :b :c :d)))
01:01sexpbotjava.lang.SecurityException: You tripped the alarm! def is bad!1
01:01johndeooops
01:02johndeoamalloy: Oh! Thanks.
01:03replacasproust: you have to use (with-open [w (writer "xxx")] (binding [*out* w] ...)), I think
01:04replacasproust: with-out-writer was considered to do too many things at once to migrate to core
01:04sproustreplaca: thanks.
01:05sproustI'll redo the macro in my code-- it's very useful.
01:05sproustWhat you wrote above is long enough for me to create an abstraction.
01:08sproustreplaca: I now get "Evaluation aborted" on evaluating (ns) directives instead of errors. Is there a fix?
01:09LauJensenMorning all ya'll
01:09replacasproust: I don't know. I haven't seen that prob.
01:10replacaMorning Lau. Congrats on all the CQL progress
01:11replacaLau: for the record, I vote for select, et al. rather than shadowing core stuff
01:11LauJensenreplaca: thanks, and thanks for your input
01:11LauJensenReading the official Wiki on library design, it occured to me that shadowing core was encouraged when there are parallel semantics
01:12LauJensenWhy would you prefer I didnt do it ?
01:14replacaLauJensen: to me it only works if the semantics are *really* identical. And the I'd rather get all the way to implementing the same underlying protocol. Plus, the semantic model of SQL is already very familiar, so hiding it seems like obfuscation
01:15pppaulshow me some CQL
01:15LauJensen@(conj! users {:name "Jack"})
01:15LauJensen>>> ({:id 1 :name "Lau"} {:id 2 :name "Christophe"} {:id 3 :name "Frank"} {:id 4 :name "Jack"})
01:15LauJensen
01:15LauJensen (-> (table {} :users)
01:15LauJensen (select (where (= :admin true)))
01:15LauJensen (aggregate [:count/* :country]))
01:15LauJensen >>> "SELECT users.country,count(users.*) FROM users WHERE (admin = true) GROUP BY country"
01:15LauJensen
01:15LauJensen@(join users visitors :id) ; USING(id)
01:15LauJensen>>> ({:id 1 :name "Lau" :guest "false"} {:id 3 :name "Frank" :guest "true"})
01:15LauJensen
01:16LauJensenpppaul: the rest is here https://github.com/LauJensen/clojureql on the front-page, scroll down
01:16replacaLauJensen: but it's important to note that my vote doesn't come from any direct experience with CQL itself
01:16LauJensenreplaca: The official way, is not to shadow when the semantics are identical, but parallel. In this case, clojure.set is an implementation of relational algebra and so is CQL. Main difference is CQL puts the results in a database
01:16LauJensenThis is more of a library design issue than a SQL issue
01:17sproustThat's very cool! Not so much as a replacement for SQL's syntax, but as a way to generate queries programmatically!
01:17LauJensenHowever - The semantics are very parallel, the primitives are identical. So I figured a familiar interface like conj/disj/sort/take etc would be great - no learning curve
01:17pppaulso, sometimes CQL wraps SQL, and sometimes you have to use SQL as text?
01:17LauJensensproust: exactly
01:17replacaLauJensen: yeah, I get that. You asked for my preference :). I would always be looking through to the generated code :)
01:18LauJensenpppaul: CQL always wraps SQL, but if you want, I let you escape our syntax with strings so tht you can write raw sql. shouldnt be necessary
01:18pppaulit looks cool... how many public symbols are there?
01:19LauJensenpppaul: https://github.com/LauJensen/clojureql/blob/master/src/clojureql/core.clj#L21 those listed in the protocol definition, + a contructor, table? and where
01:21pppaul^_^
01:22sproustHmmm... bleeding-edge SLIME w/ bleeding-edge swank w/ Bleeding-edge Clojure = broken. Errors don't trickle back up to Emacs.
01:22sproust"error in process filter"
01:23sproustG'night folks!
01:24amalloyaww. missed my chance to tell him there's a reason they call it bleeding-edge
01:24pppaultoo much bleeding
01:32quizmehow do you do a deep merge of two maps with conj ?
01:38quizme http://www.pastie.org/1296480
01:49LauJensenCan anybody think of a good name for the CQL equivalent of with-results ?
01:50quizmenm, i found it: clojure.contrib.map-utils/deep-merge-with
01:52tonyli was looking for it in contrib figure there might be something
01:52tonylcool
01:55tonylwith-records ? maybe
01:58tonylhow does this work ##(let [{a :a, b :b, c :c, :as m :or {a [2 3] b [3 4]}} {:a [5 6] :c [6 7]}] [a b c m])
01:58sexpbot⟹ [[5 6] [3 4] [6 7] {:a [5 6], :c [6 7]}]
01:59tonyli know it is destructuring
01:59tonylbut one map has the keys as symbols and are not even quoted
02:07pppaul:as /
02:07pppaul:as ????
02:08pppaulbarf @ tonyl's code
02:08tonyl:as it is a special key
02:08tonylin destructuring it returns the entire map of the binding
02:08tonylyeah, i don't get it either
02:09tonylthis is where my understanding of destructuring stops
02:09pppauli don't know :as or :or
02:09pppaullots of things to learn...
02:09tonyl&(let [[a b :as m] [1 2 3 4 5 6 ]] [a b m])
02:09sexpbot⟹ [1 2 [1 2 3 4 5 6]]
02:11tonylcheck this out http://blog.jayfields.com/2010/07/clojure-destructuring.html
02:12pppaulhot stuff
02:12tonylit's like a mini language
02:17amalloydo you still have a question, tonyl? ("how does this work" is insufficiently specific)
02:19tonyli dont understand this map {a :a, b :b ... } used in destructuring, why are the keys symbols
02:20pppaul&(doseq [[k v] {:a 1, :b 2, :c 3}]
02:20sexpbotjava.lang.Exception: EOF while reading
02:20pppaul (println k "=" v))
02:20pppaul(doseq [[k v] {:a 1, :b 2, :c 3}](println k "=" v))
02:20pppaul&(doseq [[k v] {:a 1, :b 2, :c 3}](println k "=" v))
02:20sexpbot⟹ :a = 1 :b = 2 :c = 3 nil
02:21pppaulhow does that work?
02:21pppaulthe [k v ] part
02:21amalloytonyl: the keys in map bindings are the locals (or more complicated binding forms) you want assigned to the value of the corresponding keys in the map
02:22amalloy&(let [{[a b :as c] :val} {:val [1 2 3]}] [a b c])
02:22sexpbot⟹ [1 2 [1 2 3]]
02:22tonyl&(let [{val :k} {:k "tee"}] [val])
02:22sexpbot⟹ ["tee"]
02:22tonylI guess the switch threw me off
02:23amalloyit's surprising the first time you see it, but there's a reason
02:23tonylyeah, the example I saw was big. I needed it to break it down smaller
02:24amalloytonyl: does mine make sense to you now?
02:24tonylyeah
02:24tonylthanks
02:24amalloywelcome
02:24amalloythere's a shorthand for the complicated one you posted first
02:24tonylwhat is the shorthand?
02:25amalloy&(let [{:keys [a b c] :as m} {:a [5 6] :c [6 7]}] [a b c m])
02:25sexpbot⟹ [[5 6] nil [6 7] {:a [5 6], :c [6 7]}]
02:25tonylooh :keys right
02:26tonylpppaul the map entry which is passed as a vector destructures vector to the key en value
02:27amalloypppaul: ##(seq {:a 1, :b 2, :c 3})
02:27sexpbot⟹ ([:a 1] [:b 2] [:c 3])
02:28amalloyafter that it's just destructuring a plain old list-of-lists, with no map funkiness to worry about
02:28replacatonyl: I think the answer to your question is that in a macro (and destructuring is effectively done in a macro) the map has been read but not evaled
02:28pppaulamalloy, how would i do that in a let?
02:29amalloydo what?
02:29pppaul[k v] {:a 1 :b 2 :c 3}
02:29replacatonyl: therefore, the symbols are not yet evaled and can be torn out to use as locals
02:29pppauloh
02:29pppauli see
02:29pppaulnm
02:29pppauli missed your reply
02:31replaca&(read-string "{a :a b :b}")
02:31sexpbot⟹ {a :a, b :b}
02:57MimisbrunnrHi all, I cannot for thel if of me, seem to get clojure-contrib working
02:57Mimisbrunnr*the life
02:57Mimisbrunnrthe path to the jar is in my CLASSPATH but java doesn't seem to find it
02:58Mimisbrunnr(I'm on OSX 10.5.x) ideas?
02:58tonyldoes it load clojure?
02:59Mimisbrunnryes, clojure loads fine, though I'm using -cp for that, if I use -cp for both of them, it doesn't load
02:59amalloyMimisbrunnr: you can't give two -cp entries
02:59amalloyyou need -cp /path/1:/path/2
02:59tonylare you using the right path separator
02:59Mimisbrunnramalloy: I did that, and tonyl yes I'm using : and /
03:00Mimisbrunnr(: for differnt paths / for folders )
03:00tonylare you using direct paths or relative ones?
03:03Mimisbrunnrdirect
03:03tonylnow that is weird
03:03Mimisbrunnrtonyl: hence my being here =P
03:03tonylcan you show us the full command you are using
03:04Mimisbrunnrsure, let me try it again, I'll pastebin the error as well
03:04tonylok, another thing might be permissions to the jar file
03:05Mimisbrunnr...
03:05Mimisbrunnrwell, slap my ass and call me charlie
03:05Mimisbrunnrit works
03:05Mimisbrunnrsorry to waste your time
03:05Raynes*SPANK* CHARLIE!
03:05tonylcharlie
03:05tonylnp
03:06Mimisbrunnrhaha danke =P
03:06Mimisbrunnrwell, now it works, I can go to bed, or keep coding..
03:06tonylor both
03:07MimisbrunnrI find, while I do my best napping while driving, I do my worst coding while alseep
03:07tonylhahaha now your limits, wise
04:11bmhHow can I use a function defined later on in my source in one earlier in the source?
04:12amalloybmh: (declare later-fn)
04:12amalloyor, my preference, reorder things
04:13bmhamalloy: thanks. Neither of those solutions are particularly pleasant
04:33aslamhow do I get a list of currently running thread from clojure?
04:34aslamJava's Thread has an enumerate function, but it takes an array of Thread and copies references to the array.
04:36Raynesaslam: Is there a particular reason you wish to do that via code? If you use jconsole and attach to the JVM, you can see how many threads are running and such like thatr.
04:36RaynesIn any case, this code should be easy enough to adapt: http://stackoverflow.com/questions/1323408/get-a-list-of-all-threads-currently-running-in-java
04:37aslam@raynes thanks
04:38amalloyaslam: (let [a (make-array Thread (Thread/activeCount))] (Thread/enumerate a) (seq a))
04:38RaynesThere ya go.
04:38Raynesamalloy is the much less lazy version of myself.
04:39amalloywell, it takes Raynes ten minutes to download http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Thread.html
04:39amalloyso i do the heavy lifting for him
04:39Raynes9.4 seconds
04:40aslamyou guys are awesome :)
04:40amalloyRaynes: is that timing wget/curl, or firefox with firebug?
04:41Raynesamalloy: It's clicking your link and counting while chrome loads the page.
04:41RaynesI can't be off by more than 3 seconds on either side.
04:42amalloyfwiw firebug says it takes me 3.5s
04:42Raynes&(let [a (make-array Thread (Thread/activeCount))] (Thread/enumerate a) (seq a))
04:42sexpbot⟹ (#< Thread[ObjectId-TimeFixer,5,main]> #<PoolThread Thread[27282470@qtp0-0,5,main]> #<PoolThread Thread[21680790@qtp0-1 - Acceptor0 SocketConnector@0.0.0.0:8881,5,main]> #<Thread Thread[Thread-4,5,main]> #<Thread Thread[pool-2-thread-1,5,main]> #<Thread Thread[Thread... http://gist.github.com/676047
04:42RaynesNeat, it actually works.
04:42amalloy1s if i don't bypass the cache
04:42amalloyRaynes: i would have tried it here, but i assumed you weren't allowing thread operations
04:43amalloyoh, i see. but we're not calling any methods on threads, just on Thread
04:43Raynes&(.stop (Thread. (fn [])))
04:43sexpbotjava.security.AccessControlException: access denied (java.lang.RuntimePermission stopThread)
04:44amalloyokay, i'm going to bed. have to be out of the house in like 7 hours
04:45amalloynight all; Raynes
04:45RaynesAww.
04:45RaynesNight
04:45RaynesNow I'm all alone.
04:46aslamRaynes: I see 224 users
04:47RaynesBut none of them are amalloy_ ;(
04:49aslamRaynes: ah. can't do anything about that
05:12aslamuser> (mod 10 3)
05:12aslam1
05:12aslamuser> (mod -10 3)
05:12aslam2
05:12aslamuser> (mod 10 -3)
05:12aslam-2
05:12aslamuser> (mod -10 -3)
05:12aslam-1
05:12aslamuser> (rem 10 3)
05:12aslam1
05:12aslamuser> (rem -10 3)
05:12aslam-1
05:12aslamuser> (rem 10 -3)
05:12aslam1
05:12aslamuser> (rem -10 -3)
05:12aslam-1
05:12aslamI understand that mod takes the sign of divisor and rem takes the sign of divident
05:12aslambut why is mod showing 2 when signs are opposite?
05:14aslamah got it
05:24pppaul(inc aslam)
05:24sexpbot⟹ 1
05:25pppaulwhat would be a good way to do a 2d array in clojure?
05:26pppaulis a list of lists reasonable?
05:35morphlingpppaul: vector of vectors is closer to a 2d array
05:35morphlingsince lists have O(n) access to the nth element
05:37pppaulfor my purpose execution time is not a problem
05:37pppauli guess the syntax and everything would be the same with a list or vector
05:40aslamwhat is the difference between rest and next?
05:43NikelandjeloHow to draw parametric functions using incanter.charts? For example I have functions for circle: x(t) = cos(t) y(t) = sin(t) . I can generate points for t from 0 to 2*PI, but I don't know how to draw them using charts. xy-plot and add-lines don't work. They seem to sort these points by x and then display. Is there some other function for it?
05:50pppaulaslam, look on clojure.org
05:50pppaulnext is for pure lazy seqs
05:55fliebelmorning
05:56aslamnext
05:56aslamfunction
05:56aslamUsage: (next coll)
05:56aslamReturns a seq of the items after the first. Calls seq on its
05:56aslamargument. If there are no more items, returns nil.
05:56aslamrest
05:56aslamfunction
05:56aslamUsage: (rest coll)
05:56aslamReturns a possibly empty seq of the items after the first. Calls seq on its
05:56aslamargument.
05:57aslamthe only difference seems to be the ending where next returns nil and rest returns an empty sequence
05:59aslamand since '() is true in boolean context, rest could potentially cause some infinite loops I think
06:05jarpiainaslam: (next (cons 1 (lazy-seq ...))) has to force the lazy seq to see if it should return nil
06:09aslamjarpiain: I c. thanks
06:18aslamjarpiain: that is not the case it seems
06:18aslam(def tmp (next (cons 1 (iterate #(do (println (str %1)) (flush) (inc %1)) 1))))
06:18aslamuser> (first tmp)
06:18aslam1
06:18aslamuser> (first (next tmp))
06:18aslam1
06:18aslam2
06:19aslam(first tmp) didn't cause the println to print 1
06:25zmyrgelhmm, how can I check if list of records contain specific record?
06:25zmyrgelmy quick attempt with 'some' didn't work
06:30jarpiainaslam: (iterate f x) returns (cons x (lazy-seq (iterate f (f x))), i.e., the the first cons cell is not lazy and doesn't require calling f
06:31zmyrgelyep, totally wrong predicate for some, got it fixed
06:32jarpiain,(let [x (iterate #(do (print "test") (inc %1)) 1)] (next x) (first x))
06:32clojurebottest
06:32clojurebot1
06:32jarpiain,(let [x (iterate #(do (print "test") (inc %1)) 1)] (rest x) (first x))
06:32clojurebot1
06:32raekfirst does not force the rest of the list
06:33raekah. misread it.
06:34raekalso: https://gist.github.com/480608
06:35aslamah, i c. thats interesting :) thanks
09:34zmyrgelhi, I need a bit of help writing function to create a game board
09:35zmyrgelI need to make an empty game-board and then update it with by giving it 2 parameters, string of game pieces and a row number where to put pieces
09:36zmyrgelit sounds like a job for reduce but I've only used it for simple stuff
09:36tomoj"update it"?
09:36tomojlike, assoc?
09:37tomojhow do you represent the game-board?
09:38tomojvector of vectors?
09:38zmyrgelits a vector
09:39zmyrgelhttp://pastebin.com/DiVSvMNM
09:39zmyrgelhere's my current progress
09:40tomojI see
09:40tomojso..
09:40zmyrgelI mean to have empty game board, and then apply function which would add pieces for single row to it
09:40tomojeach row of the game-board is placed in its own part of the vector?
09:41zmyrgeleach row starts at 0x0, 0x10 coordinate on the vector
09:41tomojcool
09:42tomojI don't really understand your code yet
09:42tomojbut..
09:42tomojthe (for [fen ...] (reduce apply-fen... looks problematic
09:42tomojI can only guess based on the variable/fn names
09:42zmyrgellemme give more expanded example
09:42tomojbut, if you build up a sequence and want to reduce over it
09:42tomojyou don't reduce in for
09:43tomojoh
09:43zmyrgelI have working function which does it already but I'm rewriting it
09:43tomojwas it smelly?
09:44tomojwhat does splitting on /+ leave you with?
09:44mrBlissWhat's the Common Lisp equivalent of (take n coll)?
09:44zmyrgelhttp://pastebin.com/FcEZm169
09:45zmyrgelit leaves a list of strings
09:45zmyrgelthe existing function seems quite iterative
09:45tomojand you have one string in the list for each row?
09:46zmyrgelyes, each string in the list has all the chess pieces on that row
09:47tomoj"4P3"?
09:47zmyrgelIt means 4 empty squares and pawn piece followed by 3 empty squares
09:48tomojaha
09:49tomojso
09:49zmyrgelI replaced my previous board->fen function with more functional approuch and it got much simpler
09:49tomojI think it would be helpful to avoid for
09:49zmyrgelso I wanted to see if I could do the same for this part too
09:50zmyrgelok
09:50tomojat least for me to figure out what you really want
09:50tomojmaybe for will be useful in the end
09:51zmyrgelI planned to have one function which would take a [board fen row] arguments and return new board with pieces from fen applied to row
09:51tomojwhere is map-indexed?
09:51tomojoh, right there in core
09:51tomojwow
09:52tomojso you have this list of row descriptions
09:52tomojyou can map-indexed over it
09:53tomojthen your reduce will have access to both the row fen string and the row number
09:53tomoj... I think
09:54zmyrgelhmm
09:54tomojbut what would be in the map function?
09:54tomojyou want to do all the real work in the reduce function, I guess?
09:55zmyrgelyeah
09:55tomojso the reduce fn will take a game-board (initialized to empty), and a row
09:55zmyrgeland the fen string
09:55tomojand it does all the linearization math to get the proper place to stick the pieces in the game-board array?
09:57tomojdoes your scheme for mapping all the rows into a 1d array make it so that the array is just all the pieces in row-major order?
09:57zmyrgelyes, for example, with "3p4" fen and 0x30 coord it would assign empty squares to board coordinates 0x30, 0x31 and 0x31 and so forth
09:57tomojor is there gaps?
09:58zmyrgelthere are 'gaps', its like two chess boards side by side and the others empty
09:58tomojoh, hmm
09:58tomoj(just curious, why? because the 0x30 coord for row 4 (?) is pretty?)
09:59zmyrgelso board indexes 0x20 to 0x27 are on the board and 0x28 to 0x2f are outside
09:59zmyrgelIt helps when checking piece movements and if the index is on the board
09:59tomojok
09:59zmyrgelhttp://chessprogramming.wikispaces.com/0x88
10:00tomojawesome
10:00tomojdo you have great chess-fu
10:00zmyrgelnope :)
10:00zmyrgelI haven't played chess in over 10 years and this is my first functional programming work
10:01tomojthose who can, do. those who can't, build software.
10:01zmyrgelDoing my bachelor's thesis on this
10:01tomojunfortunately I didn't get to hear the lambda tones actually play anything real
10:02tomojbut I wonder, how many of the tool pioneers are also great at whatever the tool is for?
10:02zmyrgelyeah
10:02tomojanyway
10:02zmyrgelwell, this is still the easy stuff
10:03zmyrgelonce I get to the AI stuff
10:03tomoj:D
10:03tomojwhat model?
10:03zmyrgelmodel?
10:03tomojyou can get the array coords for a piece by adding its index in the row to the row coord, right?
10:04zmyrgelyes
10:04tomojI mean, give me some buzzwords that appear often in your readings
10:04zmyrgelalphabeta pruning
10:04zmyrgelthough I would be happy with working minimax
10:05tomojbut how do you do position evaluation?
10:06zmyrgelso far it only calculates material balance and some simple board location checks
10:06zmyrgelOnce I get my pieces to move correctly I plan to move to AI stuff
10:06zmyrgelnow my rook can jump over pieces etc :)
10:07tomojwell, I think what you were planning was to reduce over the pieces in each row, maybe?
10:07tomojthen the reduce assoc's into the game-board vector according to the row coord + index in row?
10:07zmyrgelyeah, that was my plan
10:08zmyrgelI have no idea how the reduce's function arguments should be presented to it
10:09tomojwell
10:10tomojyou can always reduce (map vector coll (range))
10:10tomojoh
10:10tomojno
10:11tomoj(map-indexed vector coll)
10:11zmyrgelok
10:11tomojthis will give you the index in the row, to which you can add the row coord which should (I think) be closed over
10:12tomojso your reduce function will look like (fn [game-board [index piece]]) I think
10:14tomojassuming you can generate all the pieces into a coll/seq for a row
10:14zmyrgelyeah
10:17tomojand then each time through the reduce, you assoc (+ row-coord index) in the game-board?
10:18tomojand then you reduce over the rows... :(
10:19zmyrgelhmm, my brain starts to get pretty twisted already
10:23tomoj(reduce (fn [game-board [row-coord row]]) ...)
10:25tomojthe coll there should be [[0x00 pieces-for-row-0] [0x10 pieces-for-row-1] ...]
10:25tomojwhich you can get by doing a map-indexed over the processed row strings with a map function that looks up the index to get a coord
10:26tomojthen, in the reduce fn, you reduce again over the (pieces in the) row
10:27tomojdoing a map-indexed again to get the assoc index for each piece by adding to the row-coord, which is closed over here
10:28tomojmake any sense?
10:28zmyrgelsome, but I think it takes some repl fooling and doc reading to really sink in
10:31tomojI may be full of shit since I don't think I fully understand what you're doing
10:33mtyakahi all, i'm trying to come up with a nice way of turning a vector of strings like this: ["-a" "b" "-c" "d" "e" "f" "-g" "-h" "i"]
10:33mtyakainto this: ["-ab" "-cdef" "-g" "-hi"]
10:34mtyakaThis is what I've got so far: https://gist.github.com/676245
10:34mtyakaIs there a cleaner way?
10:37zmyrgelyeap, but at least it has given me some pointers where to focus
10:38opqdonutmtyaka: try using split-with
10:39tomojwill the very first character always be \-?
10:39mtyakayes
10:40mtyakaopqdonut: thanks for the pointer, will try it out
10:45opqdonutor if you like to keep it simple, try something like
10:45opqdonut(clojure.contrib.str-utils/re-split #"-" (str ["-a" "b" "c" "-d" "e" "-f" "g"]))
10:45opqdonuterr, apply str
10:45opqdonutI couldn't get re-split to work in clojurebot so I can't demonstrate :)
10:47LauJensen&(clojure.string/re-split #"-" (str ["-a" "b" "c" "-d" "e" "-f" "g"]))
10:47sexpbotjava.lang.Exception: No such var: clojure.string/re-split
10:47raek&(require 'clojure.string)
10:47sexpbot⟹ nil
10:47raek&(clojure.string/re-split #"-" (str ["-a" "b" "c" "-d" "e" "-f" "g"]))
10:47sexpbotjava.lang.Exception: No such var: clojure.string/re-split
10:47MayDaniel&(clojure.string/split #"-" (str ["-a" "b" "c" "-d" "e" "-f" "g"]) #"-")
10:47sexpbotjava.lang.ClassCastException: java.lang.String cannot be cast to java.util.regex.Pattern
10:47LauJensen&(clojure.string/re-split #"-" (str ["-a" "b" "c" "-d" "e" "-f" "g"]))
10:47sexpbotjava.lang.Exception: No such var: clojure.string/re-split
10:47MayDaniel&(clojure.string/split (str ["-a" "b" "c" "-d" "e" "-f" "g"]) #"-")
10:47sexpbot⟹ ["[\"" "a\" \"b\" \"c\" \"" "d\" \"e\" \"" "f\" \"g\"]"]
10:48LauJensen&(use 'clojure.contrib.str-utils)
10:48sexpbot⟹ nil
10:48LauJensen&(clojure.string/re-split #"-" (str ["-a" "b" "c" "-d" "e" "-f" "g"]))
10:48sexpbotjava.lang.Exception: No such var: clojure.string/re-split
10:48MayDaniel&(clojure.string/split (apply str ["-a" "b" "c" "-d" "e" "-f" "g"]) #"-")
10:48sexpbot⟹ ["" "abc" "de" "fg"]
10:48LauJensen&(clojure.contrib.str-utils/re-split #"-" (str ["-a" "b" "c" "-d" "e" "-f" "g"]))
10:48sexpbot⟹ ("[\"" "a\" \"b\" \"c\" \"" "d\" \"e\" \"" "f\" \"g\"]")
10:50mtyakavery nice :)
10:52Raynes&(.split (str ["-a" "b" "c" "-d" "e" "-f" "g"]) "-")
10:52sexpbot⟹ #<String[] [Ljava.lang.String;@3351c1>
11:00jweiss_is there a direct way to parse xml from a string, or do you have to create an InputStream to pass to clojure.xml/parse?
11:04tomojwell..
11:05tomojthe input-stream function (not sure where the latest version lives now... clojure.contrib.io? clojure.java.io?) can take a byte array
11:05tomojso you could pass the .getBytes of the string to input-stream
11:06tomoj&(with-open [xml-in (clojure.java.io/input-stream (.getBytes "<foo><bar/></foo>"))] (clojure.xml/parse xml-in))
11:06sexpbot⟹ {:tag :foo, :attrs nil, :content [{:tag :bar, :attrs nil, :content nil}]}
11:06clojurebot,(let [testar (fn [x y] (cond (= (reduce + (filter odd? (range 0 x))) y) (str y " is a")) )] (testar 11 25))
11:19fliebelIs there some magic to attach headers to this input stream when doing an url? I have some more java trickery set up for that currently.
11:20raekto avoid encoding issues, it would be better to make a Reader rather than an InputStream
11:21fliebelraek: Well, my connection has getInputStream, but I don't know about getReader.
11:21raekoh sorry. was refering to tomoj's suggestion
11:21fliebeloh, okay
11:22raek&(clojure.xml/parse (java.io.StringReader. "<foo><bar/></foo>"))
11:22sexpbotjava.lang.IllegalArgumentException: No matching method found: parse for class com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl
11:23raekhrm
11:24raek&(with-open [xml-in (clojure.java.io/input-stream (.getBytes "<foo><bar/></foo>" "UTF-8"))] (clojure.xml/parse xml-in))
11:24sexpbot⟹ {:tag :foo, :attrs nil, :content [{:tag :bar, :attrs nil, :content nil}]}
11:24clojurebot⟹ "Returns the metadata of obj, returns nil if there is no metadata."
11:24raek(the pedantic way...)
11:24raekthe default encoding of XML is UTF-8
11:24raekif you don't specify the encoding for .getBytes, the JVM rolls a dice for you
11:24raek:)
11:25fliebelraek: Like the xkcd one? I think they rolled the dice at the implementation and chose… forgot it, read it just yesterday.
11:26raekfliebel: this one? http://xkcd.com/221/ :-)
11:27fliebelyes sir
11:27raekfliebel: were you previous question about web dev?
11:28fliebelraek: Well, web related at least. It's just a terminal app for now. But it does web stuff.
11:28raekwhat do you mean by "attach headers to the input stream"?
11:29fliebelwell, the url needs basic auth.
11:29raekare you using ring?
11:29fliebelnow, pure java.
11:30raekare you implementing an HTTP server?
11:31fliebelno, just accessing twitter streams.
11:32fliebel(inc raek)
11:32sexpbot⟹ 1
11:32raekdo you open a stream using url.openStream() (or something like that) and want to add headers to the HTTP request?
11:33fliebelraek: meh, I'm doing some funky java stuff with urls and connections, which works just fine, but I saw someone use clojure.java.io/input-stream, so I was just wondering if there was a shorter way to do it.
11:34fliebelBut yes, adding headers I am.
11:36raekI found this http://download.oracle.com/javase/6/docs/technotes/guides/net/http-auth.html
11:37fliebelraek: extending classes is not going to be any shorter than what I have.
11:37tomojtwitter streams?
11:37tomojconsidered and rejected aleph?
11:38fliebeltomoj: http://stream.twitter.com/1/statuses/sample.json
11:38raeklooks like org.apache.commons.httpclient.HttpClient is more configurable
11:39raekhttp://www.java-tips.org/other-api-tips/httpclient/how-to-use-basic-authentication.html
11:39fliebeltomoj: Replace that with ignored and you get the picture.
11:39tomojheh
11:39tomojhttps://github.com/ztellman/aleph/wiki/Consuming-and-broadcasting-a-Twitter-stream
11:40raeklooks like java's UrlConnection does not have basic auth built in
11:40tomojoh
11:40tomojdunno if it does basic auth
11:40fliebeltomoj: But once I get to the point where I need a datastore I might as well use a library like Aleph.
11:40tomojoh, yes it does
11:41fbru02hey guys why and what's the usual cure when making a defrecord I get : Don't know how to create ISeq from: clojure.lang.Symbol ?
11:43raekfbru02: looks like you have an error in the way you're calling defrecord
11:43fbru02raek isn't defrecord classname, followed by the protocol?
11:43raeklike calling (defrecord Foo ProtoA (method [] ...)) instead of (defrecord Foo [field] ProtoA (method [] ...))
11:44raekfbru02: defrecord classname vector-of-fields protocol
11:44fliebeltomoj: Okay, that example looks terse enough to consider, together with ClojureQL or some other database.
11:45NevenaCan anyone tell me in which lib/ns is 'thrown?' function?
11:45fbru02raek: nice , now i get it , sometimes i was doing like that, sometimes id wasn't and i didn't understand the root cause thanks !
11:49fliebelHow can I tell if a reader is still open?
11:52raekif you have a BufferedReader (the fns in clojure.java.io will return one of those), readLine will return null
11:52raek.read will return -1
11:53raekdoesn't look like there is any .isClosed method or anything similar
11:53vic_nychi, was wondering if anyone has experience using date/times with mongodb (particularly congomongo) with clojure
11:53fliebelraek: But readers are not really concurrent, so if it is still open, I screw up the other tread that's reading from it.
11:53fliebelBut it looks like it's still running now.
11:54raekI guess you have to lock it before doing anything with it
11:54raekI'm really happy that those things are dead simple in clojure
11:54fliebel3000 urls and counting… :) With http://www.peopleschoice.com/pca/votenow.jsp being the top one...
11:55raekscanning tweets for urls?
11:55fliebelyea :)
11:55fliebelMaking my private crows sourced news source :)
11:56vic_nycI guess not..
11:57fliebelvic_nyc: I stored a timestamp in congomongo once, but nothing beyond that.
11:59vic_nycthx fliebel, will keep looking for ways.
11:59fliebelvic_nyc: But try asking a more concrete question, like "if i store a java.date.time.whatever in a mongodb, what will I get back?"
12:00vic_nycwas wondering what the best way would be to store dates. I found some documentation that says that transforming dates into numbers would be best (most efficient)
12:00vic_nyc(alternatively, using mongodb's datetime library would be terrible in terms of performance)
12:00fliebelyea, that is what I said about the timestamp
12:03vic_nycI guess I was looking for a function that would map some kind of date object into a number representation, in a way that would still allow efficient queries
12:03vic_nyce.g. give me all records between these dates (where the datetimes have been mapped into numbers)
12:04fliebelWhat data representation are you thinking of? With a timestamp these are just simple larger-than and smaller-than queries.
12:04fliebel*date
12:05vic_nyca timestamp would be good. however the one in congomongo relies on objectid and in my particular project I'm not using Mongo's ObjectIds
12:06fliebel*puzzled look*
12:07fliebelvic_nyc: http://download.oracle.com/javase/1.4.2/docs/api/java/util/Date.html#getTime()
12:14vic_nycthx fliebel I think that may work quite well for what I need
13:01silveenAnyone here who uses vim+slimv.vim for developement?
13:23Bronsaseangrove: i used to
13:23Bronsabut it's terrible
13:30TobiasRaederhey :)
13:30TobiasRaederis there an idiomatic way to conver the (keyword) keys of a map to their string values?
13:31technomancyTobiasRaeder: (zipmap (map name (keys m)) (vals m))
13:32VinzentHow can I get value from structmap inside macros?
13:32fliebeltechnomancy: What is this going to do to the order of the keys and value?
13:33TobiasRaeder@technomancy thx a ton
13:33technomancyfliebel: keys and vals is guaranteed to always be consistently ordered when called on the same map
13:33fliebelcool
13:33technomancyit's just that if you assoc more stuff onto the map the order may change
13:34fliebelI got into deep trouble with python in this way once. I admit I did something to them on the way though.
13:36raekVinzent: like you would with a map
13:36Vinzenthttps://gist.github.com/676400
13:36Vinzentraek, I got nil
13:37raekVinzent: you could use an ordinary function in that case
13:38raekwhat happens now is that this is evaled: ['(struct q 1) (:a '(struct q 1))]
13:40raekremember that what the macro gets as its parameter is the unevaluated code
13:41Vinzentraek, ok probably I should reorganize code, thank you
14:35bobo_anyone used appengine magic? change the number of fields in an entity and it doesnt work to store it with swank anymore, using dev_appserver works :-/
17:49mattmitchellI'm trying to call an instance method on a java object but having no luck
17:49mattmitchellfor one of the methods, I get "java.lang.ClassCastException (NO_SOURCE_FILE:0)"
17:49mattmitchelland for another I get: "java.lang.IllegalArgumentException: No matching field found: toSolrParams for class org.apache.solr.client.solrj.SolrQuery (NO_SOURCE_FILE:0)"
17:50mattmitchellbut I know the methods exist, and the object I'm working with is an instance of the class
17:50mattmitchellhere's the code I have now:
17:50mattmitchell(def sp (org.apache.solr.client.solrj.SolrQuery.))
17:50mattmitchell(.toSolrParams sp)
17:50mattmitchell(.add sp "one" "two")
17:51mattmitchellanyone have any ideas?
17:54raekmattmitchell: from the javadocs it seems that the toSolrParams method is static
17:55raekmattmitchell: (import 'org.apache.solr.client.solrj.SolrQuery) (SolrQuery/toSolrParams sp)
17:55raekif sp is an instance of NamedList
17:56pppaulto map over a 2D vector i'm doing a map of a map... is there a better way other than flattening/partitioning?
17:56raekalso, add seems to take an instance of SolrParams, rather than two arguments
17:59raekmattmitchell: the syntaxes for method calls are as follows: (.instanceMethod object arg1 arg2 ...) (Class/classMethod arg1 arg2 ...)
18:15mattmitchellraek: there is also an add that takes 2 strings: http://lucene.apache.org/solr/api/org/apache/solr/common/params/ModifiableSolrParams.html#add%28java.lang.String,%20java.lang.String...%29
18:16mattmitchellraek: does it make sense that I'd be able to just call that on the instance?
18:17mattmitchellraek: you'right about the toSolrParams, my bad!
18:17raekhrm, I think variadic methods are special
18:18raekyou could try looking at the signature with clojure.contrib.repl-utils/show
18:18raekI vagely recall that the "..." args are passes as an array or something
18:19mattmitchellraek: ok cool, i'll have a look. thanks for your help!
18:22raekusage example: (use '[clojure.contrib.repl-utils :only (show)]) (show java.lang.String #"toString")
18:22KirinDaveSo didn't chouser... I think it was chouser, have some thing about not using :only?
18:22KirinDaveI never quite understood
18:24raekwell, I think it's safer to use :only than bare use. if someone adds a new var to the namespace, you will not get any unexpected collisions
18:24raekrequire is even safer
18:24raeksince it covers the case when things are added to clojure.core
18:25KirinDaveI agree.
18:32miltondsilvaHi, the spit function in clojure core is very interesting but, is there some way to spit bytes on a clojure seq.. or on a byte-array?
18:39miltondsilvaohh.. wait.. java already does that.. sorry
18:53lrennanyone have a clojure 1.1 repl handy?
19:02kumarshantanuhi, can anybody tell how to configure log level using c.c.logging?
19:02kumarshantanuI want it to be DEBUG
19:27woobykumarshantanu: there's a 'debug' in logging you can use
20:26kumarshantanuwooby: debug log is not visible somehow
20:26kumarshantanuonly INFO is visible
20:27kumarshantanuneed to change some default setting?
20:29pppaul$8ball 8balls?
20:29sexpbotpppaul: Very doubtful.
20:43stuartsierrakumarshantanu: It's configured in the logging implementation you use.
20:54pppaulcan someone point me to a tutorial / examples of using types and records? the clojure.org site just explains them, but doesn't give examples (that i can see)
20:55pppaul&(#(% %) #(% %))
20:55sexpbotjava.lang.StackOverflowError
20:58dnolenpppaul: http://freegeek.in/blog/2010/05/clojure-protocols-datatypes-a-sneak-peek/
20:58pppaulthanks
20:58pppaulthese work as of 1.2 right?
20:58dnolenpppaul: yup
20:58pppaulwhat is special about 1.3?
20:59dnolenpppaul: changes to binding, primitive math support the biggest things
20:59pppaulinteresting
21:00pppaulso, as clojure.org tells me, i should not be using genclass?
21:00pppaul$8ball should i use genclass?
21:00sexpbotpppaul: Ask again later.
21:01stuartsierrapppaul: genclass is still necessary for some kinds of Java interop
21:01pppaulsuch as?
21:01stuartsierrasubclassing a concrete class
21:01pppaul~_^
21:01clojureboteveryday is Rich Hickey Appreciation Day
21:02pppauli'm glad that i'm rich hickey appreciation day
21:02pppauloh
21:02pppauleveryday
21:02pppaulwhy did clojurebot say that?
21:02pppaulmaking clojure seem like a cult
21:03pppauli just happen to love cults
21:11mattmitchellis there something special i have to do when calling a java method that is defined with varargs?
21:12_atomattmitchell: pass it an array of the variable arguments
21:12_atoJava's "..." stuff is just syntax sugar for passing an array as the last argument
21:12mattmitchell_ato: i see. so, i tried doing: (.method obj (to-array "arg1")) -- is that correct?
21:13_ato(to-array ["arg1"])
21:13_atootherwise you'll get an array of characters
21:14mattmitchell_ato: ahh ok
21:14_atoyou might also want into-array instead of to-array, unless the variable argument is of type "Object"
21:14mattmitchell_ato: awesome, into-array did the trick. thank you!
21:15_ato:)
21:48cemerickstuartsierra: ping
21:48cemerickbleh
22:07stuartsierratalios?
22:11taliosstuartsierra: Are you able to run 1.6 on the server, then use maven-toolchains-plugin ? http://maven.apache.org/guides/mini/guide-using-toolchains.html
22:11stuartsierrayeah, we'll try that
22:12stuartsierraCan that be configured but still permit anyone else to build on any supported JDK?
22:12cemerickhrm, hopefully hudson can autogenerate that toolchains.xml file…
22:12stuartsierrai.e. don't force users to have 1.5 intsalled
22:12taliosYou could enable that in a profile
22:12stuartsierraif they want to build locally
22:13stuartsierrayeah
22:13cemericktalios: good afternoon (or whatever) :-)
22:13stuartsierrajust would rather not complicate the POM any further
22:13taliosafternoon :) 4:16pm
22:13talios a profile in ~/.m2/settings.xml should work fine.
22:14stuartsierrathat's a thought
22:14cemerick(inc talios)
22:14sexpbot⟹ 1
22:14stuartsierra(inc talios)
22:14sexpbot⟹ 2
22:15talios:)
22:17talioscemerick: see my reply about that maven-find-plugin ? ( re source dirs of deps ) I think that'll be too messy tho, I think anything that resolves source dirs from dependencies should be separate from the pom.xml,
22:18cemericktalios: saw the email, haven't looked at the link yet
22:18cemerickAFAICT, this would not be in the pom
22:18cemericki.e. it shouldn't affect proper builds
22:18talios*nod*
22:19cemericktotally a local-environment thing; so, just a property (perhaps falling back on a env var lookup for shell types that like to set such things) would be ideal
22:19cemerickIt all seems creepy to me, but I'm trying to keep the hurdles low
22:20talioshowever it works, I was thinking "walk our poms dependencies, for each GAV - *resolve a source dir somehow* - replace the classpath entry with that
22:26stuartsierraok, too sleepy to write any more XML right now
22:31stuartsierraIf it's possible to get the plugin to target 1.5, it will be very helpful to the Clojure core release process!