#clojure logs

2011-05-24

02:41markomanI want to split string and include original value on set, what is an easy way to do this? (split #" " "some phrase") -> ("some" "phrase" "some phrase")
02:44brehaut(defn str-split-retain [s sep] (into #{s} (.split s sep))) ?
02:49markomanworks great, thanks
02:50brehautit has a terrible name though :P
02:51no_mindis it possible to introduce new tags with enlive html ?
02:53markomanname doesnt make man worse, they tell :)
02:53thorwilno_mind: i think it has no idea about specific tags, so i guess yes
05:07clgvis there something similar to juxt that allows me easily to combine funtions which create a map where every function provides a key and a value?
05:19clgvhm ok, I looked in clojure and contrib - there seems to be nothing. so I just build my own
05:23ejacksonlook a bit idiosyncratic
05:23ejacksoni guess
05:27clgvwhy do you think?
05:28clgvmy use case is (juxt-map :key1 func1 :key2 func2) that generates a function f that returns a map instead of a vector like juxt does
06:21clgvIs there a condition checking idiom for macro parameters?
06:23clgvassert-args from core is private unfortunately.
06:31cemerickclgv: if the fn does what you want, there's always the #'clojure.core/assert-args backdoor.
06:32clgvcemerick: so I should do a "with-private" hack with assert-args?
06:32cemerickwith-private?
06:33cemerickIt's not a hack; you just need to be prepared for potential breakage if assert-args changes
06:34clgvok :(. Maybe it should be made public in general
06:34clgvwrong smiley...
08:07no_mindin enlive, how do i find the value of an attribute for a given node ?
08:16mefesto`no_mind: (:attrs node) ?
08:16mefesto`or possibly: (get-in node [:attrs :blah])
08:21raekno_mind: you can use select to extract the node in question (which is represented as a map with keys :tag, :attrs and :content) and then do as mefesto` said
08:24no_mindthe problem is how do I pass the node to get ?
08:24clojurebotPeople have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....
08:24no_mindlet me paste teh code
08:25no_mindhere is the code http://pastebin.com/JsWS7seg . How do I pass the node ?
08:28raekno_mind: is this for transforming a html tree, or extracting data form it?
08:28raekno_mind: a transformation is a function that takes a node and returns a node or a sequence of nodes
08:30no_mindraek: actually transformation. I need to apply a transformation function based on the type of form element. For which I need to first extract the "type" attribute.
08:30raekno_mind: to just get the value: (let [tree (html/html-resource "something.html") node (select tree [(html/id= "entity_label")]) attr (get-in node [:attr :foo])] attr)
08:32raekthe transformation function could look like (fn [node] (let [type (-> node :attrs :type)] (case type "foo" <foo code> "bar" <bar code> <default code>)))
08:34raek(this probably looks prettier if you turn it into a defn)
08:34no_mindraek: Let me detail teh problem. I have a html file which has a form. I need to serve this html file by filling the values in form elements. The values of form elements is available as a map containing the elementid as key and corresponding value as the value to be set
08:38raekno_mind: but then you don't need to look at the type attribute, right? I think you just need to make one rule for each entry in the map, where the selector is as in your existing code and where the transformation is (set-attr :value "element value")
08:39raek(html/at tree [(html/id= "username")] (set-attr :value "raek"))
08:39no_mindI need to lookup :tag not :type . The (set-attr :value "value") will work for input type elements butfor checkboxes, select, multi-select we need more work
08:40raekI see.
08:40no_mindso I was thinking of writingmulti-method for filling value
08:40no_mindbutfor multi-method to work, I should be able to identify the type of the node
08:42raek(defn tag-multi [node] (the-multi-method (:tag node) node))
08:43raekoh, wait.
08:43raekno need for that extra function.
08:43no_mindthen
08:43no_mind?
08:43raek(defmulti your-multi-method (fn [node] (:tag node))) ; this should be enough
08:44raekthis will make the multimethod dispatch on the element type
08:44no_mindraek: Icouldfigure that but cannot figureout how to pass the node from enlive selector
08:45raekno_mind: you just do it like this in your at form: (html/at tree ...selector... your-multi-method)
08:45raekno_mind: here, "your-multi-method" will receive the node as its only argument
08:45no_mindoh ok
08:46raekhrm. but you probably want the text value to be passed too...
08:47timvishermorning everyone
08:47raek(defn fill-in [text] (fn [node] (your-multi-method [node text])))
08:47raek(defmulti your-multi-method (fn [node text] (:tag node)))
08:47timvisherwhat could cause a binding expression to _not_ rebind the var, other than perhaps a typo?
08:47raek(html/at tree ...selector... (fill-in "value"))
08:48raektimvisher: laziness
08:48timvisherraek: could you explain that a bit further?
08:48raek,(binding [*out* :foo] (lazy-seq (cons *out* nil)))
08:48clojurebot(#<StringWriter >)
08:49timvisherahh
08:49raek,(binding [*out* :foo] (doall (lazy-seq (cons *out* nil))))
08:49clojurebot(:foo)
08:50raekso the lazy expression does not remember the binding of the var...
08:50timvisherand it turns out that deftest runs lazily, i suppose?
08:50timvisherthat explains a lot of what i've been expriencing
08:51no_mindraek: no luck http://pastebin.com/7UF3ZbRw
08:51timvisheri've been assuming that i could wrap all of my deftests in a single binding expression and get a global change
08:51timvisherbut i suppose i need to wrap the is expressions instead
08:51jjidoshouldn't doall force evaluation before the binding is lost?
08:52dnolenjjido: yes, but beware of nested lazy-seqs.
08:53jjidodnolen: I see...
08:55raekno_mind: remove the parentheses around (abc) since you don't want to pass the return value of the function, but the function itself to envlive
08:55no_mindk
08:55raekno_mind: tag values are keywords, so it should be :input instead of "input"
08:56raekno_mind: enlive will only pass one argument to the supplied function (the node), so it is common to make a closure that remembers "extra arguments"
08:57raek(defn helper-fn [arg1 arg2 arg3] (fn [node] (the-real-function node arg1 arg2 arg3)))
08:57raek(html/at ... ... (helper-fn 1 2 3))
08:58no_mindaha
08:58raekhere, the call to helper-fn will return a function that takes a node, but when that function is invoked, it also knows ablut arg1 arg2 and arg3
09:02raekno_mind: https://gist.github.com/988666
09:03raekalso note how set-attr is called due to the "two stage" way of doing things
09:16no_mindraek: thnxs
11:15no_mindraek: around ?
11:15raekno_mind: yes
11:17no_mindraek: how can one iterateover nodes in enlive. I have a list of nodes in a map with map keys being id of the nodes
11:25raekno_mind: you want to transform each entry in the map to one selector-transformation pair?
11:26no_mindyes, each node matching the id key in the map
11:30raekno_mind: since at is a macro, you can either write a macro that expands into the desired at form, or use loop/recur or reduce and in each iteration make a call to at with only one selector-transformation pair
11:31raekno_mind: will the map have different values at runtime? if so, you can't use the macro approach
11:35raekno_mind: the second way could look like this: (defn foo [tree form-map] (if (empty? form-map) tree (let [[id value] (first form-map)] (recur (at tree [(id= id)] (abc value)) (rest form-map)))))
11:35raekwhere "abc" is the function from my last gist
11:39no_mindok
11:46coopernurseI'm doing this "count a sequence" problem here: http://4clojure.com/problem/22
11:46coopernurseMy solution: (fn [xs] (reduce + (for [x xs] (+ 1))))
11:46coopernurseSite is complaining that I'm using "count", which is prohibited for this problem
11:47coopernurseIs there something about for / reduce that I'm not understanding? Or is 4clojure just returning a misleading error message? From what I can tell I'm not using count
11:49manutterhmm, for might use count internally
11:50coopernursemanutter: I see. maybe they're using trickery to detect that function anywhere in the eval loop?
11:50manutterwell, I'm just guessing
11:50manuttercould just as easily be a bug at 4clojure too
11:50coopernurseok, well 200+ people figured it out, so there's clearly another right way to do it
11:51coopernursegreat site btw
11:51manutterIt sounds good, I haven't gotten around to visiting it yet
11:51coopernurseyeah, I'm new to FP, so I'm really getting a workout
11:51coopernursea bit humbling
11:52manutterI know what you mean, fp is almost a zen experience
11:52manutter"And then the Master hit him over the head with an 800 page COBOL listing, and he was enlightened."
11:53coopernurseyeah, I told my girlfriend it was like learning mandarin after learning 3-4 romance languages
11:53coopernurseyou think you're good at languages, and then *bam*
11:53manutterindeed
11:55manutterIf I were going to count a sequence without using count, I'd use a map/reduce, but that's just because map/reduce is also blowing my mind ever since I went to the NoSQL track at the last O'Reilly conf.
11:56coopernursegood hint. I'll play with that
11:59jean-philippecoopernurse: you might want to read on the reduce function, as it already iterates over the whole sequence, no for needed
11:59coopernursejean-philippe: ok thanks
12:03jean-philippecoopernurse: or start from the beginning: knowing that a sequence can be expressed as a box containing a single element (the (first seq) function) and and and pointer to the sequence of the remaining elements (the (rest seq) function), and that the empty list can be checked using (empty? seq), how can you recursively count the number of elements?
12:05coopernursecan anonymous functions be recursive?
12:05wastreluse recur should work
12:05coopernursethanks
12:05wastrelyour super welcome :]
12:39coopernurseI suspect this is not what you guys had in mind earlier.. but it works
12:39coopernurse(fn [xs] ((fn [x xs] (if (empty? xs) x (recur (+ 1 x) (rest xs)))) 0 xs))
12:43jean-philippethat's quite right, although it could be a bit cleaner using (loop)
12:43manutterI think you were closer to a nice solution with your original snippet tho
12:44coopernursemanutter: yes, I think they wanted to force you to learn some other bits of clojure.. or it's a bug in the test :-)
12:44jean-philippethe reduce function is just an abstraction of that construct
12:45raekcoopernurse: instead of nesting functions like this, you can use 'loop'
12:45coopernurseraek: thanks. reading docs
12:45raekcoopernurse: (fn [xs] (loop [x 0, xs xs] (if (empty? xs) x (recur (+ 1 x) (rest xs)))))
12:46raekcoopernurse: ...but it does exactly the same thing as your version
12:47raekI would use inc instead of (+ 1 ...), but other than that, this is what I would have written
12:47coopernurseraek: thanks. is the default variable binding in: (loop [x 0, xs xs]) a general thing you can do in functions? or is that a loop specific bit of syntax?
12:48coopernurseif I'm reading it correctly, we're saying "set x=0 if not provided"
12:48coopernurseor am I reading that incorrect?
12:48coopernurseincorrectly
12:48raekcoopernurse: it is only for loop. think of it as ((fn [x xs] ...) 0 xs), but with a different look
12:49jean-philippeit's rather, bind x to 0 in the first iteration of the loop, recur will rebind it according to the parameters
12:49raekcoopernurse: you must always provide a value
12:49coopernurseI see
12:50raekit has the same syntax as let, but works as fn/recur
12:50coopernursefrom the docs it sounds like loop avoids recursion under the hood
12:50coopernurseso it's faster than my first example that used a nested function
12:50coopernurseand won't blow up the stack if xs has lots of elements
12:50raekactually, in this case there is no big difference, since you use recur in the other case too
12:51jean-philippefor completion's sake, here's the reduce version (fn [xs] (reduce (fn [acc x] (inc acc)) 0 xs))
12:51raeki.e. the avoiding-stack-overflow-magic lies in 'recur'
12:51manutteryou're on the right track with your description of loop/recur
12:51coopernurseraek: oh, I see. thanks
12:51manutterright, what he said :)
12:53coopernursewild stuff. very terse. curious how long it will take my brain to read these types of constructs
12:54coopernursebut I understand why people find lisp elegant. there really isn't much syntax
12:54amalloycoopernurse: we macroexpand the form before checking it
12:54coopernursethe hard part is learning the vocabulary of all the abstractions built on it
12:56coopernursejean-philippe: the reduce version reads much more cleanly imho.
12:56amalloythe solution i find most elegant, though it's not shortest, is (fn [coll] (reduce + (map (constantly 1) coll)))
12:57amalloywhich is more or less what you were doing, coopernurse, but with map/constantly intead of for
12:57coopernurseamalloy: that is nice.
12:57coopernursebtw, what's the party line for making sure your arguments don't name collide with functions?
12:58amalloycoopernurse: who cares? shadowing is fine
12:58amalloysome disagree with me, of course
12:58ataggartavoid it if it can be confusing to a reader, otherwise, meh
12:58manutteramalloy: So, if that's not the shortest, what is?
12:58amalloybut (fn [list] (map inc list)) is pretty clear if the input is a list
12:58technomancywhich aren't very descriptive args to begin with
12:59coopernurseamalloy: I see.
12:59ataggartI think there's a list of idiomatic arg names somewhere
12:59amalloy#(.size (vec %)) is probably shortest, but it's surely cheating
13:00coopernurseyes, one of the clojure books I'm reading (not sure if it's Joy of Clojure or the pragmatic prog's book) has a list
13:01amalloybtw coopernurse, if you want to talk to the devs we generally hang out in #4clojure when we're around
13:01coopernurseamalloy: ah, great
13:04manutterheh, short == true, cheating == true, check check. :)
13:05manutterkinda like it tho
13:10amalloy&(.size (vec '(1 2 3 1 2 3)))
13:10sexpbot⟹ 6
13:10amalloywhew. (true? working) also
13:24dnoleninteresting core.logic can solve the Einstein constraint problem in < 2ms now, making it nearly 40 times faster at that particular problem than the Prolog implementation in Qi.
13:25ataggartdnolen: what reading material do you suggest for someone to be able to grok core.logic?
13:26dnolenataggart: The Reasoned Schemer, William Byrd miniKanren dissertation, Bratko's Prolog for Artificial Intelligence Programming
13:26ataggartthx
13:28defngood day, gents.
13:30defnback in a moment...
13:32PiskettiSpeaking of books (for noobs), any suggestion for someone who wrote his first line of clojure a few months ago?
13:33PiskettiI read Practical clojure and Programming clojure is waiting. I've also thought about ordering The joy of clojure.
13:33PiskettiBut other than that, any fundamental must-reads?
13:33PiskettiSICP maybe? Little schemer?
13:33nishantHey everyone, I'm using the extend construct to make some java classes conform to a clojure Protocol. I am then loading these classes using load, however when I am calling a function on one of these classes, the same function from a different class is invoked, which leads to a "java.lang.IllegalArgumentException: No matching method found" exception. help!
13:34chojeenjust bought "the joy of clojure", it's pretty nice for a beginner (read: me)
13:34technomancyhiredman: I bought that book from zed shaw.
13:35Piskettichojeen: really? I thought it was the first not-the-first-to-read-on-clojure ever written ;)
13:35hiredmanmine has a "USED" sticker on it, so I think it was a textbook
13:36amalloyPisketti: it was my first clojure book
13:36amalloy(and only, thus far)
13:36Piskettiamalloy: but you were not a beginner
13:36amalloywhen i read it back in july i was
13:37chojeenpisketti: sure, but I felt like a challenge, and coming from a decent functional background helps
13:37amalloyonly had a few weeks' self-taught common lisp under my belt
13:37PiskettiI thought you were an old lisp guru :D
13:38amalloyJoC is good. it's a little less spoon-fed than the others (i'm told), but if you expend some effort you will learn lots from it whether you know clojure or not
13:38PiskettiGoes to show you can learn it pretty fast
13:38amalloyindeed
13:38amalloyi'm not old enough to be an old lisp guru :P
13:38chojeenI've never found "beginners" books all that helpful, anyway
13:39qedJoC is great.
13:39qedamalloy: age has nothing to do with guruship.
13:39amalloyqed: he said "old lisp guru"
13:39Piskettichojeen: Yeah, they tend to be geared towards beginner programmers (of any language) which isn't necessarily the case
13:40amalloybut yes, i'm aware. i've taken on the mantle of git guru in an organization or two
13:40coopernurseI'm 4 days into Clojure. reading JoC and Programming Clojure - both are good. JoC is more complete.
13:40amalloySICP starts by introducing what programming is, but then it gets heavy fast. what a book
13:41dnolennishant: do you have a simple paste of your problem?
13:42chojeenJoC appealed to me because it claims to teach "the clojure way", i.e. idiomatic clojure
13:42Piskettihttp://sicpinclojure.com/ <-- This is extremely interesting. Does the person behind this happen to be on this channel?
13:42qedPisketti: I think he used to be, not sure if he's around anymore.
13:42qedIt's too bad it hasn't continued. I'm floating the idea to a few people to pick up where he left off.
13:44Piskettiqed: Do it! Seriously, that would be a great service to the community. :)
13:45amalloyPisketti, qed: https://github.com/vu3rdd/sicp seems to exist
13:45PiskettiMmm, interesting
13:45amalloymight be an easier starting point
13:47PiskettiThanks, I'll check it out.
13:47PiskettiHow about Little schemer?
13:48dnolenPisketti: Little Schemer is good for picking up the basics of idiomatic Lisp style.
13:48PiskettiOr even Land of Lisp. I bought that to a friend, and once he has finished it, I'll read it too.
13:49Piskettidnolen: that's exactly what I'm looking for
13:49dnolenLand of Lisp also good but too broad in scope to spend much time on Clojure's unique strengths
13:50PiskettiI'm thinking a healthy dose of basics of functional programming would do me good
13:52PiskettiThere's also Let Over Lambda. I just somehow get the feeling that it might be too hardcore for me at this point
13:52PiskettiNot sure though
13:53amalloyOn Lisp is probably not a good clojure book, but it's a good lisp-in-general book
13:53qedLittle Schemer is a fun read.
13:54amalloyand it has the advantage of beeing free
13:54qedThe curriculum for learning a lisp is kind of a big mixture IMO.
13:55qedIt's hard to say there's one approach that everyone should use.
13:55amalloyqed: i mostly just loved the gorgeous writing in On Lisp
13:55amalloyreminds you lisp is a beautiful language
13:56qedI'm going to pick up another copy, on that note.
13:56imadehello, how's the easiest way to make a list of functions, let's say I have functions last1, last2, last3, last4
13:57amalloy[last1 last2 last3 last4]: a list! probably not what you're looking for, though; what do you want to *do* with that list
13:57qed&[(fn [x] (+ x 1)) (fn [x2] (+ x2 1))]
13:57ataggartxy?
13:57sexpbot⟹ [#<sandbox11964$eval14849$fn__14850 sandbox11964$eval14849$fn__14850@2100f3> #<sandbox11964$eval14849$fn__14852 sandbox11964$eval14849$fn__14852@1541c3f>]
13:57clojurebotxy is http://mywiki.wooledge.org/XyProblem
13:57imaderight now I am trying to do (for [f '(last1, last2, last3, last4)] (f '(1, 2, 3, 4))), but it returns (nil nil nil nil)
13:58qedyou don't need for
13:58amalloy$google clojure list vector difference quote
13:58sexpbotFirst out of 433 results is: Clojure - cheatsheet
13:58sexpbothttp://clojure.org/cheatsheet
13:58amalloybah
13:58imadeI am trying to simplyfy my unit testing
13:58qedimade: which version of clojure
13:58amalloyqed: for is a fine solution. it's the ' that's a problem
13:58imade(deftest test-last
13:58imade (dorun
13:58imade (for [f '(last1, last2, last3, last4)]
13:58imade (is (= 4 (f '(1 2 3 4)))))))
13:58raekimade: what you wrote is a list of symbols, not a list of functions
13:58ataggart,(doc clojure.test/are)
13:58clojurebot"([argv expr & args]); Checks multiple assertions with a template expression. See clojure.template/do-template for an explanation of templates. Example: (are [x y] (= x y) 2 (+ 1 1) 4 (* 2 2)) Expands to: (do (is (= 2 (+ 1 1))) (is (= 4 (* 2 2)))) Note: This breaks some reporting features, such as line numbers."
13:59imadebut currently it's failing
13:59amalloy&((juxt inc dec) 1)
13:59sexpbot⟹ [2 0]
13:59ataggartimade: use clojure.test/are
13:59technomancyamalloy: was wondering how long it would take before you pulled out el juxt
13:59raekimade: you probably want [last1 last2 last3 last4] (as amalloy suggested) or (list last1 last2 last3 last4)
13:59raekthe first is more ideomatic, though
13:59imadek, thanks, will try them out
14:00amalloytechnomancy: i wanted to point out the problem with the current approach first. i hope that doesn't make me a bad person
14:00raekbut in the case of clojure.test, 'are' already solves this problem as ataggart pointed out
14:01PiskettiIs there any other reason for choosing a vector over a list other than "adding" to the end is faster?
14:01amalloywriting them in source code is easier
14:02amalloyand using a list gives a strong hint "these might be used as code, not data"
14:02Piskettitrue
14:06Piskettiamalloy: btw, are you (one of) the creator(s) of 4clojure?
14:06amalloyyep
14:06amalloy(one of)
14:07PiskettiOk. It's probably the best learning tool I've come across.
14:08PiskettiMostly because it's so much fun. :)
14:08coopernursePisketti: I second that
14:08coopernursealthough it is destroying my work productivity :-)
14:08amalloythe site's only been around for a little over a month. we're very pleased with the reception it's gotten
14:09dnoleninteresting Clojure protocols have the same limitation as Haskell typeclasses (as opposed to Standard ML functors) - you should really only extend a type to a protocol *once*.
14:09Pisketticoopernurse: I've fought hard not to open the page at work.
14:10amalloyhah
14:10coopernursePisketti: I lack the willpower
14:10Pisketti:)
14:10amalloyworse when you can *work* on it at work
14:10qedyeah 4clojure is awesome.
14:10Piskettiamalloy: What I really miss, is a feature that would allow the users to compare solutions
14:10qedIt's like an interactive Project Euler, which I found equally addictive.
14:10PiskettiExactly
14:11coopernurseanother site to never go to: http://www.coderloop.com/
14:11amalloyPisketti: #4clojure on twitter
14:11amalloyand under Account Settings you can join the competition for finding the shortest solution
14:11qedPisketti: we've been discussing that, but IMO it's a good idea to divorce solutions from the site to stop people from peeking too much.
14:12qedAs it stands right now you can go out to Twitter and do a bit of searching to reveal a solution, which is bit bigger barrier than say, a button that says "CHEAT!" on each problem page. :)
14:12pdk``there's no real purpose to a "project euler for clojure" sort of site if people can copy paste crap :p
14:12Piskettiamalloy: sure twitter helps and that's what I've been doing but I'm thinking something like a forum.
14:12pdk``or better yet
14:12pdk``make 4clojure 2
14:12pdk``where we copy paste assignments from our bosses and ask the public at large to solve them
14:13qed(second foreclojure)
14:13qedpdk``: i don't that's the logical next step ;)
14:13amalloypdk``: that's already where all the problems i pose come from. my boss is always asking me whether this object i can't see is a vector or a list or what
14:13qedbahahaha
14:14qedit's like rich's talk at the (first clojure-conj): factorial, the problem we need to solve every day at work
14:14qedsomething along those lines anyway, not a direct quote, but funny either way
14:14PiskettiI don't care about solving the problems per se. I just would like to see what kind of approaches other people have used once I get my own initial or second or third solution working for any particular problem
14:15qedPisketti: sure, but then what incentive do you have to think about making your solution smaller?
14:15amalloyqed: so what? not everyone wants to optimize their own solution in isolation
14:16qedamalloy: yeah I don't either really
14:16qedI guess I'm just saying having a barrier to peeking is nice, even if its superficial
14:16PiskettiBut that's point. I spend a lot of time optimizing each problem and write several versions. When I'm "done", I'd like to see how other people dit it to _learn_.
14:16qeds/its/it's/
14:16sexpbot<qed> I guess I'm just saying having a barrier to peeking is nice, even if it's superficial
14:17qedPisketti: *nod*
14:17amalloyPisketti: at some point i'd like to add *some* kind of feature for seeing other user's solutions
14:17amalloybut how to make it usable is unclear
14:17PiskettiI's like you can only learn so much by writing your own code (= keep making the same mistakes). Seeing other people's code can be an eye opening experience
14:18amalloyif you want to submit an issue at https://github.com/dbyrne/4clojure/issues, having a user request will help
14:18qedPisketti: but then it sort of cheapens the idea of having the smallest solution -- what incentive do most users have to slim down their solutions if they can just peek at the smallest solution and paste it in
14:19Piskettiqed: personally I don't care about the copy-pasters. I just want to learn.
14:19qedPisketti: *nod* -- I guess part of what I've learned as a result of not seeing solutions is that I've been getting better and better at being clever about slimming down my solutions
14:19amalloyPisketti: yes; i was the one to implement the "shortest solution" feature, but i think qed is a little too focused on it, when it's one of many good ways to learn and have fun
14:20amalloywe absolutely want to cater to you too, but catering to both is tricky. like i said, an issue request will help
14:20qedamalloy: id agree with you i am too focused on it
14:20qed:)
14:20coopernurseqed: agreed. I'm enjoying the fact that I can't see other answers
14:20qedthat being said, the focus on that aspect has been really fun and interesting
14:21coopernurseI know that I would have cheated. I honestly don't want to tell you guys how long I'm spending on some of these problems. It's embarrassing
14:21qedive been keeping a log of my solutions -- i do a "most readable" solution, followed by a smallest solution possible
14:21amalloyqed: that sounds fun
14:22qedthat combination is really great -- you get your head around the problem, see the "shape" of the solution, and then find out how to condense that "shape"
14:22amalloyback when we weren't storing solutions for you, i stored them manually, but keeping multiple copies is too much work for me :P
14:22qedamalloy is in the server room manually typing your solutions into a 286
14:22imadek, so the updated version of my unit test is like this, is it idiomatic now or could I improve it further somehow (deftest test-last
14:22imade (dorun
14:22imade (for [f [last1, last2, last3, last4]]
14:22imade (are [x coll] (= x (f coll))
14:22imade 4 '(1 2 3 4)
14:22imade nil '()
14:22amalloyhahaha
14:22imade 1 '(1)))))
14:22amalloyi meant store *my* solutions manually
14:22qed:D
14:23amalloyimade: https://gist.github.com next time you paste something long, please
14:23imadeaa, k, will do
14:23amalloydorun/for is evil. just use doseq instead, which is like for with a dorun baked in
14:23qedI do a split window: 4clojure.clj and a REPL -- bounce back and forth, then paste my solutions into 4clojure
14:23qedand usually realize at that point I didn't account for one of the cases appropriately
14:23qed:)
14:25imadethanks, amalloy
14:25imadehere's the gist also https://gist.github.com/989314
14:26amalloyi don't know how `are` works, but i'd replace '(1 2 3 4) with [1 2 3 4], and similarly elsewhere
14:27imadek vector, cause it indicates it's a data
14:28amalloy*nod* i mean, lists can be data too, and vectors can be code - it's lisp - but vectors are much more convenient when you want data
14:29imadeyep
14:29imadewow, it's awesome how short this form of testing can be
14:32qedimade: not to mention how much less you /need/ to test in general :)
14:33imadeyeah
14:33amalloyyes. it's very hard to get (map #(* 2 %) some-list) wrong
14:34CozeyOT: Do You develop javascript / css on web apps? What is the Lisper's favourite developing pattern for these? CoffeeScript? SCSS? QUnit for testing? or is it something on node.js - or - plain old code-'reload'-check in firebug pattern?
14:35ataggartimade: see the comment I added to that gist
14:36imadethank you ataggart, I edited the gist according to the recommendation
14:37amalloyataggart: i love that you can fork gists. seems more intuitive to me than writing code in the comments
14:38gfrlogI love that you can gork fists
14:43dnolenCozey: I just write regular JS / CSS + Webkit Inspector + reload.
14:43technomancyCozey: if I were doing web work I'd use coffeescript
14:43Cozeyi wonder if with all what is happening now in node.js environment (NPM packages etc), the way we code js for the browser will improve
14:44technomancyI just get so sick of playing the "where did I forget to put the explicit return" game
14:44Cozeypersonally i hate coding js in the browser because it takes so much time to find and fix bugs
14:44Cozeyor 'where did this exception come from'
14:44Cozeyor even better 'why my browser swollowed an exception'
14:45dnolenCozey: WebKit debugger is quite good, but then again I have 7 years experience w/ client-side JS
14:45Cozeyalso i don't feel like clojure-script comming to the rescue very soon
14:45Cozeydnolen: do You use some frameworks except for instance jQuery/ Prototype etc?
14:45Cozeysome object oriented thingy or functional one ?
14:46dnolenCozey: currently using mixture of Underscore, jQuery, and some hand-rolled OO-like thing sans inheritance.
14:46gfrlog there's no way to destructure sets is there? :(
14:46Cozeyand what do you thing bout node.js popularity? is it so super fast and cool 'older' languages: java/python/ruby - or clojure can't beat them?
14:46Cozeyis js faster then clojure btw?
14:47edwJavaScript would be significantly less painful if it simply adopted some sort of shorthand anonymous function syntactic sugar.
14:47dnolenCozey: no
14:47coopernurseCozey: there was a benchmark someone did of a node.js vs Compojure site. Perf was about the same
14:47dnolenCozey: I've used node.js for file-streaming, it's good for that. I've use for rapidly prototype network stuff good for that as well.
14:48qed(inc rapid-prototyping-with-node)
14:48sexpbot⟹ 1
14:48ataggartgfrlog: (seq a-set)
14:48qed(inc dnolen)
14:48sexpbot⟹ 3
14:48gfrlogataggart: yeah, that's what I've been doing. Takes a whole nother (let) expression.
14:48coopernurseCozey: the GC in V8 (node) isn't as advanced as the JVM from what I've read. I believe it's stop-the-world.. so you get some spikes in response time periodically
14:49dnolenCozey: at the same time node.js can't fix a broken language. So I'm not really interested in node.js for anything but small projects w/ very limited goals.
14:49qedwhat's up with disclojure.org? No update since May 11th?
14:49edwtechnomancy: I think it has something to do with the fact that there are a lot of domains that no longer need big-ass web app frameworks e.g. RoR and Django and Node.js is the easiest way to write non-bloated web services.
14:49coopernursednolen: agreed. I'm actually porting a hobby site off of node.js
14:49dnolenCozey: I also find the idea that code can easily be shared between server and client w/ Node.js absurd. Client code is filled with client crap. Server code filled w/ server crap.
14:50coopernursednolen: this was exactly what I wanted to explore. I found no shared code opportunities of any importance. client was all jQuery - very little html templating on the server
14:50qeddnolen: SoC
14:51edwtechnomancy: It's the triumph of XHR & Ajax: Node.js programs are basically adpters between NoSQL databases and JavaScript code on a client. Of course, it's like putting a loaded gun in the hand of a child in that it "empowers" every copy-and-paste JS monkey to start writing server-side stuff.
14:51qedsometimes things are too powerful, even for us...
14:51technomancyedw: sorry, still baffled. =)
14:52coopernurseedw: very good observation. but the avg node.js developer I've encountered is pretty skilled
14:52qed(see my first experience with pmap)
14:52qed"Oh, I just add a p and it all happens in parallel!"
14:52edwcoopernurse: Yeah, I'm more bracing for the inevitable impact.
14:52Cozeyedw: do you predict the age of node.js security horrors? ;-)
14:52technomancyhttp://p.hagelb.org/async.jpg
14:52coopernurseedw: heh.. yes. they'll need to dumb down the installation process first, although homebrew supports it now
14:52dnolenSpiderNode is also interesting, but the Node.js community seems filled with adolescent coders who can't really see what that project is trying to do - which is makes JS on the server not suck.
14:53dnolenI got mad respect for Brendan Eich and David Herman and the Mozilla Team, they're trying hard to make JS compete w/ programming languages circa 2000.
14:53technomancyyou can't library your way out of the statement/expression distinction.
14:54amalloytechnomancy: clojure is a pretty good library for java
14:54technomancyprobably a lost cause
14:54technomancyamalloy: sure, the runtime is not a lost cause =)
14:54coopernursetechnomancy: agreed. JS is a bizarre language. but there's a ton of client side developers who have gotten good at it, and want to use those skills on the server
14:55CozeyUff. this means we'll not all be forced to leave lisp and code JS .... :P Thanks for the opinions, gotta go. good night!
14:56qedJavaScript in general is like Ke$ha barfing glitter.
14:56manutterew
14:56qed:D$&#^&^$#&^$# <--example
14:56dnolenqed: problem is that JS neighter as bad as people say (Java people who don't know anything) nor as good (JS koolaid drinkers)
14:56dnolens/neighter/neither
14:56sexpbot<dnolen> qed: problem is that JS neither as bad as people say (Java people who don't know anything) nor as good (JS koolaid drinkers)
14:56edwtechnomancy: That most languages insist on that statement/expression distinction is baffling to me.
14:57qeddnolen: agreed.
14:57coopernurseit has some serious issues for anyone writing anything nontrivial
14:57PiskettiComing from a Java background, having everything as expressions is wonderful
14:57coopernurseerror propegation in async code, for example
14:58amalloyqed: i saw a good tweet on that topic: "I think the most common complain about javascript is 'Help, this language is bullshit!'"
14:58coopernurseI haven't explored Clojure's promise implemenation yet
14:58coopernurseso I'm curious how it solves that
14:59coopernurseI'm still reversing a list :P
14:59qedamalloy: heh
14:59amalloy~source promise
15:00pjstadighttp://twitter.com/#!/fogus/status/57082438286979072
15:01coopernursegreat quote
15:01edwIs there an X analog to VNC?
15:01coopernurseedw: X itself is a network protocol
15:01imadewhy (comment ...) cannot contain : character? https://gist.github.com/989395
15:01edwEr, an X analog to screen?
15:02coopernurseedw: hmm.. that I don't know
15:02wastrelxdmcp
15:02wastrelscreen?
15:02amalloy(comment) is misleading and evil
15:02wastreliono
15:02clojurebotparedit screencast is http://p.hagelb.org/paredit-screencast.html
15:02ataggartimade: because the comment form is still read by the reader.
15:02gfrlogamalloy: why?
15:03technomancyclojurebot: what are you insinuating there
15:03clojurebotTitim gan éirí ort.
15:03ataggartimade: if you want the reader to ignore the form, use the #_ reader macro
15:03amalloy&(comment TODO: do some stuff)
15:03sexpbotjava.lang.Exception: Invalid token: TODO:
15:04amalloy&(inc (comment make one bigger) 1)
15:04sexpbotjava.lang.IllegalArgumentException: Wrong number of args (2) passed to: core$inc
15:04edwcoopernurse: I want to be able to keep an X client going forever and simply re-connect my server to it.
15:04imadeI see, ok, I will investigate this #_ macro then
15:04edwThere must be some sort of X proxying app.
15:04amalloygfrlog: ^
15:04dnolen&(comment ; foobar)
15:04sexpbotjava.lang.Exception: EOF while reading
15:05coopernurseedw: gotcha. I don't know how to do that
15:05ataggart,#_(does not get read)
15:05clojurebotEOF while reading
15:05gfrlogamalloy: (comment) is misleading and evil
15:05dnolenimade: comment is fine, but you can't just have random text lying around in it, you need to to preface non sexpr lines with ;. It's still the most convenient way to block out code you don't want to get recompiled when developing, at least for me.
15:06gfrlogdnolen: what about #_?
15:06ataggartdnolen: can you think of a reason to use comment over #_ ?
15:06TimMccomment can take multiple forms
15:06TimMcSo use #_(comment ....) :-)
15:07gfrlogTimMc: or just #_(....)
15:07TimMcgfrlog: Erk, yes,
15:07dnolenjust personal preference, I use #_ to remove single exprs wedged in code, (comment ...) for blocks of various code I'm playing around with.
15:09gfrlogI agree that the name is misleading. Maybe (ignore) would be better. "comment" already means something specific that (comment) isn't
15:11dnolenah #_ is effed up in SLIME, that's why I avoid it
15:11dnolenboth for formatting and evaluation
15:12edwdnolen: I do the same (or similar): COMMENT for things like test or exercise code, #_ for individual expressions I don't want to be eval'd.
15:14amalloydnolen: really? how do you find it messed up for evaluation?
15:14ataggartspeaking of contains?, if I could go back in time, I'd have sets act as predicate fns, create a new fn called get? which behaves like current contain?, and change contains? to do what most people think it should do.
15:14dnolen#_(+ 4 5)^ C-x C-e -> 9
15:14amalloysure. i would be astonished if it traveled back *past* that sexp to the first one that's not commented
15:14TimMcdnolen: Ah, it doesn't go back far enough?
15:15amalloythat is, i think the existing behavior is useful for "does this code i've commented out still work", and some other behavior would be useful for "oh shit i wanted to test this commented-out code, not that delete-the-db function before it"
15:17dnolenamalloy: not disagreeing I use #_ when I want to test multiple possible values for an expr in an existing expr, I put snippets of test code in (comment ...)
15:19amalloyincidentally i don't think it would be possible to make slime understand #_ without a huge effort
15:22edwI use #_ extensively and I've never been bitten by this. Do you really see "(foo) #_ (apocalypse)|", type C-x C-e and expect the foo combination to be evaled? That's crazy.
15:23dnolenedw: I did say personal pref :) it affects movement and paredit as well
16:04timvisherhey all
16:04timvisheri'm using clojure.contrib.shell-out to interact with imagemagick
16:04timvisherwhen I get to an image that has bad data in it, my program just hangs
16:05timvisheri remember from my groovy days that if you don't properly consume output, you can get into this situation, but i can't find anything in the docs indicating how to consume the error stream
16:05timvisherthoughts?
16:06ataggarttry clojure.java.shell
16:10technomancydnolen: harder than you think as it would probably involve forking slime
16:10technomancysince I don't think upstream would be too keen on the feature
16:11timvisherataggart: whoo! that seems to have done it. thanks!
16:12timvisherbtw, when programming in slime, i find myself wanting to get a clean version of my namespace, i.e. wipe out all references and definitions and then reload them
16:12timvisherthe way i do this is to kill the swank server and then restart it
16:12pdk``slime
16:12timvisheris there a better way to do that?
16:12pdk``clean
16:12pdk``wipe
16:12pdk``HMMMMMM
16:12clojurebotCool story bro.
16:13technomancytimvisher: you can do ns-unmap or remove-ns, but there's nothing exposed from elisp. there should be though.
16:13TimMcclojurebot: botsnack
16:13clojurebotthanks; that was delicious. (nom nom nom)
16:13pdk``have you considered using im4java through clojure
16:14timvisherpdk``: i was looking into JMagick but they don't appear to be available through maven/clojars
16:15timvisheri then figured that if I was going to bother shelling out through im4java, i want to do something so simple that there has to be an easy way to simply shell out
16:15timvisherso far, this is really all I want to do
16:15timvisherif I need more from imagemagick, i might go with im4java
16:15timvisherjmagick seems... poorly documented
16:17timvishertechnomancy: I suppose I could effectively switch to the user namespace, (remove-ns whatever-ns) at the repl, and then switch back to the buffer and C-c C-k again.
16:21technomancybeware that remove-ns can screw up downstream consumers though
16:21technomancyactually ns-unmap may as well
16:21technomancyone way to find out
16:32amalloytimvisher: you could bind that sequence of commands to a key and just use that
16:36timvisheramalloy: indeed I could. 'nother day though. I can now generate thumbnails for my image seq. hooray! :)
16:36timvisherthanks for the awesome help as always ladies!
16:38offby1laddies?
16:39timvisherno, i meant ladies
16:39timvisheri was going to say gentlemen
16:39timvisherthen i realized there may be ladies present
16:39timvisherthen I felt like sticking it the old masculine general pronouns and just call us all ladies
16:39timvisher:)
16:40timvisherhopefully no one's offended, as I don't think i'd make much progress with clojure if I had to stop coming here
16:43offby1how dare he
16:43offby1yeah
16:43__name__I've been longing for something to feel offended about all day.
16:44__name__Oh. Wait. That's not how it works, is it?
16:44amalloyoffby1: i admire the way you immediately turned a vicious personal attack into an opportunity to profit through merchandising
16:45timvisheroffby1's got class
16:52PiskettiI wonder if there are any _real_ ladies here.
16:54amalloygood call there
16:55pjstadigi'm a dog
16:55pjstadighttp://www.unc.edu/depts/jomc/academics/dri/idog.jpg
18:05brian_FYI - I created an s4code git repo that contains all the other repos as submodules for easy cloning/updating/etc
18:06brian_oops, wrong chat!
18:15VT_entityHey all
18:15VT_entityI've got a question.
18:16VT_entityI'm trying to use cycle to produce an infinitely repeating collection. I want to use vectors because I think they will be faster
18:16VT_entity(def ringbuffermembers [1 2 3 4 5])
18:16VT_entity
18:16VT_entity(def ringbuffer (cycle ringbuffermembers))
18:17VT_entitythis works, but if I do
18:17VT_entity(take 20 ringbuffer)
18:17VT_entityit returns a list
18:17VT_entitynot a vector
18:17amalloyvectors aren't lazy
18:17amalloyyou can't have a lazy vector
18:17amalloy(also, it returns a seq, not a list; the repl renders them both as (a b c))
18:17VT_entityso... duck typing is turning my vector into a list because I'm treating it lazily?
18:18VT_entityooooh
18:18amalloy&(class (take 1 (cycle [1])))
18:18sexpbot⟹ clojure.lang.LazySeq
18:18amalloyyou can use a vector if you want, but cycle will take a sequence view on it anyway
18:18amalloyand return a sequence
18:19VT_entityyeah, I couldn't figure out why
18:19no_mindusing enlive, I have selected a node of tag type :select . Now I want to iterateover all teh optin tags under selected select node and set one of the option nodes as selected. How do I do this ?
18:19amalloy&(seq [1 2 3])
18:19sexpbot⟹ (1 2 3)
18:19raeka seq is just a sequential view of some abstract collection, which can be infinite
18:19raek...and not really a data structure, in a sense
18:20raekno_mind: at?
18:20VT_entityI'm trying to figure out whether its faster to do this with lists or vectors
18:20amalloyneither, really
18:21amalloyi mean, you might notice a slight difference
18:22VT_entityI'm still learning the language. I figured vectors might be faster because I might eventually be creating a lot of these ringbuffers
18:22amalloyand if you did, lists would probably be the winner in this particular contest, but i'm just guessing
18:23VT_entitymaybe do it with pvec
18:23VT_entityah, thanks
18:23amalloy&(doc pvec)
18:23sexpbotjava.lang.Exception: Unable to resolve var: pvec in this context
18:23VT_entityah, I guess I forgot the mnemonic for parallel vector
18:24amalloyVT_entity: i don't understand what you're talking about. parallel vector?
18:24raekVT_entity: are you concerned about whether (cycle [1 2 3]) or (cycle (list 1 2 3)) is the most efficient?
18:24VT_entitylol, yes
18:24VT_entityI am an utter noob, sorry
18:25amalloyVT_entity: there are 10,000 more important things to worry about when you're learning a language. ask this question again once you've covered them all :)
18:25VT_entityI am going to be invoking a whole bunch of these ringbuffers and popping functions off of them
18:25raekif so, it must be hard for you to get anything done if you spend your time doing these (premature) micro-optimizations all the time
18:26VT_entityit's going to be pretty intense
18:26amalloyVT_entity: madness
18:26amalloystop worrying about it
18:26VT_entityI'm building an artificial life game
18:26raekVT_entity: if a queue is what you need, there is a data structure in Clojure for that too
18:26amalloyso what? if you find out this is the bottleneck, you can change it later
18:27VT_entityah, that's a smarter way to go about it.
18:27amalloy(cycle foo) will return a lazy-seq no matter what foo is, so the consumer won't care
18:27no_mindraek: no luck http://pastebin.com/KZ1jHJV1
18:27VT_entity&(doc queue)
18:27sexpbotjava.lang.Exception: Unable to resolve var: queue in this context
18:28amalloy&(doc seque) i think?
18:28sexpbot⟹ "([s] [n-or-q s]); Creates a queued seq on another (presumably lazy) seq s. The queued seq will produce a concrete seq in the background, and can get up to n items ahead of the consumer. n-or-q can be an integer n buffer size, or an instance of java.util.concurrent B... http://gist.github.com/989895
18:28amalloyclojure's seq isn't very well polished afaik though
18:28VT_entityaaah
18:28VT_entitythanks
18:30raekno_mind: the problem with your code is that in the "transformation slot" of the outer html/at form, you don't put a transformation function
18:37raekno_mind: you need to turn (html/at <some node> [:option] abc) into a function that takes a node and returns the changed node
18:41no_mindk
18:41no_mindraek: we need a short book to explain the concepts of enlive :)
18:42raekno_mind: most of enlive is actually ordinary clojure
18:42no_mindwellclojure is not ordinary :)
18:42raekno_mind: what you put in the "transformation slot" of an 'at' form is just an ordinary clojure expression, and follows ordinary evaluation rules
18:44raekno_mind: I assume you come from a programming language where functions are not values?
18:45no_mindraek: but that still leaves the original problem unsolved. How to iterate over each option tag and set a tag value as selected ? From what I see, 'at' will select all the option tags
18:45raekno_mind: at will only operate on the tree that you give it
18:46raekno_mind: in your case, the outer at should pass the select element subtree to the inner at
18:47raekI assume you want to iterate over all the option elements of that select element
18:48no_mindraek: yes iterate over al elements and set one option as selected
18:51raekat works by matching nodes with selectors. on a match, it will pass the matched node (and its subnodes) to the corresponding transformation function.
18:52raek(at (html-snippet "<p><b>foo</b></p>") [:b] (fn [node] (prn node) {:tag :i, :content ["bar"]}))
18:52dnolenis it not possible to install swank-clojure via marmalade?
18:53raekdnolen: swank-clojure or swank-clojure.el?
18:53dnolenraek: used to install swank-clojure via ELPA, wondering if marmalade is the new way to go, has more packages, and seems more up-to-date.
18:54raekdnolen: the swank-clojure you probably want to use is not an emacs library
18:55raekthere is an old lib called swank-clojure.el from the times before Leiningen, but it was hard to use since you needed to configure the classpath (so switching betsween projects was a pain)
18:56raekdnolen: http://technomancy.us/149
18:56raekdnolen: either add [swank-clojure "1.3.1"] to your project.clj or run "lein plugin install swank-clojure 1.3.1"
18:57hiredmandnolen: does core.logic provide a cond like macro for conditional execution based on matching?
18:58raekno_mind: in that example, the transformation function receives {:tag :b, :content ("foo")} and returns another tree ("<i>bar</i>"). it also prints the original tree
18:58no_mindraek: http://pastebin.com/CFZ1LAuk it prints the whole node including the html. Whereas what I want in function xyz is bunch of :option tags only
18:58raekno_mind: in your case, you probably want to write something like (fn [node] (at node ...selector... ...transformation))
18:59dnolenhiredman: yes, conde is the primitive form, defne gives you pattern matching sugar. It's a bit different from Prolog tho since in Prolog different clauses can be defined top-level, in core.logic matching is local to fns (goals) - kinda like Clojure multi-arity fns. Hope that makes some sense. I need to document more.
19:01hiredmanand you wrap it in the whole run* thing?
19:03raekno_mind: it doesn't print the whole tree, it prints nil. the at expression returns the whole tree, though
19:03carllercheIs there a way to determine the arity of an arbitrary (anonymous?) function?
19:05dnolenhiredman: yup, run* is basically a sort of monadic thing, it threads an environment through your logic statements, it return a lazy-seq of answers.
19:06raekno_mind: sorry, actually it doesn't print anything at all. the selector does not match, somehow
19:06dnolengoals are really just closures that take an environment manipulate it (possibly replicate it) and pass it on to the next goal.
19:06no_mindraek: how come ?
19:06dnolen(== q true) -> (fn [a] (unify a q true))
19:07dnolenso I guess run* is sort of like do in Haskell.
19:09raekno_mind: strange, it works with (content "BOO") instead of xyz...
19:10raekdnolen: technomancy's recent blog post is the way to go. the previous approach (pre "clojure-jack-in") is here: http://dev.clojure.org/display/doc/Getting+Started+with+Emacs
19:11raekno_mind: (defn xyz [node] (prn node) node) works as expected...
19:12no_mindraek: the selctor for select tag is working, i checked by doing a set-attr instead of xyz and it works
19:12amalloycarllerche: no
19:13raekthe printing seems to mess it up...
19:14amalloymainly because functions can have multiple arities, and that information only really exists in the var's metadata (which anonymous function don't have) once the compiler's read it in
19:15no_mindraek: no luck here.. I am still getting the same result
19:15carllercheamalloy: there seems to be getRequiredArity it seems
19:16amalloy&(-> + var meta :arglists)
19:16sexpbot⟹ ([] [x] [x y] [x y & more])
19:16amalloyif you have an actual var object, you can work with that to see what it accepts
19:16carllerchethat doesn't really help though
19:16raekno_mind: oh, now I get it! it actually works, but prn is called in the middle of the printing of the result!
19:16amalloyno
19:16carllercheamalloy: yeah, i'm working with anonymous functions :(
19:16raektry this: (html/at rr [(html/id= "one")] (fn [node] (prn "BEGIN") (prn node) (prn "END")))
19:16amalloywhose arities you don't know, but need to know? that seems like a bad design choice
19:17carllercheamalloy: it's mostly for convenience helpers during testing
19:17amalloyi don't think that message has much information in it :P
19:18carllercheit's not a big deal, it's mostly so that I can write tests w/o _ everywhere, but whatever.. worth a shot
19:18raekno_mind: due to laziness, the transformation won't be call until needed, which happens to be in the middle of the printing of the expression
19:18no_mindraek: ok butI am still receiving the complete html in prn whereas I want only option tags
19:19raekno_mind: take a look at this: (def a (atom nil)) (defn xyz [node] (reset! a node))
19:19raekno_mind: evaluate (html/at rr [(html/id= "one")] xyz) and then look at the value of a
19:20raekno_mind: the interleaved printing confused the matter
19:22raekno_mind: to answer your original question: (html/at rr [(html/id= "one")] #(html/at % [:option] abc))
19:22raekno_mind: do you see why this works?
19:24no_mindyaa
19:30technomancywhat could cause a simple (clojure.java.shell/sh "ls") call to cause the JVM to never exit?
19:31technomancyadding shutdown-agents fixes it, but that's ridiculous
19:32technomancythere are a few futures in clojure.java.shell/sh, but they're all deref'd by the time the function returns
19:33hiredmantechnomancy: sh uses futures, which spins up the agent threadpool, etc
19:33hiredmanthe jvm waits for live threads to exit before exiting
19:33technomancyeven with no active futures?
19:33hiredmanafter the futures finish they are returned to the threadpool, and are still "live"
19:33hiredmanwaiting to be reused
19:34hiredman(kind of what a threadpool is for)
19:34technomancymakes sense if the process isn't trying to exit
19:34hiredmanwhich is why shutdown-agents was added
19:35technomancyshutdown-agents is permanent though
19:35hiredmanthe other option is to make the threadpool threads daemon threads
19:35technomancyuseless for writing composable code without a corresponding startup-agents
19:35hiredmancorrect
19:36technomancythe JVM is getting revenge on me for having ported a 75-line clojure file to a 30-line shell script
19:36hiredmanhttp://tech.puredanger.com/2010/06/08/clojure-agent-thread-pools/
19:37technomancy"If you really loved me, you wouldn't want to shell out! I've got everything you need right here. Come baaaaaaack..."
19:37hiredmanI kind of agree with the blog post, not making the threadpool threads daemon threads by default is kind of a drag
19:37technomancyI wouldn't mind one bit if I could reset the thread pool
19:38no_mindraek: calling set-attr in xyz is throwing error
19:39scgilardigiven that you can't recover from shutdown-agents, I wonder if arranging for a call to shutdown-agents in a shutdownhook would be appropriate. (Runtime.addShutdownHook)
19:40raekno_mind: what error?
19:40technomancyscgilardi: whoa; shutdown hooks.
19:40technomancythat looks like the Right Thing
19:41hiredmanthey won't run until the threadpool threads stop
19:41hiredman"The program exits normally, when the last non-daemon thread exits or when the exit (equivalently, System.exit) method is invoked, or "
19:41technomancyಠ_ಠ
19:41scgilardiIsn't a successful System/exit what we're after?
19:42technomancyin this case System/exit would break composability as well
19:42hiredmanunless lein did some kind of "run these tasks then call System/exit"
19:43hiredman(which it must, come to think of it)
19:43hiredmanto return exit codes
19:43scgilardiinc
19:43technomancyit only calls System/exit on failures
19:43technomancybut it probably should either way
19:45no_mindraek: java.lang.IllegalArgumentException: Don't know how to create ISeq from: net.cgrand.enlive_html$set_attr$fn__696
19:46raekno_mind: all I can tell from that is that you have put the (set-attr ...) call in the wrong place...
19:47raekno_mind: could you explain the surrounding code?
19:48no_mindraek: http://pastebin.com/DLVbMw2F
19:51raekno_mind: first: use = instead of .equals
19:52raekno_mind: second: you are calling set-attr wrong. remember the "two stage" thing?
19:53raekand you are missing the else expression of the if
19:53raekwhich should return the node unchanges
19:53raek-d
20:01raekno_mind: anyway, here's my approach: https://gist.github.com/990033
20:03no_mindraek: thnxs, i fixed that
20:07tomojclojurebot: single segment namespaces?
20:07clojurebotsingle-segment namespaces is unsupported. (foo instead of foo.core) they may work in a few circumstances, but you shouldn't rely on them.
20:07tomojbut why, clojurebot?
20:09amalloytomoj: default package
20:10tomojah
20:10tomojso e.g. osc-clj has (ns osc)
20:11tomojthat means if there is a java lib out there with an "osc" class in the default package, they clobber?
20:12amalloyi don't think that's the *only* issue
20:30dnolenwhen I try clojure-jack-in it says it can't find lein, how can I set the path to lein?
20:33technomancydnolen: gui-launched emacs on OS X?
20:33dnolentechnomancy: yeah
20:33technomancyyeah, your .profile is being ignored =\
20:33dnolendo I just (setq clojure-swank-command ...) ?
20:33technomancythere's some XML plist you have to edit
20:34technomancyto set your $PATH for GUI apps
20:34technomancyit's ridiculous
20:34dnolentechnomancy: got a link?
20:34technomancydnolen: actually clojure-swank-command would work too
20:35technomancybut you would still have trouble with non-swank commands like with magit
20:35technomancymaybe this? http://www.emacswiki.org/emacs/MacOSTweaks#toc11
20:36scgilardihttp://developer.apple.com/library/mac/#qa/qa1067/_index.html
20:36technomancythat's specific to emacs rather than all gui-launched programs; maybe it's good enough
20:38technomancyooh; a non-xml version. slightly less awful!
20:38technomancythat is probably the #1 most common problem people have with Emacs on any platform. probably should mention it in the swank readme.
20:39technomancy(apart from "zomg the parens" of course)
20:39scgilardiwell, it's a gui on the xml. and comes with apple's developer tools.
20:39jediah that would explain my problem with it too
20:40dnolentechnomancy: how long should jack in take? I see that it's pasting slime.el into *swank* buffer...
20:41technomancydnolen: maybe 5-10 seconds on the server JVM?
20:41dnolentechnomancy: hmm I should get a REPL ?
20:41dnolentechnomancy: I tried jack in from the dired view of my project.
20:42technomancythat oughtta work; is it just stalled?
20:42technomancywhat's at the end of the *swank* buffer?
20:43scgilardiexample environment.plist: https://gist.github.com/990084
20:44dnolentechnomancy: *swank* looks stalled on line 10000 something.
20:45dnolentechnomancy: I used: lein install plugin swank-clojure 1.4.0-SNAPSHOT, and trying to jack into a 1.3.0-alpha7 project.
20:46technomancydnolen: I haven't used it with clojure 1.3 but have seen reports of it working. what's the content at the end of the buffer?
20:46dnolentechnomancy: it just keeps freezing around line 10937: it's in the middle of pasting "slime-repl-current-input"
20:47dnolenlein jack-in 36863: exited abnormally with code 1.
20:47dnolenin *Messages*
20:47technomancyfreezing mid-function? that's odd; I haven't heard of anyone else getting that.
20:48dnolenI will say the slime.el paste it very slow, I see it scroll by
20:48dnolens/it/is
20:48sexpbot<dnolen> I will say the slime.el paste is very slow, I see is scroll by
20:48technomancyif you already have slime installed, you can stick with lein swank + m-x slime-connect
20:48technomancythis is really more of a convenience for people who haven't gone through the setup process yet
20:49technomancyI am curious what's going on though
20:49dnolentechnomancy: can you grab files from marmalade and ELPA ?
20:50technomancyyeah, you should be able to use curl or whatever
20:50technomancythey're also inside the swank-clojure jar
20:51dnolentechnomancy: won't installing package.el from ELPA override marmalade package.el?
20:52technomancyyou mean using package.el to upgrade itself?
20:52technomancyI'm not sure; I don't think the elpa version has a higher version number
20:55dsopis it true that I cannot access the cached collection inside a lazy-seq body?
20:55dsopso something like (lazy-seq (let [x (seq coll)] ... (count x)...)
21:03dnolentechnomancy: so swank-clojure is not something I should install from ELPA right?
21:10dnolenEmacs is not for the faint of heart ...
21:10hiredmandnolen: core.logic run on 1.2?
21:11dnolenhiredman: I'd like it to but I haven't had time to sort out what needs to be fixed.
21:11dnolenhiredman: I ran into some weird errors and did not pursue. There no reason for core.logic to be 1.3 centric.
21:16dnolenafter much teeth gnashing, animal sacrificing, I have a working Clojure Emacs setup again and I can get packages from Marmalade and ELPA.
22:03dnolenhiredman: OK looked at it a little, here's a real bug in 1.2.1 that prevents core.logic from working https://gist.github.com/990176
22:07dnolenif anyone knows how to work around this one, I'll be happy to fix core.logic to work w/ 1.2 now.
22:17hiredmandnolen: https://gist.github.com/990194
22:18dnolenhiredman: will that be slow? core.logic really relies on very fast map lookups.
22:19hiredmanthe other option is make Foo the full package qualified name
22:20TimMcarglbalrlgrl
22:20hiredmanbasically Foo is resolved to the wrong classname at compile time (it is resolved to the stub the compiler generates)
22:20TimMcI did my first serious Java coding today since... about a year ago.
22:20TimMcI REALLY want macros.
22:20amalloyhaha TimMc i was gonna ask if it was java-related
22:20TimMcof course
22:21amalloyTimMc: well, it could be php-related
22:21dnolenhiredman: yeah tried fully qualified name, got classloader error.
22:21dnolenattempted duplicate class definition for name
22:22hiredmanbleh
22:22hiredmanstupid deftype bugs in 1.2
22:27dnolenhiredman: difference is pretty dismal, w/ resolve in 1.2 you're looking at 600ms for 1e7 iterations, 1.3 7-9ms if I can do the real instance check.
22:28dnolencore.logic is constantly reaching into the map to check vars, add vars, etc. so equal needs to really cost near nothing.
22:29hiredmanI may noodle on it
22:30dnolenhiredman: if you come w/ something let me know, I think this is the weird issue I saw, probably the only real bug, but of course it breaks everything.
22:31amalloydnolen: (let [this-class (atom nil)] (deftype Foo [] (equals [this other] (instance? this-class other))) (reset! this-class Foo)) perhaps?
22:31dnolenamalloy: not really willing to do something like that.
22:31dnolenI'll mention this on the dev ML
22:39mefesto`dnolen: this works for me on clojure 1.2.0: https://gist.github.com/990219
22:40mefesto`not sure if it meets your performance requirements but atleast it returns true :)
22:42dnolenmefesto`: huzzah! and it's even faster it seems!, k will see if that fixes core.logic in a few, gotta run for a bit.
22:59amalloyKirinDave: i found an entry in the #clojure logs where you talk about http if-modified-since. is there a compojure wrapper that handles that already (for static file-based routes), or would i have to write it myself? so far i can't even figure out how to convince the client to send an If-Modified-Since header
23:00KirinDaveamalloy: I dunno if there is a compojure wrapper. I doubt it?
23:00KirinDaveamalloy: Which client?
23:01amalloyKirinDave: neither chrome nor firefox seem to be sending that header afaict
23:01KirinDaveamalloy: Oh
23:01KirinDaveI dunno about it.
23:01KirinDaveI see it usually in the context of proxies
23:02KirinDaveI don't know how you'd provoke Chrome or Firefox.
23:03amalloyKirinDave: i thought most clients were keeping a local cache and would involve the server in a decision whether or not updating was needed
23:04KirinDaveamalloy: Offhand I'm not sure what they do.
23:04amalloyKirinDave: looking at the headers when i request google.com a few times, it looks like mostly google says "this data is good for N seconds, don't even ask me if it's changed". but for at least one resource, they convince chrome to include If-Modified-Since
23:55dnolencore.logic is now compat w/ 1.2
23:56mefesto`very cool. now i just need to learn about this thing they call "logic"
23:58technomancyLicenser: ping