#clojure logs

2011-05-02

01:26amalloyraek: i think i'm a sinner. i've written (map #(update-in % [0] some-fn) (map first coll)) and i think it looks clearer than the equivalent for-expr
01:29amalloywhich, for those keeping score at home, is: (for [[[x & xs]] coll] (vec (cons (some-fn x) xs)))
01:57amalloytechnomancy: ping?
04:26Ian_CorneAnyone know why clojure stuck on 1.1 in the ubuntu archives?
04:33fliebelCan I use a project with only a pom.xml with leiningen?
04:34raekIan_Corne: in the most widely used ways of doing development (using a tool like lein, cake or maven) you fetch required jars (inlcuding clojure) from maven repos, so the system packages are not used at all.
04:35raekIan_Corne: I also think that this ubuntu package predates Leiningen itself (the first build tool specifically for clojure)
04:35Ian_Corneok
04:38Ian_CorneI guess the plugin for eclipse just works like it should?
04:41fliebelah, mvn clojure:repl
04:59thorwil(models/slugs) on the repl delivers stuff like ("foo" "bar" )
04:59thorwili need to turn that into a string with quoted names and , inbetween (to be read as JS array later on)
05:00thorwilthis works: (interleave (map #(str \" % \") (models/slugs)) (repeat \,))
05:00thorwilbut is there a simpler way?
05:02thorwilalmost works, that is. need to get rid of a trailing comma
05:12thorwil(butlast (mapcat #(str \" % "\",") (models/slugs)))
05:12raekthorwil: why nod use a json library?
05:12raek*not
05:13raekthen you get proper escaping inside strings too
05:14thorwilraek: i'm uneasy about introducing 2 new things at once. also seems overkill for this
05:18raekthorwil: use interpose
05:19raek,(apply str (interpose \, (map #(str \" % \") ["foo" "bar"])))
05:19clojurebot"\"foo\",\"bar\""
05:21raekthorwil: if you can prove that the strings will never contain characters that need to be escaped or non-ascii characters, then I guess rolling your own is fine
05:22raekalways assume that users will enter any possible characters :-)
05:23thorwilthe content are url slugs, guaranteed to contain nothing more fancy than - or _ :)
05:53fliebel$mail dnolen How is it possible that in Logos… core.logic adding a relation produces more results? http://paste.pocoo.org/show/381488/
05:53sexpbotMessage saved.
06:16lukaszekhi guys, what open source web app do you suggest to look into the code for person who is learning clojure. you know - just to get idea how clojure should be used for web apps?
06:21thorwillukaszek: have a look at http://cleancode.se/2011/01/04/getting-started-with-moustache-and-enlive.html
06:22lukaszekthorwil: thx
06:26thorwillukaszek: enlive is great in allowing you to work with plain html templates with no special syntax or marks in them at all. but if you prefer to generate html, look athttps://github.com/weavejester/hiccup
06:29thorwillukaszek: and this, linked from the Moustache site should also be enlightening: https://gist.github.com/109955
07:00fortxun$seen rhickey
07:00sexpbotrhickey was last seen quitting 2 days and 15 hours ago.
07:33fliebelDoes anyone know of a clean and idiomatic selection sort in Clojure?
08:04mecis there a way to extend protocols on array types
08:46gfrlogis there a standard way that clojure projects handle environmental configuration, like database connections and such?
08:54chousermec: yes, you just need to pass in the appropriate kind of Class object to defprotocol
08:56chousermec: like: (extend-protocol my-proto (class (long-array nil)) (my-method [x] ...))
08:57mecchouser: any way for all array types at once?
08:58chouserthey don't have a common base class that uniquely identifies them as arrays
08:59mecI was afraid of that
08:59chouserbut there are only a handful of array types. primitives and Object
08:59gfrlognested arrays?
09:00chouserObjects
09:00gfrloggood.
09:00chouserhm
09:00chouserwait, maybe not
09:01gfrlogbad.
09:05chousernope, I was totally wrong
09:06chouserAn array knows the type of thing (primitive or Object-subtype) that it holds, and its dimentions.
09:06chouserThere appears to be no inheritence relationships between any of them
09:07chouserso no way I can see to extend a protocol to all arrays regardless of their actual type
09:34gfrlog$findfn "thomas" #"thomas"
09:34sexpbot[]
09:34gfrlog$findfn "thomas" #"^thomas$"
09:34sexpbot[]
09:37gfrlog$findfn "bad sexpbot" "bad sexpbot"
09:37sexpbot[clojure.string/trim clojure.string/lower-case clojure.string/join clojure.string/trimr clojure.string/triml clojure.string/trim-newline clojure.set/union clojure.set/intersection clojure.set/difference clojure.core/format clojure.core/time clojure.core/dosync clojur... http://gist.github.com/951621
09:37gfrlogman clojure has a lot of functions that do that
09:39manutter,(re-pattern "thomas")
09:39clojurebot#"thomas"
09:39gfrlogsexpbot: you've got some explaining to do
09:39gfrlogmanutter: thanks
09:40manutter:)
09:40gfrlog$findfn #"thomas" "#\"thomas\""
09:40sexpbot[clojure.core/print-str clojure.core/pr-str]
09:41gfrlogoh hmm: ##(re-pattern "..")
09:41sexpbot⟹ #".."
09:41gfrlog$findfn ".." #"\.\."
09:41sexpbot[]
09:44gfrlog,(re-pattern (java.util.regex.Pattern/quote ".."))
09:44clojurebot#"\Q..\E"
09:50gfrlog$findfn {:foo "bar"} :foo "bar"
09:50sexpbot[clojure.core/deliver clojure.core/->> clojure.core/-> clojure.core/get clojure.core/trampoline]
09:52manutter,(doc escape)
09:52clojurebotGabh mo leithscéal?
09:52gfrlogmanutter: escape?
09:52manutterhmm
09:53manutter,(doc clojure.string/escape)
09:53clojurebot"([s cmap]); Return a new string, using cmap to escape each character ch from s as follows: If (cmap ch) is nil, append ch to the new string. If (cmap ch) is non-nil, append (str (cmap ch)) instead."
09:53manutterhttp://clojuredocs.org/
09:54gfrlogmanutter: you're suggesting that to use instead of java.util.regex.Pattern/quote?
09:54manutterjust playing around
09:55gfrlogkay
09:55manutterquote will work too
09:55gfrlog,(clojure.string/escape "prison")
09:55clojurebotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: string$escape
09:55manutter"Curses, Pinky, we'll have to try another plot."
10:12dnolenmec: chouser: re, arrays. You learn something new everyday. mec, thought, I suppose one work around is to change seqable? to seqable?*, and make a plain seqable? fn that calls that. wrap in try/catch, if catch something which does not extend ISeqable, extend the type of newly encountered array type to ISeqable and try again. it'll be slow only the very first time a unknown array type is encountered.
10:15dnolenfliebel: if sorto uses conde you're going to see more results.
10:17chouserWell, there is (Class/isArray ...)
10:18fliebeldnolen: :-\ But, these results would not uninfy with the results of permutationo, would they?
10:18chouserI suppose you could extend your protocol to Object and check isArray there. Perhaps then extending to that particular type as dnolen was suggesting?
10:20fliebelOr, they do obviously...
10:35whidden__What's the canonical way to test for non nil?
10:37ejacksonwhidden__: if ?
10:38whidden__hmmm, i think i out thought myself. thanks
10:38ejacksonor nil?
10:38ejacksonthat will reject false too
10:39whidden__no, (if foo) is what i needed.
10:47milkpostso is there a way to speed this up by typing this in a way that doesn't box the integers in range?
10:49milkposthttps://gist.github.com/950827
10:50milkpostwhoops lol
10:52gfrloggoogling for "clojure parse html" has not been exciting thus far...
10:53manuttergfrlog: can you use xml processing? or is it the wrong kind of html for that?
10:53milkpostso basically in clojure, if I have a range, an integer is going to get boxed as an Integer type? It seems weird that a simple filter would be so much slower than a java "for (...) { if (..) ...}" call
10:53gfrlogit's output from compojure. But clojure.xml/parse won't take it
10:54manutterhrm, hrm, that's surprising
10:54gfrlogyeah, I was surprised
10:55gfrlogtrying to figure out if Enlive does something like that
10:55gfrloghave not used enlive before
10:55manutterIt's got a bit of a learning curve, but I think it's worth learning
10:55manutterI'm doing trivial stuff with it right now, hope to build it up some soon
10:55Kerrisjust like Clojure ;-)
10:56raekgfrlog: html-resource in enlive outputs a tree of the same format as clojure.xml/parse
10:56manutterMight not help in your case though, I think it's using xml/parse under the hood
10:57gfrlogwe'll find out shortly
10:57manuttercompojure output *should* parse, maybe you'd be better off figuring out that angle?
10:58gfrlogoh wait
10:58raekenlive uses tagsoup under the hood. you can use tagsoup with clojure.xml directly: https://github.com/raek/klouzher/blob/master/src/se/raek/html.clj
10:58raekgfrlog: ^
10:59gfrlogI think I may have only tried it on the clojure documentation page, actually. My goal is to use it on compojure output :)
10:59gfrlogimportant distinction
11:00gfrlograek: thanks. I might be able to make further use of enlive though
11:00raeka web page will only work though clojure.xml/parse if it is error-free xhtml
11:00gfrlogright. We were thinking that compojure output oughta be error-free
11:01gfrlogand I've now confirmed that the compojure output does NOT parse
11:01gfrlogjava.net.MalformedURLException: no protocol:
11:03gfrloglooks like compojure doesn't handle the voodoo-header tags automatically
11:03manuttervoodoo-header tags?
11:03gfrlogall that stuff that goes before <html>
11:03gfrlog,(clojure.xml/parse "<html><head></head><body></body></html>")
11:03clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission /<html><head></head><body></body></html> read)
11:04gfrloghuh
11:04gfrlogk I'm a dummy
11:05gfrlogpardon my noise
11:05manutternp :)
11:05raekgfrlog: to parse a web page given its URL: https://github.com/raek/lcug-examples/blob/master/bot/src/se/raek/lcug/titlebot.clj#L9
11:06gfrlograek: I have an html string. So I'm gonna ramble through some of the IO namespaces to figure out how to get an input stream from a string
11:07raek,(java.io.StringReader "foo")
11:07clojurebotjava.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn
11:07raek,(java.io.StringReader. "foo")
11:07clojurebot#<StringReader java.io.StringReader@18d303>
11:07raekgfrlog: ^
11:07gfrlograek: yessir :) thanks
11:07raekI don't think there's a convenience function for that in clojure.java.io
11:07gfrlogthen you have saved me some time indeed
11:10raekgfrlog: also check out html-snippet
11:11gfrlogoh that just made everything better
11:11raekit reads html from a string (but is made for the case when the string represents a snippet *inside* a html document, so it doesn't add html and body if those are missing)
11:12raekso to parse complete pages, (-> content-as-a-string java.io.StringReader. html-resource) might still be preferred
11:14gfrloghmmm. I'm fine with the snippet output. But I'll try that there too.
11:23dnolenfliebel: sorry had to run earlier what do you mean?
11:30fliebeldnolen: Well, if the first statement returns all valid values, how can an additional statement add values to that without failing?
11:34dnolenfliebel: first statement returns all valid values, and then the next statement operates on those values, generating more values.
11:36fliebelhm… okay. I expected that because q is bound to any of these initial values, anything in the second run that is not in the first would be a failure,
11:37fliebeldnolen: So first I bind q tp [1 2 3 4], and later I bind it to [1] and that works?
11:37dnolenfliebel: a link to what this code will look like?
11:38fliebeldnolen: http://paste.pocoo.org/show/381601/
11:39fliebeldnolen: I'm having a hard time playing with logos now that it's core.unify, mainly because it no longer uses lein. ANd, since hen did you start dropping the hyphens in conde?
11:40dnolenfliebel: it's pushed to clojars.
11:41dnolenfliebel: I changed the hyphens bit a while back, that was a hold over from following jim duey's style, I decided to stick the actual miniKanren style.
11:41fliebeloh, I thought contrib projects where built on the clojure server.
11:42dnolenfliebel: they are, but a lot of people use lein, so I have a private project.clj branch that I use to keep clojars versions in sync.
11:43dnolenfliebel: it's not clear to what I should be looking for in that paste.
11:43raekhttp://repo2.maven.org/maven2/org/clojure/ <-- strange that core.unify isn't here
11:44dnolenraek: I think they just have gotten around to setting up the hudson build process for core.logic.
11:44dnolenhaven't I mean.
11:46fliebeldnolen: Well, permutationo generates all permutations for a seq, and sorto basically says that every item is more or equal to the previous item.
11:47dnolenfliebel: but it's not clear to me what the question is.
11:47dnolenfliebel: all those relations use conde, so stringing them together will always generate more results.
11:48fliebelhm…
11:54fliebeldnolen: (run* [q] (conde ((== [1 2 3] q)) ((== [3 2 1] q))) (conde ((== [1] q)) ((== [2] q)))) ; ()
11:54dnolenfliebel: because [1 2 3] can never unify with [1] or [2], same for [3 2 1]
11:55dnolenfliebel: that program expresses 4 failures.
11:55fliebeldnolen: Yes, so that is what I think I was doing with my code. But apparently I'm doing something different there?
11:56dnolenfliebel: you have to be careful with conso
11:57dnolenfliebel: sorry looking more closely at your code, even if (== s [f]) fails, because it's a conde, it will try the other clause.
11:58dnolenif the moment it fails you want to stop searching, you need to use conda.
11:58fliebeltrue...
11:58fliebel:)
12:02fliebeldnolen: uhm, that got me *only* single results. I'm going back to the drawing board :)
12:03dnolenfliebel: heh, what exactly is that supposed to do? give only the sorted permutations?
12:04fliebeldnolen: Yea, I was trying to see if Logos can sort, just for fun :)
12:04dnolenfliebel: well I don't want to spoil your fun, but it would be trivial to transliterate an existing Prolog quicksort to core.logic.
12:04fliebeldnolen: But I'm having more fun now writing lazy sorts, thanks to ejackson.
12:05fliebeldnolen: I had no idea prolog actually did that. I'm googling now...
12:05dnolenfliebel: http://www.cp.eng.chula.ac.th/~piak/teaching/dsys/quick-prolog.htm
12:06dnolenfliebel: and I would use defne to keep it as short as the Prolog version.
12:07fliebeldnolen: I will try, but I havn't much experience with that one.
12:07dnolenfliebel: on the core.logic landing page I should how to go from Prolog append to core.logic appendo, that should make it clear.
12:08fliebeldnolen: I'll have a look.
12:10ejacksonfliebel: I'm sure I warned you off tumbling down rabbit holes :)
12:11fliebelejackson: You did :) This is cmpletely my own fault.
12:12Kerrisdnolen: that is nice code
12:14fliebelIn Dutch we have a saying that says one will not walk in seven ditches at the same time. Apparently one can tumble down 7 rabbit holes in parallel.
12:14dnolenKerris: the Prolog?
12:14Kerrisdnolen: oh yes
12:15dnolenKerris: yeah, Prolog is neato.
12:15fliebelKerris: Check this one: http://boss-level.com/?p=92
12:15KerrisProlog is something I've always wanted to grok. I kinda "get" ML family languages, Lisp/Scheme less so, but Prolog is just utterly alien.
12:16KerrisAlien but familiar. Which makes it more alien, somehow.
12:18dnolenKerris: spending some time on Prolog is certainly worthwhile. operations on data structures w/o binding to concrete values is eye-opening.
12:18ejacksondnolen: what support is there is Logos for numerical relations. For instance finding all instances in a seq of numbers where there say n consequetively increasing numbers. I remember discussing the treatment in TRS with you before, is that current ?
12:18dnolenejackson: the arithmetic stuff in TRS is mostly interesting as thought experiment, I didn't include any of that stuff because it's not really useful.
12:19dnolenejackson: in Prolog, arithmetic is not relational, it's also not relational in core.logic.
12:21ejacksondnolen: ok, but can you define such statements in core.logic ?
12:22dnolenejackson: yeah you could definitely implement the TRS arithmetic stuff, and in a lot less code now that it has pattern matching via defne and matche.
12:23fliebeldnolen: I noticed you made < and > and such, but not actual arithmetic. Why? I also thing you could use a template for these functions, since the only varying part is the fn used.
12:24ejacksonhmm.... I'm in agreement that the TRS arithmetic is a bit nutty, I gave up before going any further though
12:24dnolenfliebel: because < > etc are relations we can check, with + = etc you need some notion of var creation and assignment, I would have to write a macro to handle the transformation.
12:24dnolenfliebel: I'd be willing to take a patch of course, but project handles arithmetic and many other cases.
12:26fliebelI see…
12:36dnolenejackson: what the TRS arithmetic stuff is good for is understanding how to write very complex relations in a purely declarative way, some insightful stuff that can be applied elsewhere. some other good examples in Byrd's dissertation.
12:37ejacksondnolen: yes, I took it to be good mental gymnastics.
12:38fliebelquicksort has a really bad worst case for sorted stuff, or is it just my implementation?
12:40Hun`fliebel: depends on how you choose your pivot
12:40Hun`randomized quicksort works quite nice. introsort, too
12:40fliebelHun`: Just the first item, so… yea.
12:42amalloyfliebel: yeah, don't use the first element
13:46technomancyataggart: any plans to extend the Log protocol to changing levels?
13:47ataggartnot until someone suggests a good way of doing it. "changing the level" is more complex than one might think.
13:47technomancyataggart: it can't be supported across all the backends?
13:48technomancywe've got something that seems to work fine with log4j
13:48ataggartthat's one issue. most java logging apis are meant to be configured, and not used in an interactive way.
13:48ataggartthe deeper issue is what it means to change the level
13:48ataggartfor example, what you have working with log4j
13:49ataggartwhat happens to the subordinate namespaces?
13:49TimMcataggart: I want to use command line arguments to my program to specify what logging level is to be used. Is that interactive?
13:49technomancywell hierarchy in namespaces is mostly an illusion; I wouldn't expect it to have an effect.
13:49ataggartTimMc: ah no, I'd say that's configuration. You just need to do whatever the underlying logging lib requires
13:50TimMcI ended up writing my own logger. :-/
13:50ataggarttechnomancy: illusion or not, the question is what one expects to happen. Further, which logging output should be affected when changing the level?
13:50ataggartsome systems, e.g. j.u.logging, support multiple outlets, each with possibly a separately configurable level
13:51ataggartas for log4j, the inheritance is automatic, unless a subordinate package has its own configuration, then a runtime change wouyldn't apply
13:51ataggartit's messy
13:51ataggartbut as Rich likes to say, "patches welcome"
13:51technomancygotcha
13:52technomancywell we can continue using our one-off if that's the case; just wanted to get your take on it.
13:53technomancyare there actual features in slf4j or commons-logging that make people choose it over log4j, or is it mostly just "we'll use this because some other component in our stack needs it"?
13:53ataggartSince mechanism and meaning behind setting the level is necessarily tightly coupled with the underlying implementation, a one-off is probably best
13:53technomancygood to know
13:54ataggarttechnomancy: as for other impls, I think commons-logging was intended for library authors who wouldn't know what logging a consuming app was using, nor wanted to prescribe one.
13:55ataggartsl4j is a rewrite of log4j by the same guy, iirc
13:56ataggartTimMc: have you plugged your logger into c.c.logging?
13:57ataggarttechnomamcy: what's the context of your set-level usage?
13:57ataggartjust repl output?
13:57technomancyataggart: no, it's a long-running server that gets jobs off rabbit queues
13:58technomancysometimes you want to debug without pulling out ye olde cdt. =)
13:58raektechnomancy: btw, has (read-line) always worked in lein repl, or is this something new?
13:58technomancyraek: it works when ant is not involved. standalone repls run in the same process as leiningen, so no subprocess is started.
14:00ataggarttechnomancy: does your one off do anything more than call .setLevel on the current Logger instance?
14:00raektechnomancy: standalone = outside project?
14:01technomancyataggart: I don't think so
14:01technomancyraek: ya
14:01raek...but it works for me in a project lein repl :/
14:02technomancyraek: oh, I see... yeah, because *in* is rebound
14:02technomancyit won't work from a thread or future because the root of *in* is useless
14:05technomancybasically, this ant bug means "lein repl" has to set up a socket-repl (and client), which is a neat feature, but should be totally unnecessary for simple usage.
14:07afekzwow lotsa people
14:07afekzis there a FAQ for #clojure the channel?
14:09technomancyclojurebot: contains?
14:10clojurebotcontains? is for checking whether a collection has a value for a given key. If you want to find out whether a value exists in a Collection (in linear time!), use clojure.core/some or the java method .contains
14:11technomancy^ that's the most frequently-asked question in here.
14:11afekzI've got a scenario where I know I'm missing something. I'm trying to launch to fn's in parallel, each of which runs remote TCP queries against a web service and then stores the results in a SQL db.
14:11amalloyhaha
14:11technomancypcalls?
14:11afekzI've tried pcalls, but unless I println the results of the pcall, the SQL doesn't actually execute (no new records in DB)
14:12technomancyamalloy: anyone who masters contains? is in the top bracket of Clojure newbies!
14:12afekzif I println the results of the pcall, then it blocks as it forces the resolution.
14:12amalloytechnomancy: i used contains? the other day. turned out i didn't want it, but i didn't want some either
14:12fliebelafekz: doall/drun?
14:12afekzI'm guessing (real guess here, I'm no expert) that there's some laziness interaction
14:12afekzfliebel: I'll check with dorun - think I've tried doall
14:13amalloyi really wanted to give update-in a function that handled nil the way i wanted :P
14:13fliebelafekz: Same thing, except it just throws away the result.
14:13mecHow can RT call ArraySeq/createFromObject if it is not public?
14:13technomancyhmm... yeah, that would be something like pdoseq that doesn't block on the long-runningest. I don't think it's in core.
14:13afekzfliebel: *nod* I'm flailing :)
14:14amalloymec: they're in the same package
14:14ataggart,(doc fnil)
14:14clojurebot"([f x] [f x y] [f x y z]); Takes a function f, and returns a function that calls f, replacing a nil first argument to f with the supplied value x. Higher arity versions can replace arguments in the second and third positions (y, z). Note that the function f can take any number of arguments, not just the one(s) being nil-patched."
14:14ataggartamalloy: ^
14:14amalloyataggart: yeah yeah, i know
14:14ataggartheh
14:14raekafekz: it is probably cause by a 'map' or 'for' expression. consider replacing thos with 'doseq' instead (which has the same syntax as 'for')
14:14amalloyit was a 4clojure problem to reimplement merge-with
14:15fliebelamalloy: reimplement merge-with? wow, the problems I looked at where more like _ + 1 = 2
14:15ataggartmec: absence of a visibility keyword defaults to package-private
14:15amalloyfliebel: you didn't get far enough
14:16ataggartmec: so anything in the same package can call it
14:16amalloywe have offerings for everyone, fliebel!
14:17amalloytry sorting by #solved and picking the lowest number
14:17fliebelamalloy: Can you throw me a link of something complicated?
14:17fliebelOh, I'll try
14:18amalloyhttps://www.4clojure.com/problem/53
14:18amalloyalso the most recent one, https://www.4clojure.com/problem/73
14:18fliebelamalloy: Who writes these problems?
14:19amalloyfliebel: mostly dbyrne, a few from me, a few user-contributed
14:19fliebelamalloy: Are there hidden tests, or can everything be solved with a big cond clause?
14:19amalloycond is cool if you don't mind being lame. didn't i respond to your tweet about that?
14:20fliebelI don;t think so… anyway, that is lame indeed, but with hidden checks, you could prevent that.
14:20amalloywe had hidden tests, but they confused genuine users, and we don't really care if you want to skip all the fun by "cheating"
14:20fliebelokay
14:21amalloyfliebel: https://twitter.com/#!/alanmalloy/status/62229881773232129
14:21fliebelamalloy: Oh, must have missed that. *blames his Twitter client*
14:21amalloy*chuckle*
14:22amalloywe're working on a way for experienced users to submit problems without having to fork the GH repo, which should speed things up for us
14:23fliebelamalloy: Sorting does not look right at all. This are more or less ordered, but… not really.
14:23amalloyyep. it's kinda a mess for sure
14:23fliebelamalloy: Oh, it's an ui thing btw, I was clicking the tags box :P
14:24amalloythey're in insertion order by default. feel free to fork and work on https://github.com/dbyrne/4clojure/issues/59 :P
14:24fliebelamalloy: haha, nooo, not another rabbit hole :P
14:27amalloyfliebel: c'mon, if you finish that issue we'll let you post "write a good implementation of seque and email it to fliebel" as a problem
14:28fliebelamalloy: have you seen my most recent one? But, I admit it's… oh, lost a word. enticing?
14:28clojurebotexcusez-moi
14:28amalloyenticing sounds fine. appealing?
14:29fliebelamalloy: Is use of sockets allowed in 4clojure? Otherwise it'd be hard to send the email.
14:29amalloyhaha
14:31fliebelAnyway, I'll add a kludgy chat-history mark, so I can keep you to your promise and find the issue later: ****
14:35fliebelamalloy: Oh, and if you're interested, I made something that goes well together with your fold-the-other-way I call treeduce or fold-middle, which is like a balanced binary tree version of reduce. line 36 https://gist.github.com/951553
14:36amalloyfliebel: (fn [[x y]] (f x y)) is (partial apply f)
14:36amalloyunless you want to grab exactly the first two items from a longer list, i suppose
14:37fliebelamalloy: the difference is how you handle and odd list.
14:37fliebel#(partition-all 2 [1 2 3])
14:37fliebel&(partition-all 2 [1 2 3])
14:37sexpbot⟹ ((1 2) (3))
14:37amalloyso you're just passing nil as the last param
14:38amalloy&(partition 2 2 [nil] [1 2 3])
14:38sexpbot⟹ ((1 2) (3 nil))
14:38fliebelso either you have a multi-arrity fn, or you nill-patch it.
14:39amalloyi think the "add nil at the end" behavior is clearer if you use [nil] as a pad collection for the partition, rather than implicitly turn [[x]] into [[x nil]] with destructuring
14:40fliebeltrue
14:40afekzADSL problems. Meh. fliebel: dorun neither. Why on earth would the SQL get executed (records get created) if the result of pcalls was passed to println, but not if dorun/doall? peculiar!
14:40afekzConfuses me sufficiently, not that I'd consider that too difficult in the circumstances.
14:41amalloyafekz: println is recursive. dorun applies only to the top-level seq
14:41amalloy&(dorun (repeat 1 (repeatedly #(println 3))))
14:41sexpbot⟹ nil
14:41afekzamalloy: thanks - I'll go sort which of the lower level seq's need to have dorun applied.
14:41amalloy&(repeat 1 (repeatedly #(println 3)))
14:42amalloyhaha oops
14:42amalloy&(repeat 1 (repeatedly 1 #(println 3)))
14:42sexpbot⟹ ((3nil))
14:42sexpbotExecution Timed Out!
14:46amalloyafekz: i had to force nested side-effects at some point and found (postwalk-replace identity coll) worked, though obviously it's slow
14:47afekzamalloy: ta - another possibility, for sure.
15:37fortxun$seen rhickey
15:37sexpbotrhickey was last seen quitting 3 days ago.
15:40afekzamalloy: thanks for that - seems to have solved my problems just fine
15:41afekzI still don't understand what the issue was, though, as basically if I used println, it'd lag and take around 12s(!) to do something that should've taken +-150ms.
16:36amalloytechnomancy: i assume it's an eventual goal of yours to allow slamhound to handle :require/:as where the :as doesn't match the last namespace segment?
16:47technomancyamalloy: I don't really care either way
16:47technomancyI prefer code where :as matches; I think it's more readable
16:47technomancybut I understand that may be impractical in some situations
16:48amalloytechnomancy: i dunno, i like to (:require [clojure.string :as s])
16:48amalloyand (require [sandbar.stateful-session :as session]) seems reasonable too
16:48amalloythe code i'd want to look at to add this is in search, i suppose?
16:49technomancythe problem is the compiler doesn't always give you the var
16:49technomancysometimes you just get "no such namespace s"... not a lot you can do with that
16:50hiredmanneed a pluggable compiler
16:50technomancyI guess you could look for all substring matches, but that's going to be pretty intense for something like s
16:50amalloytechnomancy: you keep the old ns-map around already
16:50amalloyif it has require/as pairs you can make a note of it before you get started
16:51technomancyamalloy: that's true; if that's supported by fallback-only then that's good enough.
16:51technomancyeven if a full search is impractical
18:12semperosusing incanter with mongodb
18:12semperosI have a dataset with 800,000+ rows
18:13semperoswhen I use incanter.mongodb/fetch-dataset, it only gets two of the rows into the dataset
18:13semperosusing congomongo's fetch fn directly, it pulls all the rows
18:13semperosso somewhere in this source, I'm missing something: https://github.com/liebke/incanter/blob/077cde547363afe675fd8400de11dda0a4b47952/modules/incanter-mongodb/src/incanter/mongodb.clj#L72
18:13semperosany thoughts anyone?
18:16semperosper usual, my own stupidity
18:16semperosstrike question
18:16Derandersemperos: what was up?
18:17Derander(just curious)
18:17semperoswell, may still be an issue
18:17semperosbut I was doing (count) on an incanter dataset, instead of (dim) to get it's dimensions
18:18semperosfor some reason, when I used did (def foo (fetch-dataset :my-data)), and viewed that, I only saw a small portion of my dataset
19:16carllercheis there any way to get `lein test` to output the tests being run as they are run?
19:17zrilakstrace *runs and hides*
19:17zrilakplease ignore, that was my cat running across the keyboard.
19:17technomancycarllerche: each individual deftest rather than the namespace you mean?
19:18carllerchetechnomancy: yes
19:18technomancycarllerche: I played around with a hack to output a . for every passing assertion, but you kinda have to monkeypatch clojure.test's guts
19:18carllercheright now, i'm doing a println w/ the name of the test at the top of each deftest :P
19:18technomancythere's already too much monkeypatching going on there for test selectors, so I dropped it
19:26SomelauwHey, I suddenly realized I don't need transients, since I can make a vector of atoms.
19:27mecthat sounds fishy
19:27technomancyatoms are meant for a substantially different purpose from transients
19:27amalloymec: it sounds like the four horsemen of apocalypse bearing down on me, personally
19:28meclol
19:30amalloyseriously atoms will give you all the pain of mutable state with none of the efficiency improvements that transients give you. don't do it
19:44SomelauwI would expect them to be just as efficient as transients, but I am not sure.
19:49technomancyclojurebot: transients?
19:49clojurebothttp://clojure.org/transients
19:50technomancyclojurebot: transients are not mutable data structures: http://technomancy.us/132
19:50clojurebothttp://clojure.org/transients
19:51technomancyclojurebot: transients |are| not mutable data structures: http://technomancy.us/132 or at least as far as you're concerned.
19:51clojurebotIk begrijp
19:59Somelauwjij begrijp?
20:03SomelauwHmm, that article explains how to use persistance.
20:03SomelauwBut not how it works.
20:04SomelauwI still think a persistent vector is the same as a vector of atoms.
20:04SomelauwThat gets frozen after a while.
20:04amalloySomelauw: you are entitled to think anything you like, of course
20:07SomelauwOn the inside.
20:08hiredmanI am equally entitled to /ignore your nonsense
20:09SomelauwI am not trolling. I am just curious about is inner workings.
20:11Somelauwanyway, I give up
20:13mecThe inner workings of a persistent or transient data structure?
20:14zrilakif you're an experienced developer learning about Clojure, this should prove to be an excellent source of information https://github.com/richhickey/clojure
20:14brehautzrilak: not the richhickey repo, use the clojure one
20:14brehauthttp://github.com/clojure/clojure/
20:15zrilakah, so I was looking at Rich's personal dev branch?
20:15zrilakthanks
20:15brehautnah, you were looking at the old repo
20:15zrilakgotcha -- thanks
20:15brehautfrom before github had organisations
20:28zrilakThere is no shorter way to declare two or more different-arity methods in a protocol other than listing their signatures, e.g. (defprotocol X (foo [_] [_ one] [_ one two])) -- correct?
20:29zrilakpardon the abuse of terminology
20:29scgilardicorect
20:29scgilardi:) correct
20:29zrilak:)
20:31amalloyzrilak: is this conceptually a single thing with default parameters? if so, consider only defining (defprotocol X (foo [_ one two])) and then writing a library wrapper function that operates on any X and supplies default parameters
20:32zrilakamalloy: that is *exactly* the thing I was after, thanks!
20:32zrilakor at least a part of it
20:33amalloyprotocols are, by design, not friendly to treat as user-facing functions. they're minimal bits of functionality, which you're intended to write a library to make conveninent
20:57zrilakI put it in a pastie; I don't expect anyone to be idle enough to actually read it through, but if someone does, I would really appreciate any and all leads as to what design misconceptions I am falling prey to http://pastie.org/1858764
20:58hiredmanno reason for make-power to be a macro
20:59amalloyoh hey, i played race for the galaxy a couple times
20:59hiredmanlooks like you are destructuring in the args list of a method implemented in a reify, which you can't do
21:00amalloyhiredman: but if he wants to destructure them in a let (which presumably he does), then it needs to be a macro, no?
21:00zrilakthat sounds reasonable, I did have problems with that
21:00zrilakhere's a formatted version: http://pastie.org/1858773
21:01zrilakI just quickly ran some speed tests of using defprotocol/reify vs. plain defn, and reified version was quicker btw.
21:01zrilakI guess that's to be expected
21:01zrilakbecause of method lookup
21:01amalloyzrilak: yeah, things that don't work can do so arbitrarily quickly
21:01zrilakhahah
21:02zrilakso make-power needn't be a macro, I can just (defn return a reified protocol), is what you're saying, right?
21:02zrilakmy main gripe with this is that I want to act on an effect like so
21:03zrilak(act some-effect state power card)
21:03zrilakat all times
21:03zrilakbut I want to be able to define powers as taking [state], [state player] or [state player card], as some powers are global and some require more information
21:05amalloyzrilak: if you want to turn a vector into a destructuring form you need a macro. but that macro should look more like `(reify Whatever (foo [argmap#] (let [{:keys ~parameter-keys} argmap#] ~@body)))
21:05amalloybecause you can't destructure the arglist of a reify body
21:06zrilakah great
21:07zrilakthanks a ton!
21:07zrilak(now off to grok all those #s and @s)
22:49dnolennew blog post, runtime dynamism + performance, http://dosync.posterous.com/51626638.
22:49dnolenmec: covers the seqable? conversation from earlier.
22:49mecdnolen: k ill check it out
23:26mecHow come I cant cast a PersistentVector to Iterable even tho it implements it?
23:27mecan nvm
23:32mecdnolen: what sort of beefy machine do you have? your 600ms example takes >30s on my comp :x
23:32dnolenmec: which version of Clojure, JDK ?
23:33dnolenClojure 1.3.0 master, 2.66ghz i7, JDK 7 64bit is what I'm running.
23:33mecjre 1.7 jdk 1.2.1
23:33mecerr clojure 1.2.1
23:34dnolenit's actually more like 500ms on my machine
23:35dnolenmec: at 30s it sounds like you're hitting some kind of reflection.
23:35mecthinks it the 1.2.1?
23:35dnolenmec: doubtful.
23:36dnolendouble-checking
23:38dnolensame perf.
23:39mecWEIRD
23:40amalloymec: set caps as an extra ctl and forget about it forever
23:40mecSo when I call (seqable? {:a 1 :b 2}) it runs both the Map and Iterable paths, which return type does it use?
23:40mecamalloy: I usually set it to | but i've been lazy
23:42mecerr wow nvm
23:42meci think my brain fell asleep early tonight
23:43amalloyfor a year or two, before emxacs, i had it completely disabled. better than the built-in behavior
23:53miwillhiteAbsolute beginner here…how do I get a list of files in a directory?
23:53miwillhiteGoogle is failing me
23:53amalloy&(doc file-seq)
23:53sexpbot⟹ "([dir]); A tree seq on java.io.Files"
23:54amalloymiwillhite: i think that recursively lists directories though, if you don't want that
23:55miwillhitewhat does the ampersand do?
23:55miwillhiteoh nm
23:55dnolen(seq (.list (java.io.File. "/foo")))
23:55dnolenmiwillhite: ^
23:55miwillhitethanks dnolen, that one did it for me
23:57dnolen(-> (java.io.File. "/Users/davidnolen") .list seq)