#clojure log - Nov 25 2010

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:02 Raynes: That doesn't look good.

0:17 quizme: is there a way to do vector addition succinctly ?

0:17 (+ [0 1] [3 4]) ; => [3 5]

0:17 amalloy: quizme: ##(map + [1 2 3] [4 5 6])?

0:17 sexpbot: ⟹ (5 7 9)

0:17 quizme: oh cool thanks

0:18 LauJensen: quizme: note, the return is not a vector

0:18 quizme: yikes

0:18 amalloy, LauJensen so call vec on that to keep it as a vector ??

0:19 i'm ok with that i guess

0:19 amalloy: quizme: that won't "keep" it as a vector. lazy seqs and vectors have different performance characteristics and storage needs, so that will involve copying back into a vector

0:19 LauJensen: quizme: Well. There are performance implications

0:19 amalloy: why do you need a vector at all?

0:20 quizme: hehe

0:20 we had this discussion a while back.

0:20 amalloy: if it's performance reasons, you might be stuck writing this as loop/recur, or maybe a clever reduce

0:20 technomancy: ,(reduce (fn [sum [x y]] (+ sum x y)) 0 (zipmap [0 1 2] [3 4 5]))

0:20 clojurebot: 15

0:20 technomancy: ^ if you want to keep it as a vector all the way through

0:20 quizme: i'm dealing with cartesian coords

0:21 it just seems natural to work with vectors

0:21 technomancy thnx

0:21 technomancy: you can replace the fn with (partial apply +)

0:22 amalloy: quizme: my advice is to just work with seqs. who cares if those seqs came from vectors or from lazy seqs?

0:22 technomancy: doesn't that do...something different from what he wanted?

0:23 technomancy: amalloy: oh... reading comprehension fail.

0:24 quizme: i dunno

0:24 i just think it's a bit odd that everything sinks into a seq blackhole

0:24 why not preserve types ?

0:25 amalloy: quizme: not feasible. you can't add to the front of a vector efficiently

0:27 and vectors aren't (and can't be) lazy, so a map over a vector would have to realize the whole thing all at once in order to return a vector

0:28 &(nth (range 1e1000) 10)

0:28 sexpbot: ⟹ 10

0:28 amalloy: &(nth (vec (range 1e1000)) 10)

0:28 sexpbot: Execution Timed Out!

0:29 trptcolin_: technomancy: reading your import-indent rule (http://p.hagelb.org/import-indent.html) - makes a lot of sense

0:29 technomancy: to think... we've been doing it wrong for years =)

0:29 actually it was danlarkin who pointed that out to me

0:30 trptcolin_: but... i kind of feel like in (:require [clojure.test :only (is)]), that clojure.test is in the same category

0:30 and it's forced to be a vector

0:30 technomancy: trptcolin_: yeah, but you never have to break the line inside that vector

0:30 so I don't think it matters there

0:31 trptcolin_: you could need a line break, right? - like if you have 10 vars in the :only?

0:31 but maybe i'm missing your point here

0:31 technomancy: well then the break is inside the :only inner vector, not the one starting with clojure.test

0:31 in which case they're peers

0:32 _ato: (:require [clojure.test :only [is]])

0:32 use a vector for the :only one

0:32 trptcolin_: ah interesting, that would follow technomancy's rule about peers

0:33 _ato: that's the way I've always done it. (foo bar) "foo" is special, like when calling a function. [foo bar] foo and bar are equals

0:34 technomancy: exactly

0:36 trptcolin_: totally makes sense. i feel like using a list is more common, though, as the seq given to :only

0:38 technomancy: possibly. I've been using the vector for use/require forever though

0:38 and now I can descend to new depths of pedantry armed with arguments!

0:39 trptcolin_: :) it was really interesting for me because i'm working on a big ol' blog post about use/require/import/ns

0:39 and hadn't considered reasoning; only what was conventional

0:40 technomancy: trptcolin_: are you going to cover the overhaul proposals?

0:40 trptcolin_: hadn't planned to. has there been activity lately? i knew there was some stuff put out there quite awhile back

0:40 technomancy: http://dev.clojure.org/jira/browse/CLJ-272

0:41 nothing's really happened with it, no.

0:42 will be good to see a post on that though; it's one of those things that is a lot more complicated than it needs to be and confuses newcomers

0:42 would be better to just fix it in Clojure of course. =)

0:42 heh... "just"

0:43 trptcolin_: exactly. every time i talk to somebody new to clojure, that's a big source of confusion

0:44 ok "every time" is hyperbole

0:46 technomancy: I wonder if rich would be open to someone just moving forward with a concrete proposal plus implementation of clj-272

0:46 amalloy: trptcolin_: every time i talk to myself about ns/require/use, there is a great deal of confusion (no hyperbole)

0:46 technomancy: the problem is it will probably just get bogged down in bikeshedding

0:47 trptcolin_: amalloy: lol

0:47 technomancy: but it would be good to time it with the breaking dynamic vars changes in order to group together all the breaking changes, perhaps.

0:48 maybe that's something I can tackle after lein 1.4

1:05 Licenser: technomancy: it nearly is working :)

1:12 * Licenser waves out for work

1:15 Lajla: Licenser, do you implement lSeq?

1:16 Can I call seq on you?

3:35 samx: I'm looking to do something like the following: (until (pred1 ..) (pred2 ...) ... (predn ...)).. where i'd like the predicated to be executed one by one, until one is executed that does not return nil. At that point, the return value of the expression would be the return value of that specific predicate. Is there a higher order function in the libs to do that directly, or what would be the recommended way?

3:38 LauJensen: ClojureQL now released as beta2

3:38 samx: sweet.. saw the video, and clojureql almost makes me want to work with relational databases again.. almost :-)

3:39 LauJensen: samx: The interfaces wouldn't change (much) when I make no-sql version so you might as well dig in :)

3:39 samx: :-)

3:42 Lajla: samx, isn't that just using or?

3:43 samx: hmm, likely.. figured there should be some easy way of doing that.. just not familiar with the libs at this point

3:43 Lajla: I guess or is what you want

3:43 and does the inverse

3:44 samx: yup, looks to be what i was looking for.. thanks :-)

3:45 Lajla: It's not a funcoin though

3:45 But it s cool

3:46 LauJensen: samx: Could also be a combination of map and or . (map #(or (pred1 %) (pred2 %) (pred3 %) :default) ...)

3:46 Lajla: &((constantly "I worship his shadow") 4)

3:46 sexpbot: ⟹ "I worship his shadow"

3:56 amalloy: samx, LauJensen: (or (p1 x) (p2 x) ...) is the same as (some #(% x) [p1 p2 ...]), isn't it?

3:56 LauJensen: no

3:58 wait, yes it is

3:58 amalloy: whew

3:58 i always get nervous when i can't understand LauJensen but he's telling me i'm wrong

3:58 LauJensen: hehe, Im just a little slow this morning, sorry :)

4:05 amalloy: which reminds me, i've never quite understood why (some even? [4 1]) returns true instead of 4. i mean, of course it's because (even? 4) is true rather than 4, but it seems like it's named (some) because of mathematical precedents

4:05 and when you say "some tall guy", you don't mean "tallness, assuming that there exists a tall person", you mean "a person, from the set of all people, who is tall"

4:07 both behaviors are useful to have (see samx's request), but having to write (first (filter tall people)) vexes me. is there something better?

4:07 raek: it would be nice to have something like (defn passes [pred] (fn [x] (when (pred x) x))) and (defn fails [pred] (fn [x] (when-not (pred x) x)))

4:08 samx: do the standard libs have any non-determinism type functions in them.. i'm looking to do something like: (weighted 0.8 (doSomeStuff) 0.2 (doSomeOtherStuff)).. i assuming i'll need to build my own macro for it, but just making sure :-)

4:08 amalloy: raek: agreed. i've written such utility functions myself, but it would be nice to have them

4:08 samx: augh not a macro. do this in a function

4:09 though incanter does have this function already

4:09 samx: amalley, if i do it as a function, i'd have to quote the (doStuffs), which would likely be a pain to use

4:09 amalloy: samx: http://liebke.github.com/incanter/distributions-api.html#incanter.distributions/roulette-wheel

4:09 raek: amalloy: I'm just curious... what names did you give them?

4:09 amalloy: samx: no; you'd have to wrap them in a function

4:10 raek: and what would you call the class of functions they return?

4:10 samx: amalloy, why would you be against doing that as a macro?

4:10 raek: some libs use the term 'validator' for a fn that retuns the/a value if something is valid and nil else

4:11 amalloy: raek: actually i guess i haven't done that. i wrote (defn verify [f x] (when (f x) x)), but i haven't used it to return another function

4:11 so far i haven't needed to, i guess

4:13 _ato: ah, nice. I often find myself trying to write something like: (if-let [x (even? (something))] ...)

4:13 amalloy: samx: because you can easily do it in a function, by using #(dostuff) or my-dostuff-fn instead of (dostuff)

4:14 _ato: macros should be a last resort, functions are much more composable

4:16 amalloy: samx: inevitably your macro will expand into (let [x (rand)] (condp < x, 0.5 (+ 1 y), 0.75 (* 2 y), 1 y))

4:16 what's so complicated about this that it needs the compiler to write it for you?

4:17 since you'll have to call your macro as (weighted-choice 0.5 (+ 1 y), 0.75 (* 2 y), 1 y) anyway...

4:19 _ato: I guess the main benefit of a macro there is short circuiting, hmm dunno

4:19 short hand

4:19 amalloy: _ato: condp short circuits, o/w it wouldn't be very useful

4:20 _ato: ah, I missed what your condp bit

4:20 yep exactly

4:22 samx: ok, thet let condp sounds nice.. i'll just use a function :-).. thx.. though, the predicate should be >

4:24 amalloy: samx: damn. i finally remember the order of arguments to <, and i get the order in which condp passes them wrong

4:27 anyway, i'm going to bed. happy thanksgiving, americans, and happy still-having-to-work-day for everyone else

4:27 samx: night

6:25 Guest44062: Hello and good day :)

8:05 octe: how do i debug ArrayIndexOutOfBoundsException when compiling?

8:08 AWizzArd: octe: you can do println debugging. Just place 5 printls on toplevel into your code. (println 1) ... (println 2) ... and so on.

8:09 When you see the printlns 1-4 but not 5, then you know that inbetween those two your array access takes place. On toplevel as it seems, otherwise you would not get an Exception during compilation.

8:11 hoeck: octe: and watch out for hashmaps

8:11 ,{:a 1, :b}

8:11 clojurebot: java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 3

8:14 jarpiain: ,(let [x {:a 1, :b}] (first x))

8:14 clojurebot: 3

8:16 jarpiain: ,(let [x (read-string "{:a 1, :b}")] (first x))

8:16 clojurebot: [:a 1]

8:18 octe: AWizzArd, hoeck: yeah, it turned out to be a syntax error in a literal map

8:18 thanks guys

8:50 fbru02: what's the best way to keep listening to incoming messages of an open socket (and query them from time to time) while continuing with your program ?

9:00 neotyk: execute listening in future

9:00 store received messages in BlockingQueue

9:01 and read it later from different thread

9:01 or go aleph

9:01 :P

9:16 fbru02: neotyk: thanks !!

9:26 neotyk: fbru02: you are welcome :)

9:46 lpetit: ~seen cemerick

9:46 clojurebot: cemerick was last seen in #clojure, 3903 minutes ago saying: then you need to use the same encoding to read the file as was used to write it

10:07 pomyk: quit

11:30 jacortinas: ,(println "Hello")

11:30 clojurebot: Hello

11:30 technomancy: clojurebot needs a will-see function

11:32 jacortinas: technomancy: eh?

11:33 technomancy: it could look into the future and let you know when that person will log on.

11:34 jacortinas: jaja

11:34 haha*

11:34 that would be pretty cool

11:35 alpheus: good morning

13:31 Raynes: technomancy: I've considered adding that to sexpbot, but I've yet to find a precognition library for Clojure/Java.

14:01 nickik: Hi all, I have a big textfile and I would like to get out it the information of witch letter comes up howmany times.

14:01 does anybody have a good tip or a library that would help me?

14:04 Raynes: &(frequencies "a b c d d b a c")

14:04 sexpbot: ⟹ {\a 2, \space 7, \b 2, \c 2, \d 2}

14:05 Raynes: Not sure how feasible that would be, considering your text file is described as 'big', but just throwing that out there anyway.

14:07 bobo_: hm, promise seems to work on gae, but i need it to have a timeout. anyway to solve that without future (that int allowed on gae)?

14:28 tonyl: is there a way to transform .class files back to .java files? I am kinda new to the java environment

14:30 Lajla: tonyl, sure, it just won't become very readable java.

14:30 that' the problem of decompilation eh.

14:31 tonyl: yeah, I bet. it comes with machine generated code

14:31 how is it done?

14:34 nickik: #Raynes thanks i'll look into it.

14:37 Lajla: tonyl, decompilation?

14:37 tonyl: yes

14:38 Lajla: tonyl, same way as compilation

14:38 technically there is also no difference.

14:38 the point is, compilation is translating a programin one language to the same program in another language.

14:39 Machine language, assembly, .class files, are also programming languages technically.

14:39 But like

14:39 a computer is still a computer

14:39 it has no sense of aesthetics

14:39 so compilation always produces 'ugly' code.

14:39 Which is hard to read.

14:39 Like, when you compile C to assembly

14:39 it produces different assembly than what humans find easy to read.

14:39 Or would make

14:39 and the same applies in the reverse

14:39 but people generally don't read assembly

14:39 so it's not an issue there

14:40 tonyl: ok

14:40 so the best way is familiarizing myself with jvm bytecode

14:41 nickik: how should the decompiler know where you used a macro for example

14:41 quite impossible

14:41 Lajla: Not impossible.

14:41 Like

14:41 you can write an AI.

14:41 That tries to replicate code as written by humans.

14:42 You can probably design a self-learning neural net for that.

14:42 but it's advanced stuff.

14:42 tonyl, well, generally people can't read assembly like that.

14:42 Raynes: Theoretically, time travel is possible.

14:42 Lajla: IT's too complex.

14:42 For large projects.

14:42 Raynes, no, theoretically it's impossible, depending on the theory.

14:43 People often misunderstand GR as allowing time travel.

14:43 But it's more that GR doesn't explicitly forbid, or is discovered to explicitly forbid local time distortions

14:43 but doesn't explicitly allow them either.

14:43 tonyl: I just saw the .class file for a hello world o.0

14:44 Lajla: But sure, it's quite possible for an AI to try to replicate human code.

14:44 I mean, nowadays that can recognise faces to some degree.

14:44 seems more daunting to me.

14:44 Or translate one natural language (badly) into another.

14:44 moogatronic: computer vision is easier than having a computer generate human code.

14:45 Lajla: I'd disagree, I think the latter is actually easier because it is descrete.

14:45 What you basically do is give the AI a lot of human examples.

14:45 And let it learn from that

14:45 moogatronic: well, the definition of "human"

14:45 Lajla: Like how google translate works.

14:45 I mean

14:45 computers can already replicate the literary style of famous writers or tyhe musical style of famous composers.

14:45 Shouldn't be hard to let them replicate the coding style of famous programmers.

14:46 Chousuke: they can't replicate the writing though. :P

14:46 moogatronic: but is the replication replicating new ideas?

14:46 Lajla: You can actually go a pretty far way with marhov chains and feed them a corpus.

14:46 moogatronic: or just emulating style and regurgitating the same ideas ,but re-written

14:46 Lajla: Let me rephrase

14:46 they write new pieces.

14:46 Which many people will say it's an unmistakable beethoven.

14:46 moogatronic: examples?

14:46 clojurebot: examples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples

14:46 Lajla: You just give hem beethoven's corpus

14:46 and you apply markhov chains to it.

14:47 And they will run for a while to exhaust a pattern in it

14:47 an work on that.

14:47 THis is a lot easier than for instance recognising faces, which is 'continuous', this is descrete, you can input musical notes in a digital format.

14:47 Just as you can with letters and code.

14:47 Like ehh

14:47 http://en.wikipedia.org/wiki/Chomskybot

14:48 this one is pretty cool.

14:48 It has a corpus of chomsky fed to it.

14:48 And it produces grammatically valid but semantically nonsensical paragraphs in the literary style of chomsky.

14:48 moogatronic: right, but thats not doing what you described as being easy.

14:49 Lajla: Yes it does

14:49 the bot has no concept of 'grammar'

14:49 It just exhausts a pattern itself.

14:49 moogatronic: right, you can develop the grammar, but the content is what is "human"

14:49 Lajla: moogatronic, as I said.

14:49 It can replicate the style of a 'famous programmer'

14:49 moogatronic: for computer vision, you are doing the same thing.

14:49 discritize points in a field, and match

14:49 ok, style.

14:50 but a famous programmer will also write code that does something, and has a purpose, and thats is sort of baked into the "style" to some degree.

14:50 Lajla: Style is also about which functions are programatically idiomatic.

14:50 No, like.

14:50 You have a famous programmer, and his code, and the assembly associated with it.

14:50 Like, it goes -> that way.

14:50 An AI should be able to exhaust that pattern and to some degree turn it around

14:50 If given a large enough corpus.

14:51 THis is how google translate works by th eway.

14:51 IT's being fed 'parallel corpora'

14:51 And natural languages are a lot harder of course than machine language.

14:51 You just feed the bot a parallel corpora of assembly and java.

14:51 moogatronic: agreed

14:51 Lajla: I'd be interested to see if the current codebase of google translate already suffices for it.

14:52 a parallel corpus*

14:52 blaspheym

14:52 I mean, it won't be completely perfect, but it c ould be a tool that makes .class files easier to read

14:52 of course, comments are probably going to be gone.

14:53 Or made it inserts them as well, if the original corpus is commented. =P

14:53 I mean, the idea is that as the limit of the corpus -> infinity, the translation -> perfect

15:17 moogatronic: Lajla: I may have been confused by your statements initially, I was just getting at the idea of "Matching" ie, computer vision -> face recognition, is easier than the idea of meaningful generation, "Human code / Human Intent", but it sounds like perhaps you are speaking of translation/matching -> stylistic code generation.

15:18 (long delay due to shower / prep for massive food eating time)

15:19 also disclaimer, my AI experience is low, currently only in an introductory university course... doing homework for it right now as well... =)

15:20 feels like were blazing through the Russell and Norvig book at breakneck speed... it seems like any given chapter could be an entire course.

15:44 Lajla: moogatronic, well, I guess just to generate code that humans would find easier to read than what decompilation usually gives.

16:05 lpetit: Hi

16:21 replaca: howdy, laurent

16:29 lpetit: replaca: howdy

16:29 hm, what does howdy mean, btw ? :)

16:33 slyrus_: short for "how do you do"

16:34 lpetit: oh!

16:34 then fine !

16:34 Still very happy to live such exciting times with clojure guys !

16:34 replaca: lpetit: it's short for "how do you do" but usually used more like "hi"

16:35 lpetit: it seems to have come from the old west

16:35 lpetit: I know what you mean. It's great to see everything happen with ccw!

16:35 lpetit: ok, it does not necessarily imply that the people using it wants a long answer, more the kind of social thing people say at the start of the day, then ;)

16:35 replaca: exactly

16:36 lpetit: yeah, in fact I'm still so grateful to anybody having been involved in making me come to the conj a reality.

16:36 But also, it's very interesting to interact with smart people for ccw: cemerick, aav, cgrand, mbrandmeyer, etc, etc

16:37 replaca: I'm still impressed that you (and cgrand, too) made such a great presentation after the trip you had

16:39 nickik: man i still feel like a outcast because i missed the conj

16:39 don't even know what pods are

16:39 replaca: nickik: rich didn't talk about pods at Clojure

16:40 lpetit: He, we dedicated the time stuck at Phillie's airport (when we really should have been playing "Go" with you) refining over and over again our pres :)

16:40 replaca: though we had a good discussion of it with chouser in a rental car parking lot on Sat night

16:40 lpetit: lol, indeed, the official site's still suggesting this pods talk :)

16:40 replaca: That go thing was fun, but I was totally fried that day

16:41 I hadn't been quite ready to go and ended up getting 2 1/2 hours sleep before my flight

16:42 lpetit: a little bit pressure before the talk, that's the "salt" without which you would not feel the "adrenaline" the same way :-D

16:42 replaca: bait and switch! complain to relevance: "we were sold pods and just got some yammer about hammocks" :)

16:44 Raynes: I remember meeting replaca in an elevator and not having a clue who he was until I happened to look at his name tag later on.

16:46 nickik: @replaca see I didn't know that :)

16:50 replaca: Raynes: hah!

16:50 just someone who doesn't sleep enough :)

18:41 edoloughlin: Anyone know how I rollback a transaction in clj-record?

19:33 tonyl: hi

19:34 Raynes: mattrepl: ohai

19:35 mattrepl: hey Raynes, saw your question about the warning

19:36 it's coming from the underlying http library, clj-apache-http

19:36 I'm not sure if there's a way to turn it off other then changing the log level

19:37 Raynes: Yeah, I started thinking that clojure-twitter probably wasn't the best place to create that issue, but I wasn't totally sure of what the actual problem was or the project that happens to be the culprit in this case.

19:37 It's not that it's a huge problem as much as it's just annoying to not be able to suppress the log noise.

19:37 mattrepl: yeah, let me post a gist that you can use to modify log level

19:38 Raynes: Cool. :.

19:38 :>*

19:39 mattrepl: oh darn, the one I have on hand is for log4j only. you don't by any chance already use it? I can whip up one for java.util.logging too though

19:39 Raynes: I'd prefer the latter, but I can always throw log4j in the mix if it's a problem.

19:39 * Raynes is starting to hate adding dependencies to sexpbot.

19:39 Raynes: Already have a shitton.

19:40 mattrepl: ok, this was original source for the set-log-level we use in clj-sys projects: http://www.paullegato.com/blog/setting-clojure-log-level/

19:42 Raynes: Hrm. log4j might be fairly useful in sexpbot in general. It's probably worth addin git.

19:42 adding it*

19:43 mattrepl: making gist

19:48 https://gist.github.com/716124

19:49 haven't actually tried that to turn off the warning messages, but I'd hope that'd do it

19:51 logging out for a bit, but lmk if that silences it

20:11 Raynes: Yay! No more annoying log messages.

22:42 http://www.dwheeler.com/readable/sweet-expressions.html

Logging service provided by n01se.net