#clojure logs

2010-11-25

00:02RaynesThat doesn't look good.
00:17quizmeis there a way to do vector addition succinctly ?
00:17quizme(+ [0 1] [3 4]) ; => [3 5]
00:17amalloyquizme: ##(map + [1 2 3] [4 5 6])?
00:17sexpbot⟹ (5 7 9)
00:17quizmeoh cool thanks
00:18LauJensenquizme: note, the return is not a vector
00:18quizmeyikes
00:18quizmeamalloy, LauJensen so call vec on that to keep it as a vector ??
00:19quizmei'm ok with that i guess
00:19amalloyquizme: 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
00:19LauJensenquizme: Well. There are performance implications
00:19amalloywhy do you need a vector at all?
00:20quizmehehe
00:20quizmewe had this discussion a while back.
00:20amalloyif it's performance reasons, you might be stuck writing this as loop/recur, or maybe a clever reduce
00:20technomancy,(reduce (fn [sum [x y]] (+ sum x y)) 0 (zipmap [0 1 2] [3 4 5]))
00:20clojurebot15
00:20technomancy^ if you want to keep it as a vector all the way through
00:20quizmei'm dealing with cartesian coords
00:21quizmeit just seems natural to work with vectors
00:21quizmetechnomancy thnx
00:21technomancyyou can replace the fn with (partial apply +)
00:22amalloyquizme: my advice is to just work with seqs. who cares if those seqs came from vectors or from lazy seqs?
00:22amalloytechnomancy: doesn't that do...something different from what he wanted?
00:23technomancyamalloy: oh... reading comprehension fail.
00:24quizmei dunno
00:24quizmei just think it's a bit odd that everything sinks into a seq blackhole
00:24quizmewhy not preserve types ?
00:25amalloyquizme: not feasible. you can't add to the front of a vector efficiently
00:27amalloyand 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
00:28amalloy&(nth (range 1e1000) 10)
00:28sexpbot⟹ 10
00:28amalloy&(nth (vec (range 1e1000)) 10)
00:28sexpbotExecution Timed Out!
00:29trptcolin_technomancy: reading your import-indent rule (http://p.hagelb.org/import-indent.html) - makes a lot of sense
00:29technomancyto think... we've been doing it wrong for years =)
00:29technomancyactually it was danlarkin who pointed that out to me
00:30trptcolin_but... i kind of feel like in (:require [clojure.test :only (is)]), that clojure.test is in the same category
00:30trptcolin_and it's forced to be a vector
00:30technomancytrptcolin_: yeah, but you never have to break the line inside that vector
00:30technomancyso I don't think it matters there
00:31trptcolin_you could need a line break, right? - like if you have 10 vars in the :only?
00:31trptcolin_but maybe i'm missing your point here
00:31technomancywell then the break is inside the :only inner vector, not the one starting with clojure.test
00:31technomancyin which case they're peers
00:32_ato(:require [clojure.test :only [is]])
00:32_atouse a vector for the :only one
00:32trptcolin_ah interesting, that would follow technomancy's rule about peers
00:33_atothat'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
00:34technomancyexactly
00:36trptcolin_totally makes sense. i feel like using a list is more common, though, as the seq given to :only
00:38technomancypossibly. I've been using the vector for use/require forever though
00:38technomancyand now I can descend to new depths of pedantry armed with arguments!
00:39trptcolin_:) it was really interesting for me because i'm working on a big ol' blog post about use/require/import/ns
00:39trptcolin_and hadn't considered reasoning; only what was conventional
00:40technomancytrptcolin_: are you going to cover the overhaul proposals?
00:40trptcolin_hadn't planned to. has there been activity lately? i knew there was some stuff put out there quite awhile back
00:40technomancyhttp://dev.clojure.org/jira/browse/CLJ-272
00:41technomancynothing's really happened with it, no.
00:42technomancywill 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
00:42technomancywould be better to just fix it in Clojure of course. =)
00:42technomancyheh... "just"
00:43trptcolin_exactly. every time i talk to somebody new to clojure, that's a big source of confusion
00:44trptcolin_ok "every time" is hyperbole
00:46technomancyI wonder if rich would be open to someone just moving forward with a concrete proposal plus implementation of clj-272
00:46amalloytrptcolin_: every time i talk to myself about ns/require/use, there is a great deal of confusion (no hyperbole)
00:46technomancythe problem is it will probably just get bogged down in bikeshedding
00:47trptcolin_amalloy: lol
00:47technomancybut it would be good to time it with the breaking dynamic vars changes in order to group together all the breaking changes, perhaps.
00:48technomancymaybe that's something I can tackle after lein 1.4
01:05Licensertechnomancy: it nearly is working :)
01:15LajlaLicenser, do you implement lSeq?
01:16LajlaCan I call seq on you?
03:35samxI'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?
03:38LauJensenClojureQL now released as beta2
03:38samxsweet.. saw the video, and clojureql almost makes me want to work with relational databases again.. almost :-)
03:39LauJensensamx: The interfaces wouldn't change (much) when I make no-sql version so you might as well dig in :)
03:39samx:-)
03:42Lajlasamx, isn't that just using or?
03:43samxhmm, likely.. figured there should be some easy way of doing that.. just not familiar with the libs at this point
03:43LajlaI guess or is what you want
03:43Lajlaand does the inverse
03:44samxyup, looks to be what i was looking for.. thanks :-)
03:45LajlaIt's not a funcoin though
03:45LajlaBut it s cool
03:46LauJensensamx: Could also be a combination of map and or . (map #(or (pred1 %) (pred2 %) (pred3 %) :default) ...)
03:46Lajla&((constantly "I worship his shadow") 4)
03:46sexpbot⟹ "I worship his shadow"
03:56amalloysamx, LauJensen: (or (p1 x) (p2 x) ...) is the same as (some #(% x) [p1 p2 ...]), isn't it?
03:56LauJensenno
03:58LauJensenwait, yes it is
03:58amalloywhew
03:58amalloyi always get nervous when i can't understand LauJensen but he's telling me i'm wrong
03:58LauJensenhehe, Im just a little slow this morning, sorry :)
04:05amalloywhich 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
04:05amalloyand 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"
04:07amalloyboth behaviors are useful to have (see samx's request), but having to write (first (filter tall people)) vexes me. is there something better?
04:07raekit 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)))
04:08samxdo 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 :-)
04:08amalloyraek: agreed. i've written such utility functions myself, but it would be nice to have them
04:08amalloysamx: augh not a macro. do this in a function
04:09amalloythough incanter does have this function already
04:09samxamalley, if i do it as a function, i'd have to quote the (doStuffs), which would likely be a pain to use
04:09amalloysamx: http://liebke.github.com/incanter/distributions-api.html#incanter.distributions/roulette-wheel
04:09raekamalloy: I'm just curious... what names did you give them?
04:09amalloysamx: no; you'd have to wrap them in a function
04:10raekand what would you call the class of functions they return?
04:10samxamalloy, why would you be against doing that as a macro?
04:10raeksome libs use the term 'validator' for a fn that retuns the/a value if something is valid and nil else
04:11amalloyraek: 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
04:11amalloyso far i haven't needed to, i guess
04:13_atoah, nice. I often find myself trying to write something like: (if-let [x (even? (something))] ...)
04:13amalloysamx: because you can easily do it in a function, by using #(dostuff) or my-dostuff-fn instead of (dostuff)
04:14_atomacros should be a last resort, functions are much more composable
04:16amalloysamx: inevitably your macro will expand into (let [x (rand)] (condp < x, 0.5 (+ 1 y), 0.75 (* 2 y), 1 y))
04:16amalloywhat's so complicated about this that it needs the compiler to write it for you?
04:17amalloysince you'll have to call your macro as (weighted-choice 0.5 (+ 1 y), 0.75 (* 2 y), 1 y) anyway...
04:19_atoI guess the main benefit of a macro there is short circuiting, hmm dunno
04:19_atoshort hand
04:19amalloy_ato: condp short circuits, o/w it wouldn't be very useful
04:20_atoah, I missed what your condp bit
04:20_atoyep exactly
04:22samxok, thet let condp sounds nice.. i'll just use a function :-).. thx.. though, the predicate should be >
04:24amalloysamx: damn. i finally remember the order of arguments to <, and i get the order in which condp passes them wrong
04:27amalloyanyway, i'm going to bed. happy thanksgiving, americans, and happy still-having-to-work-day for everyone else
04:27samxnight
06:25Guest44062Hello and good day :)
08:05octehow do i debug ArrayIndexOutOfBoundsException when compiling?
08:08AWizzArdocte: you can do println debugging. Just place 5 printls on toplevel into your code. (println 1) ... (println 2) ... and so on.
08:09AWizzArdWhen 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.
08:11hoeckocte: and watch out for hashmaps
08:11hoeck,{:a 1, :b}
08:11clojurebotjava.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 3
08:14jarpiain,(let [x {:a 1, :b}] (first x))
08:14clojurebot3
08:16jarpiain,(let [x (read-string "{:a 1, :b}")] (first x))
08:16clojurebot[:a 1]
08:18octeAWizzArd, hoeck: yeah, it turned out to be a syntax error in a literal map
08:18octethanks guys
08:50fbru02what'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 ?
09:00neotykexecute listening in future
09:00neotykstore received messages in BlockingQueue
09:01neotykand read it later from different thread
09:01neotykor go aleph
09:01neotyk:P
09:16fbru02neotyk: thanks !!
09:26neotykfbru02: you are welcome :)
09:46lpetit~seen cemerick
09:46clojurebotcemerick 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:07pomykquit
11:30jacortinas,(println "Hello")
11:30clojurebotHello
11:30technomancyclojurebot needs a will-see function
11:32jacortinastechnomancy: eh?
11:33technomancyit could look into the future and let you know when that person will log on.
11:34jacortinasjaja
11:34jacortinashaha*
11:34jacortinasthat would be pretty cool
11:35alpheusgood morning
13:31Raynestechnomancy: I've considered adding that to sexpbot, but I've yet to find a precognition library for Clojure/Java.
14:01nickikHi all, I have a big textfile and I would like to get out it the information of witch letter comes up howmany times.
14:01nickikdoes anybody have a good tip or a library that would help me?
14:04Raynes&(frequencies "a b c d d b a c")
14:04sexpbot⟹ {\a 2, \space 7, \b 2, \c 2, \d 2}
14:05RaynesNot sure how feasible that would be, considering your text file is described as 'big', but just throwing that out there anyway.
14:07bobo_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:28tonylis there a way to transform .class files back to .java files? I am kinda new to the java environment
14:30Lajlatonyl, sure, it just won't become very readable java.
14:30Lajlathat' the problem of decompilation eh.
14:31tonylyeah, I bet. it comes with machine generated code
14:31tonylhow is it done?
14:34nickik#Raynes thanks i'll look into it.
14:37Lajlatonyl, decompilation?
14:37tonylyes
14:38Lajlatonyl, same way as compilation
14:38Lajlatechnically there is also no difference.
14:38Lajlathe point is, compilation is translating a programin one language to the same program in another language.
14:39LajlaMachine language, assembly, .class files, are also programming languages technically.
14:39LajlaBut like
14:39Lajlaa computer is still a computer
14:39Lajlait has no sense of aesthetics
14:39Lajlaso compilation always produces 'ugly' code.
14:39LajlaWhich is hard to read.
14:39LajlaLike, when you compile C to assembly
14:39Lajlait produces different assembly than what humans find easy to read.
14:39LajlaOr would make
14:39Lajlaand the same applies in the reverse
14:39Lajlabut people generally don't read assembly
14:39Lajlaso it's not an issue there
14:40tonylok
14:40tonylso the best way is familiarizing myself with jvm bytecode
14:41nickikhow should the decompiler know where you used a macro for example
14:41nickikquite impossible
14:41LajlaNot impossible.
14:41LajlaLike
14:41Lajlayou can write an AI.
14:41LajlaThat tries to replicate code as written by humans.
14:42LajlaYou can probably design a self-learning neural net for that.
14:42Lajlabut it's advanced stuff.
14:42Lajlatonyl, well, generally people can't read assembly like that.
14:42RaynesTheoretically, time travel is possible.
14:42LajlaIT's too complex.
14:42LajlaFor large projects.
14:42LajlaRaynes, no, theoretically it's impossible, depending on the theory.
14:43LajlaPeople often misunderstand GR as allowing time travel.
14:43LajlaBut it's more that GR doesn't explicitly forbid, or is discovered to explicitly forbid local time distortions
14:43Lajlabut doesn't explicitly allow them either.
14:43tonylI just saw the .class file for a hello world o.0
14:44LajlaBut sure, it's quite possible for an AI to try to replicate human code.
14:44LajlaI mean, nowadays that can recognise faces to some degree.
14:44Lajlaseems more daunting to me.
14:44LajlaOr translate one natural language (badly) into another.
14:44moogatroniccomputer vision is easier than having a computer generate human code.
14:45LajlaI'd disagree, I think the latter is actually easier because it is descrete.
14:45LajlaWhat you basically do is give the AI a lot of human examples.
14:45LajlaAnd let it learn from that
14:45moogatronicwell, the definition of "human"
14:45LajlaLike how google translate works.
14:45LajlaI mean
14:45Lajlacomputers can already replicate the literary style of famous writers or tyhe musical style of famous composers.
14:45LajlaShouldn't be hard to let them replicate the coding style of famous programmers.
14:46Chousukethey can't replicate the writing though. :P
14:46moogatronicbut is the replication replicating new ideas?
14:46LajlaYou can actually go a pretty far way with marhov chains and feed them a corpus.
14:46moogatronicor just emulating style and regurgitating the same ideas ,but re-written
14:46LajlaLet me rephrase
14:46Lajlathey write new pieces.
14:46LajlaWhich many people will say it's an unmistakable beethoven.
14:46moogatronicexamples?
14:46clojurebotexamples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples
14:46LajlaYou just give hem beethoven's corpus
14:46Lajlaand you apply markhov chains to it.
14:47LajlaAnd they will run for a while to exhaust a pattern in it
14:47Lajlaan work on that.
14:47LajlaTHis 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:47LajlaJust as you can with letters and code.
14:47LajlaLike ehh
14:47Lajlahttp://en.wikipedia.org/wiki/Chomskybot
14:48Lajlathis one is pretty cool.
14:48LajlaIt has a corpus of chomsky fed to it.
14:48LajlaAnd it produces grammatically valid but semantically nonsensical paragraphs in the literary style of chomsky.
14:48moogatronicright, but thats not doing what you described as being easy.
14:49LajlaYes it does
14:49Lajlathe bot has no concept of 'grammar'
14:49LajlaIt just exhausts a pattern itself.
14:49moogatronicright, you can develop the grammar, but the content is what is "human"
14:49Lajlamoogatronic, as I said.
14:49LajlaIt can replicate the style of a 'famous programmer'
14:49moogatronicfor computer vision, you are doing the same thing.
14:49moogatronicdiscritize points in a field, and match
14:49moogatronicok, style.
14:50moogatronicbut 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:50LajlaStyle is also about which functions are programatically idiomatic.
14:50LajlaNo, like.
14:50LajlaYou have a famous programmer, and his code, and the assembly associated with it.
14:50LajlaLike, it goes -> that way.
14:50LajlaAn AI should be able to exhaust that pattern and to some degree turn it around
14:50LajlaIf given a large enough corpus.
14:51LajlaTHis is how google translate works by th eway.
14:51LajlaIT's being fed 'parallel corpora'
14:51LajlaAnd natural languages are a lot harder of course than machine language.
14:51LajlaYou just feed the bot a parallel corpora of assembly and java.
14:51moogatronicagreed
14:51LajlaI'd be interested to see if the current codebase of google translate already suffices for it.
14:52Lajlaa parallel corpus*
14:52Lajlablaspheym
14:52LajlaI mean, it won't be completely perfect, but it c ould be a tool that makes .class files easier to read
14:52Lajlaof course, comments are probably going to be gone.
14:53LajlaOr made it inserts them as well, if the original corpus is commented. =P
14:53LajlaI mean, the idea is that as the limit of the corpus -> infinity, the translation -> perfect
15:17moogatronicLajla: 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:18moogatronic(long delay due to shower / prep for massive food eating time)
15:19moogatronicalso disclaimer, my AI experience is low, currently only in an introductory university course... doing homework for it right now as well... =)
15:20moogatronicfeels like were blazing through the Russell and Norvig book at breakneck speed... it seems like any given chapter could be an entire course.
15:44Lajlamoogatronic, well, I guess just to generate code that humans would find easier to read than what decompilation usually gives.
16:05lpetitHi
16:21replacahowdy, laurent
16:29lpetitreplaca: howdy
16:29lpetithm, what does howdy mean, btw ? :)
16:33slyrus_short for "how do you do"
16:34lpetitoh!
16:34lpetitthen fine !
16:34lpetitStill very happy to live such exciting times with clojure guys !
16:34replacalpetit: it's short for "how do you do" but usually used more like "hi"
16:35replacalpetit: it seems to have come from the old west
16:35replacalpetit: I know what you mean. It's great to see everything happen with ccw!
16:35lpetitok, 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:35replacaexactly
16:36lpetityeah, in fact I'm still so grateful to anybody having been involved in making me come to the conj a reality.
16:36lpetitBut also, it's very interesting to interact with smart people for ccw: cemerick, aav, cgrand, mbrandmeyer, etc, etc
16:37replacaI'm still impressed that you (and cgrand, too) made such a great presentation after the trip you had
16:39nickikman i still feel like a outcast because i missed the conj
16:39nickikdon't even know what pods are
16:39replacanickik: rich didn't talk about pods at Clojure
16:40lpetitHe, 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:40replacathough we had a good discussion of it with chouser in a rental car parking lot on Sat night
16:40lpetitlol, indeed, the official site's still suggesting this pods talk :)
16:40replacaThat go thing was fun, but I was totally fried that day
16:41replacaI hadn't been quite ready to go and ended up getting 2 1/2 hours sleep before my flight
16:42lpetita little bit pressure before the talk, that's the "salt" without which you would not feel the "adrenaline" the same way :-D
16:42replacabait and switch! complain to relevance: "we were sold pods and just got some yammer about hammocks" :)
16:44RaynesI 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:46nickik@replaca see I didn't know that :)
16:50replacaRaynes: hah!
16:50replacajust someone who doesn't sleep enough :)
18:41edoloughlinAnyone know how I rollback a transaction in clj-record?
19:33tonylhi
19:34Raynesmattrepl: ohai
19:35mattreplhey Raynes, saw your question about the warning
19:36mattreplit's coming from the underlying http library, clj-apache-http
19:36mattreplI'm not sure if there's a way to turn it off other then changing the log level
19:37RaynesYeah, 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:37RaynesIt'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:37mattreplyeah, let me post a gist that you can use to modify log level
19:38RaynesCool. :.
19:38Raynes:>*
19:39mattreploh 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:39RaynesI'd prefer the latter, but I can always throw log4j in the mix if it's a problem.
19:39RaynesAlready have a shitton.
19:40mattreplok, 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:42RaynesHrm. log4j might be fairly useful in sexpbot in general. It's probably worth addin git.
19:42Raynesadding it*
19:43mattreplmaking gist
19:48mattreplhttps://gist.github.com/716124
19:49mattreplhaven't actually tried that to turn off the warning messages, but I'd hope that'd do it
19:51mattrepllogging out for a bit, but lmk if that silences it
20:11RaynesYay! No more annoying log messages.
22:42Rayneshttp://www.dwheeler.com/readable/sweet-expressions.html