#clojure logs

2012-02-26

00:12lynaghkDoes anyone have a suggestion for how to map with an accumulator
00:12lynaghk value? I have a collection of maps and want to return new ones that
00:12lynaghk contain an offset field based on all of the maps before it.
00:12lynaghkugggg emacs, sorry about that folks.
00:14lynaghkThe 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:14juhu_chapait 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:14juhu_chapaany clue?
00:14lynaghkjuhu_chapa, can't say without more code.
00:15juhu_chapaI tried changing the delimiter to ":" and that behavior does not appear anymore
00:15ibdknoxso after watching the bret victor video
00:15ibdknoxI decided to try and create a real-time editing experience for CLJS
00:15amalloylynaghk: isn't that just reductions?
00:16lynaghkamalloy: reductions just returns the value of the accumulator. I want those values to be within maps
00:17juhu_chapalynaghk: this is the whole code: (do
00:17juhu_chapa (println (.split "key=value" "=")))
00:18juhu_chapaif you run just the split method it works
00:18juhu_chapabut inside in this case of another form it DOES NOT WORK
00:18lynaghkamalloy: I'm looking for [{:val 1} {:val 2} {:val 3}] => [{:val 1 :offset 0} {:val 2 :offset 1} {:val 3 :offset 3}]
00:19amalloylynaghk: yeah, it's not really that pretty with reductions. i'd just bash together a quick recursive lazy-seq for it
00:21amalloyyou 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:22lynaghkYeah, that sounds right
00:22amalloyit's *almost* like an unfold, but i don't think it would be that convenient to write as one
00:23lynaghkI'm not that familiar with functional idioms beyond map, to be completely honest.
00:24lynaghkI 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:24amalloyloop/recur won't be lazy. i don't think that would make you happy
00:25lynaghkSo you think recursive lazy-seq would be the way to go?
00:25amalloythe 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:26amalloyi tried to write out more detail but i don't actually know what you're doing, so i gave up
00:26lynaghkJust doing a rolling sum
00:26amalloywell, i was writing the more general case, i think
00:27lynaghkOkay, I'll dig into that and see how it checks out. I might also do the double map for clarity.
00:28lynaghkjuhu_chapa: I tried your code and it worked fine inside the do.
00:29amalloyfor what it's worth, reductions followed by map really only goes over the sequence once anyway, because of laziness
00:31muhoowell my first semi-useful set of little functions in clojure: https://refheap.com/paste/860
00:31muhoofeel free to tell my why that sucks balls.
00:31lynaghkamalloy: good point.
00:32sritchiehey all -- have you guys experienced leiningen running really, really slowly?
00:32sritchieI have a few projects that take minutes and minutes to run deps
00:32tomojyes, clean as well
00:32sritchieis there something I can do to diagnose this, or fix it?
00:33juhu_chapalynaghk: you are right I am going to public the "erroneous" code in pastebin
00:33ibdknoxsritchie: happens to me too :(
00:33sritchieit started with 1.6.2, I think
00:33ibdknoxsritchie: the workaround seems to be that if you do rm -rf classes/ every time it would do a clean, it "fixes" it
00:33tomojit's intermittent, right?
00:34sritchieoh, that's interesting
00:34sritchieibdknox: any idea what it's doing with that classes dir?
00:34ibdknoxno clue, I've been annoyed by it, but haven't actually taken the time figure out what's going on
00:36muhoodoh! ##2r101101
00:36muhoo&2r101101
00:36lazybot⇒ 45
00:36sritchieibdknox: I hadn't found a reference anywhere, it almost feels taboo
00:36espringeHow do I get mildly readable errors out of clojure? Like here's an example one i get:
00:36espringe"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:36muhoo&16r3e0F9
00:36lazybot⇒ 254201
00:37espringeIt doesn't tell me the line at all
00:37espringethe backtrace is all in Compiler.eval
00:37espringeThe only thing it tells me is the file
00:37ibdknoxespringe: sounds like an ns error :(
00:37ibdknoxthose are notoriously difficult to deal with
00:37amalloyyes, quite likely. but also the backtrace isn't *all* in compiler.eval
00:38espringeWell *none* of it is in my code
00:38amalloylike, main.clj:0 is probably saying the issue is at the beginning of your main.clj file, i think?
00:38espringenah, it's definitely not
00:38tomojsritchie: I was going to ask about it the other day, also couldn't find any other mentions
00:38espringeCause since it was last working, i've only modified like 10 lines -- none near the top of the file
00:38sritchietechnomancy, any ideas?
00:39ibdknoxespringe: can you put up a paste of the file?
00:39espringeibdknox: sure
00:40espringeibdknox: http://pastebin.com/4MbCNYA6
00:41espringeAlso 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:41tomojI think delete-file-recursively is the culprit
00:41espringethe protocol/record thing i'm using, seems to be a crap approach?
00:43ibdknoxespringe: multi-methods are a better solution for this kind of stuff
00:43espringeibdknox: multi-methods that dispatch based on value, rather than type?
00:43espringeis that how to do it?
00:44ibdknoxespringe: 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:44muhooast?
00:45tomojsritchie: interesting you say 1.6>2
00:45ibdknoxAbstract Syntax Tree
00:45espringeabstract-syntax-tree
00:45sritchiethat's speculation, I had a buddy upgrade to 1.6.2 and start exclaiming about how slow things were
00:45tomojhttps://github.com/technomancy/leiningen/commit/32ebf41f23b0fdc5b35991ab3f04a506ac0934c5
00:45espringeibdknox: I'll look into doing that, but i'll need to figure out why it's not compiling now before i start refactoring
00:45tomojthis System/gc is in the hotspot that showed up in my profiler run
00:46ibdknoxsritchie: does it eat your CPU too? for me it pegs a core
00:46ibdknoxespringe: yeah I'm looking at your file
00:46tomojhow much time and money has this commit cost? :)
00:46ibdknoxnothing obvious is jumping out
00:47sritchieibdknox: 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:47ibdknoxsritchie: hah! finally someone else has the same thing
00:47espringeAre 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:48tomojhmm
00:48tomojthe System/gc shouldn't be the problem, though
00:49tomojoh, maybe
00:49xeqitomoj: it causes FullGCs on my system, so I could see it being the culprit
00:50ibdknoxespringe: line 101 is your problem
00:50ibdknoxespringe: what version of clojure are you using?
00:50espringe1.2.0
00:50espringeibdknox: ah nice, thank you
00:50espringehow did you find it?
00:50ibdknoxespringe: 1.3.0 will give you *much* better error messages
00:51ibdknoxran it in a 1.3 repl :) and saw where it blew up
00:51espringeibdknox: oh sweet, i'll give that a go. That's been my #1 pain point so far
00:51espringein 1.2 the _only_ useful information is the filename
00:51ibdknoxespringe: 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:52ibdknoxthey might've gone into the 1.4alphas
00:52espringeibdknox: 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:52technomancysritchie: never heard of that myself. I assume it's not snapshots?
00:53ibdknoxtechnomancy: it's the same thing happening to me. I've ruled out plugins and it happens on 1.7
00:53technomancysritchie: would be interested in seeing if you can repro on lein 2 from git master
00:54tomojhow do you test a source checkout?
00:54tomoj(of lein)
00:54technomancyespringe: try clj-stacktrace; it gives way more helpful messages
00:54technomancytomoj: see "building" in the readme on master; you need 1.x to bootstrap it right now
00:54ibdknoxespringe: 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:54muhooibdknox: sritchie: os specific?
00:55ibdknoxsritchie: you on OS X?
00:55espringeibdknox: thanks
00:55sritchieyup, OS X Lion
00:55ibdknoxsame
00:55sritchietechnomancy: I can try that out tomorrow
00:55espringetechnomancy: is that for just pretty-printing stack traces, or it gives better ones as well?
00:55technomancyespringe: it colorizes frames from clojure internals and java differently
00:56technomancysritchie: would be interested in hearing how lein2 works for you since it sounds like you have a pretty big codebase
00:56technomancyit should be usable at this stage but hasn't been widely tested
00:56muhoothat'd explain why you're getting "wfm"'s from the linux users :-
00:56sritchietechnomancy: I've got a number of plugins, so it's time for me to try it out
00:56sritchieI love checkout deps, btw
00:56technomancysweet
00:57technomancysritchie: 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:57ibdknoxI'm going to have a really cool demo for you guys tomorrow I think :D
00:57sritchienice
00:57muhooso the lein-deps-melts-the-cpu problem seems isolated to osx lion?
00:57sritchieinteresting, it seems like that might be the case
00:57technomancythe top 10 plugins are lein2 compatible
00:58sritchiegotta run for now, guys, but ibdknox, I'm glad we spoke up on this :)
00:58technomancyaccording to a mostly unscientific ranking somewhat based on clojuresphere data
00:58tomojhmm, I get https://gist.github.com/197712ab7da69da50931 trying to run lein2
00:58ibdknoxsritchie: indeed! Ttyl sir
00:58technomancyyeah I need to head off too
00:58espringetechnomancy: another stupid question, does lein support scala (as in, an all-scala project)?
00:58sritchieespringe: that's a good question, actually, I'm interesting in creating jars from scala projects
00:59sritchielein-scalac is quite nice
00:59technomancytomoj: that indicates you're using clojure 1.2
00:59technomancytomoj: oh, maybe clear out lib/ in the lein checkout?
00:59technomancyespringe: theoretically it should work, but I have no idea if it's practical
01:00tomojyeah, deleted and recloned lein checkout, and it's fine
01:00technomancygreat; would love to hear feedback
01:01technomancytomoj: found the erronous lib/ inclusion in bin/lein; will get rid of that
01:01muhootechnomancy: sounds like you have an os-specific bug in lein.
01:01technomancymuhoo: oh, I have plenty
01:01tomojmuhoo: I'm on ubuntu
01:01technomancymost of them are for winders, but it's no surprise that mackosecks has a few too
01:02xeqiI think its more dep file size related
01:02muhoowhy would that be? different jvm versions?
01:02ibdknoxwoah now. Them be fightin' words.
01:02xeqiI can see a >2 sec change on a ubuntu vm from 1.6.1.1 to 1.6.2
01:04technomancythe first thing to ask is whether you are running deps because you have to or because you think you have to.
01:04muhooor because you're on the bleediing edge doing cljs and al the deps are snapshots?
01:04tomojdoes deps call clean?
01:05amalloywith checksum-deps, is there ever a time when you have to?
01:06technomancyamalloy: only to pull in new snapshots if you're not using checkout deps
01:06technomancyotherwise it's a bug in lein
01:07tomoj`lein clean` on this project took 1m42s, `lein2 clean` took 2.2s
01:07espringeibdknox: Thanks for those earlier links, they're kick ass and helping immensely
01:07technomancyholy smokes
01:07ibdknoxespringe: np :)
01:08amalloythe 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:08technomancyclean has no eval-in-project
01:08amalloyi'm going to pretend you said "nope, that's not it"
01:09xeqitomoj: can you do LEIN_JVM_OPTS=-verbose-gc for those?
01:09xeqierr
01:09xeqiLEIN_JVM_OPTS=-verbose:gc
01:11daakui'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:11tomojxeqi: https://gist.github.com/ec7e2d7114d0014d8d74
01:11tomojlots more like that
01:11daakuseems 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:13tomojbisecting..
01:16tomojhmm
01:17tomojgit-bisect doesn't seem to want to help find out where the bug was fixed
01:17tomojoh well
01:20xeqiis there a public project that you guys have the slowdown on?
01:31muhoowhat does a double-colon mean? i.e. ::foo ?
01:38juhu_chapawhat is @def?
01:40espringeI 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:40espringe(defmethod emit-llvm-type
01:40espringe [:int 34] [_] (str 'i 34))
01:40espringeLike how do i make the condition a function or something?
01:42muhooespringe: (class foo?)
01:43espringemuhoo: There's no better way? That really sucks, as I'll now need to nest multimethods inside each other :/
01:44espringeSurely there's a way to not specify a dispatch value, but a dispatch-function ?
01:44muhoolook at the source of defmethod?
01:47jedahumacro problem
01:48jedahu(defmacro foo [& body] `(let [a# 9] (macrolet [(~'bar [] `(+ 1 ~a#))] ~@body)))
01:48jedahu(foo (bar))
01:48jedahu=> Compiler exception
01:48jedahujava.lang.InstantiationException
01:49jedahuany ideas?
01:51muhoojedahu: wfm
01:51jedahumuhoo: ?
01:52muhooworks for me. i ran your defmacro in clj 1.3.0 and it gave no error
01:52muhooi've no idea what it's supposed to DO, but it didn't error
01:53jedahumuhoo: did you run (foo (bar)) ?
01:53jedahuthe defmacro works fine for me too
02:07duck1123Is there something written already for parsing http link headers? "<http://example.com&gt;; rel=\"alternate\"; type=\"application/atom+xml\""
02:08duck1123If not, is there a better way than trying to write a regexp to parse that?
02:20muhooduck1123: enlive? but there may be something less heavyweight
02:21muhoojedahu: i tried (foo "bar"), but there's no macrolet definition
02:21muhoomaybe macrolet is where the problem is?
02:21jedahumuhoo: you will need to :use clojure.tools.macro
02:22jedahuwhich is here: https://github.com/clojure/tools.macro
02:29callen(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:29callenI do believe this code has gotten out of hand.
02:31callenespringe: this is some of the worst code I've ever written
02:32callenespringe: I am enjoying this more than I can express.
02:32callenespringe: if you're wondering how one reaches this point, the answer is over-reliance on REPL-driven-development over Hammock-D-D.
02:33espringecallen: rofl, i was thinking it was machine generated ;D
02:33espringeor at least, macro generated
02:34espringeSearch my code for the largest amount of sequential closing braces, i have found:
02:34espringe]]]]]))
02:35muhoocallen: looks like the throw-arity stuff in potempkin
02:35callenespringe: no that's home-grown insanity.
02:35callenmuhoo: just seeing if I can out-do Tellman on the depths of madness.
02:35callenmuhoo: I felt like impressing a Perlist I guess.
02:35muhooso far the ugliest thing i've seen today has to be the regexp from youtube-dl
02:36muhoothough, that's not a clojure thing
02:36callenmuhoo: Clojure isn't idiomatic to my brain yet, I'm still trying to crack it like I have Python.
02:36callenmuhoo: doing 4clojure to fix my brain.
02:36callenI'm still getting used to the "transformation" style.
02:36callenI need to use more let bindings.
02:37muhoofunny, i'm reading docs and code for mundane stuff, and finally almost understandnig the functional way to wrap stuff, i.e. ring middleware
02:38muhoocallen: i have to wonder what that vec-poss business would look like indented
02:38espringeWhen 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:39callenmuhoo: well. I could just screenshare and you could watch this madness take form.
02:39callenmuhoo: it's already cleaned up a lot because I added a particularly choice let binding or two.
02:39callenmuhoo: I've got an emacs split between repl and the indented form.
02:42muhoogo ahead, refheap it
02:43muhooespringe: i did a quick search in emacs, and found some files with 20 closing parentheses
02:43muhooand a huge number with >10 closing parentheses
02:43muhooin a row
02:44muhoothat's in EMACS, not in clojure
02:44espringeThat makes my 6-in-a-row seem very unimpressive
02:44espringeIn your emacs code, or in emacs itself?
02:44muhooi do believe rhickey explicitly set out to make such insanity unnecessary, even difficult
02:44muhoono, this was in emacs source code
02:44muhoo//usr/lib/emacs
02:45muhoobecause someone on #emacs was chiding me, telling me that if i had more than 5 levels of nesting then may code was broken
02:45callentbqh, I write cleaner elisp than Clojure right now.
02:45callenand cleaner clisp
02:45callenI'm not used to clj yet.
02:45callenrefheap forthcoming.
02:46muhooso 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:46amalloy5 is an absurd limit
02:46callenmuhoo: https://refheap.com/paste/861 scroll to see the madness grow.
02:46amalloyyou can start to worry at 14 or something
02:46callenwell with indentation, it scarcely matters.
02:47amalloywhat does indentation have to do with this?
02:47callenamalloy: check out that refheap paste, you may enjoy that.
02:47callenamalloy: my ugly code led to this conversation.
02:48muhoolol Evaluation aborted
02:49callenmuhoo: don't make fun of me :(
02:50muhoonot at all
02:51callenI have a working example now.
02:51muhooso you're writing a function to reverse the characters?
02:52callenmuhoo: https://refheap.com/paste/862
02:52callenmuhoo: no, palindrome predicate
02:52callenmuhoo: anyway, seems to work for odds-n-evens now.
02:52callengoing to test it @ 4clojure.
02:52muhooistr there's some kind of pop/push business which works in opposite directions on vectors vs lists
02:53muhoofor reverseing thins
02:53callenreversing isn't really the tricky part
02:53callenI'm just calling reverse.
02:57callenmuhoo: pretty awful eh? :P
02:58callenthe code works locally, but 4clojure seems to be failing.
02:58callenamalloy: You failed the unit tests
02:58callenwait.
02:58callenI might be an idiot.
02:58callenjfsdnerg
03:18muhoooh cagwd
03:18muhoothere is some function in clojure that will return true if ALL of the elements in the collection are true
03:18muhooit had a nice name like "all", but there doesn't appear to be an "all" function
03:18callenmuhoo: whatsit?
03:19muhooi read it in the "joy of clojure" book or in one of the dozens of blogs i've read. i have no idea.
03:19muhooalzheimer's has struck me early.
03:20callenmuhoo: every?
03:21callenmuhoo: http://clojuredocs.org/clojure_core/clojure.core/every_q
03:21muhooya
03:21muhoo every
03:21callenmuhoo: you're welcome.
03:23muhoothanks
03:33amalloyso callen, are you an idiot?
03:33amalloyor was 4clojure broken?
03:34callenamalloy: I'm an idiot.
03:34callenamalloy: fixing my code.
03:36callento my credit, I did make a function that passes the test
03:37callenit's lunacy. Really fat series of sequential let bindings
03:38callenhttps://refheap.com/paste/863 worst. code. ever.
03:38amalloycallen: 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:39callenamalloy: sure, most of my answers are as short as yours.
03:39RaynesWhat does that function do?
03:39callenamalloy: I followed that madness to its conclusion even though I knew to compare the reverse to itself after being seq'd
03:39callenamalloy: I just wanted to force myself to learn how to abuse the shit out of it.
03:39callenRaynes: palindrone predicate.
03:39RaynesHoly shit.
03:39callenRaynes: I'm aware of #(= (reverse %) (seq %))
03:40callenRaynes: but I wanted to try madness.
03:40muhoocallen: i got a surprise for you
03:40muhoohang on
03:40aperiodicthat's kind of awesome
03:40amalloy(comp (partial apply =) (juxt reverse seq)) ;; who needs variable names
03:40callenaperiodic: I'm glad you appreciate my objective here.
03:40callenamalloy: points-free?
03:41amalloyusually just point-free
03:41aperiodicone of my recent objectives has been to try to be more point free
03:41callenI really enjoy writing horrible code too much.
03:41callenI should stop that, haha. :)
03:41aperiodicmainly because i remember seeing some nice point-free haskell
03:41callenyou should see what I've made in Python.
03:41muhooah crap, man you guys totally toasted me.
03:41aperiodicas long as you can keep it under control
03:42callenI've done some absurd one-liners with list comprehensions, map, filter, and reduce.
03:42muhooi'd got it down to 3 lines and thought i'd accomplished something.
03:42callenaperiodic: well it's not something I put in production, I just indulge this source of amusement when I'm futzing around.
03:42amalloyaperiodic: point-free clojure can be nice, but haskell really does take the cake; our syntax frequently leads to fairly bad point-free code
03:42muhooand it looks like you can do it in like one line, 3 functions. faaaack.
03:43tjgillieswhat version of node is clojurescript developed against?
03:43RaynesI'm not convinced they actually test that things work with node.
03:44amalloyRaynes: the cljs devs, or the node devs?
03:44Raynes~rimshot
03:44clojurebotBadum, *tish*
03:44aperiodicamalloy: it may be amatuerish, but i do feel burdened by the parens sometimes
03:44tjgillieslol
03:44aperiodicamalloy: whereas $ and . are very succinct
03:44amalloyyep
03:44muhooi thought they developed against rhino
03:44callentjgillies: hey I have some code to show you.
03:45tjgilliescallen: yay
03:45amalloy$google clojure github hiredman functional
03:45lazybot[hiredman/clojurebot - GitHub] https://github.com/hiredman/clojurebot
03:45callentjgillies: https://refheap.com/paste/864 When you understand the zen of Clojure, you'll be able to write stuff like that!
03:45amalloyhmph
03:46muhooi 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:46tjgilliescallen: when i understand the zen of clojure im going to take over the world
03:46callenmuhoo: similar, yes!
03:46aperiodicso, somehow, i'm having trouble finding lein2
03:47amalloyaperiodic: 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:48amalloy(scroll to the bottom to see what he's getting at)
03:50aperiodicamalloy: ooh, i really like the flip operator
03:50muhoogod damn i suck
03:51aperiodicso, is uncurry needed to get haskell-style function chaining to work with variadic clojure fns?
03:52muhoocallen: you with this palindrome thing.... i've spent a half hour on it now
03:52aperiodici'm not familiar with that operator
03:52muhooand it'll take me another 2 to understand how the correct solution, this partial apply juxt reverse seq business, actually works
03:53aperiodicmuhoo: the partial apply juxt reverse seq is really quite simple
03:54aperiodici mean, you're just asserting that the seq (phrase) is equal to its reverse
03:54muhoosuuuuure it is :-)
03:54aperiodicwhich is remarkably like the definition of a palindrome
03:55muhooi should show you the lameness i came up with. once i finish it.
03:55aperiodicdon't mean to come of harsh or condescending :)
03:55muhoothat's ok, i don't mean to sound clueless and stupid either :-)
03:58amalloyaperiodic: you can't get haskell's currying with varargs
03:59amalloyyou have to be very clear about how many args every function takes, in an expression, in order to have the automated curry/partialing
03:59muhooi ended up with this: (every? identity (map #(= %1 %2) (seq p) (reverse p)))
04:00amalloy(every? true? (map = p (reverse p))) is a less verbose way to write the same idea
04:00nybbleshm 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:03aperiodicamalloy: yeah, i knew that was too good to be true. found the hoogle definition
04:03amalloyaperiodic: of what?
04:03aperiodicamalloy: the uncurry thing
04:05muhoomaybe what rhickey is going to announce at clj west is a haskell that runs on the jvm
04:10callenmuhoo: you're still trying to unroll my palindrone predicate?
04:12callenmuhoo: you have no idea how much it pleases me to know I've nerd-sniped you into grotesque horror.
04:15muhoocallen: worse than that. it took that long for me to produce my own one-liner, which i shared above
04:16muhooand now i'm trying to understand the other one-liners, the ones with juxt/partial/comp
04:21callenmuhoo: have you unrolled mine yet?
04:34muhoogad no
04:34muhooi did come up with a very tight oneliner though
04:34muhootaking the one someone posted above, and shaving it down a bit
04:35muhooremoved the partial and the comp
04:35muhoo(defn palindrome? [p] (apply = ((juxt reverse seq) p)))
04:35callenmuhoo: no no, it's not fun if you don't trace the horror.
04:36muhooseriously dude? i have deal with php and java for a living
04:36muhooi have MORE than enough horror, thank you
04:36muhootracing the horror is what i have to do to survive. when i'm not being paid, no horror if i can avoid it.
04:38callenmuhoo: d'aww. Just having some fun.
04:38callenmuhoo: I still say #(= (reverse %) (seq %)) is the most elegant.
04:38muhooyeah, i'm going to try that one next
04:39muhooyep, it is, i agree.
04:40muhootightest yet
04:41callenmuhoo: 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:41callenwith a bunch of unnecessary transforms.
04:42muhoowhere i went wrong was in not remembering that you can check equality of a sequence without iterating over it
04:42muhooso i was doing stupid stuff with list comprehensions and doseq and that lot
04:42callenmuhoo: ouch.
04:42AimHereWhat'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:43callenmuhoo: you could use (every? ...) but there's not much point.
04:43muhoofinally narrowed it down to that map business, then i got schooled about the juxt thing
04:43muhooyeah, i ended up with every which is as far as i got on my own. the conceptual error was iterating
04:43muhoo(= (reverse p) (seq p)) states it so much more clearly
04:43callenAimHere: 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:44callenmuhoo: I don't mind %()
04:44callenmuhoo: it's composable.
04:44AimHereI mean the logic operations 'and' or 'or'. Which aren't functions, they're macros, so apply and map won't take them
04:44callenAimHere: I need a concrete example of what you're trying to accomplish.
04:44callenAimHere: what you're saying doesn't make sense man.
04:44callenAimHere: can you paste it at refheap.com?
04:45AimHereWell I'd like something like (foo and [true true true false ...]) to return the logical and of all the stuff in the vector
04:45muhooAimHere: ahaa! every?
04:45AimHereOrdinarily 'apply' would do the job just fine
04:46AimHereEvery? doesn't work
04:46AimHereI've taken to something like "(fn [p v] (eval (list* 'a v))" at the moment only macroified,
04:47muhoo&(every? identity [ true true true false])
04:47lazybot⇒ false
04:48muhoo&(every? identity [ true true true true])
04:48lazybot⇒ true
04:49AimHereHeh, well that's and. Now I'll have to find 'any?' or a synonym for or
04:49callenclojure.contrib could use some expansion on the text-processing front.
04:49callenI may come up with something to contribute.
04:49muhooAimHere: http://clojure.org/cheatsheet
04:50AimHereSaved me hunting for the bookmark
04:50muhoo&(some identity [ true true true true])
04:50lazybot⇒ true
04:50AimHere&(some identity [true false false false])
04:50lazybot⇒ true
04:50muhoo&(some identity [ false false false])
04:50lazybot⇒ nil
04:51muhoo&(some identity [ false false false])
04:51lazybot⇒ nil
04:51muhooyyeah, like that
04:51muhoocallen: you know that clojure.contrib is depreciated, right?
04:52callenmuhoo: I heard something to that effect, what's going on exactly?
04:52AimHereOf 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:52callenAimHere: I bet there's a macro (app) for that.
04:53muhoocallen: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
04:53muhoo~contrib
04:53clojurebotMonolithic 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:53AimHereFor passing generic boolean pred macros into the contents of a list? I don't think so
04:54muhooi'm new, but i can't see a reason to make it a macro. why not a function?
04:55AimHereBecause you want it to stop evaluating the arguments once it's decided it knows what the answer is
04:55LajlaGreetings my brethren
04:55LajlaI am the best programmer in the world second only to the Microsoft Chief Software Architect
04:55AimHere&(or true (println "This never happens))
04:55lazybotjava.lang.RuntimeException: EOF while reading string
04:56AimHere&(or true (println "This doesn't happen even if I stringify it properly"))
04:56lazybot⇒ true
04:56muhooside effects of or, eh?
04:56callenhrm.
04:56AimHereNot really, it's working as intended.
04:56callenmuhoo: how open are they to ruby-esque shortcut functions in clojure.string?
04:56clojurebotHuh?
04:57callenmuhoo: I'm wondering if there's a demand for predicates like upper-case? and lower-case?
04:57muhoocallen: i haven't a clue. ask on mailing list?
04:57muhoowait
04:57callenmuhoo: the objective being to avoid duplication of effort.
04:57callenmuhoo: what?
04:57muhoo&(.toUpperCase "fuu")
04:57lazybot⇒ "FUU"
04:57muhoolike that?
04:57callenno, predicate.
04:58callenthe ? means predicate.
04:58callenupper-case already exists.
04:58muhooah, yes. i dunno then.
04:58callen(upper-case? \A) => true
04:58callen(upper-case? \a) => false
04:58callen(filter upper-case? "HeLlO") => "HLO"
04:58callenmuhoo: see nao?
04:59muhooi'd say, why not write a library that does that stuff, put it up on github, ???? .. profit!
04:59callenmuhoo: these are things that need to be in core to be useful.
04:59callenmuhoo: elimination of duplication of effort.
04:59muhooi dunno. sounds like a mailing list questino to me
05:00muhooif yoou want duplicatino of effort, how many oauth libraries are there for clojure now
05:00callener. I'm just trying to build simple foundational stuff for core
05:00callenNot boil the ocean and lob it into core
05:00callenoauth stuff would be *completely* inappropriate.
05:01muhooi have no authority, so i can't even guess. but the core people do read the mailing list
05:01muhooi doubt any are here
05:02callenI'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:03muhoogood point.
05:05callenI 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:11stevelknievelHi all. Trying to build tools.nrepl and mvn can't find "clojure:jar:1.4.0-master-SNAPSHOT". Which repository am I missing?
05:11Raynesmuhoo: As far as I know there is only one oauth library...
05:17callenRaynes: how much do you know behind the culture for contributing to core?
05:17RaynesNot much.
05:18callenRaynes: 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:18callenstuff like you get with Ruby/Python/etc
05:19RaynesIf 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:20callenRaynes: I'm okay with that. I'll check for duplication in Java-land and proceed from there. Thanks.
05:21callenyeah, my ideas aren't in java.lang.String
05:25Raynes$max
05:25Raynes$load max
05:25lazybotLoaded.
05:25Raynes$max
05:25lazybotThe most users ever in #clojure is 376
05:30callenwait, I'm retarded, it exists in Character
05:30callenfml.
06:52jamiiWho are the moderators for the clojure google group?
06:55callenjamii: soup?
06:56jamiicallen: is that a name?
06:57callenjamii: no, wondering what's up.
06:58jamiicallen: oh, my post seems to have been deleted. I wondered if I did something wrong
06:58callenjamii: are you positive that's the case? Google Groups is known for being a bit off. What was the post about?
06:59jamiicallen: subject was "Crowdfunding an open-source clojure library for p2p NAT traversal, dynamic addressing and pubsub"
07:00callenyeah. no.
07:00callenthat sounds like advertisement/bullshit to me.
07:00calleneither make it or don't.
07:00callendon't try to busk for "crowdfunds"
07:00callenno wonder they deleted it, haha.
07:01jamiiFair enough
07:02callenjamii: I would advise not simply rewording it and reposting
07:02callenjamii: either make it or not, if you do make it, post about it and ask if anybody wants to contribute. Fin.
07:02jamiicallen: I wasn't intending to repost
07:03callenjus' sayin'
07:07jamiicallen: 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:08callenjamii: don't ever ask for money on the mailing list.
07:08callenjamii: it's never appropriate to do that.
07:09jamiicallen: sure
07:15lnostdal_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:16callenlnostdal_: you redfined it
07:16callenredefined*
07:16wiseenis 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:16wiseenor am I missing that macro ?
07:16lnostdal_yeah, i can see how that would be ok in some sense .. but other times some "slack" right there is needed
07:19lnostdal_(= (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:07callenNo matching field found: indexOf for class java.lang.String
08:07callencaused by user> (.indexOf "Leroy")
08:07callenwhich is pure lunacy.
08:08callenhow can't it find the method indexOf for the string?
08:12dedeibelAny ideas? http://stackoverflow.com/questions/9453117/has-anyone-a-case-implementation-for-clojurescript
08:14callendedeibel: would it kill you to implement it yourself?
08:14callenI guess I don't see what the problem is :\
08:15bsteuber(defmacro case [& args] `(condp = ~@args))
08:15morphlingcallen: indexOf takes two arguments
08:16bsteuberdedeibel: or just use condp for now
08:16bsteuberI'm sure it will be added to cljs
08:16callenmorphling: hrm. Staying up all night appears to have driven me mad. Good clal.
08:16callenGood call*
08:17dedeibelbsteuber: thx
08:18dedeibelWell there is an easy olution and one that is fast and everyone could benefit from
08:18dedeibel*solution
08:23LauJensenSo, everybody going to the EuroClojure event?
08:27bsteuberLauJensen: maybe..
09:59gtrakwhat's the best way to run arbitrary clojure code remotely these days? possibly secure?
10:00gtrakI'm thinking of creating a http-client that registers itself with a server, then the server calls stuff on it
10:04gtrakthe idea being that the server has all the code, but no state, the client is a dumb stateful thing
10:08trptcolinso the server remotely executes code on the clients?
10:08gtrakyea
10:08gtrakthe client keeps a persistent connection
10:08gtrakone 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:10trptcolinnot sure i follow how that use case motivates that execution context, but maybe the "client" could run an nrepl server.
10:11gtrakwell, the server has a public IP, my local box doesn't :-)
10:12trptcolinoh, ok, so this isn't about remote-executing on *many* clients, it's more of a work-delegation thing?
10:12gtrakyea
10:12gtrakthough I suppose there are use cases I haven't thought of that make sense for multiple clients
10:13gtraklike a distributed computing grid
10:18gtrakI found this: https://github.com/nakkaya/net-eval/blob/master/src/net_eval.clj maybe I can adapt it
10:25gtrakactually, I can get rid of one use case, is there a safe clj reader that just allows literals?
10:27gtrakfound it, clj-config
11:11miner49r,(doc sequence)
11:12clojurebotExecution Timed Out
11:45twhumeAnyone up for answering a newbie-q?
11:46AimHereThat's not how IRC works. Just blurt the question out into the ether, and ghostly voices may, or may not reply
11:47AimHereAsking to ask is considered silly
11:48twhumeOK… I'm trying to rewrite this to use a short-form anonymous function passed to map:
11:48twhume(defn digest [input]
11:48twhume "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:48twhume (let [words (str/split input #"\s") ]
11:48twhume (into {} (map (fn[key] [key (count (filter #{key} words))] ) words))
11:48twhume))
11:49twhumeI thought it'd be (into {} (map #([% (count (filter #{%} words))]) words)) … but no.
11:49AimHereWell for future reference, I suggest pastebinning anything that's more than one line of code
11:50stuartsierra#([ is wrong. It's like trying to invoke the vector.
11:50stuartsierraSee http://dev.clojure.org/display/doc/FAQ under "Syntax"
11:51twhumeThanks stuart :)
11:51stuartsierratwhume: 'welcome
12:07TimMctechnomancy: Huh, I wonder why the nix package manager isn't in the Ubuntu repos.
12:29dnolenStarted a Clojure GSoC 2012 project ideas page - http://dev.clojure.org/display/community/Google+Summer+of+Code+2012
13:05cran1988hi!!! how to run a thread with time limit ?
13:05cran1988for example to run a thread for 5 sec only
13:06luciancran1988: it's not possible to stop a thread from another thread reliably, in general
13:08cran1988lucian: so i can not say (thread (run-something) 5000) where 5000 is 5 seconds
13:09luciancran1988: as i said, not reliably. there's thread interruption APIs, but they don't always work
13:09raekcran1988: 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:09lucianthat's generally something only possible with processes
13:10cran1988(thank-you!)
13:10lucianalthough 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:11cran1988sandbox sounds good
13:12lucianwhat are you trying to build?
13:15cran1988i try to run jetty-server only in a specific time
13:15ibdknoxjetty has a shutdown functio
13:15ibdknoxn
13:15ibdknoxjust call that from another thread after n-seconds
13:17cran1988yes you are right ... now i am imagine it using Thread/sleep
13:17ibdknoxno
13:17ibdknoxjust use a Timer
13:17cran1988Timer ?
13:18ibdknoxhttp://docs.oracle.com/javase/1.5.0/docs/api/java/util/Timer.html
13:19cran1988it looks great thanks!!
13:26clj_newbHi can I obtain an InputStream out of a String?
13:27clj_newbI'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:28rlbclj_newb: http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/with-in-str
13:28rlbperhaps?
13:28raekclj_newb: if the API you are using acceps Readers (text streams), you can use a StringReader
13:29raekif you really need an InputStream (binary data stream), convert the String into a byte array and create a ByteArrayInputStream
13:29raek(StringReader. "foo bar")
13:29clj_newbI tried (parse (with-in-str var)) but does not work and also the (input-stream var)
13:30gtrakis there a way to treat environment variables as a map?
13:30raek(ByteArrayInputStream. (.getBytes "foo bar" "UTF-8"))
13:31rlbahh, right.
13:32clj_newbthanks raek
13:33gtrakoh yea, system.getenv() returns a map
13:34vijaykiran(into {} (System/getenv))
13:34gtrakyup, just found it :-), beautiful
13:35gtrak,(into {} (System/getenv))
13:35clojurebot#<AccessControlException java.security.AccessControlException: access denied (java.lang.RuntimePermission getenv.*)>
13:35gtrak&(into {} (System/getenv))
13:35lazybotjava.security.AccessControlException: access denied (java.lang.RuntimePermission getenv.*)
13:35vijaykiranthe bot java.policy is different, I guess :)
13:36cran1988are there any good examples for scaling clojure ?
13:36sritchiecran1988: scaling in what sense?
13:36vijaykiranwhat you mean by scaling ?
13:36cran1988the same way the web administrators do
13:37vijaykiranscaling clojure web applications ?
13:37cran1988yes
13:37vijaykirandepends on type of app you build - I guess.
13:38sritchiecran1988: yeah, people toss around the term "scale" a lot --
13:38sritchiebetter to talk about # of machines, or requests per second, or something that can be benchmarked
13:39sritchiehere's a nice post by dnolen on benchmarking aleph: http://dosync.posterous.com/22516635
13:39gtrakinfinite requests/(machine*seconds)
13:40cran1988thanks , i am checking it now ...
13:40lucianweb requests are an embarrassingly parallel problem. the only hard bit is the data store
13:41clj_newbraek: it worked, thank you! But is there any clojure-only way to do it ? wondering
13:42cran1988so i should use a NoSQL server ?
13:43lucianthat benchmark is stupid
13:43lucianjust don't worry about it for now, make your app first
13:43vijaykirancran1988: there's no one single answer - as I said, it always depends on what kind of application you are trying to build
13:43lucianand use postgres if sql fits
13:44cran1988yes postgres i am using ... ok thanks , i understand
13:58cran1988can i ask something ? every object that i create in repl , stay alives for how long ? can i destroy an object in the repl ?
13:59cran1988i think i ask to much
13:59luciancran1988: why would you care?
13:59lucianit stays alive as long as there's a reference to it
13:59cran1988for fun
14:00cran1988i thought lisp is just an OS :D and objects are programs
14:03luciansome early lisps were similar to what one might call an OS nowadays
14:03lucianclojure objects are at some point jvm objects
14:04scriptorcran1988: 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:04cran1988yeah , jvm does not give control over objects
14:05scriptorcran1988: what do you mean?
14:06cran1988the Object Class does not have a method to destroy itself
14:06lucianwhy would it?
14:06lucianjust don't reference it, the gc will clean it up
14:06scriptorthat method is only needed when something *extra* needs to be done when the jvm destroys it
14:07lucianand there are finalizers, but they're rarely useful (and the way they're implemented in the jvm makes them problematic)
14:08ferdWhat's more idiomatic?: (:key mymap) or: (mymap :key)
14:08cran1988hm... its ok ... clojure is great , i was just checking how far it can go.
14:08lucianferd: from what i've seen, neither. whichever feels better
14:09dnolenferd: (:key map)
14:09rlb(and in many cases, relying on a destructor can be "wrong" (in any language) -- i.e. closing files, for example)
14:09scriptorcran1988: how far did you want it to go? A repl is basically like python's interactive prompt or ruby's irb
14:10ferdthanks
14:10cran1988i want clojure repl goes even far than python and ruby. In my mind , I have SBCL and Factor
14:10dnolenferd: field/property access is generally of that form - (.field object) and (.-property object) in CLJS
14:11scriptorcran1988: what can SBCL's repl do that clojure's can't? I'm curious about this
14:12scriptorI know factor's repl has some neat tricks related to reloading code
14:13ferddnolen: I "feel" more confortable with (:key map)... But (map :key) makes more sense if I have to explain why it works :-)
14:13pipelinei was honestly unaware until now that clojure didn't support reloading running code
14:13dnolen,(nil :key)
14:13dnolen,(:key nil)
14:13clojurebotnil
14:13clojurebot#<CompilerException java.lang.IllegalArgumentException: Can't call nil, compiling:(NO_SOURCE_PATH:0)>
14:14dnolen,(nil :key)
14:14clojurebot#<CompilerException java.lang.IllegalArgumentException: Can't call nil, compiling:(NO_SOURCE_PATH:0)>
14:14dnolenferd: also you should consider this ^
14:14cran1988scriptor: not only that , in Lisp you control the gc for real
14:14lucianpipeline: it kinda does
14:15ferddnolen: good point
14:15lucianpipeline: the same way java supports it
14:15pipelinehttp://travis-whitton.blogspot.com/2009/09/hot-code-swapping-with-clojure.html
14:19callenSerious 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:19callenI don't think my brain has fully enveloped immutable FP yet.
14:20luciancallen: i feel the same, often
14:20callenwell my concern is that I'll never shake the feeling
14:20luciani doubt it, there was a time when i had trouble with while loops
14:20callenif 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:20dnolencallen: I now feel the opposite
14:21callenI 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:21luciani've sometimes written it in python iteratively, then rewritten in python functionally, then clojure/scheme
14:22callenI have 44 problems solved on 4Clojure and I still feel like a fricking idiot.
14:22luciancallen: SICP appears to help me, give it a try
14:22callennono, I've done SICP Scheme before
14:22lucianthen?
14:22callenyou tell me chief. I'm having the same friction with Clojure that I had with haskell.
14:22callenI didn't have this with CLisp or Scheme.
14:23dnolencallen: I don't personally find working on 4Clojure a useful way to understand the ins/outs the language
14:23lucianclisp i can see, but scheme? it doesn't exactly encourage mutability
14:23dnolenI'd rather see how Clojure applies to common problems.
14:24callenlucian: admittedly, and I was more adept at CLisp than Scheme.
14:24lucianterrible stack traces and debuggers sucks too
14:25callendnolen: 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:25callenI'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:25scriptorcallen: what's the main issue you have, translating what you want into a functional style?
14:26dnolencallen: I'm not talking about talking to databases - commons tasks like manipulating data, modeling solutions
14:26callenscriptor: 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:27callenscriptor: I've 44 questions done on 4Clojure, still feel like a moron.
14:27gtrakplaying 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:27scriptorcallen: hmm, I guess you could try redoing some of those questions and seeing if it's any easier this time around
14:28callenscriptor: well, I either come up with the answer in a few seconds
14:28callenscriptor: or I spend an inordinate amount of time on it.
14:28callenoftentimes because I don't know stuff like complement or tree-seq exists.
14:29dnolencallen: how long have you been writing Clojure? (also a well placed atom is a lovely thing)
14:29callenscriptor: 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:29callendnolen: off-and-on for like a year.
14:30callenthe 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:30scriptordo many of the 4clojure problems need mutation? I thought most of them were doable without
14:30callenall of the ones I've done so far are doable without.
14:31callenI've not used a single mutable datatype so far.
14:31callenI think that's sorta the point, to understand how to do things immutably.
14:31callenthe 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:31dnolencallen: 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:32scriptorI had the same issue with haskell in the beginning, the idea of declarative programming helped a lot
14:32callendnolen: I purchased Fogus and Halloways books IIRC
14:32callenscriptor: I understand the concept.
14:32callenscriptor: if I didn't, I wouldn't have gotten 44 problems done.
14:33tmcivercallen: 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:33callenscriptor: it's that the process of coming to an answer is too binary and makes me feel stupid until it suddenly unravels.
14:33callentmciver: that's encouraging, thank you.
14:33callensort of.
14:33tmciverdnolen: cool. I'll have to look into those resources myself.
14:33callenexcept for the part where I wonder where amalloy_'s head is.
14:33callendnolen: btw, loved your talk on predicate dispatch if you're who I think you are.
14:34dnolencallen: 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:34dnolencallen: thx!
14:34callendnolen: the problem is that I found OCaml and Haskell *agonizing*
14:35callenI own Programming in Haskell on Amazon, *shudders*
14:35dnolencallen: did you read a good book? (I think Real World Haskell stinks)
14:35dnolencallen: The Craft of Functional Programming (Haskell) is very good
14:35callendnolen: supposedly PiH is the foremost book for plain ole programmers wanting to learn Haskell.
14:35callendnolen: I find the *semantics* agonizing.
14:36scriptorlyah does a decent job at at least introducing FP's concepts and how to work with it
14:36dnolencallen: doesn't mean it doesn't stink, I hate books that don't start with programming.
14:36dnolenright away
14:36tmciverdnolen: I'd assume that it would be difficult to learn clojure with a book on ML or Haskell.
14:36callenI'm not new to FP, I'm new to trying to get things done with FP without having mutability available.
14:36callenI like the concept of transformation and threading immutable data through composed functions.
14:36callenyou guys have to understand, I've been writing CLisp for literally half my life, as long as I have C.
14:36luciani'm rewriting my first 4clojure solutions, they're tons shorter now :)
14:36callenit's not the FP, it's the immutability.
14:37dnolentmciver: not really, a lot more of Clojure makes sense if you've read a book on Haskell/SML
14:37callenmy default code doesn't mutate.
14:37callendnolen: and I have, and I ran for the hills screaming :(
14:37scriptortmciver: not really, once I learned enough of haskell learning clojure's syntax got me pretty far
14:37tmciverdnolen: Hmm, that's interesting. I've been thinking of learing Haskell anyway.
14:37lucianlearn you a haskell for great good is interesting
14:37dnolencallen: find a better book
14:37callenI desperately want to use Clojure more regularly and I'm struggling.
14:37tmciverlucian: yeah, I've heard a lot of good about that book.
14:37dnolenif you having a hard time - often the teacher stinks
14:38dnolen4Clojure is not a teacher, it's just disconnected puzzles
14:38callenit's helped me to learn a lot of core though.
14:38callenlike tree-seq, mapcat, etc.
14:38scriptorlyah is pretty good, especially if you get to the part where it introduces how map/fold/filter/etc are implemented
14:38scriptorand instead of reading the implementations you try to write them yourself first
14:38callenI understand things like map, foldl, foldr, reduce, and filter just fine.
14:39scriptorcallen: can you give a specific example where it's the immutability you had a problem with?
14:39ferdExercise: 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:39callenMost of the problems on 4Clj are trivial for me, but will totally gork me. Let me link an example.
14:39callenscriptor: 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:40callenmy approach involves abusing .indexOf
14:40callenbut I'm having a problem modeling the iteration in my head.
14:40dnolencallen: 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:40callenas well as the aggregation.
14:41callendnolen: when/where is it appropriate to use mutation in Clojure? I felt like it was supposed to be avoided at almost all costs.
14:41dnolencallen: nope
14:41callenhow does one do mutations if it's simply a mechanism for an algorithm or approach? var?
14:42dnolencallen: clojure.xml uses mutation, ClojureScript compiler uses mutation to simplify identifying loop/recur expressions
14:42dnolenwhen it makes sense to use state - use it.
14:43callendnolen: 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:43callendnolen: I wasn't certain how austere they wanted String.clj to be.
14:44callenin core that is.
14:44Vinzentcallen, why do you need .indexOf? You can use e.g. (reduce (fn [[acc prev] new] ...))
14:44dnolencallen: I think simple helper functions will have a hard time making it in. but you can try!
14:44dnolencallen: best to bring it up on the dev ML first
14:44callenof course.
14:44callendnolen: is there a guiding document or something that describes what they prefer to see?
14:45callenI take it they don't want anything that they think most people can come up with themselves or isn't somehow foundational?
14:45Vinzentcallen, also, if you really need mutation, you can use java arrays (see to-array, aset, etc)
14:45dnolencallen: pretty much.
14:45callenI'd rather not, I think my brain is just broken.
14:45callenVinzent: I'm not totally sure where you're doing with that reduction :(
14:46callenI mean, I figured it was a reduction, (the answer to #30), but the devil is in the details.
14:46callenlet me see what I can come up with.
14:48dnolenferd: (every? #(= (% map-x) (% map-y)) (keys map-y))
14:49callenVinzent: can you tell me where you were going with that? :(
14:50Vinzentcallen, 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:51Vinzenthm, actually I don't need prev at all
14:51callenI find loop/recur awkward still, so I was trying to avoid it
14:52callenIt 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:53callenVinzent: how'd you eliminate prev?
14:53Vinzentcallen, I've gisted updated code
14:54callenVinzent: thank you!
14:55Vinzentcallen, yeah, it quickly becomes your second nature and you're starting using such things without even thinking about them
14:55Vinzentnp, glad to help
14:56callenVinzent: 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:57callenif you get my meaning.
14:58scriptorcallen: 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:58callenscriptor: 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:59scriptorwhat's it involve?
14:59callenscriptor: I have Programming in Clojure 1st Ed and Joy of Clojure
14:59callenscriptor: 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:00callenscriptor: technomancy wanted one awhile back and I haven't delivered yet :(
15:01scriptorsounds like a good project, you might be putting too much emphasis on 4clojure itself
15:01callenI feel like I shouldn't by stymied so easily by 4Clojure.
15:01callenbe*
15:02callenwell. "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:03sramsayQuestion: 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:03ferddnolen: Thanks. That's almost exactly like the my first take (except I used "get" hoping to make it clearer)
15:03Vinzentcallen, 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:04callenVinzent: 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:05scriptorcallen: 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:05callenthe tricky part of the IRC project isn't the lang or the immutability
15:05callenit's modeling the hand-offs
15:05callenthat'd be a PITA in any language.
15:05callenit's basically a dispatch problem.
15:06callenI could model each client as an agent.
15:09callenthanks everyone for your advice and help. I'll start on my project and start working through another book.
15:11jaleyI'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:20gfredericksjaley: that sounds decent
15:20gfredericksempty row == empty vector or vector with blank entries?
15:21scriptorprobably blank entries
15:21gfredericksI like empty vector better, since in connect 4 you can only add to the end (top?) of a column
15:21jaleygfredericks: yeah - thinking blank enteries, so I can drop-while == :_
15:21gfredericksso you have conj/pop, rather than assoc
15:22gfredericksI guess I shoulda said "column" instead of "row"
15:22gfredericksbut I think it's all personal preference at this point
15:23jaleyalso, I don't think any choice of data structure here will make detecting wins simpler :/
15:23jaleydiagonals!
15:23gfrederickssure it will, if you use the data structure {:winning-moves [...], :losing-moves [...]}, then it's quite easy
15:24jaleyoh... I was thinking of writing something like, (defn win? [board] ...)
15:25gfredericksyeah that works too
15:25gfredericksdoesn't tell you what to do to win though
15:25jaley:-)
15:25jaleyi'm sure the dots will work...
15:26jaleysolutions are always sparse in clojure
15:26gfredericksI guess the most information is win/lose/draw and a move-count
15:26gfredericksor something like http://www.shredderchess.com/online-chess/online-databases/endgame-database.html
15:37Bronsaisn't there a way to have varargs using deftype?
15:37gtrakseriously contemplating writing yet another url parser/micro-router
15:37gtrakmoustache is like 80% what I want but not quite
15:39brehautgtrak: if you do, reversible routes would be my number one feature ontop of what moustache offers
15:39gtrakwhat's a reversible route?
15:40brehautit lets you referenate a url from a route and a list of arguments
15:40gfredericksfunctions -> URLs?
15:40gtrakah, interesting idea
15:41brehautive thought about adding it to moustache myself, but that code is quite complex ;)
15:41gtrakbrehaut, 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:41gtrakso when I generate the links in my templates, there's no simple way to correlate it to the route
15:41brehautah sure
15:41brehautyeah, i maintain some multimethods to reverse stuff in my code
15:42brehaut(but thats relatively easy because im using big blobs of couchdb data with :type tags)
15:42gtrakoh, 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:43brehauti no idea sorry ;)
15:44brehautif you could use core.match to make static routes that'd be pretty cool though
15:44gtrakit seems like it
15:44brehautboth moustache and compojure allow fall throughs, so theres an opening for something different
15:45Raynescgrand doesn't write anything that human beings can comprehend.
15:46gtrakyea, that's nasty stuff
15:46gtrakI want something much simpler
15:48gtrakand core.match gives bindings already
15:58gtrakbrehaut, 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:59brehautnot in an arbitrary way i dont think?
16:00gtrakI 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:01gtrakand maybe provide some functions, like generate a url like the one I have, except change the third-from last path segment?
16:02brehautif i were to write it ontop of what moustache provides
16:02brehautid want a way to name routes, possibly as meta data? and a Reversible protocol
16:03gtrakI still don't quite get it, the point is to simplify route generation within the handler or downstream, yes?
16:03brehautyeah
16:04brehautdjango's got a reasonable implementation
16:04gtrakhmm
16:04brehautbut it leverages the fact that you can compare functions in python
16:05gtrakdo you have a link?
16:05brehauttrying to find it
16:05brehautdjangos docs are comprehensive, but a bit of a pain to navigate
16:06brehauthttps://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:06gtrakwait... so is the generated url actually meaningful?
16:07brehautyes
16:08gtrakah, I see
16:08gtrakhow does it know?
16:08brehauthttps://docs.djangoproject.com/en/1.3/topics/http/urls/
16:08brehautthats the general url config docs; but i cant point you to a single useful point
16:08gtraki did a little bit of django once, it was way too magical for me
16:08brehauthttps://docs.djangoproject.com/en/1.3/topics/http/urls/#reverse just tells you the same stuff as url does
16:09brehauti have many grumbles about django ;)
16:09brehauturls are the part that i would complain about the least
16:09ibdknoxhave you guys heard of Noir? I hear it's less a lot more straightforward than django ;)
16:09ibdknoxconfusion abounds
16:09brehautibdknox: too much ceremony! raw ring for life
16:10gtrakibdknox, do you use it? ;-)
16:10ibdknoxgtrak: I've been experimenting with it. Still reserving my judgement until I really dig in
16:10gtraki hope the vim's not slowing you down too much
16:10ibdknoxI'm very close to a killer CLJS demo
16:11ibdknoxI have Bret Victor's modify a game while it's running thing basically done
16:11ibdknoxin cljs :D
16:11gtrakawesome
16:11ibdknoxgetting the cljs compiler to play nicely in real-time was interesting
16:12dnolenibdknox: always working on the cool stuff
16:13ibdknoxdnolen: well.. I've been working from sun up to sun down the past couple weeks, I needed to do something fun :)
16:14ibdknoxthe whole thing ended up being surprisingly simple
16:15ibdknoxI think even the projecting time into space thing is pretty easy. haven't done that part yet
16:15bbloomJust yesterday I came up with something that seems to work for cljs & vim relatively nicely
16:15dnolenibdknox: you going to demo this @ ClojureWest?
16:16ibdknoxbbloom: oh?
16:16bbloomhere's what i do:
16:16bbloomhttps://github.com/franks42/lein-repls
16:16ibdknoxdnolen: I was going to write a blog post about it tonight :)
16:16bbloomrun two terminals
16:16bbloomboth in tmux
16:16bbloomin one, i run lien repls
16:16bbloomin the other i run cljsh
16:17bbloomso they share an environment
16:17bbloomthen i open two macvims
16:17bbloomone in my clj directory
16:17bbloomand one in the cljs directory
16:17bbloomsrc/clj and src/cljs that is
16:17bbloomthen i use vim-tslime
16:17bbloomone per vim for each of the tmux sessions
16:17dnolenibdknox: sweet
16:18ibdknoxdnolen: with a little video and the code so people can mess around with it, or at the very least see it
16:18dnolenbbloom: also probably worth a blog post, not enuf CLJS workflow info out there.
16:18dnolenibdknox: !
16:18bbloomthis results in a 4-way split screen with a server/macro terminal & vim; and a terminal/vim client side terminal
16:18ibdknoxsince 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:19bbloomdnolen: ok,maybe I'll write it up later — where is best to help people find such an article? post it on mailing list?
16:20ibdknoxdnolen: I will say though, it is ridiculous amounts of fun. He was right about this being a much better experience
16:20dnolenbbloom: yes, also perhaps worth linking to from the ClojureScript wiki
16:21bbloomgood call
16:21bbloomwould really like to see more work done on networked repls in the core clojure stuff
16:21bbloomability to fork repls
16:21bbloommultiplex them
16:21bbloometc
16:22bbloomi'd love to send a form from vim to multiple simultaneous browsers
16:22bbloomstuff like that
16:22dnolenbbloom: brenton ashworth is working on that feature for CLJS
16:22bbloomawesome.
16:22bbloomlink?
16:23dnolenbbloom: I'm sure he could use help, https://github.com/clojure/clojurescript/tree/multi-browser-repl
16:23dnolenbbloom: if you haven't sent in your CA, you should, and then pitch in :)
16:24bbloomdnolen: I'm a registered contributor now :-)
16:24bbloomstill 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:24octagonhello 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:24bbloombrb
16:27gfredericksoctagon: 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:28gfredericksor are you just trying to play around with point-free expressions?
16:28octagongfredericks: yes, i feel like i'm missing some important concept here
16:29gfrederickswhat makes you think that? what made you think of this "collect" function?
16:29octagongfredericks: well i'm trying to understand which of the higher order functions are the real fundamentals
16:30octagongfredericks: and which ones can be built just by composing those fundamentals
16:30gfredericksoh man; that sounds messy
16:31octagongfredericks: so collect is just an example of binding stuff out of order
16:31gfrederickslike a reversed partial?
16:32octagongfredericks: i considered this (defn applyto [args f] (apply f args))
16:32octagongfredericks: but it didn't turn out to be completely useful in this case
16:32octagongfredericks: you know using (partial applyto ...)
16:33octagongfredericks: i have a "partiar" btw
16:33gfredericksI 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:34octagongfredericks: point-free, i didn't know that term
16:35gfredericks(def collect (comp (partial apply comp) reverse (partial list vector)))
16:35gfredericksoctagon: point-free means not using function literals, I believe
16:35gfredericksor locals in general
16:36octagongfredericks: yes, and google comes up with all kinds of interesting things that refrerence the term
16:36gfredericksI think.
16:36gfredericksoctagon: it seems to be what you're trying to play around with
16:36octagongfredericks: totally, thanks for that
16:37gfrederickssure
16:39octagonis there any discussion of the design tradeoffs involved with using varargs like clojure does?
16:50mdeboardSo 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:50gfredericksyou can't (defmulti foo (fn [& args] (count args)))?
16:50mdeboardgfredericks: Oh.
16:50gfredericks(defmulti foo (comp count list)) also
16:51brehauti wonder if theres much difference between list and (fn [& args] args)
16:51gfredericksmdeboard: so you want it extensible? just providing different function definitions doesn't work?
16:51mdeboardgfredericks: My objective is to capture arity cases `[foo & kwargs]` and `[& kwargs]`
16:52gfredericksmdeboard: how do you recognize a foo?
16:52mdeboardwhich I can't do with e.g. `(defn foo ([foo & kwargs] stuff) ([& kwargs] stuff))`
16:52brehaut,(first (apply (fn [& args] args) (range)))
16:52clojurebot0
16:52brehaut,(first (apply list (range)))
16:52clojurebotExecution Timed Out
16:54gfredericksmdeboard: so all you want is an optional first argument?
16:54mdeboardgfredericks: 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:54mdeboardright
16:54gfredericksmdeboard: you have a default value for when it's missing?
16:56mdeboardgfredericks: 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:56mdeboard"...inserts a node composed of a hash-map of the args as a..."
16:58mdeboardThat sounds kind of dumb now that I've typed it out.
16:58gfredericksyeah 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:58mdeboardHOF?
16:58clojurebotHOF is Higher-Order Function
16:58mdeboardah
16:58mdeboardgotcha
16:59mdeboardtype dispatch it is.
16:59gfredericks:/
16:59mdeboard:P
16:59mdeboardI think I'm just going about this dumb.
16:59technomancycallen: I think 4clojure is designed to be frustrating in a way
17:00callentechnomancy: you're telling me, I spent last night pissing blood until I passed out at 6 am.
17:00gfredericksis it unidiomatic to use multimethods that aren't intended to be extended?
17:00technomancyit'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:00mdeboardcallen: I... I don't think that was 4clojure.
17:00technomancyhah
17:00technomancycallen: anyway, I wouldn't beat your head against it; it's probably healthy to vary between that and something more practical
17:01technomancygfredericks: I wouldn't say that
17:01callentechnomancy: my ulcer thanks you. I'm getting back on that IRC bouncer.
17:01technomancycallen: no pressure though!
17:01callentechnomancy: startup life hijacked my soul.
17:01gfrederickstechnomancy: doesn't it unnecessarily break up a function's definition?
17:01callentechnomancy: 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:02gfredericksseems kind of messy :/
17:02gfredericksat least wrt code structure
17:03technomancygfredericks: 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:04mdeboardgfredericks: 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:04mdeboards/works/does what I wanted
17:06gfrederickstechnomancy: a small fixed set of dispatch values. So no reason for anyone else or even myself to extend it
17:06technomancysounds like simple polymorphism to me
17:06gfredericks:/
17:07gfredericksmaybe I don't mean anything
17:11pipelinewhover pointed out 4clojure is a pretty awesome dude
17:11gfredericksonly one-third as awesome as whoever made 4clojure
17:11callenpipeline: you're welcome?
17:12callenpipeline: thank amalloy
17:12mdeboardpipeline: Warning, 4clojure will apparently make you piss blood
17:12bbloomdnolen: https://github.com/clojure/clojurescript/wiki/Vim
17:12Raynesamalloy didn't start 4Clojure.
17:12mdeboardcallen: What problem exsanguinated you
17:12RaynesThat would be dbyrne, wherever he is.
17:12mdeboardHe's in my basement
17:12callenRaynes: I saw his commit. name names if you like.
17:12bbloomibdknox: youu too
17:13bbloomhopefully that will help cljs vim users out :-)
17:13cemerickmdeboard: thank you for 'exsanguinated' :-)
17:13amalloyyeah, that's today's word of the day
17:13mdeboardcemerick: Triple word score
17:13callenmdeboard: 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:13mdeboardoh yeah
17:13callenmdeboard: it doesn't help that I'm not awful comfortable with loop/recur yet.
17:20mdeboardcallen: 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:22callenmdeboard: tree-seq and complement saved my arse last night too.
17:22callenI'll add those to my "contemplate deeply" list.
17:22callenmdeboard: thank you.
17:22mdeboardfor the flatten re-implementation?
17:22technomancytree-seq is sublime
17:22callenmdeboard: yes.
17:22mdeboardI cheated and looked at the flatten source for that problem :P
17:22Raynestechnomancy: text 2
17:22callenI accidentally re-implemented, then re-discovered tree-seq.
17:27ivanthis may interest anyone backing up blip.tv https://github.com/ivankozik/youtube-dl/commit/801531e66a4a47d1c739ee93c77c1e6a73f6bacb
17:27ivanfunny how the source videos are sometimes 3x smaller than the default .flv
17:28mdeboardtechnomancy: Why sublime? What about it blows you away?
17:30technomancymdeboard: it's just such a high level of abstraction just sitting there
17:30technomancyI think everyone coming to Clojure would expect to have to write it themselves
17:31octagongfredericks: 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:36amalloymy 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:36ivandoes this work for traversing directory trees?
17:36amalloyit works for anything you want. all the interesting bits are pluggable with functions
17:37ivanheh, I should have read one defn below and seen file-seq
17:37nybbleshey 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:37nybblesi mean.. syntactically
17:37ivannybbles: metadata
17:38callennybbles: it's short for (meta ...)
17:38callennybbles: they're tagging it.
17:39nybblesivan, callen: ah ok cool thanks, didn't expect it in the middle of a function
17:39amalloy"it's short for (meta ...)" is totally wrong, though
17:39mheldhey y'all
17:40callenamalloy: well fuck. correct me. :(
17:40callennybbles: don't listen to me.
17:40dnolencallen: with-meta
17:41amalloyit's *close* to being shorthand for with-meta
17:41nybbleshaha, ok, i figured as much :)
17:41amalloybut it's really read-time metadata, which is not the same thing as runtime metadata
17:41callenI was basing it on what I saw on the cheatsheet.
17:41callenit said ^form is (meta form)
17:41callenso that's why I misunderstood.
17:42nybblesamalloy: so the stuff in "^{}" will not show up in a function call to (meta.. ) with the tagged thing?
17:42amalloythat was probably true in clojure 1.0 or 1.1 or something, but it isn't anymore
17:42amalloynybbles: try it
17:42nybblesok :P
17:43amalloy&(meta ^{:x 1} (map inc []))
17:43lazybot⇒ nil
17:43callennow I am seriously worried I've missed something critical. :|
17:43amalloynaw. it's just that clojure.org never updates :P
17:44callenamalloy: is the site on github?
17:44callenamalloy: if so, one could make a pull request or something.
17:44amalloydon't we all wish
17:45callenamalloy: is it worth proposing on the mailing list?>
17:47technomancymight as well mention it; just don't expect a response
17:47amalloyi suppose it's possible rich would let the website have a looser rein than the language
17:47nybbleshm
17:48nybbles&(meta (with-meta {} {:x 1}))
17:48lazybot⇒ {:x 1}
17:48nybblesok that makes sense
17:48nybbles&(meta ^{:x 1} {})
17:48lazybot⇒ nil
17:48nybbleswhaat
17:48dnolencallen: yes
17:49nybblesmy clojure repl gives me: "{:x 1}"
17:49nybblesweird
17:49technomancynybbles: smells like a lazybot bug
17:50nybblestechnomancy: ok so the problem is with lazybot, so why is it that with (meta ^{:x 1} {}) i should expect {:x 1}, but..
17:50nybbles&(meta ^{:x 1} (into {} []))
17:50lazybot⇒ nil
17:51tjgillieswhats with symbols with asterisk, like *this* ?
17:51dnolentjgillies: to denote vars that might be dynamically rebound
17:51technomancynybbles: I think you're placing metadata on the into call
17:51amalloyIMO it's more of a bug in clojure that read-time metadata ever leaks out to runtime
17:52technomancynybbles: that is, the metadata application happens in the reader before into is ever called
17:53tjgilliesdnolen: by dynamically you mean by user or by program?
17:53nybblestechnomancy: so why would the read-time metadata application be different for {} versus (into {} [])?
17:53technomancynybbles: because {} evaluates to itself
17:53technomancysince it's a literal
17:54technomancy(into {} []) evaluates into a function call
17:54technomancyand you're placing metadata on the source code, not on the result
17:56nybblestechnomancy: 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:56amalloyno. it attaches read-time metadata to the source code, and then just returns the source code at runtime
17:59nybblesok 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:59amalloythat's what i just explained
17:59amalloya literal evaluates to itself, so it just evaluates to the source code
17:59amalloythe source code is: {}, with metadata of {:x 1}
18:00tjgilliescan i tap a repl into an already running environment? like in erlang, or do i need to start the repl first always?
18:02weavejestertjgillies: repl first, as far as I'm aware, though in theory it should be possible to make a library to inject a repl
18:03nybblesamalloy: oh i get it now, ok thanks
18:04nybblestheres a little section in Practical Clojure that's useful..
18:04nybblesto understanding it
18:04tmciveramalloy: 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:04amalloyit's not
18:04amalloyit's being attached to the source code for that function call
18:04nybblesi wasn't realizing that the form gets evaluated and goes away, and then the result does not have the source code
18:05nybblesarch i mean "the result does not have the metadata attached to it"
18:05amalloythe compiler has no use for that metadata, so it compiles a regular function call
18:05nybblestmciver: it's being attached for the source code "(into {} [])"
18:05tmciveramalloy: it has no use for it so it removes it?
18:06nybbleswith-meta is the call to attach it to the actual result of (into {} [])
18:07nybblestmciver: http://t.co/xNQI5YPP
18:07tmcivernybbles: thanks. Looking.
18:08tmcivernybbles: that's one Clojure book I don't have. Do you like it?
18:08nybblesi don't have it either, but i like it now :)
18:11tjgillieshrm 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:11tjgilliesit's
18:11amalloythat assumes you want a :main at all. most of my clojure projects i don't bother
18:11tjgilliesamalloy: how do you run them?
18:12amalloyrepl, swank
18:12tjgilliesah, i thought that was just for debugging and exploratory didn't know people actually ran them that way
18:13amalloywhen you're deploying into a production environment, sure, it's good to have a :main
18:13amalloybut almost all the time you spend with a project is exploring and debugging
18:14gtrakhmm, why wouldn't I be able to instantiate a record from another ns? I've :use'd the ns
18:15ibdknoxgtrak: gotta import it
18:15gtrakah
18:15ferd&(and (resolve 'IamUndefined) (var? #'IamUndefined))
18:15lazybotjava.lang.SecurityException: You tripped the alarm! resolve is bad!
18:15dnolengtrak: IMO, better to use the provided ctor fns, or write your own.
18:16gtrakwhat's a provided one?
18:16amalloyonly provided in 1.3+
18:17amalloybut i agree that's true
18:17amalloyferd: i suspect #'IamUndefined get looked up at compile-time, so the short-circuiting and won't protect you
18:18gtrakah, I see there's a factory function
18:18ferdamalloy: thanks... What's a clean way to check if a var is defined and bound ?
18:18tjgilliesim 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:18amalloywell resolve gives you the var back
18:18amalloyjust call bound? on that
18:18tjgilliesusing "lein run" to invoke
18:18ferdahh... idiot
18:19amalloybut...this is a very questionable thing to be doing. why are you wondering whether a particular var is defined
18:19ferdI have a unit test that depends on some vars so me set (to load some fixture data)
18:20ferdif they are not set, I want to def them to some special values
18:20ferdthe vars are normally set by the build environemnt... but when developing interactively, I want them to be automatically set to some values
18:20ferdam I clean ?
18:20ferdclear ?
18:21amalloyso why not just def them to the default values in source code, and then let the build env redefine them
18:21amalloyrather than not defining them at all
18:22ferdhmmm but if I def them in the test (with a value) it will overwrite whatever value the env defined :-\
18:24tjgilliesis there a convention for capitalizing hashmap keys? like :Foo vs :foo ?
18:24ferdamalloy: may be I can do something like: (do (def xxx) (if-not (bound? #'xxx) (def xxx "my-value")))
18:25ferdamalloy: there's gotta be a cleaner way... Learning here.
18:26choffsteinHey 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:26choffsteintasks. 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:26pipelinemdeboard: I'm only on problem 24, so that's not really ar isk yet.
18:26dnolentjgillies: Clojure doesn't generally capitalize anything - deftype/record/protocols are an exception in Clojure
18:27dnolenferd: just provide default values - if you're going to rebind something, perhaps you want dynamic vars. if not then you have with-redefs.
18:28tjgilliesdnolen: i ask because in http://clojure.org/runtime_polymorphism there is a lot of captialized keys
18:28tjgilliesare a lot*
18:29dnolentjgillies: that's an old and somewhat intentionally contrived example
18:30dnolentjgillies: Clojurians don't usually capitalize their keywords
18:30ferddnolen: ... 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:30ferdSo, I think I will def it (which is a noop if it's already defined) then check if it's bound?
18:32tjgilliesdnolen: thnx
18:35Rayneshttp://en.wikipedia.org/wiki/Dead_Space_Extraction
18:35RaynesEh, wrong channel.
18:36tmciverRaynes: is that game any good?
18:36Raynestmciver: It's pretty intense.
18:37RaynesNot as much horror as I had hoped.
18:37RaynesBut plenty of action.
18:37tmciverRaynes: I'm surprised you have time for games.
18:37RaynesI really don't.
18:37RaynesI hardly ever play games.
18:37tmciverI used to play some call of duty but ever since I found Clojure, not so much.
18:38tmciverIt'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:41scriptorthis is probably far-fetched, but is there any way to destructure the metadata of an object?
18:42tmciverRaynes: 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:43RaynesWell, 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:43RaynesI don't know how well Enlive would do in that situation.
18:44tmciverRaynes: OK, thanks.
18:46amroscriptor: same way you'd destructure anything, (let [... (meta foo)] bar) where ... is your destructuring
18:48gtrakwhat causes No single method: handle of interface ... on a record call?
18:48gtraksome of the protocol methods work, others don't
18:48scriptoramro: 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:49gtrakoh shit, protocols don't do varargs
18:50gtrakthat's a little weird
18:51amroscriptor: then don't do it in the parameters. use a let inside your fn
18:51scriptorit'd be neat to be able to do something like (fn foo [{:value val :meta {:keys [meta-key1 meta-key2]}}] ...)
18:52scriptorof course, that might conflict when you pass it a hash like {:value "bla"}
19:27choffsteinAnyone here have experiene with Avout? I'm trying to figure out why Zookeeper is still needed for mongo-refs...
19:34jweissany 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:08BostXhi guys
20:08BostXI have a definition: (defn foo [func x y] (func x y))
20:09BostXand I'd like to do a call: (foo java.net.URLEncoder/encode "bar & baz" "UTF-8")
20:09BostXbut I get #<CompilerException java.lang.Exception: Unable to find static field: encode in class java.net.URLEncoder (NO_SOURCE_FILE:1)>
20:09BostXdoes anyone know how is the proper syntax?
20:09scriptorif I remember correctly, you can't pass java methods as you would clojure functions
20:10brehautscriptor is right. you'll probably want #(…) or memfn
20:11BostXscriptor, yea I read about that: http://stackoverflow.com/questions/2208865/how-do-i-pass-a-static-method-to-comp-in-clojure
20:11BostXbut if I do:
20:11BostX(map #(java.net.URLEncoder/encode %1 %2) ["bar & baz"] ["UTF-8"])
20:11BostXthen it works!
20:12brehaut,(map #(java.net.URLEncoder/encode %1 %2) [["bar & baz", "UTF-8"]])
20:12alexbaranoskyBostX, are you located in beantown?
20:12clojurebot#<ExecutionException java.util.concurrent.ExecutionException: clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox$eval29$fn>
20:12BostXno... Im in germany
20:12scriptorneed to pass it two lists
20:13BostXscriptor, ???
20:13lazybotBostX: Yes, 100% for sure.
20:13brehautBostX: in that variation you'll want a long winded anon fn
20:13scriptorer, vectors
20:13alexbaranoskyBostX, well you're still invited to this Wednesdays BAZNEX gathering if you can make it ;)
20:13scriptorBostX: sorry, that was aimed at brehaut
20:13brehaut,(map (fn [[s e]] (java.net.URLEncoder/encode s e)) [["bar & baz", "UTF-8"]])
20:13clojurebot("bar+%26+baz")
20:14brehautscriptor: yeah sorry, i forgot to add the descriptive comment at the end
20:14BostXbrehaut, hmmm... l'll try it out
20:15brehaut,'#(inc %)
20:15clojurebot(fn* [p1__89#] (inc p1__89#))
20:16brehautBostX: the full fn form lets you use destructuring in the argument vector to unpack the incoming sequence
20:16scriptorhow do you comment out entire sexps in emacs?
20:17scriptorah, found it
20:17scriptorM-;
20:17scriptoronce you select the sexpr first
20:19BostXbrehaut, uff... destructuring of the argument vector and unpacking the incoming sequence... oh je!
20:19scriptoron another note, why is my multimethod still working even when I comment it out
20:19BostXbrehaut, java sounds simpler :)
20:19brehautscriptor: the defmulti services reloads;
20:20brehautBostX: its not honest
20:20brehauterr
20:20brehautscriptor: the defmulti survives reloads. it is effectively defonced
20:20brehaut,(apropos 'unmap)
20:20clojurebot(ns-unmap)
20:20brehautscriptor: use ns-unmap to remove it
20:21brehautscriptor: you can also get caught there if you redefine the defmulti's dispatch function, and have it not get pickedup on reload
20:21gfredericksis there something about using clojure.java.shell that would cause the jvm to hang for ~30sec before exiting?
20:21scriptorbrehaut: the same seems to happen with my defns
20:21brehautscriptor: then i have no idea
20:22brehautalthough i suspect they might hang around too actually
20:22brehautyou'd need to ask someone with better understanding of the ns and reload machinary
20:23BostXOk, guys thanks a lot... it's 2:21 a.m. now i gotta got to bed
20:24scriptorhmm, the repl's not loading new functions either
20:25brehautweird
20:25brehautyou are saving the file in the right place?
20:26scriptoryep
20:26scriptorI'll try restarting the repl
20:31gfredericksall I have to do is (clojure.java.shell "ls" "-l") and the jvm will hang for 30 seconds
20:31scriptorboth tried reconnecting slime and restarting the swank server and it's still not working, hmm
20:32brehautscriptor: you arent by chance running your repl inside a vbox vm with a shared folder are you?
20:33scriptorbrehaut: nope
20:53scriptorwait, I messed something up, restarting swank *did* fix it
22:30callenis Aleph ninja-rockstar tech?
22:34mdeboardIs `|` not allowed in macro names
22:57arohnermdeboard: technically: yes. though I find emac's clojure-mode gets very bitchy if I have | in the file
22:57mdeboardYeah ditto
22:58callenis | actually legal?
22:59callenif so, I'm going to have some macros named lo||apalooza
22:59arohnercallen: it's not explicitly disallowed, so it currently works
22:59callenI now know a new way to torment people with my code, thanks.
23:00arohneryou mean aside from ə?
23:01callenthe drunk pacman letter!
23:06TimMccallen: Use fullwidth latin characters, cyrillic lookalikes for latin script, accented chars...
23:06callenTimMc: if Hickey had left reader macros in, I'd have made an APL dialect.
23:07callenTimMc: concatenative mindfuck.
23:07TimMccallen: Oh, and make sure to take full advantage of the 4 normalization formats of UTF-8.
23:07TimMcerr, of Unicode
23:07callenTimMc: why are you helping me be evil?
23:08TimMcUnicode awareness.
23:08callenTimMc: it'll just make people hate unicode.
23:10ibdknoxbwahahahah
23:10ibdknoxmission accomplished
23:10dnolenibdknox: ?
23:11ibdknoxI got his mapping time to space stuff to work
23:11ibdknoxit's ridiculous neat to play with
23:11dnolenibdknox: uh ... where's the video dude!?
23:11ibdknoxhopefully within the hour :)
23:15jessetrimblesorry to drop such a trivial question here, but I'm having some problems figuring out some regexp stuff.
23:15jessetrimbleI want to split a string on whitespace-only lines, but the following doesn't seem to be working for me:
23:15jessetrimble(re-split #"^[ ]*\n" "stuff\nand\n \njunk")
23:16jessetrimbleany thoughts?
23:16TimMcmultiline mode, I think?
23:16TimMcWell, maybe not.
23:17jessetrimblemaybe something with the beginning of line match? this works:
23:17jessetrimble(re-split #"\n" "stuff\nand\njunk")
23:18arohner&(re-split irc://irc.freenode.net:6667/#"^[ ]*\n" "stuff\nand\n  \njunk")
23:18lazybotjava.lang.RuntimeException: Unable to resolve symbol: re-split in this context
23:22arohner&(clojure.string/split "stuff\nand\n \njunk" #"[ ]+\n")
23:22lazybot⇒ ["stuff\nand\n" "junk"]
23:22mdeboardTimMc: What was that pastebin you linked yesterday? refpaste?
23:22arohner&(clojure.string/split "stuff\nand\n \njunk" #"[ ]*\n")
23:22lazybot⇒ ["stuff" "and" "" "junk"]
23:23jessetrimbleoh, interesting. thanks arohner!
23:23jessetrimbleany idea what the underlying difference between 're-split and plain 'split is?
23:24mdeboardOne uses regex, one doesn't?
23:24mdeboard&(doc re-split)
23:24lazybotjava.lang.RuntimeException: Unable to resolve var: re-split in this context
23:24dnolenjessetrimble: isn't re-split a clojure.contrib thing?
23:24jessetrimbleyeah
23:24arohnerjessetrimble: no, but re-split came from contrib, while clojure.string is more tested
23:24dnolenjessetrimble: if so it's deprecated
23:24TimMcmdeboard: refheap.com
23:24mdeboardAh, blast
23:24callendidn't Raynes make refheap?
23:25callenor did I fuck up attribution of authorship a second time today?
23:25TimMcyep
23:25mdeboardhttps://gist.github.com/1921384 This sort of repetitive code is the right place for a macro, right?
23:25jessetrimblednolen: ok, good to know. thanks
23:26TimMcmdeboard: Or a higher-order function.
23:27TimMc(def -& (make-foo :and))
23:29callen&(def -& (make-foo :and))
23:29lazybotjava.lang.SecurityException: You tripped the alarm! def is bad!
23:29callenhrm. okay then.
23:30amalloymdeboard: i prefer HOFs here, like TimMc says
23:31amalloyyour 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:35mdeboardamalloy, TimMc: I see. I guess I'm confused by how I do this in this instance.
23:36mdeboardLike I'm familiar with (partial) and #(foo-fn %&) but having trouble putting it together here.
23:36amalloy(defn wrapper [connector] (fn [coll] (paren-wrap (clojure.string/join (connector connectors) (map build-querystring coll))))) (def -& (wrapper :and))?
23:37mdeboardNot what you had in mind then? https://gist.github.com/1921435
23:37mdeboardThat's very python-y
23:37mdeboard(my gist)
23:38mdeboardgross python-y
23:38amalloymeh. that's okay
23:38amalloybut you're not taking advantage of the ability to easily construct functions
23:38mdeboardYeah I guess that's what I mean by python-y
23:38amalloy(also, every time i see apply-str/interpose i cry. i used clojure.string/join as a hint, there)
23:39mdeboardOh, right.
23:39TimMcDon't make amalloy cry.
23:39dnolenmdeboard: 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:40mdeboarddnolen: Just the two. Repetitive code makes me gag, changing/fixing identical code blocks in more than one place is gross.
23:40dnolenmdeboard: solving problems not worth solving makes me gag more ;)
23:42mdeboardI'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:42dnolenmdeboard: Clojure has made me comfortable /w redundancy.
23:42dnolenthe lack of inheritance - redundancy is better than spaghetti
23:43mdeboarddnolen: Yeah I understand what you're saying. "Foolish consistency is the hobgoblin of little minds"
23:44TimMcLocalized redundancy is not so bad.
23:45TimMcEveryone has a different threshold for what is acceptable, though.
23:46mdeboardIt's a personal pet peeve, is all.
23:46mdeboardFOolish consistency :)
23:48mdeboardOn the plus side that puts my Solr API into I guess alpha.
23:50mdeboardI mean, after I fix the apply str interpose.
23:51callenyou know, mutable languages are capable of being as powerful/concise as Clojure, but they don't spend enough time thinking about data transformation.
23:51callenI mean, what's reasonably popular that has an equivalent to tree-seq? itertools in Python looks lame by comparison. :(