2012-02-26
| 00:12 | lynaghk | Does anyone have a suggestion for how to map with an accumulator |
| 00:12 | lynaghk | value? I have a collection of maps and want to return new ones that |
| 00:12 | lynaghk | contain an offset field based on all of the maps before it. |
| 00:12 | lynaghk | ugggg emacs, sorry about that folks. |
| 00:14 | lynaghk | The only thing I can think of is to calculate the values of the accumulator in advance using 'reductions, then mapping over both sequences at the same time, but it'd be nice to be able to walk the collection just once |
| 00:14 | juhu_chapa | it may sounds strange but when I execute in the REPL: (.split "key=value" "=") it works as expected, but when I execute the whole program where it is found that method does not work. |
| 00:14 | juhu_chapa | any clue? |
| 00:14 | lynaghk | juhu_chapa, can't say without more code. |
| 00:15 | juhu_chapa | I tried changing the delimiter to ":" and that behavior does not appear anymore |
| 00:15 | ibdknox | so after watching the bret victor video |
| 00:15 | ibdknox | I decided to try and create a real-time editing experience for CLJS |
| 00:15 | amalloy | lynaghk: isn't that just reductions? |
| 00:16 | lynaghk | amalloy: reductions just returns the value of the accumulator. I want those values to be within maps |
| 00:17 | juhu_chapa | lynaghk: this is the whole code: (do |
| 00:17 | juhu_chapa | (println (.split "key=value" "="))) |
| 00:18 | juhu_chapa | if you run just the split method it works |
| 00:18 | juhu_chapa | but inside in this case of another form it DOES NOT WORK |
| 00:18 | lynaghk | amalloy: I'm looking for [{:val 1} {:val 2} {:val 3}] => [{:val 1 :offset 0} {:val 2 :offset 1} {:val 3 :offset 3}] |
| 00:19 | amalloy | lynaghk: yeah, it's not really that pretty with reductions. i'd just bash together a quick recursive lazy-seq for it |
| 00:21 | amalloy | you sorta need two functions, yeah? one for computing a new accumulator, and one for computing a value for the sequence based on an accumulator and an input item |
| 00:22 | lynaghk | Yeah, that sounds right |
| 00:22 | amalloy | it's *almost* like an unfold, but i don't think it would be that convenient to write as one |
| 00:23 | lynaghk | I'm not that familiar with functional idioms beyond map, to be completely honest. |
| 00:24 | lynaghk | I mean, I started to write it as a loop/recur, but I thought I'd check and see if there was a nice way to do that built into the std lib. |
| 00:24 | amalloy | loop/recur won't be lazy. i don't think that would make you happy |
| 00:25 | lynaghk | So you think recursive lazy-seq would be the way to go? |
| 00:25 | amalloy | the skeleton will be like (defn map-accumulating [next-item next-acc init-acc coll] ((fn step [acc xs] (lazy-seq (when-let [[x & xs] (seq xs)] ...))) init-acc coll)) |
| 00:26 | amalloy | i tried to write out more detail but i don't actually know what you're doing, so i gave up |
| 00:26 | lynaghk | Just doing a rolling sum |
| 00:26 | amalloy | well, i was writing the more general case, i think |
| 00:27 | lynaghk | Okay, I'll dig into that and see how it checks out. I might also do the double map for clarity. |
| 00:28 | lynaghk | juhu_chapa: I tried your code and it worked fine inside the do. |
| 00:29 | amalloy | for what it's worth, reductions followed by map really only goes over the sequence once anyway, because of laziness |
| 00:31 | muhoo | well my first semi-useful set of little functions in clojure: https://refheap.com/paste/860 |
| 00:31 | muhoo | feel free to tell my why that sucks balls. |
| 00:31 | lynaghk | amalloy: good point. |
| 00:32 | sritchie | hey all -- have you guys experienced leiningen running really, really slowly? |
| 00:32 | sritchie | I have a few projects that take minutes and minutes to run deps |
| 00:32 | tomoj | yes, clean as well |
| 00:32 | sritchie | is there something I can do to diagnose this, or fix it? |
| 00:33 | juhu_chapa | lynaghk: you are right I am going to public the "erroneous" code in pastebin |
| 00:33 | ibdknox | sritchie: happens to me too :( |
| 00:33 | sritchie | it started with 1.6.2, I think |
| 00:33 | ibdknox | sritchie: the workaround seems to be that if you do rm -rf classes/ every time it would do a clean, it "fixes" it |
| 00:33 | tomoj | it's intermittent, right? |
| 00:34 | sritchie | oh, that's interesting |
| 00:34 | sritchie | ibdknox: any idea what it's doing with that classes dir? |
| 00:34 | ibdknox | no clue, I've been annoyed by it, but haven't actually taken the time figure out what's going on |
| 00:36 | muhoo | doh! ##2r101101 |
| 00:36 | muhoo | &2r101101 |
| 00:36 | lazybot | ⇒ 45 |
| 00:36 | sritchie | ibdknox: I hadn't found a reference anywhere, it almost feels taboo |
| 00:36 | espringe | How do I get mildly readable errors out of clojure? Like here's an example one i get: |
| 00:36 | espringe | "Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol (main.clj:0) " |
| 00:36 | muhoo | &16r3e0F9 |
| 00:36 | lazybot | ⇒ 254201 |
| 00:37 | espringe | It doesn't tell me the line at all |
| 00:37 | espringe | the backtrace is all in Compiler.eval |
| 00:37 | espringe | The only thing it tells me is the file |
| 00:37 | ibdknox | espringe: sounds like an ns error :( |
| 00:37 | ibdknox | those are notoriously difficult to deal with |
| 00:37 | amalloy | yes, quite likely. but also the backtrace isn't *all* in compiler.eval |
| 00:38 | espringe | Well *none* of it is in my code |
| 00:38 | amalloy | like, main.clj:0 is probably saying the issue is at the beginning of your main.clj file, i think? |
| 00:38 | espringe | nah, it's definitely not |
| 00:38 | tomoj | sritchie: I was going to ask about it the other day, also couldn't find any other mentions |
| 00:38 | espringe | Cause since it was last working, i've only modified like 10 lines -- none near the top of the file |
| 00:38 | sritchie | technomancy, any ideas? |
| 00:39 | ibdknox | espringe: can you put up a paste of the file? |
| 00:39 | espringe | ibdknox: sure |
| 00:40 | espringe | ibdknox: http://pastebin.com/4MbCNYA6 |
| 00:41 | espringe | Also if anyone doesn't mind, can they tell me how bad my code is. I haven't done a dynamically typed language in over 10 years, and i feel like i'm defeating its entire purpose |
| 00:41 | tomoj | I think delete-file-recursively is the culprit |
| 00:41 | espringe | the protocol/record thing i'm using, seems to be a crap approach? |
| 00:43 | ibdknox | espringe: multi-methods are a better solution for this kind of stuff |
| 00:43 | espringe | ibdknox: multi-methods that dispatch based on value, rather than type? |
| 00:43 | espringe | is that how to do it? |
| 00:44 | ibdknox | espringe: the cljs compiler is a really good example of the multi-method approach to emitting code, basically build up an ast and then just walk the tree calling emit based on the node type |
| 00:44 | muhoo | ast? |
| 00:45 | tomoj | sritchie: interesting you say 1.6>2 |
| 00:45 | ibdknox | Abstract Syntax Tree |
| 00:45 | espringe | abstract-syntax-tree |
| 00:45 | sritchie | that's speculation, I had a buddy upgrade to 1.6.2 and start exclaiming about how slow things were |
| 00:45 | tomoj | https://github.com/technomancy/leiningen/commit/32ebf41f23b0fdc5b35991ab3f04a506ac0934c5 |
| 00:45 | espringe | ibdknox: I'll look into doing that, but i'll need to figure out why it's not compiling now before i start refactoring |
| 00:45 | tomoj | this System/gc is in the hotspot that showed up in my profiler run |
| 00:46 | ibdknox | sritchie: does it eat your CPU too? for me it pegs a core |
| 00:46 | ibdknox | espringe: yeah I'm looking at your file |
| 00:46 | tomoj | how much time and money has this commit cost? :) |
| 00:46 | ibdknox | nothing obvious is jumping out |
| 00:47 | sritchie | ibdknox: I don't know that I'm able to have children anymore from the heat my laptop puts out when I run lein deps |
| 00:47 | ibdknox | sritchie: hah! finally someone else has the same thing |
| 00:47 | espringe | Are there plans on fixing the clojure errors/stacktraces? Other than my occasional "found X expected X" in scala, this has got to be the least helpful compile error i've seen :( |
| 00:48 | tomoj | hmm |
| 00:48 | tomoj | the System/gc shouldn't be the problem, though |
| 00:49 | tomoj | oh, maybe |
| 00:49 | xeqi | tomoj: it causes FullGCs on my system, so I could see it being the culprit |
| 00:50 | ibdknox | espringe: line 101 is your problem |
| 00:50 | ibdknox | espringe: what version of clojure are you using? |
| 00:50 | espringe | 1.2.0 |
| 00:50 | espringe | ibdknox: ah nice, thank you |
| 00:50 | espringe | how did you find it? |
| 00:50 | ibdknox | espringe: 1.3.0 will give you *much* better error messages |
| 00:51 | ibdknox | ran it in a 1.3 repl :) and saw where it blew up |
| 00:51 | espringe | ibdknox: oh sweet, i'll give that a go. That's been my #1 pain point so far |
| 00:51 | espringe | in 1.2 the _only_ useful information is the filename |
| 00:51 | ibdknox | espringe: yeah 1.2's error messages were rough. 1.3's are a lot better, but there still tons of room for improvement. I think there were a couple patches in Jira somewhere for better defn error messages |
| 00:52 | ibdknox | they might've gone into the 1.4alphas |
| 00:52 | espringe | ibdknox: You know of a simple example of someone using multimethods to decompose a dynamically-typed AST? (I'm looking at cljs atm, but it's a bit overwhelming) |
| 00:52 | technomancy | sritchie: never heard of that myself. I assume it's not snapshots? |
| 00:53 | ibdknox | technomancy: it's the same thing happening to me. I've ruled out plugins and it happens on 1.7 |
| 00:53 | technomancy | sritchie: would be interested in seeing if you can repro on lein 2 from git master |
| 00:54 | tomoj | how do you test a source checkout? |
| 00:54 | tomoj | (of lein) |
| 00:54 | technomancy | espringe: try clj-stacktrace; it gives way more helpful messages |
| 00:54 | technomancy | tomoj: see "building" in the readme on master; you need 1.x to bootstrap it right now |
| 00:54 | ibdknox | espringe: korma sort of does it (http://github.com/ibdknox/korma). Ambrose's DSL article does too: http://pragprog.com/magazines/2011-07/growing-a-dsl-with-clojure |
| 00:54 | muhoo | ibdknox: sritchie: os specific? |
| 00:55 | ibdknox | sritchie: you on OS X? |
| 00:55 | espringe | ibdknox: thanks |
| 00:55 | sritchie | yup, OS X Lion |
| 00:55 | ibdknox | same |
| 00:55 | sritchie | technomancy: I can try that out tomorrow |
| 00:55 | espringe | technomancy: is that for just pretty-printing stack traces, or it gives better ones as well? |
| 00:55 | technomancy | espringe: it colorizes frames from clojure internals and java differently |
| 00:56 | technomancy | sritchie: would be interested in hearing how lein2 works for you since it sounds like you have a pretty big codebase |
| 00:56 | technomancy | it should be usable at this stage but hasn't been widely tested |
| 00:56 | muhoo | that'd explain why you're getting "wfm"'s from the linux users :- |
| 00:56 | sritchie | technomancy: I've got a number of plugins, so it's time for me to try it out |
| 00:56 | sritchie | I love checkout deps, btw |
| 00:56 | technomancy | sweet |
| 00:57 | technomancy | sritchie: plugins are going to be the biggest sticking point for upgrading, but I'm trying to help out with upgrading the most commonly-used ones |
| 00:57 | ibdknox | I'm going to have a really cool demo for you guys tomorrow I think :D |
| 00:57 | sritchie | nice |
| 00:57 | muhoo | so the lein-deps-melts-the-cpu problem seems isolated to osx lion? |
| 00:57 | sritchie | interesting, it seems like that might be the case |
| 00:57 | technomancy | the top 10 plugins are lein2 compatible |
| 00:58 | sritchie | gotta run for now, guys, but ibdknox, I'm glad we spoke up on this :) |
| 00:58 | technomancy | according to a mostly unscientific ranking somewhat based on clojuresphere data |
| 00:58 | tomoj | hmm, I get https://gist.github.com/197712ab7da69da50931 trying to run lein2 |
| 00:58 | ibdknox | sritchie: indeed! Ttyl sir |
| 00:58 | technomancy | yeah I need to head off too |
| 00:58 | espringe | technomancy: another stupid question, does lein support scala (as in, an all-scala project)? |
| 00:58 | sritchie | espringe: that's a good question, actually, I'm interesting in creating jars from scala projects |
| 00:59 | sritchie | lein-scalac is quite nice |
| 00:59 | technomancy | tomoj: that indicates you're using clojure 1.2 |
| 00:59 | technomancy | tomoj: oh, maybe clear out lib/ in the lein checkout? |
| 00:59 | technomancy | espringe: theoretically it should work, but I have no idea if it's practical |
| 01:00 | tomoj | yeah, deleted and recloned lein checkout, and it's fine |
| 01:00 | technomancy | great; would love to hear feedback |
| 01:01 | technomancy | tomoj: found the erronous lib/ inclusion in bin/lein; will get rid of that |
| 01:01 | muhoo | technomancy: sounds like you have an os-specific bug in lein. |
| 01:01 | technomancy | muhoo: oh, I have plenty |
| 01:01 | tomoj | muhoo: I'm on ubuntu |
| 01:01 | technomancy | most of them are for winders, but it's no surprise that mackosecks has a few too |
| 01:02 | xeqi | I think its more dep file size related |
| 01:02 | muhoo | why would that be? different jvm versions? |
| 01:02 | ibdknox | woah now. Them be fightin' words. |
| 01:02 | xeqi | I can see a >2 sec change on a ubuntu vm from 1.6.1.1 to 1.6.2 |
| 01:04 | technomancy | the first thing to ask is whether you are running deps because you have to or because you think you have to. |
| 01:04 | muhoo | or because you're on the bleediing edge doing cljs and al the deps are snapshots? |
| 01:04 | tomoj | does deps call clean? |
| 01:05 | amalloy | with checksum-deps, is there ever a time when you have to? |
| 01:06 | technomancy | amalloy: only to pull in new snapshots if you're not using checkout deps |
| 01:06 | technomancy | otherwise it's a bug in lein |
| 01:07 | tomoj | `lein clean` on this project took 1m42s, `lein2 clean` took 2.2s |
| 01:07 | espringe | ibdknox: Thanks for those earlier links, they're kick ass and helping immensely |
| 01:07 | technomancy | holy smokes |
| 01:07 | ibdknox | espringe: np :) |
| 01:08 | amalloy | the only time i've had lein take a long time is when it's transitively AOT-compiling a bunch of stuff i don't want. perhaps it accidentally does that pre-clean? |
| 01:08 | technomancy | clean has no eval-in-project |
| 01:08 | amalloy | i'm going to pretend you said "nope, that's not it" |
| 01:09 | xeqi | tomoj: can you do LEIN_JVM_OPTS=-verbose-gc for those? |
| 01:09 | xeqi | err |
| 01:09 | xeqi | LEIN_JVM_OPTS=-verbose:gc |
| 01:11 | daaku | i'm trying to get ac-slime working (have clojure-mode, auto-complete and ac-slime installed via el-get and swank-clojure 1.4.0 globally installed) and i'm getting a java.lang.ClassNotFoundException when auto completing in the repl -- here's a screenshot of the state: http://postimage.org/image/o1ds4gejr/ |
| 01:11 | tomoj | xeqi: https://gist.github.com/ec7e2d7114d0014d8d74 |
| 01:11 | tomoj | lots more like that |
| 01:11 | daaku | seems similar to the issue described to be fixed in this: https://github.com/purcell/swank-clojure/commit/7172c275f390c59d0b532ec3dc2994b2b9f72167 -- but seems like maybe-resolve-sym should be handling it in the 1.4.0 branch |
| 01:13 | tomoj | bisecting.. |
| 01:16 | tomoj | hmm |
| 01:17 | tomoj | git-bisect doesn't seem to want to help find out where the bug was fixed |
| 01:17 | tomoj | oh well |
| 01:20 | xeqi | is there a public project that you guys have the slowdown on? |
| 01:31 | muhoo | what does a double-colon mean? i.e. ::foo ? |
| 01:38 | juhu_chapa | what is @def? |
| 01:40 | espringe | I have this as a multi-method dispatch. This works great, except I want it to match any integer, not just 34. What's the way to doing it? |
| 01:40 | espringe | (defmethod emit-llvm-type |
| 01:40 | espringe | [:int 34] [_] (str 'i 34)) |
| 01:40 | espringe | Like how do i make the condition a function or something? |
| 01:42 | muhoo | espringe: (class foo?) |
| 01:43 | espringe | muhoo: There's no better way? That really sucks, as I'll now need to nest multimethods inside each other :/ |
| 01:44 | espringe | Surely there's a way to not specify a dispatch value, but a dispatch-function ? |
| 01:44 | muhoo | look at the source of defmethod? |
| 01:47 | jedahu | macro problem |
| 01:48 | jedahu | (defmacro foo [& body] `(let [a# 9] (macrolet [(~'bar [] `(+ 1 ~a#))] ~@body))) |
| 01:48 | jedahu | (foo (bar)) |
| 01:48 | jedahu | => Compiler exception |
| 01:48 | jedahu | java.lang.InstantiationException |
| 01:49 | jedahu | any ideas? |
| 01:51 | muhoo | jedahu: wfm |
| 01:51 | jedahu | muhoo: ? |
| 01:52 | muhoo | works for me. i ran your defmacro in clj 1.3.0 and it gave no error |
| 01:52 | muhoo | i've no idea what it's supposed to DO, but it didn't error |
| 01:53 | jedahu | muhoo: did you run (foo (bar)) ? |
| 01:53 | jedahu | the defmacro works fine for me too |
| 02:07 | duck1123 | Is there something written already for parsing http link headers? "<http://example.com>; rel=\"alternate\"; type=\"application/atom+xml\"" |
| 02:08 | duck1123 | If not, is there a better way than trying to write a regexp to parse that? |
| 02:20 | muhoo | duck1123: enlive? but there may be something less heavyweight |
| 02:21 | muhoo | jedahu: i tried (foo "bar"), but there's no macrolet definition |
| 02:21 | muhoo | maybe macrolet is where the problem is? |
| 02:21 | jedahu | muhoo: you will need to :use clojure.tools.macro |
| 02:22 | jedahu | which is here: https://github.com/clojure/tools.macro |
| 02:29 | callen | (split-at (/ (count (into (first (split-at (/ (count (vec poss)) 2) (vec poss))) (reverse (flatten (cons (last (first (split-at (/ (count (vec poss)) 2) (vec poss)))) (rest (split-at (/ (count (vec poss)) 2) (vec poss)))))))) 2) (count (into (first (split-at (/ (count (vec poss)) 2) (vec poss))) (reverse (flatten (cons (last (first (split-at (/ (count (vec poss)) 2) (vec poss)))) (rest (split-at (/ (count (vec poss)) 2) (vec poss))))))))) |
| 02:29 | callen | I do believe this code has gotten out of hand. |
| 02:31 | callen | espringe: this is some of the worst code I've ever written |
| 02:32 | callen | espringe: I am enjoying this more than I can express. |
| 02:32 | callen | espringe: if you're wondering how one reaches this point, the answer is over-reliance on REPL-driven-development over Hammock-D-D. |
| 02:33 | espringe | callen: rofl, i was thinking it was machine generated ;D |
| 02:33 | espringe | or at least, macro generated |
| 02:34 | espringe | Search my code for the largest amount of sequential closing braces, i have found: |
| 02:34 | espringe | ]]]]])) |
| 02:35 | muhoo | callen: looks like the throw-arity stuff in potempkin |
| 02:35 | callen | espringe: no that's home-grown insanity. |
| 02:35 | callen | muhoo: just seeing if I can out-do Tellman on the depths of madness. |
| 02:35 | callen | muhoo: I felt like impressing a Perlist I guess. |
| 02:35 | muhoo | so far the ugliest thing i've seen today has to be the regexp from youtube-dl |
| 02:36 | muhoo | though, that's not a clojure thing |
| 02:36 | callen | muhoo: Clojure isn't idiomatic to my brain yet, I'm still trying to crack it like I have Python. |
| 02:36 | callen | muhoo: doing 4clojure to fix my brain. |
| 02:36 | callen | I'm still getting used to the "transformation" style. |
| 02:36 | callen | I need to use more let bindings. |
| 02:37 | muhoo | funny, i'm reading docs and code for mundane stuff, and finally almost understandnig the functional way to wrap stuff, i.e. ring middleware |
| 02:38 | muhoo | callen: i have to wonder what that vec-poss business would look like indented |
| 02:38 | espringe | When i get more time, i'll write a utility to search through a project and find the deepest nested s-expr. I wonder what major clojure project will win |
| 02:39 | callen | muhoo: well. I could just screenshare and you could watch this madness take form. |
| 02:39 | callen | muhoo: it's already cleaned up a lot because I added a particularly choice let binding or two. |
| 02:39 | callen | muhoo: I've got an emacs split between repl and the indented form. |
| 02:42 | muhoo | go ahead, refheap it |
| 02:43 | muhoo | espringe: i did a quick search in emacs, and found some files with 20 closing parentheses |
| 02:43 | muhoo | and a huge number with >10 closing parentheses |
| 02:43 | muhoo | in a row |
| 02:44 | muhoo | that's in EMACS, not in clojure |
| 02:44 | espringe | That makes my 6-in-a-row seem very unimpressive |
| 02:44 | espringe | In your emacs code, or in emacs itself? |
| 02:44 | muhoo | i do believe rhickey explicitly set out to make such insanity unnecessary, even difficult |
| 02:44 | muhoo | no, this was in emacs source code |
| 02:44 | muhoo | //usr/lib/emacs |
| 02:45 | muhoo | because someone on #emacs was chiding me, telling me that if i had more than 5 levels of nesting then may code was broken |
| 02:45 | callen | tbqh, I write cleaner elisp than Clojure right now. |
| 02:45 | callen | and cleaner clisp |
| 02:45 | callen | I'm not used to clj yet. |
| 02:45 | callen | refheap forthcoming. |
| 02:46 | muhoo | so i said, "oh yeah?" and pasted a list off file sin emacs itself that had like 10 or more closing parens in a row |
| 02:46 | amalloy | 5 is an absurd limit |
| 02:46 | callen | muhoo: https://refheap.com/paste/861 scroll to see the madness grow. |
| 02:46 | amalloy | you can start to worry at 14 or something |
| 02:46 | callen | well with indentation, it scarcely matters. |
| 02:47 | amalloy | what does indentation have to do with this? |
| 02:47 | callen | amalloy: check out that refheap paste, you may enjoy that. |
| 02:47 | callen | amalloy: my ugly code led to this conversation. |
| 02:48 | muhoo | lol Evaluation aborted |
| 02:49 | callen | muhoo: don't make fun of me :( |
| 02:50 | muhoo | not at all |
| 02:51 | callen | I have a working example now. |
| 02:51 | muhoo | so you're writing a function to reverse the characters? |
| 02:52 | callen | muhoo: https://refheap.com/paste/862 |
| 02:52 | callen | muhoo: no, palindrome predicate |
| 02:52 | callen | muhoo: anyway, seems to work for odds-n-evens now. |
| 02:52 | callen | going to test it @ 4clojure. |
| 02:52 | muhoo | istr there's some kind of pop/push business which works in opposite directions on vectors vs lists |
| 02:53 | muhoo | for reverseing thins |
| 02:53 | callen | reversing isn't really the tricky part |
| 02:53 | callen | I'm just calling reverse. |
| 02:57 | callen | muhoo: pretty awful eh? :P |
| 02:58 | callen | the code works locally, but 4clojure seems to be failing. |
| 02:58 | callen | amalloy: You failed the unit tests |
| 02:58 | callen | wait. |
| 02:58 | callen | I might be an idiot. |
| 02:58 | callen | jfsdnerg |
| 03:18 | muhoo | oh cagwd |
| 03:18 | muhoo | there is some function in clojure that will return true if ALL of the elements in the collection are true |
| 03:18 | muhoo | it had a nice name like "all", but there doesn't appear to be an "all" function |
| 03:18 | callen | muhoo: whatsit? |
| 03:19 | muhoo | i read it in the "joy of clojure" book or in one of the dozens of blogs i've read. i have no idea. |
| 03:19 | muhoo | alzheimer's has struck me early. |
| 03:20 | callen | muhoo: every? |
| 03:21 | callen | muhoo: http://clojuredocs.org/clojure_core/clojure.core/every_q |
| 03:21 | muhoo | ya |
| 03:21 | muhoo | every |
| 03:21 | callen | muhoo: you're welcome. |
| 03:23 | muhoo | thanks |
| 03:33 | amalloy | so callen, are you an idiot? |
| 03:33 | amalloy | or was 4clojure broken? |
| 03:34 | callen | amalloy: I'm an idiot. |
| 03:34 | callen | amalloy: fixing my code. |
| 03:36 | callen | to my credit, I did make a function that passes the test |
| 03:37 | callen | it's lunacy. Really fat series of sequential let bindings |
| 03:38 | callen | https://refheap.com/paste/863 worst. code. ever. |
| 03:38 | amalloy | callen: are you aware you can follow people on 4clojure and see their solutions once you've solved a problem? it would help you see less-awful-mess sorts of answers |
| 03:39 | callen | amalloy: sure, most of my answers are as short as yours. |
| 03:39 | Raynes | What does that function do? |
| 03:39 | callen | amalloy: I followed that madness to its conclusion even though I knew to compare the reverse to itself after being seq'd |
| 03:39 | callen | amalloy: I just wanted to force myself to learn how to abuse the shit out of it. |
| 03:39 | callen | Raynes: palindrone predicate. |
| 03:39 | Raynes | Holy shit. |
| 03:39 | callen | Raynes: I'm aware of #(= (reverse %) (seq %)) |
| 03:40 | callen | Raynes: but I wanted to try madness. |
| 03:40 | muhoo | callen: i got a surprise for you |
| 03:40 | muhoo | hang on |
| 03:40 | aperiodic | that's kind of awesome |
| 03:40 | amalloy | (comp (partial apply =) (juxt reverse seq)) ;; who needs variable names |
| 03:40 | callen | aperiodic: I'm glad you appreciate my objective here. |
| 03:40 | callen | amalloy: points-free? |
| 03:41 | amalloy | usually just point-free |
| 03:41 | aperiodic | one of my recent objectives has been to try to be more point free |
| 03:41 | callen | I really enjoy writing horrible code too much. |
| 03:41 | callen | I should stop that, haha. :) |
| 03:41 | aperiodic | mainly because i remember seeing some nice point-free haskell |
| 03:41 | callen | you should see what I've made in Python. |
| 03:41 | muhoo | ah crap, man you guys totally toasted me. |
| 03:41 | aperiodic | as long as you can keep it under control |
| 03:42 | callen | I've done some absurd one-liners with list comprehensions, map, filter, and reduce. |
| 03:42 | muhoo | i'd got it down to 3 lines and thought i'd accomplished something. |
| 03:42 | callen | aperiodic: well it's not something I put in production, I just indulge this source of amusement when I'm futzing around. |
| 03:42 | amalloy | aperiodic: point-free clojure can be nice, but haskell really does take the cake; our syntax frequently leads to fairly bad point-free code |
| 03:42 | muhoo | and it looks like you can do it in like one line, 3 functions. faaaack. |
| 03:43 | tjgillies | what version of node is clojurescript developed against? |
| 03:43 | Raynes | I'm not convinced they actually test that things work with node. |
| 03:44 | amalloy | Raynes: the cljs devs, or the node devs? |
| 03:44 | Raynes | ~rimshot |
| 03:44 | clojurebot | Badum, *tish* |
| 03:44 | aperiodic | amalloy: it may be amatuerish, but i do feel burdened by the parens sometimes |
| 03:44 | tjgillies | lol |
| 03:44 | aperiodic | amalloy: whereas $ and . are very succinct |
| 03:44 | amalloy | yep |
| 03:44 | muhoo | i thought they developed against rhino |
| 03:44 | callen | tjgillies: hey I have some code to show you. |
| 03:45 | tjgillies | callen: yay |
| 03:45 | amalloy | $google clojure github hiredman functional |
| 03:45 | lazybot | [hiredman/clojurebot - GitHub] https://github.com/hiredman/clojurebot |
| 03:45 | callen | tjgillies: https://refheap.com/paste/864 When you understand the zen of Clojure, you'll be able to write stuff like that! |
| 03:45 | amalloy | hmph |
| 03:46 | muhoo | i think it's the same kind of zen that, back in the 90s, causd my friends and i to voluntarily watch a marathon of "styx kilroy was here" and "kiss vs the phantom of the park" |
| 03:46 | tjgillies | callen: when i understand the zen of clojure im going to take over the world |
| 03:46 | callen | muhoo: similar, yes! |
| 03:46 | aperiodic | so, somehow, i'm having trouble finding lein2 |
| 03:47 | amalloy | aperiodic: https://github.com/hiredman/odds-and-ends/blob/master/functional.clj is not something i'd really recommend, but it's a good example of what you can do with lisp to mimic haskell |
| 03:48 | amalloy | (scroll to the bottom to see what he's getting at) |
| 03:50 | aperiodic | amalloy: ooh, i really like the flip operator |
| 03:50 | muhoo | god damn i suck |
| 03:51 | aperiodic | so, is uncurry needed to get haskell-style function chaining to work with variadic clojure fns? |
| 03:52 | muhoo | callen: you with this palindrome thing.... i've spent a half hour on it now |
| 03:52 | aperiodic | i'm not familiar with that operator |
| 03:52 | muhoo | and it'll take me another 2 to understand how the correct solution, this partial apply juxt reverse seq business, actually works |
| 03:53 | aperiodic | muhoo: the partial apply juxt reverse seq is really quite simple |
| 03:54 | aperiodic | i mean, you're just asserting that the seq (phrase) is equal to its reverse |
| 03:54 | muhoo | suuuuure it is :-) |
| 03:54 | aperiodic | which is remarkably like the definition of a palindrome |
| 03:55 | muhoo | i should show you the lameness i came up with. once i finish it. |
| 03:55 | aperiodic | don't mean to come of harsh or condescending :) |
| 03:55 | muhoo | that's ok, i don't mean to sound clueless and stupid either :-) |
| 03:58 | amalloy | aperiodic: you can't get haskell's currying with varargs |
| 03:59 | amalloy | you have to be very clear about how many args every function takes, in an expression, in order to have the automated curry/partialing |
| 03:59 | muhoo | i ended up with this: (every? identity (map #(= %1 %2) (seq p) (reverse p))) |
| 04:00 | amalloy | (every? true? (map = p (reverse p))) is a less verbose way to write the same idea |
| 04:00 | nybbles | hm could someone familiar with aleph please tell me why for some urls, the :body in @(http-request {:method :get :url some-url }) is a channel and for other urls, it's a TruncatedChannelBuffer? |
| 04:03 | aperiodic | amalloy: yeah, i knew that was too good to be true. found the hoogle definition |
| 04:03 | amalloy | aperiodic: of what? |
| 04:03 | aperiodic | amalloy: the uncurry thing |
| 04:05 | muhoo | maybe what rhickey is going to announce at clj west is a haskell that runs on the jvm |
| 04:10 | callen | muhoo: you're still trying to unroll my palindrone predicate? |
| 04:12 | callen | muhoo: you have no idea how much it pleases me to know I've nerd-sniped you into grotesque horror. |
| 04:15 | muhoo | callen: worse than that. it took that long for me to produce my own one-liner, which i shared above |
| 04:16 | muhoo | and now i'm trying to understand the other one-liners, the ones with juxt/partial/comp |
| 04:21 | callen | muhoo: have you unrolled mine yet? |
| 04:34 | muhoo | gad no |
| 04:34 | muhoo | i did come up with a very tight oneliner though |
| 04:34 | muhoo | taking the one someone posted above, and shaving it down a bit |
| 04:35 | muhoo | removed the partial and the comp |
| 04:35 | muhoo | (defn palindrome? [p] (apply = ((juxt reverse seq) p))) |
| 04:35 | callen | muhoo: no no, it's not fun if you don't trace the horror. |
| 04:36 | muhoo | seriously dude? i have deal with php and java for a living |
| 04:36 | muhoo | i have MORE than enough horror, thank you |
| 04:36 | muhoo | tracing the horror is what i have to do to survive. when i'm not being paid, no horror if i can avoid it. |
| 04:38 | callen | muhoo: d'aww. Just having some fun. |
| 04:38 | callen | muhoo: I still say #(= (reverse %) (seq %)) is the most elegant. |
| 04:38 | muhoo | yeah, i'm going to try that one next |
| 04:39 | muhoo | yep, it is, i agree. |
| 04:40 | muhoo | tightest yet |
| 04:41 | callen | muhoo: that's the initial answer I came up with, but I decided I want to see how far I could go with a rube goldbergian answer. |
| 04:41 | callen | with a bunch of unnecessary transforms. |
| 04:42 | muhoo | where i went wrong was in not remembering that you can check equality of a sequence without iterating over it |
| 04:42 | muhoo | so i was doing stupid stuff with list comprehensions and doseq and that lot |
| 04:42 | callen | muhoo: ouch. |
| 04:42 | AimHere | What's the idiomatic clojure way of applying 'and' or 'or' to the contents of a collection? 'apply' and 'every?' and 'reduce' don't like taking on macros, and something like (reduce #(and %1 %2) ...) looks awful to me |
| 04:43 | callen | muhoo: you could use (every? ...) but there's not much point. |
| 04:43 | muhoo | finally narrowed it down to that map business, then i got schooled about the juxt thing |
| 04:43 | muhoo | yeah, i ended up with every which is as far as i got on my own. the conceptual error was iterating |
| 04:43 | muhoo | (= (reverse p) (seq p)) states it so much more clearly |
| 04:43 | callen | AimHere: I don't know what you mean by 'and' and 'or', but if you want to apply a given operation to all the contents of a collection, you're usually thinking of a map or an apply. |
| 04:44 | callen | muhoo: I don't mind %() |
| 04:44 | callen | muhoo: it's composable. |
| 04:44 | AimHere | I mean the logic operations 'and' or 'or'. Which aren't functions, they're macros, so apply and map won't take them |
| 04:44 | callen | AimHere: I need a concrete example of what you're trying to accomplish. |
| 04:44 | callen | AimHere: what you're saying doesn't make sense man. |
| 04:44 | callen | AimHere: can you paste it at refheap.com? |
| 04:45 | AimHere | Well I'd like something like (foo and [true true true false ...]) to return the logical and of all the stuff in the vector |
| 04:45 | muhoo | AimHere: ahaa! every? |
| 04:45 | AimHere | Ordinarily 'apply' would do the job just fine |
| 04:46 | AimHere | Every? doesn't work |
| 04:46 | AimHere | I've taken to something like "(fn [p v] (eval (list* 'a v))" at the moment only macroified, |
| 04:47 | muhoo | &(every? identity [ true true true false]) |
| 04:47 | lazybot | ⇒ false |
| 04:48 | muhoo | &(every? identity [ true true true true]) |
| 04:48 | lazybot | ⇒ true |
| 04:49 | AimHere | Heh, well that's and. Now I'll have to find 'any?' or a synonym for or |
| 04:49 | callen | clojure.contrib could use some expansion on the text-processing front. |
| 04:49 | callen | I may come up with something to contribute. |
| 04:49 | muhoo | AimHere: http://clojure.org/cheatsheet |
| 04:50 | AimHere | Saved me hunting for the bookmark |
| 04:50 | muhoo | &(some identity [ true true true true]) |
| 04:50 | lazybot | ⇒ true |
| 04:50 | AimHere | &(some identity [true false false false]) |
| 04:50 | lazybot | ⇒ true |
| 04:50 | muhoo | &(some identity [ false false false]) |
| 04:50 | lazybot | ⇒ nil |
| 04:51 | muhoo | &(some identity [ false false false]) |
| 04:51 | lazybot | ⇒ nil |
| 04:51 | muhoo | yyeah, like that |
| 04:51 | muhoo | callen: you know that clojure.contrib is depreciated, right? |
| 04:52 | callen | muhoo: I heard something to that effect, what's going on exactly? |
| 04:52 | AimHere | Of course, this doesn't work for writing my own boolean logical predicate macros, but I'm sure I'll work that out if I need to |
| 04:52 | callen | AimHere: I bet there's a macro (app) for that. |
| 04:53 | muhoo | callen: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go |
| 04:53 | muhoo | ~contrib |
| 04:53 | clojurebot | Monolithic clojure.contrib has been split up in favor of smaller, actually-maintained libs. Transition notes here: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go |
| 04:53 | AimHere | For passing generic boolean pred macros into the contents of a list? I don't think so |
| 04:54 | muhoo | i'm new, but i can't see a reason to make it a macro. why not a function? |
| 04:55 | AimHere | Because you want it to stop evaluating the arguments once it's decided it knows what the answer is |
| 04:55 | Lajla | Greetings my brethren |
| 04:55 | Lajla | I am the best programmer in the world second only to the Microsoft Chief Software Architect |
| 04:55 | AimHere | &(or true (println "This never happens)) |
| 04:55 | lazybot | java.lang.RuntimeException: EOF while reading string |
| 04:56 | AimHere | &(or true (println "This doesn't happen even if I stringify it properly")) |
| 04:56 | lazybot | ⇒ true |
| 04:56 | muhoo | side effects of or, eh? |
| 04:56 | callen | hrm. |
| 04:56 | AimHere | Not really, it's working as intended. |
| 04:56 | callen | muhoo: how open are they to ruby-esque shortcut functions in clojure.string? |
| 04:56 | clojurebot | Huh? |
| 04:57 | callen | muhoo: I'm wondering if there's a demand for predicates like upper-case? and lower-case? |
| 04:57 | muhoo | callen: i haven't a clue. ask on mailing list? |
| 04:57 | muhoo | wait |
| 04:57 | callen | muhoo: the objective being to avoid duplication of effort. |
| 04:57 | callen | muhoo: what? |
| 04:57 | muhoo | &(.toUpperCase "fuu") |
| 04:57 | lazybot | ⇒ "FUU" |
| 04:57 | muhoo | like that? |
| 04:57 | callen | no, predicate. |
| 04:58 | callen | the ? means predicate. |
| 04:58 | callen | upper-case already exists. |
| 04:58 | muhoo | ah, yes. i dunno then. |
| 04:58 | callen | (upper-case? \A) => true |
| 04:58 | callen | (upper-case? \a) => false |
| 04:58 | callen | (filter upper-case? "HeLlO") => "HLO" |
| 04:58 | callen | muhoo: see nao? |
| 04:59 | muhoo | i'd say, why not write a library that does that stuff, put it up on github, ???? .. profit! |
| 04:59 | callen | muhoo: these are things that need to be in core to be useful. |
| 04:59 | callen | muhoo: elimination of duplication of effort. |
| 04:59 | muhoo | i dunno. sounds like a mailing list questino to me |
| 05:00 | muhoo | if yoou want duplicatino of effort, how many oauth libraries are there for clojure now |
| 05:00 | callen | er. I'm just trying to build simple foundational stuff for core |
| 05:00 | callen | Not boil the ocean and lob it into core |
| 05:00 | callen | oauth stuff would be *completely* inappropriate. |
| 05:01 | muhoo | i have no authority, so i can't even guess. but the core people do read the mailing list |
| 05:01 | muhoo | i doubt any are here |
| 05:02 | callen | I'll formulate some type-hinted functions that I think would be handy and see what they say. I doubt they want to waste any time discussing hypotheticals. |
| 05:03 | muhoo | good point. |
| 05:05 | callen | I already have the lower? and upper? ones written, I'll peruse the ruby-docs and see what other ideas I can steal for Clojure. |
| 05:11 | stevelknievel | Hi all. Trying to build tools.nrepl and mvn can't find "clojure:jar:1.4.0-master-SNAPSHOT". Which repository am I missing? |
| 05:11 | Raynes | muhoo: As far as I know there is only one oauth library... |
| 05:17 | callen | Raynes: how much do you know behind the culture for contributing to core? |
| 05:17 | Raynes | Not much. |
| 05:18 | callen | Raynes: could you take a guess at how warm they'd be to the idea of more common-case helper functions/predicates/transforms in String.clj? |
| 05:18 | callen | stuff like you get with Ruby/Python/etc |
| 05:19 | Raynes | If the things are useful and not already in java.lang.String, then you've got a shot. You'd really have to start a mailing list thread about it. This involves sending Rich Hickey a signed CA and then asking for membership to the clojure-dev group. |
| 05:20 | callen | Raynes: I'm okay with that. I'll check for duplication in Java-land and proceed from there. Thanks. |
| 05:21 | callen | yeah, my ideas aren't in java.lang.String |
| 05:25 | Raynes | $max |
| 05:25 | Raynes | $load max |
| 05:25 | lazybot | Loaded. |
| 05:25 | Raynes | $max |
| 05:25 | lazybot | The most users ever in #clojure is 376 |
| 05:30 | callen | wait, I'm retarded, it exists in Character |
| 05:30 | callen | fml. |
| 06:52 | jamii | Who are the moderators for the clojure google group? |
| 06:55 | callen | jamii: soup? |
| 06:56 | jamii | callen: is that a name? |
| 06:57 | callen | jamii: no, wondering what's up. |
| 06:58 | jamii | callen: oh, my post seems to have been deleted. I wondered if I did something wrong |
| 06:58 | callen | jamii: are you positive that's the case? Google Groups is known for being a bit off. What was the post about? |
| 06:59 | jamii | callen: subject was "Crowdfunding an open-source clojure library for p2p NAT traversal, dynamic addressing and pubsub" |
| 07:00 | callen | yeah. no. |
| 07:00 | callen | that sounds like advertisement/bullshit to me. |
| 07:00 | callen | either make it or don't. |
| 07:00 | callen | don't try to busk for "crowdfunds" |
| 07:00 | callen | no wonder they deleted it, haha. |
| 07:01 | jamii | Fair enough |
| 07:02 | callen | jamii: I would advise not simply rewording it and reposting |
| 07:02 | callen | jamii: either make it or not, if you do make it, post about it and ask if anybody wants to contribute. Fin. |
| 07:02 | jamii | callen: I wasn't intending to repost |
| 07:03 | callen | jus' sayin' |
| 07:07 | jamii | callen: The content of the post was that I'm planning to post this as a small project on indiegogo and I was asking for feedback on the protocol. At the moment I work on this sort of stuff anyway and fund it with freelance work. I'm just wondering if funding it more directly is feasible. |
| 07:08 | callen | jamii: don't ever ask for money on the mailing list. |
| 07:08 | callen | jamii: it's never appropriate to do that. |
| 07:09 | jamii | callen: sure |
| 07:15 | lnostdal_ | deftype redefinitions and isa? https://refheap.com/paste/865 .. how do you guys deal with this? .. i like doing some run-time type checking, but... |
| 07:16 | callen | lnostdal_: you redfined it |
| 07:16 | callen | redefined* |
| 07:16 | wiseen | is there any particular reason why core.match doesn't have something like (fnmatch [case-a] (exp) ...) where fnmatch would be a macro that generates a function that pattern matches arguments ? |
| 07:16 | wiseen | or am I missing that macro ? |
| 07:16 | lnostdal_ | yeah, i can see how that would be ok in some sense .. but other times some "slack" right there is needed |
| 07:19 | lnostdal_ | (= (str (class -blah-)) (str Blah)) => true ;; though .. but, hm, not exactly the same as isa? with regards to subtypes |
| 07:31 | __deo` | I want to make a async request for each item in a list and wait until a callback is called for the current req until making the next. |
| 07:32 | __deo` | cant figure it out |
| 08:07 | callen | No matching field found: indexOf for class java.lang.String |
| 08:07 | callen | caused by user> (.indexOf "Leroy") |
| 08:07 | callen | which is pure lunacy. |
| 08:08 | callen | how can't it find the method indexOf for the string? |
| 08:12 | dedeibel | Any ideas? http://stackoverflow.com/questions/9453117/has-anyone-a-case-implementation-for-clojurescript |
| 08:14 | callen | dedeibel: would it kill you to implement it yourself? |
| 08:14 | callen | I guess I don't see what the problem is :\ |
| 08:15 | bsteuber | (defmacro case [& args] `(condp = ~@args)) |
| 08:15 | morphling | callen: indexOf takes two arguments |
| 08:16 | bsteuber | dedeibel: or just use condp for now |
| 08:16 | bsteuber | I'm sure it will be added to cljs |
| 08:16 | callen | morphling: hrm. Staying up all night appears to have driven me mad. Good clal. |
| 08:16 | callen | Good call* |
| 08:17 | dedeibel | bsteuber: thx |
| 08:18 | dedeibel | Well there is an easy olution and one that is fast and everyone could benefit from |
| 08:18 | dedeibel | *solution |
| 08:23 | LauJensen | So, everybody going to the EuroClojure event? |
| 08:27 | bsteuber | LauJensen: maybe.. |
| 09:59 | gtrak | what's the best way to run arbitrary clojure code remotely these days? possibly secure? |
| 10:00 | gtrak | I'm thinking of creating a http-client that registers itself with a server, then the server calls stuff on it |
| 10:04 | gtrak | the idea being that the server has all the code, but no state, the client is a dumb stateful thing |
| 10:08 | trptcolin | so the server remotely executes code on the clients? |
| 10:08 | gtrak | yea |
| 10:08 | gtrak | the client keeps a persistent connection |
| 10:08 | gtrak | one use-case, I want to put up source code to the site on github, but keep sensitive configuration locally, or run a db locally |
| 10:10 | trptcolin | not sure i follow how that use case motivates that execution context, but maybe the "client" could run an nrepl server. |
| 10:11 | gtrak | well, the server has a public IP, my local box doesn't :-) |
| 10:12 | trptcolin | oh, ok, so this isn't about remote-executing on *many* clients, it's more of a work-delegation thing? |
| 10:12 | gtrak | yea |
| 10:12 | gtrak | though I suppose there are use cases I haven't thought of that make sense for multiple clients |
| 10:13 | gtrak | like a distributed computing grid |
| 10:18 | gtrak | I found this: https://github.com/nakkaya/net-eval/blob/master/src/net_eval.clj maybe I can adapt it |
| 10:25 | gtrak | actually, I can get rid of one use case, is there a safe clj reader that just allows literals? |
| 10:27 | gtrak | found it, clj-config |
| 11:11 | miner49r | ,(doc sequence) |
| 11:12 | clojurebot | Execution Timed Out |
| 11:45 | twhume | Anyone up for answering a newbie-q? |
| 11:46 | AimHere | That's not how IRC works. Just blurt the question out into the ether, and ghostly voices may, or may not reply |
| 11:47 | AimHere | Asking to ask is considered silly |
| 11:48 | twhume | OK… I'm trying to rewrite this to use a short-form anonymous function passed to map: |
| 11:48 | twhume | (defn digest [input] |
| 11:48 | twhume | "Parses an input block of text and returns a sequence of name/number pairs, each of which indicates a word from the input and the confidence of its importance" |
| 11:48 | twhume | (let [words (str/split input #"\s") ] |
| 11:48 | twhume | (into {} (map (fn[key] [key (count (filter #{key} words))] ) words)) |
| 11:48 | twhume | )) |
| 11:49 | twhume | I thought it'd be (into {} (map #([% (count (filter #{%} words))]) words)) … but no. |
| 11:49 | AimHere | Well for future reference, I suggest pastebinning anything that's more than one line of code |
| 11:50 | stuartsierra | #([ is wrong. It's like trying to invoke the vector. |
| 11:50 | stuartsierra | See http://dev.clojure.org/display/doc/FAQ under "Syntax" |
| 11:51 | twhume | Thanks stuart :) |
| 11:51 | stuartsierra | twhume: 'welcome |
| 12:07 | TimMc | technomancy: Huh, I wonder why the nix package manager isn't in the Ubuntu repos. |
| 12:29 | dnolen | Started a Clojure GSoC 2012 project ideas page - http://dev.clojure.org/display/community/Google+Summer+of+Code+2012 |
| 13:05 | cran1988 | hi!!! how to run a thread with time limit ? |
| 13:05 | cran1988 | for example to run a thread for 5 sec only |
| 13:06 | lucian | cran1988: it's not possible to stop a thread from another thread reliably, in general |
| 13:08 | cran1988 | lucian: so i can not say (thread (run-something) 5000) where 5000 is 5 seconds |
| 13:09 | lucian | cran1988: as i said, not reliably. there's thread interruption APIs, but they don't always work |
| 13:09 | raek | cran1988: it is possible to force a thread to stop, but there are issues: http://docs.oracle.com/javase/1.4.2/docs/guide/misc/threadPrimitiveDeprecation.html |
| 13:09 | lucian | that's generally something only possible with processes |
| 13:10 | cran1988 | (thank-you!) |
| 13:10 | lucian | although if what you're trying is a time-limited sandbox, you could conceivably have the sandbox make sure it would be relatively safe for it to be killed |
| 13:11 | cran1988 | sandbox sounds good |
| 13:12 | lucian | what are you trying to build? |
| 13:15 | cran1988 | i try to run jetty-server only in a specific time |
| 13:15 | ibdknox | jetty has a shutdown functio |
| 13:15 | ibdknox | n |
| 13:15 | ibdknox | just call that from another thread after n-seconds |
| 13:17 | cran1988 | yes you are right ... now i am imagine it using Thread/sleep |
| 13:17 | ibdknox | no |
| 13:17 | ibdknox | just use a Timer |
| 13:17 | cran1988 | Timer ? |
| 13:18 | ibdknox | http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Timer.html |
| 13:19 | cran1988 | it looks great thanks!! |
| 13:26 | clj_newb | Hi can I obtain an InputStream out of a String? |
| 13:27 | clj_newb | I'm trying to parse xml, but I have a String (as I can see in (class var)) but xml/parse keeps looking for a File called like the content of the xml string |
| 13:28 | rlb | clj_newb: http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/with-in-str |
| 13:28 | rlb | perhaps? |
| 13:28 | raek | clj_newb: if the API you are using acceps Readers (text streams), you can use a StringReader |
| 13:29 | raek | if you really need an InputStream (binary data stream), convert the String into a byte array and create a ByteArrayInputStream |
| 13:29 | raek | (StringReader. "foo bar") |
| 13:29 | clj_newb | I tried (parse (with-in-str var)) but does not work and also the (input-stream var) |
| 13:30 | gtrak | is there a way to treat environment variables as a map? |
| 13:30 | raek | (ByteArrayInputStream. (.getBytes "foo bar" "UTF-8")) |
| 13:31 | rlb | ahh, right. |
| 13:32 | clj_newb | thanks raek |
| 13:33 | gtrak | oh yea, system.getenv() returns a map |
| 13:34 | vijaykiran | (into {} (System/getenv)) |
| 13:34 | gtrak | yup, just found it :-), beautiful |
| 13:35 | gtrak | ,(into {} (System/getenv)) |
| 13:35 | clojurebot | #<AccessControlException java.security.AccessControlException: access denied (java.lang.RuntimePermission getenv.*)> |
| 13:35 | gtrak | &(into {} (System/getenv)) |
| 13:35 | lazybot | java.security.AccessControlException: access denied (java.lang.RuntimePermission getenv.*) |
| 13:35 | vijaykiran | the bot java.policy is different, I guess :) |
| 13:36 | cran1988 | are there any good examples for scaling clojure ? |
| 13:36 | sritchie | cran1988: scaling in what sense? |
| 13:36 | vijaykiran | what you mean by scaling ? |
| 13:36 | cran1988 | the same way the web administrators do |
| 13:37 | vijaykiran | scaling clojure web applications ? |
| 13:37 | cran1988 | yes |
| 13:37 | vijaykiran | depends on type of app you build - I guess. |
| 13:38 | sritchie | cran1988: yeah, people toss around the term "scale" a lot -- |
| 13:38 | sritchie | better to talk about # of machines, or requests per second, or something that can be benchmarked |
| 13:39 | sritchie | here's a nice post by dnolen on benchmarking aleph: http://dosync.posterous.com/22516635 |
| 13:39 | gtrak | infinite requests/(machine*seconds) |
| 13:40 | cran1988 | thanks , i am checking it now ... |
| 13:40 | lucian | web requests are an embarrassingly parallel problem. the only hard bit is the data store |
| 13:41 | clj_newb | raek: it worked, thank you! But is there any clojure-only way to do it ? wondering |
| 13:42 | cran1988 | so i should use a NoSQL server ? |
| 13:43 | lucian | that benchmark is stupid |
| 13:43 | lucian | just don't worry about it for now, make your app first |
| 13:43 | vijaykiran | cran1988: there's no one single answer - as I said, it always depends on what kind of application you are trying to build |
| 13:43 | lucian | and use postgres if sql fits |
| 13:44 | cran1988 | yes postgres i am using ... ok thanks , i understand |
| 13:58 | cran1988 | can i ask something ? every object that i create in repl , stay alives for how long ? can i destroy an object in the repl ? |
| 13:59 | cran1988 | i think i ask to much |
| 13:59 | lucian | cran1988: why would you care? |
| 13:59 | lucian | it stays alive as long as there's a reference to it |
| 13:59 | cran1988 | for fun |
| 14:00 | cran1988 | i thought lisp is just an OS :D and objects are programs |
| 14:03 | lucian | some early lisps were similar to what one might call an OS nowadays |
| 14:03 | lucian | clojure objects are at some point jvm objects |
| 14:04 | scriptor | cran1988: but otherwise, clojure and most other modern lisps are just regular programming languages, objects you create in the repl reside in the memory given to that repl |
| 14:04 | cran1988 | yeah , jvm does not give control over objects |
| 14:05 | scriptor | cran1988: what do you mean? |
| 14:06 | cran1988 | the Object Class does not have a method to destroy itself |
| 14:06 | lucian | why would it? |
| 14:06 | lucian | just don't reference it, the gc will clean it up |
| 14:06 | scriptor | that method is only needed when something *extra* needs to be done when the jvm destroys it |
| 14:07 | lucian | and there are finalizers, but they're rarely useful (and the way they're implemented in the jvm makes them problematic) |
| 14:08 | ferd | What's more idiomatic?: (:key mymap) or: (mymap :key) |
| 14:08 | cran1988 | hm... its ok ... clojure is great , i was just checking how far it can go. |
| 14:08 | lucian | ferd: from what i've seen, neither. whichever feels better |
| 14:09 | dnolen | ferd: (:key map) |
| 14:09 | rlb | (and in many cases, relying on a destructor can be "wrong" (in any language) -- i.e. closing files, for example) |
| 14:09 | scriptor | cran1988: how far did you want it to go? A repl is basically like python's interactive prompt or ruby's irb |
| 14:10 | ferd | thanks |
| 14:10 | cran1988 | i want clojure repl goes even far than python and ruby. In my mind , I have SBCL and Factor |
| 14:10 | dnolen | ferd: field/property access is generally of that form - (.field object) and (.-property object) in CLJS |
| 14:11 | scriptor | cran1988: what can SBCL's repl do that clojure's can't? I'm curious about this |
| 14:12 | scriptor | I know factor's repl has some neat tricks related to reloading code |
| 14:13 | ferd | dnolen: I "feel" more confortable with (:key map)... But (map :key) makes more sense if I have to explain why it works :-) |
| 14:13 | pipeline | i was honestly unaware until now that clojure didn't support reloading running code |
| 14:13 | dnolen | ,(nil :key) |
| 14:13 | dnolen | ,(:key nil) |
| 14:13 | clojurebot | nil |
| 14:13 | clojurebot | #<CompilerException java.lang.IllegalArgumentException: Can't call nil, compiling:(NO_SOURCE_PATH:0)> |
| 14:14 | dnolen | ,(nil :key) |
| 14:14 | clojurebot | #<CompilerException java.lang.IllegalArgumentException: Can't call nil, compiling:(NO_SOURCE_PATH:0)> |
| 14:14 | dnolen | ferd: also you should consider this ^ |
| 14:14 | cran1988 | scriptor: not only that , in Lisp you control the gc for real |
| 14:14 | lucian | pipeline: it kinda does |
| 14:15 | ferd | dnolen: good point |
| 14:15 | lucian | pipeline: the same way java supports it |
| 14:15 | pipeline | http://travis-whitton.blogspot.com/2009/09/hot-code-swapping-with-clojure.html |
| 14:19 | callen | Serious question, is it normal for 4Clojure to make you feel stupid/frustrated? I feel like I could come up with the answer an order of magnitude faster in a different language sometimes. |
| 14:19 | callen | I don't think my brain has fully enveloped immutable FP yet. |
| 14:20 | lucian | callen: i feel the same, often |
| 14:20 | callen | well my concern is that I'll never shake the feeling |
| 14:20 | lucian | i doubt it, there was a time when i had trouble with while loops |
| 14:20 | callen | if I can't shake that feeling and inability to avoid getting stuck like that, it's difficult for me to justify using the language. |
| 14:20 | dnolen | callen: I now feel the opposite |
| 14:21 | callen | I don't think I want the opposite either, I have to interact with code I haven't written on a regular basis. I guess I'm wondering if there's a way to fix my brain, and if the way of fixing it is to keep going with 4Clojure. |
| 14:21 | lucian | i've sometimes written it in python iteratively, then rewritten in python functionally, then clojure/scheme |
| 14:22 | callen | I have 44 problems solved on 4Clojure and I still feel like a fricking idiot. |
| 14:22 | lucian | callen: SICP appears to help me, give it a try |
| 14:22 | callen | nono, I've done SICP Scheme before |
| 14:22 | lucian | then? |
| 14:22 | callen | you tell me chief. I'm having the same friction with Clojure that I had with haskell. |
| 14:22 | callen | I didn't have this with CLisp or Scheme. |
| 14:23 | dnolen | callen: I don't personally find working on 4Clojure a useful way to understand the ins/outs the language |
| 14:23 | lucian | clisp i can see, but scheme? it doesn't exactly encourage mutability |
| 14:23 | dnolen | I'd rather see how Clojure applies to common problems. |
| 14:24 | callen | lucian: admittedly, and I was more adept at CLisp than Scheme. |
| 14:24 | lucian | terrible stack traces and debuggers sucks too |
| 14:25 | callen | dnolen: well, I know I can play database fire brigade (my common day-to-day) with Clojure, but I want to try to push myself so that I know my limits. |
| 14:25 | callen | I'm wondering if I shouldn't go ahead and proceed with my idea for a side project (which is something that scratches an itch of technomancy's) and see how it goes. |
| 14:25 | scriptor | callen: what's the main issue you have, translating what you want into a functional style? |
| 14:26 | dnolen | callen: I'm not talking about talking to databases - commons tasks like manipulating data, modeling solutions |
| 14:26 | callen | scriptor: somewhat. It's worth remembering that my Python is functional as it is, but I fall back to mutation/reassignment from time to time and the inability to do so in Clojure is *BORKING* my head. |
| 14:27 | callen | scriptor: I've 44 questions done on 4Clojure, still feel like a moron. |
| 14:27 | gtrak | playing around with moustache, why does the ring map after having been routed not have a :url relative to root, and how would I get that? |
| 14:27 | scriptor | callen: hmm, I guess you could try redoing some of those questions and seeing if it's any easier this time around |
| 14:28 | callen | scriptor: well, I either come up with the answer in a few seconds |
| 14:28 | callen | scriptor: or I spend an inordinate amount of time on it. |
| 14:28 | callen | oftentimes because I don't know stuff like complement or tree-seq exists. |
| 14:29 | dnolen | callen: how long have you been writing Clojure? (also a well placed atom is a lovely thing) |
| 14:29 | callen | scriptor: the problem is that it feels "tricky" to me, like the questions on 4Clojure are impossible-feeling until I know some sort of trick/fold to it. |
| 14:29 | callen | dnolen: off-and-on for like a year. |
| 14:30 | callen | the problems on 4Clj feel brittle is the word I would use. They don't gradually unravel or break-apart like the things I do in Python. |
| 14:30 | scriptor | do many of the 4clojure problems need mutation? I thought most of them were doable without |
| 14:30 | callen | all of the ones I've done so far are doable without. |
| 14:31 | callen | I've not used a single mutable datatype so far. |
| 14:31 | callen | I think that's sorta the point, to understand how to do things immutably. |
| 14:31 | callen | the problem is that I find the process disheartening/discouraging and it's making me feel like I'm too stupid for the language/paradigm. |
| 14:31 | dnolen | callen: I find it strange that people rely on online resources for learning something the new - why not learn Clojure w/ a really good book on FP, rhickey's list of resources on Amazon is incredible |
| 14:32 | scriptor | I had the same issue with haskell in the beginning, the idea of declarative programming helped a lot |
| 14:32 | callen | dnolen: I purchased Fogus and Halloways books IIRC |
| 14:32 | callen | scriptor: I understand the concept. |
| 14:32 | callen | scriptor: if I didn't, I wouldn't have gotten 44 problems done. |
| 14:33 | tmciver | callen: FWIW, I feel similarly. I think a lot of the problems of 4clojure marked easy are not that easy. I'm not looking forward to the hard ones. |
| 14:33 | callen | scriptor: it's that the process of coming to an answer is too binary and makes me feel stupid until it suddenly unravels. |
| 14:33 | callen | tmciver: that's encouraging, thank you. |
| 14:33 | callen | sort of. |
| 14:33 | tmciver | dnolen: cool. I'll have to look into those resources myself. |
| 14:33 | callen | except for the part where I wonder where amalloy_'s head is. |
| 14:33 | callen | dnolen: btw, loved your talk on predicate dispatch if you're who I think you are. |
| 14:34 | dnolen | callen: I think 4Clojure is about puzzles not problems - I've also found that a good book on Haskell or Standard ML is a killer way to focus on functional thinking. |
| 14:34 | dnolen | callen: thx! |
| 14:34 | callen | dnolen: the problem is that I found OCaml and Haskell *agonizing* |
| 14:35 | callen | I own Programming in Haskell on Amazon, *shudders* |
| 14:35 | dnolen | callen: did you read a good book? (I think Real World Haskell stinks) |
| 14:35 | dnolen | callen: The Craft of Functional Programming (Haskell) is very good |
| 14:35 | callen | dnolen: supposedly PiH is the foremost book for plain ole programmers wanting to learn Haskell. |
| 14:35 | callen | dnolen: I find the *semantics* agonizing. |
| 14:36 | scriptor | lyah does a decent job at at least introducing FP's concepts and how to work with it |
| 14:36 | dnolen | callen: doesn't mean it doesn't stink, I hate books that don't start with programming. |
| 14:36 | dnolen | right away |
| 14:36 | tmciver | dnolen: I'd assume that it would be difficult to learn clojure with a book on ML or Haskell. |
| 14:36 | callen | I'm not new to FP, I'm new to trying to get things done with FP without having mutability available. |
| 14:36 | callen | I like the concept of transformation and threading immutable data through composed functions. |
| 14:36 | callen | you guys have to understand, I've been writing CLisp for literally half my life, as long as I have C. |
| 14:36 | lucian | i'm rewriting my first 4clojure solutions, they're tons shorter now :) |
| 14:36 | callen | it's not the FP, it's the immutability. |
| 14:37 | dnolen | tmciver: not really, a lot more of Clojure makes sense if you've read a book on Haskell/SML |
| 14:37 | callen | my default code doesn't mutate. |
| 14:37 | callen | dnolen: and I have, and I ran for the hills screaming :( |
| 14:37 | scriptor | tmciver: not really, once I learned enough of haskell learning clojure's syntax got me pretty far |
| 14:37 | tmciver | dnolen: Hmm, that's interesting. I've been thinking of learing Haskell anyway. |
| 14:37 | lucian | learn you a haskell for great good is interesting |
| 14:37 | dnolen | callen: find a better book |
| 14:37 | callen | I desperately want to use Clojure more regularly and I'm struggling. |
| 14:37 | tmciver | lucian: yeah, I've heard a lot of good about that book. |
| 14:37 | dnolen | if you having a hard time - often the teacher stinks |
| 14:38 | dnolen | 4Clojure is not a teacher, it's just disconnected puzzles |
| 14:38 | callen | it's helped me to learn a lot of core though. |
| 14:38 | callen | like tree-seq, mapcat, etc. |
| 14:38 | scriptor | lyah is pretty good, especially if you get to the part where it introduces how map/fold/filter/etc are implemented |
| 14:38 | scriptor | and instead of reading the implementations you try to write them yourself first |
| 14:38 | callen | I understand things like map, foldl, foldr, reduce, and filter just fine. |
| 14:39 | scriptor | callen: can you give a specific example where it's the immutability you had a problem with? |
| 14:39 | ferd | Exercise: Cleanest way to know of "map-y" is fully contained on "map-x"? My naive take: (every? #(= (get map-x %) (get map-y %)) (keys map-y) ) |
| 14:39 | callen | Most of the problems on 4Clj are trivial for me, but will totally gork me. Let me link an example. |
| 14:39 | callen | scriptor: I think I have an approach for this, but it took me far too long to come up with: http://www.4clojure.com/problem/30 |
| 14:40 | callen | my approach involves abusing .indexOf |
| 14:40 | callen | but I'm having a problem modeling the iteration in my head. |
| 14:40 | dnolen | callen: knowing about the various fns is less useful than understanding how to write useful programs w/o mutations - even better when you understand where mutation *simplifies* the problem. |
| 14:40 | callen | as well as the aggregation. |
| 14:41 | callen | dnolen: when/where is it appropriate to use mutation in Clojure? I felt like it was supposed to be avoided at almost all costs. |
| 14:41 | dnolen | callen: nope |
| 14:41 | callen | how does one do mutations if it's simply a mechanism for an algorithm or approach? var? |
| 14:42 | dnolen | callen: clojure.xml uses mutation, ClojureScript compiler uses mutation to simplify identifying loop/recur expressions |
| 14:42 | dnolen | when it makes sense to use state - use it. |
| 14:43 | callen | dnolen: since you're a contributor I thought I'd ask, how open are they to Ruby-esque helper-functions for strings that eliminate duplication of effort? |
| 14:43 | callen | dnolen: I wasn't certain how austere they wanted String.clj to be. |
| 14:44 | callen | in core that is. |
| 14:44 | Vinzent | callen, why do you need .indexOf? You can use e.g. (reduce (fn [[acc prev] new] ...)) |
| 14:44 | dnolen | callen: I think simple helper functions will have a hard time making it in. but you can try! |
| 14:44 | dnolen | callen: best to bring it up on the dev ML first |
| 14:44 | callen | of course. |
| 14:44 | callen | dnolen: is there a guiding document or something that describes what they prefer to see? |
| 14:45 | callen | I take it they don't want anything that they think most people can come up with themselves or isn't somehow foundational? |
| 14:45 | Vinzent | callen, also, if you really need mutation, you can use java arrays (see to-array, aset, etc) |
| 14:45 | dnolen | callen: pretty much. |
| 14:45 | callen | I'd rather not, I think my brain is just broken. |
| 14:45 | callen | Vinzent: I'm not totally sure where you're doing with that reduction :( |
| 14:46 | callen | I mean, I figured it was a reduction, (the answer to #30), but the devil is in the details. |
| 14:46 | callen | let me see what I can come up with. |
| 14:48 | dnolen | ferd: (every? #(= (% map-x) (% map-y)) (keys map-y)) |
| 14:49 | callen | Vinzent: can you tell me where you were going with that? :( |
| 14:50 | Vinzent | callen, yeah of coursr here is the code: https://gist.github.com/1918617 It's pretty common pattern to use reduce with accumulator instead of explicit loop\recur |
| 14:51 | Vinzent | hm, actually I don't need prev at all |
| 14:51 | callen | I find loop/recur awkward still, so I was trying to avoid it |
| 14:52 | callen | It may be that part of my problem is that I haven't developed this repertoire of methods like reduction with an accumulator and a threading macro. |
| 14:53 | callen | Vinzent: how'd you eliminate prev? |
| 14:53 | Vinzent | callen, I've gisted updated code |
| 14:54 | callen | Vinzent: thank you! |
| 14:55 | Vinzent | callen, yeah, it quickly becomes your second nature and you're starting using such things without even thinking about them |
| 14:55 | Vinzent | np, glad to help |
| 14:56 | callen | Vinzent: the problem is that my faculties for modeling the problems are limited because the way one generally uses FP in say, Python, is purely for simple one-dimensional threading/transformation of data. |
| 14:57 | callen | if you get my meaning. |
| 14:58 | scriptor | callen: since lacking the repertoire of knowing all the idioms is an issue, I think picking up a good book and start a decent-sized project might be the way to go |
| 14:58 | callen | scriptor: I agree on picking up a good book. the current project I have in mind might too easily allow me to dodge my limitations though. |
| 14:59 | scriptor | what's it involve? |
| 14:59 | callen | scriptor: I have Programming in Clojure 1st Ed and Joy of Clojure |
| 14:59 | callen | scriptor: it's conceptually just an IRC bouncer, but I want to build an IRC framework around it so that people can easily make things like IRC bots, clients, etc. |
| 15:00 | callen | scriptor: technomancy wanted one awhile back and I haven't delivered yet :( |
| 15:01 | scriptor | sounds like a good project, you might be putting too much emphasis on 4clojure itself |
| 15:01 | callen | I feel like I shouldn't by stymied so easily by 4Clojure. |
| 15:01 | callen | be* |
| 15:02 | callen | well. "easily", it's an 80/20 thing. 80% of the time, I breeeeze right through it, 20% of the time, I get stuck really badly. |
| 15:03 | sramsay | Question: Is there a way to take a system path string (e.g. /home/rhickie/foo/bar.txt) and turn it into a URL (file:///home/rhickie/foo/bar.txt)? |
| 15:03 | ferd | dnolen: Thanks. That's almost exactly like the my first take (except I used "get" hoping to make it clearer) |
| 15:03 | Vinzent | callen, yeah, it requires some time to get used to. You may want to try to translate some of your python code to clojure - i think it's a good exercise |
| 15:04 | callen | Vinzent: most of my Python code is pretty damn FP already, I'd just be rewriting the syntax. I have to find those painful edge cases to really bump into this. That's the usefulness of 4Clojure. |
| 15:05 | scriptor | callen: hmm, for both the irc project and translating python you've said that it'd be pretty easy, why not go ahead any see if it is ;) |
| 15:05 | callen | the tricky part of the IRC project isn't the lang or the immutability |
| 15:05 | callen | it's modeling the hand-offs |
| 15:05 | callen | that'd be a PITA in any language. |
| 15:05 | callen | it's basically a dispatch problem. |
| 15:06 | callen | I could model each client as an agent. |
| 15:09 | callen | thanks everyone for your advice and help. I'll start on my project and start working through another book. |
| 15:11 | jaley | I'm playing with writing a connect 4 AI in Clojure. Any recommendations on how to represent the board states? I was planning to just use a vector of vectors. Is there a better way? |
| 15:20 | gfredericks | jaley: that sounds decent |
| 15:20 | gfredericks | empty row == empty vector or vector with blank entries? |
| 15:21 | scriptor | probably blank entries |
| 15:21 | gfredericks | I like empty vector better, since in connect 4 you can only add to the end (top?) of a column |
| 15:21 | jaley | gfredericks: yeah - thinking blank enteries, so I can drop-while == :_ |
| 15:21 | gfredericks | so you have conj/pop, rather than assoc |
| 15:22 | gfredericks | I guess I shoulda said "column" instead of "row" |
| 15:22 | gfredericks | but I think it's all personal preference at this point |
| 15:23 | jaley | also, I don't think any choice of data structure here will make detecting wins simpler :/ |
| 15:23 | jaley | diagonals! |
| 15:23 | gfredericks | sure it will, if you use the data structure {:winning-moves [...], :losing-moves [...]}, then it's quite easy |
| 15:24 | jaley | oh... I was thinking of writing something like, (defn win? [board] ...) |
| 15:25 | gfredericks | yeah that works too |
| 15:25 | gfredericks | doesn't tell you what to do to win though |
| 15:25 | jaley | :-) |
| 15:25 | jaley | i'm sure the dots will work... |
| 15:26 | jaley | solutions are always sparse in clojure |
| 15:26 | gfredericks | I guess the most information is win/lose/draw and a move-count |
| 15:26 | gfredericks | or something like http://www.shredderchess.com/online-chess/online-databases/endgame-database.html |
| 15:37 | Bronsa | isn't there a way to have varargs using deftype? |
| 15:37 | gtrak | seriously contemplating writing yet another url parser/micro-router |
| 15:37 | gtrak | moustache is like 80% what I want but not quite |
| 15:39 | brehaut | gtrak: if you do, reversible routes would be my number one feature ontop of what moustache offers |
| 15:39 | gtrak | what's a reversible route? |
| 15:40 | brehaut | it lets you referenate a url from a route and a list of arguments |
| 15:40 | gfredericks | functions -> URLs? |
| 15:40 | gtrak | ah, interesting idea |
| 15:41 | brehaut | ive thought about adding it to moustache myself, but that code is quite complex ;) |
| 15:41 | gtrak | brehaut, yea, that's kind of the issue I'm having now, it expects the url path segments in a format that won't let me specify it just once |
| 15:41 | gtrak | so when I generate the links in my templates, there's no simple way to correlate it to the route |
| 15:41 | brehaut | ah sure |
| 15:41 | brehaut | yeah, i maintain some multimethods to reverse stuff in my code |
| 15:42 | brehaut | (but thats relatively easy because im using big blobs of couchdb data with :type tags) |
| 15:42 | gtrak | oh, I'm just tooling around on basic web stuff, writing my own framework, considering it as an opportunity for playing with core.match, though? |
| 15:43 | brehaut | i no idea sorry ;) |
| 15:44 | brehaut | if you could use core.match to make static routes that'd be pretty cool though |
| 15:44 | gtrak | it seems like it |
| 15:44 | brehaut | both moustache and compojure allow fall throughs, so theres an opening for something different |
| 15:45 | Raynes | cgrand doesn't write anything that human beings can comprehend. |
| 15:46 | gtrak | yea, that's nasty stuff |
| 15:46 | gtrak | I want something much simpler |
| 15:48 | gtrak | and core.match gives bindings already |
| 15:58 | gtrak | brehaut, for reversible routes, you'd need to define mappings that are truly invertible, is there any way to tell that an arbitrary mapping is equivalent to another? |
| 15:59 | brehaut | not in an arbitrary way i dont think? |
| 16:00 | gtrak | I think you can't do much better at the end of the day than passing a seq of the original url into the handler? |
| 16:01 | gtrak | and maybe provide some functions, like generate a url like the one I have, except change the third-from last path segment? |
| 16:02 | brehaut | if i were to write it ontop of what moustache provides |
| 16:02 | brehaut | id want a way to name routes, possibly as meta data? and a Reversible protocol |
| 16:03 | gtrak | I still don't quite get it, the point is to simplify route generation within the handler or downstream, yes? |
| 16:03 | brehaut | yeah |
| 16:04 | brehaut | django's got a reasonable implementation |
| 16:04 | gtrak | hmm |
| 16:04 | brehaut | but it leverages the fact that you can compare functions in python |
| 16:05 | gtrak | do you have a link? |
| 16:05 | brehaut | trying to find it |
| 16:05 | brehaut | djangos docs are comprehensive, but a bit of a pain to navigate |
| 16:06 | brehaut | https://docs.djangoproject.com/en/1.3/ref/templates/builtins/#url is probably the most useful examples of it in use (in the template language) |
| 16:06 | gtrak | wait... so is the generated url actually meaningful? |
| 16:07 | brehaut | yes |
| 16:08 | gtrak | ah, I see |
| 16:08 | gtrak | how does it know? |
| 16:08 | brehaut | https://docs.djangoproject.com/en/1.3/topics/http/urls/ |
| 16:08 | brehaut | thats the general url config docs; but i cant point you to a single useful point |
| 16:08 | gtrak | i did a little bit of django once, it was way too magical for me |
| 16:08 | brehaut | https://docs.djangoproject.com/en/1.3/topics/http/urls/#reverse just tells you the same stuff as url does |
| 16:09 | brehaut | i have many grumbles about django ;) |
| 16:09 | brehaut | urls are the part that i would complain about the least |
| 16:09 | ibdknox | have you guys heard of Noir? I hear it's less a lot more straightforward than django ;) |
| 16:09 | ibdknox | confusion abounds |
| 16:09 | brehaut | ibdknox: too much ceremony! raw ring for life |
| 16:10 | gtrak | ibdknox, do you use it? ;-) |
| 16:10 | ibdknox | gtrak: I've been experimenting with it. Still reserving my judgement until I really dig in |
| 16:10 | gtrak | i hope the vim's not slowing you down too much |
| 16:10 | ibdknox | I'm very close to a killer CLJS demo |
| 16:11 | ibdknox | I have Bret Victor's modify a game while it's running thing basically done |
| 16:11 | ibdknox | in cljs :D |
| 16:11 | gtrak | awesome |
| 16:11 | ibdknox | getting the cljs compiler to play nicely in real-time was interesting |
| 16:12 | dnolen | ibdknox: always working on the cool stuff |
| 16:13 | ibdknox | dnolen: well.. I've been working from sun up to sun down the past couple weeks, I needed to do something fun :) |
| 16:14 | ibdknox | the whole thing ended up being surprisingly simple |
| 16:15 | ibdknox | I think even the projecting time into space thing is pretty easy. haven't done that part yet |
| 16:15 | bbloom | Just yesterday I came up with something that seems to work for cljs & vim relatively nicely |
| 16:15 | dnolen | ibdknox: you going to demo this @ ClojureWest? |
| 16:16 | ibdknox | bbloom: oh? |
| 16:16 | bbloom | here's what i do: |
| 16:16 | bbloom | https://github.com/franks42/lein-repls |
| 16:16 | ibdknox | dnolen: I was going to write a blog post about it tonight :) |
| 16:16 | bbloom | run two terminals |
| 16:16 | bbloom | both in tmux |
| 16:16 | bbloom | in one, i run lien repls |
| 16:16 | bbloom | in the other i run cljsh |
| 16:17 | bbloom | so they share an environment |
| 16:17 | bbloom | then i open two macvims |
| 16:17 | bbloom | one in my clj directory |
| 16:17 | bbloom | and one in the cljs directory |
| 16:17 | bbloom | src/clj and src/cljs that is |
| 16:17 | bbloom | then i use vim-tslime |
| 16:17 | bbloom | one per vim for each of the tmux sessions |
| 16:17 | dnolen | ibdknox: sweet |
| 16:18 | ibdknox | dnolen: with a little video and the code so people can mess around with it, or at the very least see it |
| 16:18 | dnolen | bbloom: also probably worth a blog post, not enuf CLJS workflow info out there. |
| 16:18 | dnolen | ibdknox: ! |
| 16:18 | bbloom | this results in a 4-way split screen with a server/macro terminal & vim; and a terminal/vim client side terminal |
| 16:18 | ibdknox | since it's CLJS, which has to compile putting it on a website probably won't work.. the latency would kill the changes as you type bit of it |
| 16:19 | bbloom | dnolen: ok,maybe I'll write it up later — where is best to help people find such an article? post it on mailing list? |
| 16:20 | ibdknox | dnolen: I will say though, it is ridiculous amounts of fun. He was right about this being a much better experience |
| 16:20 | dnolen | bbloom: yes, also perhaps worth linking to from the ClojureScript wiki |
| 16:21 | bbloom | good call |
| 16:21 | bbloom | would really like to see more work done on networked repls in the core clojure stuff |
| 16:21 | bbloom | ability to fork repls |
| 16:21 | bbloom | multiplex them |
| 16:21 | bbloom | etc |
| 16:22 | bbloom | i'd love to send a form from vim to multiple simultaneous browsers |
| 16:22 | bbloom | stuff like that |
| 16:22 | dnolen | bbloom: brenton ashworth is working on that feature for CLJS |
| 16:22 | bbloom | awesome. |
| 16:22 | bbloom | link? |
| 16:23 | dnolen | bbloom: I'm sure he could use help, https://github.com/clojure/clojurescript/tree/multi-browser-repl |
| 16:23 | dnolen | bbloom: if you haven't sent in your CA, you should, and then pitch in :) |
| 16:24 | bbloom | dnolen: I'm a registered contributor now :-) |
| 16:24 | bbloom | still need to push harder on the Var work for cljs I did…. I'm finding them useful, but I don't have a demo ready yet... |
| 16:24 | octagon | hello clojure! i'm new, and trying to figure out some of the basics of functional programming. i feel like i should be able to define this function, (defn collect [f] (comp f vector)), without using defn, and only by composition of higher order functions. example usage ((collect (partial reduce +)) 1 1 1) => 3 |
| 16:24 | bbloom | brb |
| 16:27 | gfredericks | octagon: is there a more motivating use case for this? your thing there is can obviously just be (reduce + [1 1 1]), since the arguments are given explicitly... |
| 16:28 | gfredericks | or are you just trying to play around with point-free expressions? |
| 16:28 | octagon | gfredericks: yes, i feel like i'm missing some important concept here |
| 16:29 | gfredericks | what makes you think that? what made you think of this "collect" function? |
| 16:29 | octagon | gfredericks: well i'm trying to understand which of the higher order functions are the real fundamentals |
| 16:30 | octagon | gfredericks: and which ones can be built just by composing those fundamentals |
| 16:30 | gfredericks | oh man; that sounds messy |
| 16:31 | octagon | gfredericks: so collect is just an example of binding stuff out of order |
| 16:31 | gfredericks | like a reversed partial? |
| 16:32 | octagon | gfredericks: i considered this (defn applyto [args f] (apply f args)) |
| 16:32 | octagon | gfredericks: but it didn't turn out to be completely useful in this case |
| 16:32 | octagon | gfredericks: you know using (partial applyto ...) |
| 16:33 | octagon | gfredericks: i have a "partiar" btw |
| 16:33 | gfredericks | I guess I still don't quite understand the way you're approaching it, but I'm sure we could change your original defn to be point-free just for the fun of it... |
| 16:34 | octagon | gfredericks: point-free, i didn't know that term |
| 16:35 | gfredericks | (def collect (comp (partial apply comp) reverse (partial list vector))) |
| 16:35 | gfredericks | octagon: point-free means not using function literals, I believe |
| 16:35 | gfredericks | or locals in general |
| 16:36 | octagon | gfredericks: yes, and google comes up with all kinds of interesting things that refrerence the term |
| 16:36 | gfredericks | I think. |
| 16:36 | gfredericks | octagon: it seems to be what you're trying to play around with |
| 16:36 | octagon | gfredericks: totally, thanks for that |
| 16:37 | gfredericks | sure |
| 16:39 | octagon | is there any discussion of the design tradeoffs involved with using varargs like clojure does? |
| 16:50 | mdeboard | So I'm using type dispatch in a multimethod (https://github.com/mattdeboard/clj-solr/blob/master/src/clj_solr/core.clj#L6) because I don't know how to dispatch based on arity, and haven't been able to find any examples of arity dispatch. How would I go about doing this? |
| 16:50 | gfredericks | you can't (defmulti foo (fn [& args] (count args)))? |
| 16:50 | mdeboard | gfredericks: Oh. |
| 16:50 | gfredericks | (defmulti foo (comp count list)) also |
| 16:51 | brehaut | i wonder if theres much difference between list and (fn [& args] args) |
| 16:51 | gfredericks | mdeboard: so you want it extensible? just providing different function definitions doesn't work? |
| 16:51 | mdeboard | gfredericks: My objective is to capture arity cases `[foo & kwargs]` and `[& kwargs]` |
| 16:52 | gfredericks | mdeboard: how do you recognize a foo? |
| 16:52 | mdeboard | which I can't do with e.g. `(defn foo ([foo & kwargs] stuff) ([& kwargs] stuff))` |
| 16:52 | brehaut | ,(first (apply (fn [& args] args) (range))) |
| 16:52 | clojurebot | 0 |
| 16:52 | brehaut | ,(first (apply list (range))) |
| 16:52 | clojurebot | Execution Timed Out |
| 16:54 | gfredericks | mdeboard: so all you want is an optional first argument? |
| 16:54 | mdeboard | gfredericks: Well, to be specific about my example, the signature for the (filter) function would be either `[my-node :param1 val :param2 :val]` or just `[:param1 val :param2 val]` |
| 16:54 | mdeboard | right |
| 16:54 | gfredericks | mdeboard: you have a default value for when it's missing? |
| 16:56 | mdeboard | gfredericks: If it's missing, it just returns a hash-map of the args. If the optional first argument is missing, it inserts a node as a sibling to the optional first argument. |
| 16:56 | mdeboard | "...inserts a node composed of a hash-map of the args as a..." |
| 16:58 | mdeboard | That sounds kind of dumb now that I've typed it out. |
| 16:58 | gfredericks | yeah I don't think there would be built in support for this kind of thing because there's no default way to tell if the first arg is there; but if you supply a first-arg-recognizer you could make a simple enough HOF for this... |
| 16:58 | mdeboard | HOF? |
| 16:58 | clojurebot | HOF is Higher-Order Function |
| 16:58 | mdeboard | ah |
| 16:58 | mdeboard | gotcha |
| 16:59 | mdeboard | type dispatch it is. |
| 16:59 | gfredericks | :/ |
| 16:59 | mdeboard | :P |
| 16:59 | mdeboard | I think I'm just going about this dumb. |
| 16:59 | technomancy | callen: I think 4clojure is designed to be frustrating in a way |
| 17:00 | callen | technomancy: you're telling me, I spent last night pissing blood until I passed out at 6 am. |
| 17:00 | gfredericks | is it unidiomatic to use multimethods that aren't intended to be extended? |
| 17:00 | technomancy | it's trying to tie your hands behind your back and force you into a corner so you have to learn something new to break through |
| 17:00 | mdeboard | callen: I... I don't think that was 4clojure. |
| 17:00 | technomancy | hah |
| 17:00 | technomancy | callen: anyway, I wouldn't beat your head against it; it's probably healthy to vary between that and something more practical |
| 17:01 | technomancy | gfredericks: I wouldn't say that |
| 17:01 | callen | technomancy: my ulcer thanks you. I'm getting back on that IRC bouncer. |
| 17:01 | technomancy | callen: no pressure though! |
| 17:01 | callen | technomancy: startup life hijacked my soul. |
| 17:01 | gfredericks | technomancy: doesn't it unnecessarily break up a function's definition? |
| 17:01 | callen | technomancy: sure, but I want to make something that is of use to you, you've made a kajillion things that the community depends on. |
| 17:02 | gfredericks | seems kind of messy :/ |
| 17:02 | gfredericks | at least wrt code structure |
| 17:03 | technomancy | gfredericks: you mean it's not intended to be extended outside your own code base or it's not intended to be extended beyond a single dispatch value? |
| 17:04 | mdeboard | gfredericks: Well, my foray into multimethods was just to do *something* with them since I'd not used them before. I wrote one that works but I don't like how the methods return different types of things. |
| 17:04 | mdeboard | s/works/does what I wanted |
| 17:06 | gfredericks | technomancy: a small fixed set of dispatch values. So no reason for anyone else or even myself to extend it |
| 17:06 | technomancy | sounds like simple polymorphism to me |
| 17:06 | gfredericks | :/ |
| 17:07 | gfredericks | maybe I don't mean anything |
| 17:11 | pipeline | whover pointed out 4clojure is a pretty awesome dude |
| 17:11 | gfredericks | only one-third as awesome as whoever made 4clojure |
| 17:11 | callen | pipeline: you're welcome? |
| 17:12 | callen | pipeline: thank amalloy |
| 17:12 | mdeboard | pipeline: Warning, 4clojure will apparently make you piss blood |
| 17:12 | bbloom | dnolen: https://github.com/clojure/clojurescript/wiki/Vim |
| 17:12 | Raynes | amalloy didn't start 4Clojure. |
| 17:12 | mdeboard | callen: What problem exsanguinated you |
| 17:12 | Raynes | That would be dbyrne, wherever he is. |
| 17:12 | mdeboard | He's in my basement |
| 17:12 | callen | Raynes: I saw his commit. name names if you like. |
| 17:12 | bbloom | ibdknox: youu too |
| 17:13 | bbloom | hopefully that will help cljs vim users out :-) |
| 17:13 | cemerick | mdeboard: thank you for 'exsanguinated' :-) |
| 17:13 | amalloy | yeah, that's today's word of the day |
| 17:13 | mdeboard | cemerick: Triple word score |
| 17:13 | callen | mdeboard: I'm 44 problems in. I've breezed through 80% of the problems, and gotten rather stuck on 20%. A recent sticker is: http://www.4clojure.com/problem/30 but someone showed me how to do with a reduce + accumulator pattern. |
| 17:13 | mdeboard | oh yeah |
| 17:13 | callen | mdeboard: it doesn't help that I'm not awful comfortable with loop/recur yet. |
| 17:20 | mdeboard | callen: Something that helped me when I was on a 4clojure marathon last weekend was learning about `partition-by`, `group-by` and `mapcat` . I used some formulation of those three (with `apply` and `reduce` sprinkled in here and there) for several solutions. |
| 17:22 | callen | mdeboard: tree-seq and complement saved my arse last night too. |
| 17:22 | callen | I'll add those to my "contemplate deeply" list. |
| 17:22 | callen | mdeboard: thank you. |
| 17:22 | mdeboard | for the flatten re-implementation? |
| 17:22 | technomancy | tree-seq is sublime |
| 17:22 | callen | mdeboard: yes. |
| 17:22 | mdeboard | I cheated and looked at the flatten source for that problem :P |
| 17:22 | Raynes | technomancy: text 2 |
| 17:22 | callen | I accidentally re-implemented, then re-discovered tree-seq. |
| 17:27 | ivan | this may interest anyone backing up blip.tv https://github.com/ivankozik/youtube-dl/commit/801531e66a4a47d1c739ee93c77c1e6a73f6bacb |
| 17:27 | ivan | funny how the source videos are sometimes 3x smaller than the default .flv |
| 17:28 | mdeboard | technomancy: Why sublime? What about it blows you away? |
| 17:30 | technomancy | mdeboard: it's just such a high level of abstraction just sitting there |
| 17:30 | technomancy | I think everyone coming to Clojure would expect to have to write it themselves |
| 17:31 | octagon | gfredericks: hey, thanks again. i found this excellent paper that describes exactly the thing i was trying to understand http://www.stanford.edu/class/cs242/readings/backus.pdf |
| 17:36 | amalloy | my most recent use of tree-seq was to find the largest number in a structure like {:a {:p [1 9 10] :q 4} :b [6]} with arbitrary nesting. tree-seq is so great for that |
| 17:36 | ivan | does this work for traversing directory trees? |
| 17:36 | amalloy | it works for anything you want. all the interesting bits are pluggable with functions |
| 17:37 | ivan | heh, I should have read one defn below and seen file-seq |
| 17:37 | nybbles | hey I'm reading through some lamina code - what does "^{:pipeline pipeline}" mean? seems like a general clojure thingie, it's in the body of a let |
| 17:37 | nybbles | i mean.. syntactically |
| 17:37 | ivan | nybbles: metadata |
| 17:38 | callen | nybbles: it's short for (meta ...) |
| 17:38 | callen | nybbles: they're tagging it. |
| 17:39 | nybbles | ivan, callen: ah ok cool thanks, didn't expect it in the middle of a function |
| 17:39 | amalloy | "it's short for (meta ...)" is totally wrong, though |
| 17:39 | mheld | hey y'all |
| 17:40 | callen | amalloy: well fuck. correct me. :( |
| 17:40 | callen | nybbles: don't listen to me. |
| 17:40 | dnolen | callen: with-meta |
| 17:41 | amalloy | it's *close* to being shorthand for with-meta |
| 17:41 | nybbles | haha, ok, i figured as much :) |
| 17:41 | amalloy | but it's really read-time metadata, which is not the same thing as runtime metadata |
| 17:41 | callen | I was basing it on what I saw on the cheatsheet. |
| 17:41 | callen | it said ^form is (meta form) |
| 17:41 | callen | so that's why I misunderstood. |
| 17:42 | nybbles | amalloy: so the stuff in "^{}" will not show up in a function call to (meta.. ) with the tagged thing? |
| 17:42 | amalloy | that was probably true in clojure 1.0 or 1.1 or something, but it isn't anymore |
| 17:42 | amalloy | nybbles: try it |
| 17:42 | nybbles | ok :P |
| 17:43 | amalloy | &(meta ^{:x 1} (map inc [])) |
| 17:43 | lazybot | ⇒ nil |
| 17:43 | callen | now I am seriously worried I've missed something critical. :| |
| 17:43 | amalloy | naw. it's just that clojure.org never updates :P |
| 17:44 | callen | amalloy: is the site on github? |
| 17:44 | callen | amalloy: if so, one could make a pull request or something. |
| 17:44 | amalloy | don't we all wish |
| 17:45 | callen | amalloy: is it worth proposing on the mailing list?> |
| 17:47 | technomancy | might as well mention it; just don't expect a response |
| 17:47 | amalloy | i suppose it's possible rich would let the website have a looser rein than the language |
| 17:47 | nybbles | hm |
| 17:48 | nybbles | &(meta (with-meta {} {:x 1})) |
| 17:48 | lazybot | ⇒ {:x 1} |
| 17:48 | nybbles | ok that makes sense |
| 17:48 | nybbles | &(meta ^{:x 1} {}) |
| 17:48 | lazybot | ⇒ nil |
| 17:48 | nybbles | whaat |
| 17:48 | dnolen | callen: yes |
| 17:49 | nybbles | my clojure repl gives me: "{:x 1}" |
| 17:49 | nybbles | weird |
| 17:49 | technomancy | nybbles: smells like a lazybot bug |
| 17:50 | nybbles | technomancy: ok so the problem is with lazybot, so why is it that with (meta ^{:x 1} {}) i should expect {:x 1}, but.. |
| 17:50 | nybbles | &(meta ^{:x 1} (into {} [])) |
| 17:50 | lazybot | ⇒ nil |
| 17:51 | tjgillies | whats with symbols with asterisk, like *this* ? |
| 17:51 | dnolen | tjgillies: to denote vars that might be dynamically rebound |
| 17:51 | technomancy | nybbles: I think you're placing metadata on the into call |
| 17:51 | amalloy | IMO it's more of a bug in clojure that read-time metadata ever leaks out to runtime |
| 17:52 | technomancy | nybbles: that is, the metadata application happens in the reader before into is ever called |
| 17:53 | tjgillies | dnolen: by dynamically you mean by user or by program? |
| 17:53 | nybbles | technomancy: so why would the read-time metadata application be different for {} versus (into {} [])? |
| 17:53 | technomancy | nybbles: because {} evaluates to itself |
| 17:53 | technomancy | since it's a literal |
| 17:54 | technomancy | (into {} []) evaluates into a function call |
| 17:54 | technomancy | and you're placing metadata on the source code, not on the result |
| 17:56 | nybbles | technomancy: so does it fail to attach read-time metadata to the literal and then fallback to run-time metadata, and that's why the (meta..) call returns non-nil? |
| 17:56 | amalloy | no. it attaches read-time metadata to the source code, and then just returns the source code at runtime |
| 17:59 | nybbles | ok i understand that for the (meta ^{:x 1} (into {} [])) situation, but how does that work for the (meta ^{:x 1} {}) situation? why would i get back {:x 1}? |
| 17:59 | amalloy | that's what i just explained |
| 17:59 | amalloy | a literal evaluates to itself, so it just evaluates to the source code |
| 17:59 | amalloy | the source code is: {}, with metadata of {:x 1} |
| 18:00 | tjgillies | can i tap a repl into an already running environment? like in erlang, or do i need to start the repl first always? |
| 18:02 | weavejester | tjgillies: repl first, as far as I'm aware, though in theory it should be possible to make a library to inject a repl |
| 18:03 | nybbles | amalloy: oh i get it now, ok thanks |
| 18:04 | nybbles | theres a little section in Practical Clojure that's useful.. |
| 18:04 | nybbles | to understanding it |
| 18:04 | tmciver | amalloy: I'm confused by this meta stuff as well. For (meta ^{:x 1} (into {} [])), if metadata is being attached to the function call as technomancy says, why does that meta call return nil? |
| 18:04 | amalloy | it's not |
| 18:04 | amalloy | it's being attached to the source code for that function call |
| 18:04 | nybbles | i wasn't realizing that the form gets evaluated and goes away, and then the result does not have the source code |
| 18:05 | nybbles | arch i mean "the result does not have the metadata attached to it" |
| 18:05 | amalloy | the compiler has no use for that metadata, so it compiles a regular function call |
| 18:05 | nybbles | tmciver: it's being attached for the source code "(into {} [])" |
| 18:05 | tmciver | amalloy: it has no use for it so it removes it? |
| 18:06 | nybbles | with-meta is the call to attach it to the actual result of (into {} []) |
| 18:07 | nybbles | tmciver: http://t.co/xNQI5YPP |
| 18:07 | tmciver | nybbles: thanks. Looking. |
| 18:08 | tmciver | nybbles: that's one Clojure book I don't have. Do you like it? |
| 18:08 | nybbles | i don't have it either, but i like it now :) |
| 18:11 | tjgillies | hrm why doesn't leiningen create a default :main entry in project file? the majority of the time in my use cases it project_name.core |
| 18:11 | tjgillies | it's |
| 18:11 | amalloy | that assumes you want a :main at all. most of my clojure projects i don't bother |
| 18:11 | tjgillies | amalloy: how do you run them? |
| 18:12 | amalloy | repl, swank |
| 18:12 | tjgillies | ah, i thought that was just for debugging and exploratory didn't know people actually ran them that way |
| 18:13 | amalloy | when you're deploying into a production environment, sure, it's good to have a :main |
| 18:13 | amalloy | but almost all the time you spend with a project is exploring and debugging |
| 18:14 | gtrak | hmm, why wouldn't I be able to instantiate a record from another ns? I've :use'd the ns |
| 18:15 | ibdknox | gtrak: gotta import it |
| 18:15 | gtrak | ah |
| 18:15 | ferd | &(and (resolve 'IamUndefined) (var? #'IamUndefined)) |
| 18:15 | lazybot | java.lang.SecurityException: You tripped the alarm! resolve is bad! |
| 18:15 | dnolen | gtrak: IMO, better to use the provided ctor fns, or write your own. |
| 18:16 | gtrak | what's a provided one? |
| 18:16 | amalloy | only provided in 1.3+ |
| 18:17 | amalloy | but i agree that's true |
| 18:17 | amalloy | ferd: i suspect #'IamUndefined get looked up at compile-time, so the short-circuiting and won't protect you |
| 18:18 | gtrak | ah, I see there's a factory function |
| 18:18 | ferd | amalloy: thanks... What's a clean way to check if a var is defined and bound ? |
| 18:18 | tjgillies | im calling (clojure.main/repl) in a function and it outputs a repl prompt, but when i type a command it doesn't "do" anything |
| 18:18 | amalloy | well resolve gives you the var back |
| 18:18 | amalloy | just call bound? on that |
| 18:18 | tjgillies | using "lein run" to invoke |
| 18:18 | ferd | ahh... idiot |
| 18:19 | amalloy | but...this is a very questionable thing to be doing. why are you wondering whether a particular var is defined |
| 18:19 | ferd | I have a unit test that depends on some vars so me set (to load some fixture data) |
| 18:20 | ferd | if they are not set, I want to def them to some special values |
| 18:20 | ferd | the vars are normally set by the build environemnt... but when developing interactively, I want them to be automatically set to some values |
| 18:20 | ferd | am I clean ? |
| 18:20 | ferd | clear ? |
| 18:21 | amalloy | so why not just def them to the default values in source code, and then let the build env redefine them |
| 18:21 | amalloy | rather than not defining them at all |
| 18:22 | ferd | hmmm but if I def them in the test (with a value) it will overwrite whatever value the env defined :-\ |
| 18:24 | tjgillies | is there a convention for capitalizing hashmap keys? like :Foo vs :foo ? |
| 18:24 | ferd | amalloy: may be I can do something like: (do (def xxx) (if-not (bound? #'xxx) (def xxx "my-value"))) |
| 18:25 | ferd | amalloy: there's gotta be a cleaner way... Learning here. |
| 18:26 | choffstein | Hey all. I have a system design question with clojure. I am trying to provide an API for data and proprietary algorithm access. I am using aleph as my HTTP server, with redis and resque-clojure to fire off background jobs. My issue is, I don't know the right way to get the jobs BACK to the HTTP server, or how to keep the HTTP server from just sitting in a holding pattern (and possibly blocking, or worse, timing out?) on long |
| 18:26 | choffstein | tasks. My only thought was to theoretically associate a job UUID with each resque-clojure task, and just have my HTTP server poll redis over and over until the job is marked complete -- but that seems like overkill. My only other thought was maybe some sort of callback system using channels -- but I don't know if passing the channels over redis could even possibly work. Any ideas? |
| 18:26 | pipeline | mdeboard: I'm only on problem 24, so that's not really ar isk yet. |
| 18:26 | dnolen | tjgillies: Clojure doesn't generally capitalize anything - deftype/record/protocols are an exception in Clojure |
| 18:27 | dnolen | ferd: just provide default values - if you're going to rebind something, perhaps you want dynamic vars. if not then you have with-redefs. |
| 18:28 | tjgillies | dnolen: i ask because in http://clojure.org/runtime_polymorphism there is a lot of captialized keys |
| 18:28 | tjgillies | are a lot* |
| 18:29 | dnolen | tjgillies: that's an old and somewhat intentionally contrived example |
| 18:30 | dnolen | tjgillies: Clojurians don't usually capitalize their keywords |
| 18:30 | ferd | dnolen: ... hmm no... I have code that needs the value of a global var... but if this global var is not defined (and bound), then I what to define it with a default value. |
| 18:30 | ferd | So, I think I will def it (which is a noop if it's already defined) then check if it's bound? |
| 18:32 | tjgillies | dnolen: thnx |
| 18:35 | Raynes | http://en.wikipedia.org/wiki/Dead_Space_Extraction |
| 18:35 | Raynes | Eh, wrong channel. |
| 18:36 | tmciver | Raynes: is that game any good? |
| 18:36 | Raynes | tmciver: It's pretty intense. |
| 18:37 | Raynes | Not as much horror as I had hoped. |
| 18:37 | Raynes | But plenty of action. |
| 18:37 | tmciver | Raynes: I'm surprised you have time for games. |
| 18:37 | Raynes | I really don't. |
| 18:37 | Raynes | I hardly ever play games. |
| 18:37 | tmciver | I used to play some call of duty but ever since I found Clojure, not so much. |
| 18:38 | tmciver | It's probably for the best; I was sick of getting my ass handed to me by 15-year-olds that play all day and night. |
| 18:41 | scriptor | this is probably far-fetched, but is there any way to destructure the metadata of an object? |
| 18:42 | tmciver | Raynes: I remember hearing that you tried working with enlive and then abandoned it. I'm trying to use enlive to do a html->xml tranformation; do youkonw if it's the right tool? It looks like it's good for filling in template files which is not what I'm doing? |
| 18:43 | Raynes | Well, I didn't really try and give up on it. A found a bug which was promptly fixed, but the reason I didn't use it after that was because mustache was a better fit for what I was doing. |
| 18:43 | Raynes | I don't know how well Enlive would do in that situation. |
| 18:44 | tmciver | Raynes: OK, thanks. |
| 18:46 | amro | scriptor: same way you'd destructure anything, (let [... (meta foo)] bar) where ... is your destructuring |
| 18:48 | gtrak | what causes No single method: handle of interface ... on a record call? |
| 18:48 | gtrak | some of the protocol methods work, others don't |
| 18:48 | scriptor | amro: right, but if you were to use this technique in the parameters you'd have to make every call to the function be something like (f foo (meta foo)) |
| 18:49 | gtrak | oh shit, protocols don't do varargs |
| 18:50 | gtrak | that's a little weird |
| 18:51 | amro | scriptor: then don't do it in the parameters. use a let inside your fn |
| 18:51 | scriptor | it'd be neat to be able to do something like (fn foo [{:value val :meta {:keys [meta-key1 meta-key2]}}] ...) |
| 18:52 | scriptor | of course, that might conflict when you pass it a hash like {:value "bla"} |
| 19:27 | choffstein | Anyone here have experiene with Avout? I'm trying to figure out why Zookeeper is still needed for mongo-refs... |
| 19:34 | jweiss | any slingshot users here? Trying to figure out how to catch a java exception and throw+ a clojure object, with the java exception as the initCause. |
| 20:08 | BostX | hi guys |
| 20:08 | BostX | I have a definition: (defn foo [func x y] (func x y)) |
| 20:09 | BostX | and I'd like to do a call: (foo java.net.URLEncoder/encode "bar & baz" "UTF-8") |
| 20:09 | BostX | but I get #<CompilerException java.lang.Exception: Unable to find static field: encode in class java.net.URLEncoder (NO_SOURCE_FILE:1)> |
| 20:09 | BostX | does anyone know how is the proper syntax? |
| 20:09 | scriptor | if I remember correctly, you can't pass java methods as you would clojure functions |
| 20:10 | brehaut | scriptor is right. you'll probably want #(…) or memfn |
| 20:11 | BostX | scriptor, yea I read about that: http://stackoverflow.com/questions/2208865/how-do-i-pass-a-static-method-to-comp-in-clojure |
| 20:11 | BostX | but if I do: |
| 20:11 | BostX | (map #(java.net.URLEncoder/encode %1 %2) ["bar & baz"] ["UTF-8"]) |
| 20:11 | BostX | then it works! |
| 20:12 | brehaut | ,(map #(java.net.URLEncoder/encode %1 %2) [["bar & baz", "UTF-8"]]) |
| 20:12 | alexbaranosky | BostX, are you located in beantown? |
| 20:12 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox$eval29$fn> |
| 20:12 | BostX | no... Im in germany |
| 20:12 | scriptor | need to pass it two lists |
| 20:13 | BostX | scriptor, ??? |
| 20:13 | lazybot | BostX: Yes, 100% for sure. |
| 20:13 | brehaut | BostX: in that variation you'll want a long winded anon fn |
| 20:13 | scriptor | er, vectors |
| 20:13 | alexbaranosky | BostX, well you're still invited to this Wednesdays BAZNEX gathering if you can make it ;) |
| 20:13 | scriptor | BostX: sorry, that was aimed at brehaut |
| 20:13 | brehaut | ,(map (fn [[s e]] (java.net.URLEncoder/encode s e)) [["bar & baz", "UTF-8"]]) |
| 20:13 | clojurebot | ("bar+%26+baz") |
| 20:14 | brehaut | scriptor: yeah sorry, i forgot to add the descriptive comment at the end |
| 20:14 | BostX | brehaut, hmmm... l'll try it out |
| 20:15 | brehaut | ,'#(inc %) |
| 20:15 | clojurebot | (fn* [p1__89#] (inc p1__89#)) |
| 20:16 | brehaut | BostX: the full fn form lets you use destructuring in the argument vector to unpack the incoming sequence |
| 20:16 | scriptor | how do you comment out entire sexps in emacs? |
| 20:17 | scriptor | ah, found it |
| 20:17 | scriptor | M-; |
| 20:17 | scriptor | once you select the sexpr first |
| 20:19 | BostX | brehaut, uff... destructuring of the argument vector and unpacking the incoming sequence... oh je! |
| 20:19 | scriptor | on another note, why is my multimethod still working even when I comment it out |
| 20:19 | BostX | brehaut, java sounds simpler :) |
| 20:19 | brehaut | scriptor: the defmulti services reloads; |
| 20:20 | brehaut | BostX: its not honest |
| 20:20 | brehaut | err |
| 20:20 | brehaut | scriptor: the defmulti survives reloads. it is effectively defonced |
| 20:20 | brehaut | ,(apropos 'unmap) |
| 20:20 | clojurebot | (ns-unmap) |
| 20:20 | brehaut | scriptor: use ns-unmap to remove it |
| 20:21 | brehaut | scriptor: you can also get caught there if you redefine the defmulti's dispatch function, and have it not get pickedup on reload |
| 20:21 | gfredericks | is there something about using clojure.java.shell that would cause the jvm to hang for ~30sec before exiting? |
| 20:21 | scriptor | brehaut: the same seems to happen with my defns |
| 20:21 | brehaut | scriptor: then i have no idea |
| 20:22 | brehaut | although i suspect they might hang around too actually |
| 20:22 | brehaut | you'd need to ask someone with better understanding of the ns and reload machinary |
| 20:23 | BostX | Ok, guys thanks a lot... it's 2:21 a.m. now i gotta got to bed |
| 20:24 | scriptor | hmm, the repl's not loading new functions either |
| 20:25 | brehaut | weird |
| 20:25 | brehaut | you are saving the file in the right place? |
| 20:26 | scriptor | yep |
| 20:26 | scriptor | I'll try restarting the repl |
| 20:31 | gfredericks | all I have to do is (clojure.java.shell "ls" "-l") and the jvm will hang for 30 seconds |
| 20:31 | scriptor | both tried reconnecting slime and restarting the swank server and it's still not working, hmm |
| 20:32 | brehaut | scriptor: you arent by chance running your repl inside a vbox vm with a shared folder are you? |
| 20:33 | scriptor | brehaut: nope |
| 20:53 | scriptor | wait, I messed something up, restarting swank *did* fix it |
| 22:30 | callen | is Aleph ninja-rockstar tech? |
| 22:34 | mdeboard | Is `|` not allowed in macro names |
| 22:57 | arohner | mdeboard: technically: yes. though I find emac's clojure-mode gets very bitchy if I have | in the file |
| 22:57 | mdeboard | Yeah ditto |
| 22:58 | callen | is | actually legal? |
| 22:59 | callen | if so, I'm going to have some macros named lo||apalooza |
| 22:59 | arohner | callen: it's not explicitly disallowed, so it currently works |
| 22:59 | callen | I now know a new way to torment people with my code, thanks. |
| 23:00 | arohner | you mean aside from ə? |
| 23:01 | callen | the drunk pacman letter! |
| 23:06 | TimMc | callen: Use fullwidth latin characters, cyrillic lookalikes for latin script, accented chars... |
| 23:06 | callen | TimMc: if Hickey had left reader macros in, I'd have made an APL dialect. |
| 23:07 | callen | TimMc: concatenative mindfuck. |
| 23:07 | TimMc | callen: Oh, and make sure to take full advantage of the 4 normalization formats of UTF-8. |
| 23:07 | TimMc | err, of Unicode |
| 23:07 | callen | TimMc: why are you helping me be evil? |
| 23:08 | TimMc | Unicode awareness. |
| 23:08 | callen | TimMc: it'll just make people hate unicode. |
| 23:10 | ibdknox | bwahahahah |
| 23:10 | ibdknox | mission accomplished |
| 23:10 | dnolen | ibdknox: ? |
| 23:11 | ibdknox | I got his mapping time to space stuff to work |
| 23:11 | ibdknox | it's ridiculous neat to play with |
| 23:11 | dnolen | ibdknox: uh ... where's the video dude!? |
| 23:11 | ibdknox | hopefully within the hour :) |
| 23:15 | jessetrimble | sorry to drop such a trivial question here, but I'm having some problems figuring out some regexp stuff. |
| 23:15 | jessetrimble | I want to split a string on whitespace-only lines, but the following doesn't seem to be working for me: |
| 23:15 | jessetrimble | (re-split #"^[ ]*\n" "stuff\nand\n \njunk") |
| 23:16 | jessetrimble | any thoughts? |
| 23:16 | TimMc | multiline mode, I think? |
| 23:16 | TimMc | Well, maybe not. |
| 23:17 | jessetrimble | maybe something with the beginning of line match? this works: |
| 23:17 | jessetrimble | (re-split #"\n" "stuff\nand\njunk") |
| 23:18 | arohner | &(re-split irc://irc.freenode.net:6667/#"^[ ]*\n" "stuff\nand\n \njunk") |
| 23:18 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: re-split in this context |
| 23:22 | arohner | &(clojure.string/split "stuff\nand\n \njunk" #"[ ]+\n") |
| 23:22 | lazybot | ⇒ ["stuff\nand\n" "junk"] |
| 23:22 | mdeboard | TimMc: What was that pastebin you linked yesterday? refpaste? |
| 23:22 | arohner | &(clojure.string/split "stuff\nand\n \njunk" #"[ ]*\n") |
| 23:22 | lazybot | ⇒ ["stuff" "and" "" "junk"] |
| 23:23 | jessetrimble | oh, interesting. thanks arohner! |
| 23:23 | jessetrimble | any idea what the underlying difference between 're-split and plain 'split is? |
| 23:24 | mdeboard | One uses regex, one doesn't? |
| 23:24 | mdeboard | &(doc re-split) |
| 23:24 | lazybot | java.lang.RuntimeException: Unable to resolve var: re-split in this context |
| 23:24 | dnolen | jessetrimble: isn't re-split a clojure.contrib thing? |
| 23:24 | jessetrimble | yeah |
| 23:24 | arohner | jessetrimble: no, but re-split came from contrib, while clojure.string is more tested |
| 23:24 | dnolen | jessetrimble: if so it's deprecated |
| 23:24 | TimMc | mdeboard: refheap.com |
| 23:24 | mdeboard | Ah, blast |
| 23:24 | callen | didn't Raynes make refheap? |
| 23:25 | callen | or did I fuck up attribution of authorship a second time today? |
| 23:25 | TimMc | yep |
| 23:25 | mdeboard | https://gist.github.com/1921384 This sort of repetitive code is the right place for a macro, right? |
| 23:25 | jessetrimble | dnolen: ok, good to know. thanks |
| 23:26 | TimMc | mdeboard: Or a higher-order function. |
| 23:27 | TimMc | (def -& (make-foo :and)) |
| 23:29 | callen | &(def -& (make-foo :and)) |
| 23:29 | lazybot | java.lang.SecurityException: You tripped the alarm! def is bad! |
| 23:29 | callen | hrm. okay then. |
| 23:30 | amalloy | mdeboard: i prefer HOFs here, like TimMc says |
| 23:31 | amalloy | your macro would probably be written *only* to defn functions, whereas a HOF is way more flexible - you can create a function inline, for example, or create them all at once with a for-comprehension |
| 23:35 | mdeboard | amalloy, TimMc: I see. I guess I'm confused by how I do this in this instance. |
| 23:36 | mdeboard | Like I'm familiar with (partial) and #(foo-fn %&) but having trouble putting it together here. |
| 23:36 | amalloy | (defn wrapper [connector] (fn [coll] (paren-wrap (clojure.string/join (connector connectors) (map build-querystring coll))))) (def -& (wrapper :and))? |
| 23:37 | mdeboard | Not what you had in mind then? https://gist.github.com/1921435 |
| 23:37 | mdeboard | That's very python-y |
| 23:37 | mdeboard | (my gist) |
| 23:38 | mdeboard | gross python-y |
| 23:38 | amalloy | meh. that's okay |
| 23:38 | amalloy | but you're not taking advantage of the ability to easily construct functions |
| 23:38 | mdeboard | Yeah I guess that's what I mean by python-y |
| 23:38 | amalloy | (also, every time i see apply-str/interpose i cry. i used clojure.string/join as a hint, there) |
| 23:39 | mdeboard | Oh, right. |
| 23:39 | TimMc | Don't make amalloy cry. |
| 23:39 | dnolen | mdeboard: personally I don't think there was much worth fixing in the first gist, unless you are going to have a lot of functions that look like that. |
| 23:40 | mdeboard | dnolen: Just the two. Repetitive code makes me gag, changing/fixing identical code blocks in more than one place is gross. |
| 23:40 | dnolen | mdeboard: solving problems not worth solving makes me gag more ;) |
| 23:42 | mdeboard | I'm a newb though, I need to learn from these small examples. I don't have the experience/understanding to know what is/isn't worth fixing, so for now I'm idiom-seeking. |
| 23:42 | dnolen | mdeboard: Clojure has made me comfortable /w redundancy. |
| 23:42 | dnolen | the lack of inheritance - redundancy is better than spaghetti |
| 23:43 | mdeboard | dnolen: Yeah I understand what you're saying. "Foolish consistency is the hobgoblin of little minds" |
| 23:44 | TimMc | Localized redundancy is not so bad. |
| 23:45 | TimMc | Everyone has a different threshold for what is acceptable, though. |
| 23:46 | mdeboard | It's a personal pet peeve, is all. |
| 23:46 | mdeboard | FOolish consistency :) |
| 23:48 | mdeboard | On the plus side that puts my Solr API into I guess alpha. |
| 23:50 | mdeboard | I mean, after I fix the apply str interpose. |
| 23:51 | callen | you know, mutable languages are capable of being as powerful/concise as Clojure, but they don't spend enough time thinking about data transformation. |
| 23:51 | callen | I mean, what's reasonably popular that has an equivalent to tree-seq? itertools in Python looks lame by comparison. :( |