#clojure logs

2011-09-27

00:23andar__How can I improve this function? Is there a way to use doto with a sequence of args? http://pastebin.com/PnnCDcK7
00:25amalloyandar__: off the top of my head it looks like you could simplify to (loop [[[x y] & others] xy-coll] (... (recur others)))
00:26amalloyor probably turn the whole thing into a doseq with a similar binding
00:27amalloyie, more like https://gist.github.com/1244341
00:27brehautandar__: also, nil is one of the two falsy values in clojure, so you dont need to test (nil? x)
00:29andar__thanks amalloy and brehaut
00:32brehautandar__: more generally you use a reduce just about anywhere you would use primitive recursion with loop / recur.
00:32brehautandar__: although doseq is clearer in this case because its indicative of side effecting code
00:32amalloybrehaut: i don't know that i would say that. in many cases you would use map, not reduce, for example
00:33amalloyie, loop/recur can implement a lot of patterns, and while of course so can reduce, it's not always the right "upgrade"
00:33brehautandar__: but (reduce (fn [series [x y]] (doto series (.add x y)) (XYSeries. name) xy-coll)
00:33brehautamalloy: thats why i set primative recursion
00:33brehautwhich is the case that reduce is equivalent to
00:33amalloyuhh
00:34brehauti think is probably more haskell assery
00:35amalloy*chuckle*
00:35amalloybrehaut: i mean, you can implement map as a reduce, provided you either have a lazy language or don't mind strictness
00:35brehautim also having a typing fail today. sorry about that
00:35brehautamalloy: definately, map in a lazy language is fairly trivial example of primative recursion
00:36amalloyno worries, my comparative languages class in college had a section on "sleepy typos"
00:36brehauthah
00:36brehautits for the best
00:38brehauti should go cook dinner
00:39amalloyhuh, i'm always learning something from 4clojure. it finally occurred to me to do bounds-checking with (every? true? (map < [-1 -1] [y x] [h w]))
00:39amalloytaking advantage of the multi-arity versions of < *and* map, neither of which i ever use
00:39technomancythat is really slick EXCEPT for how every? requires a predicate. that part is dumb.
00:40amalloytechnomancy: isn't a change to that on the horizon?
00:40technomancyamalloy: open ticket; chouser approves, but no discussion so far
00:40technomancyI guess I could give it a poke again now that 1.3 is out
00:40amalloychouser approves! it's practically 1.0 already
00:41technomancywell... he suggested the same thing like two years ago. I guess that doesn't imply he still approves.
00:41amalloy*laugh*
00:42amalloytechnomancy: i forget, did you want to extend any of these things to 3+ args as well, or just allow a 1-arg version?
00:42technomancyamalloy: just using identity as the default predicate
00:43technomancy3+ args would be map-style for multiple-argument predicates?
00:43amalloytechnomancy: i dunno. that seemed viable but possibly confusing, and i haven't thought much about it, so i hoped you'd tell me whether you'd already figured it out
00:44amalloyeg, a map-style filter makes only marginal sense, since there's no element to return. but a multi-arg not-any? seems to make sense
00:44technomancyhaven't thought that through all the way
00:45amalloythen i wouldn't even need a default predicate - i could write (every? < [-1 -1] [y x] [h w])
00:45technomancyhandy for that, but I'm not sure how generally-applicable it'd be
00:45amalloynor am i
00:45technomancythe only drawback I can see with 2-arg filter is that I like it a lot more when the optional arg can be last.
00:46technomancybut that's certainly not a hard-and-fast rule
00:49amalloyi think a hard-and-fast rule should be that when you write (every? true? ...) you have to try to pronounce it out loud
00:52technomancyin Mandarin, question-ness is indicated by appending "ma" to the sentence since you can't use tonality.
00:52technomancyCL's whatever-p always reminded me of that for some reason.
00:53technomancyif I ever invent a joke lisp dialect I will be sure to use -ma as the convention for predicate naming.
00:53technomancyor should I say... WHEN I invent a joke lisp dialect.
01:18TheBusbyjust FYI, it's "ka" for Japanese...
01:18TheBusbyanyone have any luck in getting clj-http to ignore self-signed certs?
02:11amalloytechnomancy: link to the ticket? i might as well kick the tires
03:10carkanybody knows how to type hint for an array of objects ?
03:15carkah there it is : ^"[Ljava.awt.Color;"
03:15carkwas missing the last ;
03:16michaelr525kool
03:46pyribdknox: still around ?
03:48ibdknoxpyr: for a min, what's up?
03:51pyribdknox: pe/on has a very weird behavior
03:51pyribdknox: for me in pinot
03:51pyribdknox: most of the time it doesn't catch events
03:52pyribdknox: setting aside my own code, if you take the todo code for instance
03:53pyribdknox: it will only remove the last item which usually gets 3 calls
03:54pyribdknox: (using the snapshot you posted yesterday)
04:27ibdknoxpyr: hm, I just tried it locally and it worked fine
04:27pyrah
04:27ibdknoxpyr: to confirm, the call looks like this, right?: (pe/on todo-item :click ...
04:28pyryep
04:28ibdknoxand what is it doing for you?
04:28pyr(pe/on (dom/query ...) rather)
04:29pyr(pe/on (dom/query foo) :click some-func)
04:29pyrrather
04:29ibdknoxyeah
04:29ibdknoxthat doesn't delegate
04:29ibdknoxhttps://github.com/ibdknox/pinot/blob/master/examples/todo.cljs
04:29ibdknoxyou wanna do it like that
04:30ibdknoxwith it that way, anything ever created using the todo-item partial
04:30ibdknoxwill have that event bound on it
04:30pyrso i need to create partial even for my links
04:30ibdknoxyou don't have to, no
04:31pyrbinding to dom/query doesn't seem to work right
04:31ibdknoxmkay
04:31pyrthe array return and handled in nodelist->coll seems to be empty
04:32pyri'll try with partials
04:32pyr(also, wasn't i supposed to use the reorg branch ?)
04:33ibdknoxI merged it all into master :)
04:33pyrah, ok
04:33pyrwill switch
04:33ibdknoxpyr: yeah I'm seeing weird behavior. I'll debug it tomorrow, I'm dead tired
04:33pyrnp
04:33pyrcool to have it confirmed :)
04:34ibdknoxthanks for the catch :) I'll let you know when it's fixed!
04:35BlafaselHmm.. Is clooj usable?
04:35michaelr525what is clooj?
04:35BlafaselJust started the latest version (eclipse/ccw is not helpful) and it seems to do ~nothing~
04:35Blafaselmichaelr525: One of the 'IDE' options linked to from GettingStarted
04:36BlafaselA clojure ~ide~ develped in clojure it seems.
04:36amalloyBlafasel: i have heard of people using it with every indication of enjoyment
04:37amalloywhen i turned it on just for fun, it seemed to work okay, but i'm happy with emacs
04:37michaelr525yeah, i'm happy to learn emacs, it really gives me satisfaction ;)
04:38Blafaselamalloy: Hmm.. The repl doesn't work for me (it just repeats my input, 1 -> 1, (1) -> (1), (println "foo") -> (println "foo") .. And it goes down from there. :( So maybe I need to give CCW another try then.
04:38michaelr525yesterday started stabbing paredit - and this kind of completes the picture
04:40robermannabout Emacs / paredit: is it possible to have matching parentesis of different colors?
04:41raekthere is a rainbow-paren-mode
04:41robermannwow - where is it?
04:42raekcould be this one http://dishevelled.net/elisp/rainbow-parens.el
04:42kjeldahlrobermann: I'm on emacs24, and it looks like they are "rainbow" colored by default...
04:42raekI tried it, but I don't use it.
04:43robermannkjeldahl: I'm on GNU Emacs 23.1.50
04:44robermannfor Windows... :) Also Aquamacs does not color them
04:44amalloyi used rainbow-parens for a while. it looked reasonably nice but wasn't actually very useful
04:44xianHi. I can't seem to run jars built with 'lein jar' or 'lein uberjar'. I get a NoClassDefFoundException with the following message: Could not find the main class: match1.core. Program will exit.
04:44xianUpon inspecting the jar I found out that there was no class named match1.core in the jar.
04:45robermannkjeldahl: I mean in the REPL
04:45PupenoAny recommendation on a body of Clojure samples to use to test syntax highlighting?
04:46robermannamalloy: when I am on the REPL and I'm editing an existing function (M-p) I find difficult to remember all the matching parenthesis
04:46kjeldahlrobermann: In repl, I'm not seeing rainbows either...
04:47amalloyyeah, i can see that being handy. i don't do much typing into the actual repl; i usually edit the source file (or *scratch* buffer) and eval stuff from there with C-M-x and friends
04:48kjeldahlrobermann: But doing "highlight-parenthesis-mode" in repl gives me rainbows (at least if activated after paredit-mode like I just tested - not sure if paredit is needed at all)
04:48kzarIs there a way to have clojure.repl used by default when you're connecting to the REPL with Emacs?
04:49michaelr525i also found this, but did't try it: http://stackoverflow.com/questions/2413047/how-do-i-get-rainbow-parentheses-in-emacs
04:49robermannkjeldahl : how do I turn on highlight-parenthesis-mode? M-x + tab does not show it
04:50kjeldahlkzar: Add a ":repl-init my-namespace.clj" in project.clj which pulls it in...
04:50kjeldahlkzar: Oops, minus the .clj extension (just the namespace name, not filename).
04:50kjeldahlrobermann: Could be emacs24... Shows up automatically here.
04:51michaelr525robermann: i have it being loaded from .emacs. found it somewhere on the internetz. do you want it?
04:52kzarkjeldahl: Ah right thanks
04:52kjeldahlkzar: I was wrong. It's in my elisp directory. Points to http://nschum.de/src/emacs/highlight-parentheses/
04:53kjeldahlkzar: Should work fine for your version as well.
04:53michaelr525robermann: http://pastie.org/2598687
04:54kjeldahlHa ha, mixed up kzar and robermann. Sorry guys, but you got it I guess.
04:54robermannthank you all men, I'm going to try :)
04:54kjeldahlrobermann: Prepare for unicorn land!
04:56robermann:)
05:42robermannkjeldahl: now I'm in the unicorn land!
05:43robermannmichaelr525: about this script http://pastie.org/2598687
05:43robermannI had to remove the load-path stuff
05:44robermannand copy highlight-parentheses.el into d:/mannai/ClojureBox/emacs/EmacsW32/lisp/
05:44robermann(clojurebox laod it: "Adding d:/mannai/ClojureBox/emacs/EmacsW32/lisp/ to load-path")
05:45robermannBTW michaelr525 , 'load-path can also load single files, aside from directories ?
06:09robermannI tried also http://www.emacswiki.org/emacs/RainbowDelimiters, now I'm using that
06:10carkrobermann: isn't it slowing down your emacs too much ?
06:11robermannmmm no
06:11robermannI compiled it: M-x byte-compile-file <location of rainbow-delimiters.el>
06:11carkcool
06:11carki might try that some day
06:11robermannyes, nice setup instructions: http://www.emacswiki.org/emacs/RainbowDelimiters#toc2
06:12robermannthey work for me too, a newbie on Emacs
06:13carki was just worried about performance
06:13carkit's already slow enough as it is =P
06:14robermannwell, as for now it is the best IDE for clojure (holy war starts.. :D )
06:14robermannIMHO (stop war)
06:14carkagreed
06:27sridcan I make 'cake deps' automatically reload swank?
06:27srid(so there is no need to reconnect from emacs)
06:38miclorb_hrm... can you use multi methods as a way to dispatch based on literal values?
06:38miclorb_(thinking like erlang def's and matching)
06:41clgvmiclorb_: well, you can dispatch via a custom function
06:41miclorb_clgv: oh?
06:42miclorb_I am dealing with command line args (ie single word - whihc kinda matches up with function name)
06:52clgvmiclorb_: can you give an example for what you want to do?
06:53miclorb_clgv: hrm.. it is as simple as a string (from user) "foo" - to dispatch to a function (defn foo ...)
06:53cemerickkzar: FYI, a new clutch 0.2.5-SNAPSHOT has been pushed that should resolve the issue you hit yesterday
06:53kzarcemerick: Awesome, thanks :)
06:53miclorb_I thought I should learn multimethods (reading about them - I still don't get what they are about - so it was a stab)
06:53cemerickkzar: let me know if it works or not; I'd like to do a 0.2.5 release today or tomorrow if possible
06:54kzarcemerick: How do I make sure lein re-downloads it?
06:54clgvmiclorb_: ok then have a look at multimethod examples first ;)
06:54cemerickkzar: just `lein deps` should do it — I think it always checks for new snapshots
06:55miclorb_clgv: - it looks close, will play a bit more, my spider sense tells me they are pretty cool
07:01TallAdamhi guys - any reason that (class (Integer/parseInt "1")) returns java.lang.Long in Clojure 1.3
07:02cemerickTallAdam: because starting in 1.3, Clojure boxes all primitive integers as Long, and all primitive decimals as Double.
07:02TallAdamcemerick: is that for performance reasons?
07:03cemerickTallAdam: Mostly, it simplifies the numerics model in Clojure-land.
07:03TallAdamcemerick: thanks for that
07:04cemerickWell, I was going to explain further, but…
07:04robermannexplain explain please
07:04robermann:)
07:05zoldaryes, we're all ears
07:05robermannI read the 1.3 changelog, but this news surprise me
07:06cemerickrobermann: you have to keep going, and read the links linked in the changelog: https://github.com/clojure/clojure/blob/master/changes.txt#L75 :-)
07:07cemerickBasically, if you have a primitive value somewhere (bound in a let form, for example), then Clojure will leave it alone (so you can pass it to e.g. Java methods without a problem), but if you use it as an argument to a Clojure function that is not declared to accept primitive values, then the value will be boxed to Long or Double prior to being passed.
07:09cemerickYou can declare functions to accept and return primitive longs and doubles though, so your primitive int (or short or float, etc) will be coerced to a long or double before being passed to such a function.
07:11cemerickThe long and short of it is that Clojure math always uses long and double and Big* (when necessary). If you want an int or short or float, then you either need to create it explicitly, or if it's an interop situation, use the coercion hints.
07:14kzarcemerick: I found and deleted my local copy of the jar to force it to downloaf and yep it's working now. It does give me a bunch of warnings when I first load clutch though: http://paste.lisp.org/display/124879#2
07:15cemerickkzar: That's expected — those are caused by libraries clutch depends upon. None of those vars should ever be rebound, though (I've never hit a code path that causes an issue).
07:15cemerickThanks for verifying the new build fixes that problem for you. :-)
07:15cemerickFYI, I'm hoping to get an 0.3.0 release out that will replace the libraries that cause those warnings.
07:15cemericks/out/out soon
07:15lazybot<cemerick> FYI, I'm hoping to get an 0.3.0 release out soon that will replace the libraries that cause those warnings.
07:16ZolrathI'm trying out Pinot and the pinor.dom library doesn't seem to actually get provided. The other pinot libraries work but even the example code won't compile as it tries to use pinot.dom
07:20kzarcemerick: Gotya OK
07:27ZolrathHm maybe the version on clojars isn't compiled properly, that file is missing from the .jar
07:33michaelr525sleepy afternoon
08:27manutterlovely, my machine was compromised by the drive-by download malware someone installed on mysql.com yesterday. Guess I know how the rest of my day is going to go.
08:33michaelr525manutter: the rest is going to be great!
09:24crazyFoxhi everyone. i'm installing emacs and the emacs-starter-kit from technomancy. Now i'm trying to download the emacs 24 sources. When using https://github.com/emacsmirror/emacs/zipball/master the download file is named emacsmirror-emacs-EMACS_23_3-8876-g6cda373.zip. Meaning version 23. How can i get version 24?
09:25crazyFoxok. never mind. the file name is misleading. it DOES contain version 24. tss...
09:29robermannthanks to you :) I even didn't know there was such a "starter kit"
09:44BlafaselHmm.. I find myself in need of a 'yield' of some sorts. Probably doing it wrong again.
09:46MenthyIn clojure.set there's a join fn, is there any support for other joins than natural (left, right, cross, outer?)
09:57joegalloyou can do a cartesian product with for, i suppose
09:57clgvBlafasel: what do you mean`
09:58fdaoudBlafasel: as in call the function you were passed as arg? Just call it :)
09:58fdaoudas in (defn something [passed-in-fn] (if true (passed-in-fn) "or else"))
09:59duck1123Is there any official guide as to when you're supposed to use vectors and when you use lists within a ns form?
09:59kzarBlafasel: Yield runs the given block, in Clojure you would just pass a function as a parameter and then call it
09:59kzarBlafasel: You could even call the parameter yield if you wanted
09:59neotykGood morning everyone
10:00fdaoudduck1123: my understanding is that you could use lists, just that vectors look nicer
10:00Blafaselyield as in C#/F# lazily generating values. Trying to wrap my head around lazy-cat right now..
10:00neotykcan you help us spreading word about clj meetup? https://twitter.com/#!/amsclj/status/118684755804946432
10:01clgvBlafasel: lazy-seq could be what you are looking for
10:02kzarBlafasel: Sorry I thought you meant in the Ruby sense
10:02clgvduck1123: there is the suggestions to use vectors where all contained elements are equal and to use lists where the first element is special. like in (:use (clojure set zip)) and (:use [clojure.set :only [f1 f2]])
10:03Blafaselclgv: Hmm.. Looking for both ~yield~ (generate and return one value) and ~yield!~ (lazily consume/concat a list). The latter seems to be lazy-cat? Need to look at lazy-seq
10:04clgvBlafasel: lazy-seq is used to build a lazy sequence via a recursive description
10:05BlafaselOkay. Learning :)
10:10shep-hometechnomancy: sorry, was asleep :-)
10:11shep-homedo you mean, where did I get clojure-mode? or where dif I get the error? or ... ?
10:11shep-homedid*
10:14crazyFoxroberman: ur welcome ^^ - i also just found it rather by coincidence. i generally find all the various places with clojure ressources of some sort confusing...
10:22fdaoudkzar: me too
10:35robermannBTW: does anyone know why a 4clojure execise is scored as "easy" rather than "medium"? For example, it's quite funny to see that "Cartesian Product" (http://4clojure.com/problem/90) is as easy as Pascal's Triangle (http://4clojure.com/problem/97)
11:14timvisherhey all
11:14timvisheranyone know what happened to clojure-jack-in in emacs 24?
11:14timvisherwell, emacs HEAD?
11:15timvisherspecifically, it used to use locate-dominating-file but now it appears not to
11:28TimMcrobermann: Cartesian Product being, in your view, harder or easier?
11:29robermannvery easier
11:29TimMcok
11:30robermannjust one-line
11:30TimMcyeah
11:31robermannthe other, well, I had to think about it :)
11:33TimMcrobermann: OK, yeah -- Pascal's Triangle involves actually using recursion (or doing some math!)
11:33TimMcI suppose it depends on where the cut-off between Easy and Medium is.
11:35nkozamm.. kilim + clojure will make a better erlang than erlang
11:37TimMcrobermann: amalloy solved it with math, I solved it with recursion.
11:38robermannI used recursion, too
11:50robermannsee you people, bye
11:58technomancyshep-home: I mean where did you get clojure-mode
12:08pyribdknox: around ?
12:25shep-hometechnomancy: package.el (says version 1.10.0)
12:33shep-homeI just updated to 1.11.1 (but package still lists the old version as obsolete)
12:42shep-homebut the same issue exists
12:52shep-homeI /do/ have the getRoot / getRawRoot hack added manually for clojure 1.3
12:53technomancydid it happen before you upgraded clojure-test-mode?
12:55shep-hometechnomancy: sorry I was confusing... I've had the same version of -test-mode throughout. I did update -mode, but that was *after* the problem popped up.
12:56shep-homeI swear that the "change" that caused it was just writing more code :-)
12:58kzarCan exceptions inside futures stall them? So that we're waiting for this thread to come back but it just never will
13:09technomancyderefing should re-throw the in-future exception
13:09technomancy,@(future (/ 1 0))
13:09clojurebot#<RuntimeException java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.ArithmeticException: Divide by zero>
13:12kzartechnomancy: Would there be any ways that the exception wouldn't be re-thrown?
13:13winkanyone got a sample project on github or whatever where I can have a look regarding test layout (which files where, etc)
13:14manutterwink: you mean just how the test dirs are set up and stuff?
13:15joegallolein new this-is-an-example
13:15joegallo:)
13:15winkhmm, yeah
13:17manutterPick almost any of the clojure tools at clojure-toolbox and look at their github repos, should be a good guide
13:17manutterI'm partial to midje testing myself
13:17joegallohere's one that's built up on that a bit: https://github.com/dakrone/cheshire
13:17winkthanks
13:17kzartechnomancy: (We're working on this, https://github.com/marktriggs/xml-picker-seq/blob/master/src/xml_picker_seq/core.clj and when I messed up the extract-fn the thread hung forever with no exception. I think Mark's going to figure it out but it just made me wonder.)
13:17manutterI was geeking out last night: figured out how to integrate midje testing with slingshot exception handling
13:17kzargotta run anyway
13:18manutterI'm like "Dang, it's this easy? Seriously?"
13:19winkthink I'm switchin languages too fast lately. I don't even have clojure on this machine...
13:20winkplus I had written tests already. counterclockwise just ignored the test dir. doh
13:28neotykHas anyone used clache successfully ?
13:28neotykI'm having problems getting FIFOCache to work
13:29neotykI initialize it with: (FIFOCache. {} [] 100)
13:29shep-hometechnomancy: could I be causing myself problems by trying to use clojure 1.3.0 when swank-clojure pulls in 1.2.1?
13:30neotykand get 'Can't pop empty vector' in clache.clj:62
13:34technomancyshep-home: it should be ok; swank pulls 1.2 only for standalone swank sessions outside a project
13:36neotyknow it works: (FIFOCache. {} clojure.lang.PersistentQueue/EMPTY 100)
13:37shep-hometechnomancy: sure enough, I moved the version down and still see the same issue
13:37technomancyshep-home: something about process filter arguments?
13:41shep-hometechnomancy: error in process filter: Wrong number of arguments: nil, 11
13:44pyrgetting the gist of cljs and pinot
13:44pyrcool stuff
13:47dnolenpyr: yes it is.
13:49pyri had feared i would be trapped in google closure layout hell
13:51dnolenpyr: nah, it seems so far that google closure is good about providing functionality a la carte.
13:51pyryep, was able to reintegrate my previous layout quite easily
13:52duck1123So with pinot, can you define your view once and use it in both places?
13:52pyryou can do that
13:52pyralthough
13:52pyri just do client-side hiccup now
13:52duck1123I converted all of my views to soy, but haven't used them from js yet
13:53duck1123so you're sending hiccup over the wire?
13:53ibdknoxyou *could* send hiccup over the wire
13:53ibdknoxbut you don't need to
13:53ibdknoxit depends on how you organize your web app
13:54duck1123oh, I get it. You're doing all your generation client side, right?
13:56pyribdknox: does my dom/replace make sense ?
13:56ibdknoxpyr: it does, though it needs to be a bit more complicated, sadly
13:56ibdknoxpyr: take for instance, being in the middle of a list
13:57pyrah, yeah
13:57pyrit would not retain the position
13:57pyri use it for changing "pages"
13:57pyrmy pinot fork now has dom/toggle-class too
13:58ibdknoxpyr: yeah, I need to add those functions too :)
13:58pyruseful for modals, menus, stuff like that
13:58ibdknoxpyr: definitely
13:58ibdknoxdnolen: did I miss any discussion on how we could make a file readable as both clj and cljs?
13:59ibdknoxthat would solve duck1123 issue completely
13:59ibdknoxyou could just use the same file with partials in it in both places
14:01duck1123That would be nice
14:02duck1123Actually, using Closure Templates hasn't been that bad. It's a lot slower to type, but easier to just move things around
14:02ibdknoxanother nice solution would be to wrap mustache.js
14:03ibdknoxand use stencil on the server
14:03duck1123It's a lot better now that I'm using lein. Under maven I had to re-process the resources and re-eval the template ns
14:03ibdknoxthen you can just use mustache templates both client-side and server side
14:03ibdknoxduck1123: good to hear you're using lein :)
14:04duck1123most of the things that were keeping me on maven have been fixed, and I got sick of not being able to use the cool plugins
14:05dnolenibdknox: I haven't heard any progress on that front. Anything interesting would require changes to Clojure.
14:06ibdknoxdnolen: why not just meta-data in the ns decl of .clj files?
14:06ibdknoxdnolen: then the cljs compiler reads any .clj that has that meta in it
14:08duck1123You would have to be very careful. It would be too easy to make a change that doesn't work in one or the other.
14:08ibdknoxthat's true regardless of the solution
14:08shep-hometechnomancy: Created a new project with lein, it doesn't have the same problem
14:08shep-homeso it must be something about my code
14:09shep-hometime to binary-comment things out :-)
14:11amalloyTimMc: i've also solved it with lazy seqs; i have a gist somewhere
14:12amalloyhttps://gist.github.com/1140970
14:14ibdknoxamalloy: pascal's triangle I assume?
14:14amalloyibdknox: quite a coincidental output if not
14:14ibdknoxhaha
14:15ibdknoxbah, should've looked at the name of the file :-p
14:15ibdknoxneat solution
14:16amalloyyeah, it was kinda neat not to have to treat the outer edges specially, just shove some imaginary 0s in there
14:16shep-hometechnomancy: narrowed down the cause
14:16shep-homehttps://gist.github.com/1245810
14:16shep-homewell, a reproducible case
14:16shep-homewho knows why it's really wrong :-)
14:17dnolennice, http://scriptstoprograms.wordpress.com/2011/09/27/javascript-shared-state/
14:17technomancyshep-home: cool; can you open an issue on clojure-test-mode?
14:18shep-hometechnomancy: sure thing, it is the same git repo, as clojure-mode, right?
14:18technomancyright
14:21shep-hometechnomancy: done
14:21shep-homethanks :-)
14:22technomancygreat
14:33TimMcamalloy: Nice use of "for partition" in there.
14:34TimMcI also used the imaginary zeros, but mapped + across the two colls.
14:34amalloy*nod*
14:35TimMcThree? I thought you less than three.
14:36amalloyer
14:36amalloyso did i
14:41winkback to testing, I've looked a bit and didn't really find any uptodate info on code coverage. anyone got some pointers? :) (sorry if I'm being annoying)
14:41technomancy~radagast
14:41clojurebotI don't understand.
14:42technomancy~radagast is a simplistic test coverage tool: https://github.com/seajure/radagast/
14:42clojurebotOk.
14:42winkthanks
14:42technomancyit's not particularly good
14:44winkmy code's most probably worse :)
14:45seanm_how do I find the name/artifact/version for :dependencies in leiningen? I'm trying to get javax.xml so I can use XPath
14:45amalloyany package starting with "java" is already in the jre
14:46hiredmannot so for javax
14:46seanm_yeah not for javax =)
14:46amalloyhiredman: really? i guess it's been too long since i did that
14:47hiredmanlein uses [groupid/artifactid "version"] which you can get from the maven info
14:47amalloyeg, javax.swing *is* in the jre; i thought the javax packages were "standard extensions" or something
14:47hiredmanjavaxmail is not
14:48seanm_hiredman: thanks!! It's working now
14:48joegallomany javax packages are available in the jre by default
14:49joegalloin those situations, the javax is an indication that it was at one time not available by default, but was later included (without changing the package, though)
14:49TimMcIt may depend on whether you have JRE or JDK, I think.
14:50jeremyheilerMuch of the javax packages are in Java EE
14:50jeremyheilerWhich is completely separate from the JDK/JRE
14:51jeremyheilerhttp://java.sun.com/javaee/6/docs/api/
14:53joegalloin this case, though, javax.xml is available in the jre (at least, it is in version 6, for which i'm looking at the classes in rt.jar)
14:54amalloythey got added in 1.4, i think. kinda weird that you could have an environment without them
14:56jeremyheilerseanm_: The javax.xml.xpath package is in the JRE
14:56foodoohow can I create a string from a list of chars using only the functions in clojure.core? (4clojure)
14:56jeremyheileramalloy: it makes sense to keep the EE stuff separate, as not all environments need JPA, mail, servlets, etc.
14:57jeremyheilerYou can even pick and choose what parts of EE you need
14:57tsdhIs it intended that clojure allows symbols containing whitespace?
14:57tsdh##(symbol "faa bar")
14:57lazybot⇒ faa bar
14:57tsdh##(type (symbol "faa bar"))
14:57lazybot⇒ clojure.lang.Symbol
14:57hiredmanfoodoo: why use 4clojure at all if you are not going to figure it out?
14:57technomancytsdh: I think it's intentional
14:58foodoohiredman: I suppose there is some built-in function for that. But I can't seem to find it
14:58technomancythere was an open issue for it for a while, I had a patch that got rejected.
14:59foodoohiredman: and I suppose that's really not part of the main challenge. But I could be wrong
14:59tsdhtechnomancy: I know that CL does (|foo bar|), but I don't see a way to use such a symbol in, say, def...
14:59amalloytsdh: macros would work. but don't :P
15:00tsdhbtw, the print representation is ("foo bar") here at my 1.3 repl...
15:00tsdhSo there's no way for the reader to distinguish a symbol with whitespace from a list with a string...
15:00foodoohiredman: https://www.4clojure.com/problem/102 dropping the - and making a character uppercase is already done. Now I need to glue the pieces together
15:02TimMcfoodoo: How did you get to problem 102 without first encountering a whole bunch of problems that tell you how to glue chars together into a string?
15:02tsdhamalloy: Yeah, I don't. :-)
15:03foodooTimMc: I'm not sure if I really did them in order. I remember one time resorting to (. foo toString) but this seem to work this time
15:04foodooI mean it doesn't seem to work this time
15:04technomancy,(let [x (bean [])] (prn (class x)) (:foo x))
15:04clojurebotclojure.core.proxy$clojure.lang.APersistentMap$0
15:04clojurebot#<NullPointerException java.lang.NullPointerException>
15:04technomancy...!
15:04fdaoudfoodoo: why not just (str foo)
15:05ibdknoxfdaoud: you mean (apply str foo)
15:05TimMcwell, there's the answer
15:05fdaoudibdknox: yes, you're right, to concat.. I meant instead of (. foo toString)
15:05amalloy~source bean
15:06fdaoud,(apply str [\b \o \n \j \o \u \r])
15:06clojurebot"bonjour"
15:06foodoofdaoud: (= "foobar" (str (concat "foo" "bar"))); is false
15:06foodoo(using 1.3 if that matters)
15:06TimMcfoodoo: concat takes colls
15:06TimMc,(concat "foo" "bar")
15:06clojurebot(\f \o \o \b \a ...)
15:07TimMcErm, I guess it takes seq-ables.
15:07ibdknoxyeah
15:07ibdknox~source concat
15:07fdaoud,(apply str (concat "foo" "bar"))
15:07clojurebot"foobar"
15:07TimMc,(str "foo" "bar")
15:07clojurebot"foobar"
15:07foodoothank you all :)
15:08TimMc,(ancestors (class {}))
15:08clojurebot#{java.util.concurrent.Callable clojure.lang.Counted clojure.lang.IObj clojure.lang.IPersistentMap java.util.Map ...}
15:08tsdhCan't I test if a fns :pre fails? (is (thrown? AssertionError (foo "bad input"))) errors with an AssertionError...
15:08TimMc&(ancestors (class {}))
15:08lazybot⇒ #{clojure.lang.IObj :clout.core/request clojure.lang.AFn clojure.lang.IFn clojure.lang.IMeta java.io.Serializable clojure.lang.IPersistentMap clojure.lang.Counted clojure.lang.MapEquivalence java.lang.Runnable java.lang.Object java.util.concurrent.Callable clojure.... https://gist.github.com/1245930
15:12pyribdknox: i have a nicer alternative
15:12pyribdknox: to replace
15:13ibdknoxpyr: oh?
15:14ibdknoxfwiw, I think replace should exist no matter what
15:19pcavswhat's the way to use rest args in a shorthand anonymous function? like #(apply + %&) but %& doesn't work...
15:19bhenrybut %& does work...
15:19pcavsor nvm, it does =\
15:20ibdknoxlol
15:20amalloy...have you actually tried %&?
15:20pcavs<— stupid
15:20pyribdknox: let me prepare a gist
15:20pcavsthank you thank you, I'm hear all week, try the lamb
15:20ibdknoxpyr: okidoke
15:20pyrhttps://gist.github.com/1245966
15:21pyr(I love emacs gist-mode!)
15:21pyrit's a different approach
15:21ibdknoxpyr: yeah, that's basically the same as JQuery's html()
15:21pyryup
15:22pyrbut it doesn't use innerHTML (so no wiping out of the event binding tree)
15:22TimMcpcavs: I bet you used &% by accident. I keep typoing it.
15:22pcavsTimMc: I think the fact I'm dumb is a simpler more elegant explanation
15:22ibdknoxpyr: mhm
15:22TimMc>_<
15:22ibdknoxlol
15:23tsdhAh, stupid me. The assertion error was in another test...
15:23hugodpyr: which gist mode?
15:23pyrhttps://github.com/defunkt/gist.el
15:23hugodthanks
15:23pyryou get gist-region and gist-buffer
15:24pyrwith private alternatives
15:24pyrvery useful
15:24ibdknoxoff to lunch
15:24amalloyyep. gist.el: useful enough to get one of my C-c bindings
15:26Blafasel*sigh* "java.lang.IllegalArgumentException: Parameter declaration letfn should be a vector (utils.clj:8)" .. I'm hooked but the error messages are confusing me all the time
15:28amalloyBlafasel: you forgot the arglists to a function
15:28amalloy(defn foo (letfn ...)) instead of (defn foo [x y] (letfn...))
15:30BlafaselIt's a file with 11 lines. I - can't see it. I'm already in the 'blindly shuffle things around' mode, now I get 'Parameter declaration let should be a vector' - and I know I had that problem in the past, passing a list or forgetting it. But now? Don't see it.
15:30BlafaselAnd especially not in the line mentioned..
15:30TimMcThe error *should* say, "expected a vector, found symbol 'letfn"
15:30amalloyTimMc: that's not accurate though
15:30TimMc+param decl
15:30amalloy"expected a vector, found list beginning with symbol letfn"
15:30TimMcah, right
15:31BlafaselAh.. Got that. Now I just need to make lazy-seq happy..
15:31hiredmanamalloy: well (fn [] ...) and (fn ([] ...)) are both legal
15:32scodeIs the order preservation of literal maps co-incidental or a documented guarantee?
15:32amalloyah, interesting point. i hadn't thought of it from that perspective
15:32hiredmanscode: implementation detail for literal maps with less than N entries where N maybe 8 right now
15:32BlafaselI'm trying something like (letfn [(foo [args]) ...... (lazy-seq (cons something (foo newargs))]) and foo cannot be resolved. Stupid Ben?
15:33scodehiredman: Thanks!
15:34amalloyhiredman: i think it's 10
15:34BlafaselOn a sidenote: Thanks for this (patient, friendly) place to get started.. Helps a lot to lurk around here or cry for help, occasionally.
15:34VinzentBlafasel, should it be (letfn [(foo [args] ...... ...)?
15:35BlafaselVinzent: Ah. It is. My bad.
15:36BlafaselVinzent: Method, couple things, branch to a) recur or b) (lazy-seq (cons computedThingy callToSelfHere))
15:37BlafaselI hope that makes sense...
15:41dansis everyone who uses vim still using vimclojure or is there a better option?
15:42foodoodans: I'm still using vimclojure. But the REPL ist broken for 1.3
15:42dansok foodoo
15:58babilendans: same here (although I am still on 1.2)
15:59babilendans: You might want to take a look at slimv though (or at least use its paredit implementation in vimclojure)
15:59elderling,(clojure-version)
15:59clojurebot"1.3.0-master-SNAPSHOT"
16:02dansbabilen, thanks
16:02dansactually im doing just that, installing both with vundle
16:03dansfor some reason :set ft? still returns filetype= (not recognising clj files) so syntax highlighting isnt working
16:06Blktgood evening everyone
16:11babilendans: Same setup here, but ft works for me. (cf. https://github.com/babilen/dotfiles/blob/master/vim/vimrc)
16:14tsdhIs there something that helps writing complex argument destructuring for macros like defmacro itself?
16:14tsdhI mean, where you have optional docstrings, option maps, plus varargs parameters...
16:16sridI add `:exclusions [clojure.contrib]` to project.cl, then `rm -rf lib classes build`, but `lein deps` will still fetch clojure-contrib jar in lib/. why?
16:16dnolentsdh: no but it's come up before and other people are interested in it. Just need someone to actually do the work.
16:16amalloyclojure.contrib is not clojure-contrib?
16:17chouseramalloy: hey, you around? I have a proposition for you.
16:17amalloywell, i just betrayed my presence, i guess
16:17tsdhdnolen: Ok, thanks.
16:18chouseroh, indeed. so, what if 4clojure used a different golf scoring method?
16:18khaliGi've got some code generating some html - http://paste.lisp.org/display/124909 - and i need to run a counter through the loop for setting up the rows and columns of a table. What's the best way to achieve that?
16:19amalloychouser: counting number of forms, i bet?
16:19chouseryessir. http://groups.google.com/group/clojure/msg/0ff2be94aef767dd
16:20chousergranted: any kind of golf will have goals that diverge from what you use when writing "real code"
16:21amalloy*nod* there are two issues. one is that it's (slightly) harder to educate users about how this works. the other is that, of course, we already have one scoring method, and taking it away will annoy people
16:21chouserbut if golf is to have any real value at all, it would be to encourage learning the target platform.
16:21amalloywhen i built the charts, i actually wanted to have "count characters" and "count forms" scores separate, both on the graph
16:21khaliGall i can think of atm is using a closure which i call each time to get a new value (probably by calling swap! atm inc) - any other ideas?
16:21chouseramalloy: what would be fantastic!
16:22chouserof course then you'd want to be able to submit two (or more) solutions. :-)
16:22hiredmanreal value?
16:22hiredmanof golf?
16:22chouserhiredman: right. for learning.
16:22hiredmansure
16:22hiredman*eyeroll*
16:22chouser:-P
16:22amalloychouser: have you played spacechem? i wanted to mimic their charts exactly, since they look great and score you on multiple axes
16:23chouseramalloy: no, I haven't.
16:23amalloyi put up a screenshot somewhere but sadly it's not in my logs at work and i can't produce another one
16:23amalloybut the frontend stuff - making a pretty graph with incanter, figuring out how to work it into the page - was just too much for me
16:24chouseramalloy: ok
16:24amalloyi'd love to accept a patch, though, from any interested parties, such as yourself
16:25BlafaselAny https://gist.github.com/1246123 - some feedback for improvements of non-idiomatic usage? This is a more or less straight port from F#. I understand that this is the nth function to do this, but - I'm just fooling around/exploring and just using contrib is boring.
16:27amalloychouser: aha, of course someone else has put up a screenshot already. http://downwithshooters.blogspot.com/2011/05/not-chemistry-i-remember.html
16:28amalloyBlafasel: this is mis-indented
16:29amalloynewTable should be new-table
16:29danshmm everything works fine if i :set ft=clojure, i wonder why it doesnt automatically recognise .clj
16:29amalloy(assoc m k (conj (get m k) v)) is just (update-in m [k] conj v)
16:31rata_hi
16:31Blafaselamalloy: indentation is something I have to learn from scratch for lisps, I guess. Any guides, specific remarks? (and thanks for the rest!)
16:32teromBlafasel: I believe the docstring should be before (empty) argument vector.
16:33amalloyBlafasel: https://gist.github.com/1246161 is a stylistic rewrite
16:34amalloyi added a number of newlines you might not agree with, but i think it helps to clarify what goes with what
16:34BlafaselI've no trouble with the formatting. In fact, I've no clue how to format these things yet.
16:34Blafaseljust read about update-in: Didn't know that at all. And you're right of course, exactly what I do there.
16:35Blafaselterom: Thanks! He fixed that as well :)
16:36shep-homeBlafasel: If you find a good reference on idiomaticness, I'd love to see it :-)
16:36shep-homeIn a protocol, can you declare a method twice, with different arguments?
16:36Blafaselshep-home: Heh. Guess this channel is as close as I could get to anything clojure so far, so...
16:37technomancy~style guide?
16:37clojurebotstyle is http://paste.lisp.org/display/81021
16:37technomancywhat
16:37amalloy$google mumble scheme style
16:37lazybot[Riastradh's Lisp Style Rules - mumble.net main page] http://mumble.net/~campbell/scheme/style.txt
16:37technomancythere we go
16:38technomancyBlafasel: ^^
16:38shep-hometechnomancy: no big differences for Clojure-specific whatnot?
16:38technomancynot much
16:39technomancyclojurebot: why do we not place losing parens on their own line is <reply> because the parentheses grow lonely if their closing brackets are all kept separated and segregated.
16:39clojurebotAlles klar
16:40BlafaselFunny response, clojurebot..
16:40ibdknox_he's half German
16:40Blafaseltechnomancy: amalloy: Thanks a lot! Reading material :)
16:40Blafaselibdknox_: ;)
16:41technomancyand half gaelic, and half greek, and half...
16:41shep-hometechnomancy: you lost your 'c' in "closing"
16:43BlafaselLooking at that gist I'm more confused than before, I guess, regarding indentation.. But maybe that link will provide some insights. Some things that are on the same ~depth~ for me are now using different indentation.
16:44BlafaselWeird. New.
16:50sridduck1123: i noticed that you ported aleph to clojure 1.3; may I ask how you would specify your fork as a lein dependency?
16:53BlafaselIs there any way to get a diff between gists? That webinterface is confusing...
16:54BlafaselThe new version doesn't work, 'nth not supported on this type: Integer'. No line information, nth is not (directly) part of the code -> Hard.
16:54amalloyBlafasel: sorry, i messed up the update-in
16:54amalloyshould be [key], not key
16:55BlafaselAhhh.. Makes sense now.
16:55BlafaselThanks
16:55amalloyyou would get line information if you put this into a file and loaded it; the only reason you don't is you typed it into the repl
16:56amalloyand gist's styling isn't always perfect; if you copy this to a source file of some kind you should see that it's never the case that two things on the same depth have different indentation
16:56BlafaselAh, ok. Loaded a file into a repl, but probably the tool in use just pipes text, 'pastes' or something
16:58BlafaselI copied the raw version. I especially don't get the indentation around the (lazy-seq) call, the cons below is indented 'funny', that is exactly one space. Most things are aligned to a 2 space boundary?
16:59BlafaselNot sure if that's a glitch (manually on your side, with the gist thing) or correct. Since I'm trying to learn I want to confirm that this is something I should get used to :)
17:01cfahey guys -- quick swank-clojure question: if i add a dependency to project.clj and run lein deps, i there any way of continuing work in my existing repl or do i need to kill swank and clojure-jack-in again?
17:01cfa(apologies if i'm missing something really obvious here)
17:01technomancycfa: currently no way to do that
17:01technomancyjust M-x clojure-jack-in again
17:01cfawill clojure-jack-in safely kill off the old swank? (i've been manually killing the swank buffer so far)
17:02technomancyit will if you have the latest version
17:02cfai believe i do; installed from the official instructions last week
17:02amalloyBlafasel: that's correct
17:02amalloyusually if you put a newline immediately after the function/macro/operator, you indent the next form by only once space
17:03amalloyand that's how emacs does it automatically, of course
17:03BlafaselHeh..
17:03BlafaselOkay, thanks for the patience. No, emacs is not an option right now :)
17:10mabesarg.. marmalade is down... it would appear that marmalade is written in node.js using mongodb... that is what I gather from the error I just got
17:11technomancymarmalade is ... not the most stable
17:12mabesI was able to even infer the guy's github name from the stacktrace which led me right to the code :) https://github.com/nex3/marmalade
17:12mabesI don't think I'll try and fix it though
17:12cfatechnomancy: thanks
17:13cfahmm, the second time i did this: "error in process filter: Symbol's value as variable is void: java\.lang\.RuntimeException:"
17:13technomancycfa: sounds like an old version of clojure-mode
17:14cfahmm, let me check how i fetched it
17:14technomancycfa: if you reinstall without updating the package list you will pull in old versions
17:14technomancyM-x package-refresh-contents; analogous to apt-get update
17:14cfai might have forgotten to do that
17:14cfacurrently running 1.10.0
17:15technomancy1.11.1 is the latest
17:16cfaright, fetched
17:18cfais it safe to M-x unload-feature?
17:18technomancygreat question; I've never tried that
17:18technomancyor even heard of it, actually =)
17:19technomancyit's probably safe
17:19cfa:) trying now
17:19cfai explicitly called package-load-all-descriptors and -archive-contents
17:19cfaso hopefully the new version will get picked up
17:20cfaalso, for reference: i've unloaded -autoloads too
17:22Blktgood night everyone
17:22cfahmm
17:22cfanot only did that not work; starting a fresh emacs is still pulling in 1.10 (even though 1.11 is downloaded)
17:23cfaoh, wait
17:23cfaclojure-mode-version returns "1.10.0" in v1.11 :/
17:23technomancycfa: oh no; oops!
17:24cfanow i'm very confused
17:24cfawell, might as well try clojure-jack-in again
17:24technomancyM-x package-list-packages is the one you should trust
17:25cfasame error when i try to jack in, but who knows which version i'm using :)
17:25cfaokay -- the elpa dir is definitely 1.11
17:25cfaperhaps i should just restart emacs
17:27technomancyjust reloading the defun for clojure-jack-in would do it
17:29technomancyI wonder if the byte-compilation isn't overriding the old version that's already loaded
17:32cfatechnomancy: so 1.11 will re-use the old repl unlike 1.10, right?
17:33duck1123srid: you still around? I just noticed your question
17:34technomancycfa: there's still a bug where sometimes it opens *slime-repl nil* that I haven't tracked down yet
17:34duck1123My fork isn't on clojars, but I push a copy to my repository at build.jiksnu.com
17:35cfatechnomancy: ah okay. well, thanks for the help.
17:47carllercheIs there a way to apply a java static function that takes varargs to a vector?
17:47amalloydump the vector into an array
17:49ClojurificIs anyone here actively contributing to the Leiningen project?
17:50technomancyClojurific: sure
17:50amalloytechnomancy claims to be, but he's a tricky one
17:50technomancyclojurebot: are all cretans liars?
17:50ClojurificCool :] technomancy, what are your future plans for Lein?
17:50clojurebotCool story bro.
17:51technomancyClojurific: here's a thread discussing the plans for 2.0: http://groups.google.com/group/leiningen/browse_thread/thread/1223cd092b83f007
17:52cfanight all
17:52technomancythere are a few things I'd like to add to the 1.6 series, but they are pretty boring (see TODO.org on the 1.x branch)
17:53ClojurificVery nice
17:53ClojurificNo, boring is very necessary sometimes
17:53ClojurificIt's an awesome tool; thank you for all your work
17:54technomancygreat; glad it's helpful
17:55gfredericksLet's say I have a function that returns a canonical version of an object. And it's expensive. So if it gets called with an arg that has already been canonicalized, I'd prefer it not go through all the computation to return the same object. My question is: Is this use case an idiomatic use for metadata? (i.e., tag the return objects with {::canonized true} and check the args for it). Or unidiomatic?
17:55gfredericksI've nearly never used custom metadata.
17:55dnolengfredericks: sounds like a use case for memoization
17:55dnolen,(doc memoize)
17:55clojurebot"([f]); Returns a memoized version of a referentially transparent function. The memoized version of the function keeps a cache of the mapping from arguments to results and, when calls with the same arguments are repeated often, has higher performance at the expense of higher memory use."
17:56gfredericksdnolen: I know about memoization. What if I don't want to worry about the memoization map hogging the memory?
17:56dnolengfredericks: hook up your own memoize to unk
17:56dnolenhttps://github.com/fogus/unk
17:57carkbtw, is there a memoization like function that would only remember one set of arguments and only one result value ?
17:57gfredericksdnolen: so you think metadata is such a bad idea that using an entire library is better?
17:57gfredericksI don't mean that critically, I'm just trying to figure out what metadata is good for
17:58kharringtoncark: memoize on the clojure.org/atoms page with an if statement?
17:59amalloygfredericks: i dunno, seems like a reasonable case for metadata. i don't think memoization is a great choice
17:59carkyes i guess that's an easy one, just wanted to make sure it's not already in the bow
17:59dnolengfredericks: since I don't know the details of your problem I can't say which approach is better. But it sounds like memoization to me.
17:59technomancycark: unk can do that with fifo of depth 1
17:59carkbox*
18:00dnolengfredericks: metadata is cool, though I've found it most powerful in conjunction w/ macros.
18:00amalloyeg, if the canonical form of 7 is 8 (nearest power of 2, say), then you'll compute it once for 7. if you then try to canonicalize that again, you'll have to do it over because 8 isn't in the memo cache
18:00gfredericksamalloy: ah hah! excellent point :)
18:00gfredericksdnolen wants to double my computation :)
18:00technomancygfredericks: it's not always obvious what operations persist metadata, so if you do a bit of transformation to your object it may or may not consider itself still canonical.
18:00amalloyie, memoization doesn't do (all of) what you want, because you have special knowledge about what (f (f x)) is
18:01gfrederickstechnomancy: I figured that might be the case
18:01jedahuThe following error occurs when I run lein and clojure-1.3.0.jar is in lib/dev/. I am at loss as to what to do given it is required by my dev-dependencies. Exception in thread "main" java.lang.RuntimeException: java.lang.NoSuchMethodError: clojure.lang.KeywordLookupSite.<init>(ILclojure/lang/Keyword;)V
18:02gfredericksdnolen: amalloy: technomancy: thanks for the thoughts
18:02technomancyjedahu: that's expected; clojure 1.3.0 should never be a dev dependency with lein 1.x.
18:02dnolenamalloy: seems like you could do 7 - 8 as part of the cache policy, no?
18:02jedahuso upgrade to lein 2?
18:02gfredericksdnolen: that must be a special feature of unk?
18:02technomancyjedahu: if only. it hasn't been written yet. =(
18:03technomancytry to find what's placing 1.3.0 in lib/dev
18:03dnolengfredericks: https://github.com/fogus/unk/blob/master/src/fogus/unk.clj#L41
18:03dnolenseriously, unk should get promoted to contrib ASAP
18:03gfrederickstechnomancy: so for now it's (not (and 1.3 lein))?
18:03technomancydnolen: why?
18:03technomancygfredericks: you can use 1.3 in your projects, just not in your plugins
18:04dnolentechnomancy: because tweaking memoization is not uncommon, and the protocol is something everyone can standardize against.
18:04gfrederickstechnomancy: ah ha -- sense it makes
18:04jedahutechnomancy: so I should make any leiningen plugin I write depend on clojure 1.2?
18:04gfredericks~second
18:04clojurebotMotion seconded and carried. Next agenda item.
18:04gfredericksdnolen: ^
18:05gfredericksclojurebot: so that means you just promoted it to contrib?
18:05clojurebotPardon?
18:05technomancyjedahu: all plugins implicitly depend on everything leiningen depends upon, so don't declare any additional dependencies unless they aren't in lein already
18:05gfredericksdnolen: I've often thought core/memoize's unconfigurability was a bit ugly.
18:06technomancyjedahu: you should read Leiningen's doc/PLUGINS.md
18:06dnolengfredericks: many people have complained - yr not the first.
18:06technomancyit's like two lines to expose the memoization atom, but it got shot down
18:06gfrederickstechnomancy: as metadata?
18:06jedahutechnomancy: thanks, will do
18:06technomancygfredericks: yep
18:08amalloyisn't this because "memoize" specifically means what core/memoize actually does? if you want a configurable cachine library, then write one (as fogus did); i don't think making core/memoize configurable makes sense
18:08gfredericksamalloy: maybe it's an unfortunate name then?
18:08hiredmanamalloy: I concur
18:08technomancyamalloy: it's not about configuration as much as it is about reversibility
18:09amalloytechnomancy: reversibility?
18:09hiredmangfredericks: memoizing is exactly what it does
18:09technomancyirreversible memoization makes tests very difficult
18:09amalloyah
18:09gfrederickshiredman: right, I mean it should do something more useful
18:09hiredmanit is useful
18:09gfrederickshiredman: and perhaps therefore be called something else as well
18:09gfrederickshiredman: I didn't say it wasn't. I said it should do something _more_ useful :)
18:10hiredmanyou want caching, what is a very complex issue, and there are libraries like unk which provide it
18:10gfrederickshiredman: as technomancy said, it'd be a two line change to make the memoize function be a mildly more useful caching function
18:10amalloytechnomancy: i usually (let) a memoized version of the function for testing of that sort; i'm sure you have some use case where that's no good, and i'm curious what it is
18:11technomancya common pattern is (alter-var-root #'my-fn memoize) immediately following a defn
18:11carkhaha ok i didn't understand that unk is a library name, just thought technomancy was having keyboard mishaps
18:11technomancyheh
18:12amalloytechnomancy: but that's horrible and evil, right? i mean, if you don't *really-really* mean that the function itself should be memoized, then don't do that
18:12dnolengfredericks: others have pointed out that memoize isn't really meant for creating top level fns anyhow. if you want something top level you need a caching policy.
18:12dnolengfredericks: exposing it means encouraging people to using a broken cache policy by default.
18:12technomancyamalloy: it should always[1] be memoized. [1] - for certain values of always which do not include the test suite.
18:13technomancythere are lots of things you should never[2] do [2] - for certain values of never which do not include the test suite
18:13amalloytechnomancy: so make a :private non-memoized function, and (def public-version (memoize private-version))
18:13technomancywhat, with no docstring?
18:13amalloyfeh
18:14amalloybut i see where you're going, yes
18:15jedahuWhen I run lein, I get this in the listing. I've looked in core.clj and in myplugin.clj but I can't see what I'm doing wrong. leiningen.myplugin Problem loading: java.lang.IllegalArgumentException: Wrong number of args (4) passed to: core$assert (core.clj:186)
18:16gfredericksdnolen: hiredman: you are both persuasive.
18:18carkallright this hunk library is golden
18:19gfrederickscark: it would let me cache in a DB?
18:19hiredmancache in sunyata!
18:19carkgfredericks: i'm not yet done reading the code
18:20carkbut looks like you can plug any memoization scheme you want
18:21hiredmanhttps://github.com/hiredman/sunyata
18:21gfrederickshiredman: ah hah. I expect that will be much more informative than http://en.wikipedia.org/wiki/%C5%9A%C5%ABnyat%C4%81
18:21hiredmanor, like, I guess you could just use inifinispan
18:21dnolengfredericks: the whole is built ontop of well defined protocols, so swapping in a DB won't be much work.
18:21hiredmanwithout the training wheels
18:23hiredmanit's a joke, cause "what are you relying on to store your data?" "nothing"
18:23gfredericks:)
18:23hiredmanit's much funnier in sanskrit
18:23gfrederickswhat isn't?
18:24sridduck1123: I'm thinking of using your fork, but I cannot fetch the dependencies from your maven repo: https://gist.github.com/1246439
18:24technomancythe ineffable emptiness of the void... is it or is it not web scale?
18:24sridduck1123: btw, have you considered opening a pull request for ztellman to merge your 1.3 support?
18:24technomancysrid: ding! correct question.
18:25srid,+1 srid
18:25clojurebot1
18:25srid,+1 srid
18:25clojurebot1
18:25duck1123He's merged some of my changes, I need to send another one for the rest
18:25technomancy(inc srid)
18:25lazybot⟹ 1
18:25sridalways 1?
18:25gfrederickssrid: not if it happens again
18:25technomancyclojurebot doesn't handle karma, and lazybot won't let you inc yourself
18:26MoominpapaHi, I wanted to ask about scope.
18:26gfredericks(inc gfredericks)
18:26lazybotYou can't adjust your own karma.
18:26gfrederickshmm
18:27MoominpapaI've been trying to write a hook that adds to #'leiningen.ring/ring
18:27gfredericksmaybe the tilde got ignored
18:27MoominpapaAnd it works.
18:27MoominpapaUnless I remove lein-ring from the lib directory
18:27MoominpapaThen it stops deps from working, which is rather bad.
18:28MoominpapaCan anyone tell me how to get around this?
18:28sridduck1123: n/m i fixed the deps issue by browsing the repo; wrong lamina version
18:28sridi hope it gets merged to upstream soon.
18:29duck1123I'm about to push out a new copy, and then I'll put in a pull request
18:29sridexcellent
18:29duck1123of lamina at least, need to check aleph
18:31technomancyMoominpapa: sounds like you need to wrap with some try/catch
18:32technomancyMoominpapa: although hook loading is already wrapped in try/catch if you use :hooks in project.clj
18:33MoominpapaAh, that's cool. I'll look that up.
18:33MoominpapaI was hoping there was a way to detect if "require" would throw.
18:33technomancyhm; elisp has that
18:34technomancyoptional noerror arg
18:34technomancyclojure does not
18:34MoominpapaBut even then, I can get compilation errors. Thinking I need to wrap more stuff in eval.
18:34MoominpapaPity.
18:34MoominpapaThank you! :)
18:36hiredmanugh, really?
18:36hiredmanwhy are you wrapping stuff in eval?
18:38MoominpapaOK, simplest version
18:38Moominpapa(add-hook #'leiningen.ring/ring (myns.watch/watch))
18:39MoominpapaProblem is, if my deps aren't there, myns.watch doesn't compile and everything falls over in a heap.
18:39hiredman(when-let [v (resolve 'lein....ring)] (add-hook v ...))
18:39technomancy:hooks loading actually has a special case where it doesn't even report errors if lib/ is empty
18:47Moominpapaok, so :hooks specifies a list of namespaces that add hooks?
18:49technomancyyup
18:49MoominpapaCool, I will try this tomorrow. Thankyou very much :)
18:59duck1123srid: Ok, I've updated those 3 libraries and pushed them to my repository. I also got around to sending in the pull requests for 2 of them, but gloss' tests are failing on me
18:59duck1123looks like a ratio vs. floats issue
18:59sridduck1123: yea, just saw them :-) i've been using your fork, except for one lamina "closed channel" warning everything is working.
19:00duck1123yeah, I've been getting that one too. Not sure what's up on that.
19:02sridyour snapshot releases are based on ztellman's HEAD or his latest public release?
19:02duck1123off of head
19:03duck1123I can push a rebased version if you want. It's the same few commits over and over again
19:05duck1123When I get a chance, I want to try to replace the use of prxml with data.xml. Those few dynamic warnings drive me nuts
19:16shep-homeIs there a common meaning for a function that ends in a hyphen?
19:17dnolenshep-home: like what?
19:17gfredericksclojure.core/- :)
19:17shep-homeWell, now I'm worried I'm imagining things
19:17dnolenheh
19:18dnolenshep-home: there's defn-
19:18shep-homeI felt I had seen some function pairs like foo and foo-
19:18technomancyit means someone was typing a function name and paused to think of the right word and forgot to start typing again
19:18gfredericksif I saw it I would imagine it's similar to foo and foo*
19:18duck1123actually, I just saw on in gloss, let me find it
19:18shep-homegfredericks: what would that mean then?
19:19dnolenshep-home: foo will often be defined in terms of foo*.
19:19gfredericksshep-home: My interpretation is that foo- is a private simpler version of the function and foo is some wrapper around it
19:19gfredericksshep-home: also what dnolen said
19:19shep-homeand it would be unexpected for an outside user to call the * or - version
19:19gfredericksyes
19:20gfredericksshep-home: I ofter have a macro-function pair where the function ends in *
19:20gfrederickss/ofter/often
19:20lazybot<gfredericks> shep-home: I often have a macro-function pair where the function ends in *
19:20gfredericksshep-home: I suppose in that case it wouldn't be unheard of to call the * version
19:20shep-homebut it would still be more of a "you know what you are doing by calling this"
19:21gfredericksyeah. not the standard interface.
19:24shep-homedefn- nicely answers the related question I was going to ask, so thanks for pointing it out :-)
19:24gfredericksin #clojure we always try to answer your current question and your next question in one go
19:25nappingare there any examples of long polling with ring?
19:25shep-homegfredericks: is your *answer-seq* of length 2, or do i need to take more?
19:25shep-home:-)
19:26gfredericksshep-home: nil
19:26gfredericksnapping: is aleph not appropriate?
19:26nappingnever heard of it, thanks
19:26gfredericksnp
19:27nappingI found https://github.com/mmcgrana/picard
19:28gfredericksyou'd think if I search for "mmcgrana picard" in github's search box that something would come up :|
19:28duck1123Aleph works great for that
19:29duck1123in aleph, you get a channel. When you're ready to send, just enqueue the channel
19:30ibdknox_the reason aleph is good for long polling is primarily that it's built on netty
19:30ibdknox_which is important for long running connections
19:40gfredericksI'm using aleph TCP and frequently get nil messages coming through the channels...does anybody know what that means?
19:53ZolrathI'm trying to use pinot to add elements to the DOM but nothing I try seems to actually… do anything?
19:54Zolrath(dom/append (dom/query "body") (ph/html [:p "Test"])) results in no change, but from what I can tell that should add <p>Test</p> into the body tags on my page
19:54ibdknox_Zolrath: are you including the script file after the body tag is loaded?
19:54ZolrathIf I do a (js/alert "Test") it appears so the javascript is getting loaded
19:54Zolrathoooooh
19:54ZolrathNo I'm not
19:54ibdknox_:)
19:54ZolrathThank you very much
19:54ibdknox_that got me too
19:54ibdknox_lol
19:55gfrederickswhat's all this? the <script> goes after the <body>?
19:56ibdknox_<body>..content... <script> </body>
19:56ibdknox_it's a common pattern in JS
19:56gfrederickspresumably just barely uncommon enough that I've never heard of it
19:56gfredericksis that an alternative to the dom:ready event?
19:57ibdknox_there is no dom ready in gclosure
19:57ibdknox_sadly
19:57gfredericksthus the <script> positioning?
19:57ibdknox_yessir
19:57brehautgfredericks: older browsers would also wait for scripts to load and compile before loading other resources
19:57ibdknox_though there are other benefits
19:57ibdknox_yeah
19:57brehautwhich would block images and css
19:58ibdknox_it allows all your content to come in before the script loads/runs
19:58gfredericksin the newer browsers it would slightly delay the request for the script?
19:59brehautmodern browsers have much more sophisticated heuristics on how and when to load scripts
19:59brehauti dont tihnk you could make a blanket statement about them
20:00gfredericksbrehaut: I just meant that it wouldn't even know about the script until it had at least read through the page
20:00brehautsure
20:00gfredericksI'm sure it's not a big deal though
20:00gfredericksthx for educate
20:00gfredericksI learn something new every time I asks questions about topics I'm ignorant of.
20:00ibdknox_gfredericks: http://stackoverflow.com/questions/2024018/using-domcontentready-considered-anti-pattern-by-google
20:01gfredericksibdknox_: thx
20:02brehauti think yahoo's yslow agrees with that too
20:02upwardindexYes, I'm pretty sure I read putting scripts at the very end in yahoo's recommendation for web dev
20:03gfredericksFrom now on I'm doing <script> ...content... <body></script>, just to be controversial
20:03gfredericksI'm sure the browsers will figure it out
20:04upwardindexgfredericks: http://developer.yahoo.com/performance/rules.html might want to check this (also "Put scripts at the bottom" section
20:11gfredericksI'm using (.readLine *in*) in a program, and have found that `java -jar my-uber.jar` works while `lein run` doesn't -- anybody know the difference?
20:11amalloygfredericks: one of those uses lein
20:11amalloy~rimshot
20:11clojurebotBadum, *ching*
20:12nappingIs there some way to pick up new dependencies in project.clj without restarting slime?
20:12gfredericksI'll switch to make immediately!
20:12amalloyseriously though, there's something i don't understand which makes it hard to get stdin when running through lein or cake
20:12nappingI've run lein deps in a shell, which copied in more files, but they don't seem to be visible in the repl
20:12amalloynapping: no
20:13amalloy(sorry, that's just the way it is)
20:13technomancygfredericks: try lein trampoline run
20:14nappingOk, that's what I was doing anyway
20:15technomancyamalloy: tempted to add code to swank that shells out and runs add-classpath or something absurd like that
20:15gfrederickstechnomancy: that totally worked.
20:15gfredericks(inc technomancy)
20:15lazybot⟹ 14
20:15technomancygfredericks: finally, a use for that task! =)
20:16gfrederickswell wuddayaknow.
20:18ibdknox_what does lein trampoline do?
20:19gfredericksibdknox_: A: There's a bug in the Ant library that Leiningen uses to spawn new processes that blocks access to console input. This means that functions like read-line will not work as expected in most contexts, though the repl task necessarily includes a workaround. You can also use the trampoline task to launch your project's JVM after Leiningen's has exited rather than launching it as a subprocess
20:19gfredericks^ quoted from lein readme
20:20ibdknox_I see
20:20technomancyit's like clojure.core/trampoline, but operating on tasks instead of functions
20:20technomancysorta
20:20gfrederickstechnomancy: if my task returns a function, will it launch another jvm?
20:20ibdknox_is read-line really the only use for it?
20:20technomancygfredericks: no
20:20technomancywell
20:21technomancyreally it just runs all the tasks you specify but with eval-in-project replaced with something that just records what should have been run, then passes control back to the shell script
20:21technomancyand the shell script can invoke java with the project's own classpath directly
20:21technomancyibdknox_: so you can also use it to save memory since it allows leiningen's own java process to exit
20:22ibdknox_technomancy: gotcha
20:22technomancybasically it's to make up for the fact that java's posix support is a joke and it doesn't implement exec.
20:25amalloymmmm, trampoline. sounds super. i've been vexed recently by that extra jvm sticking around forever
20:26technomancyactually vexed or just a bit irritated?
20:27amalloytechnomancy: i don't think vex is inherently a stronger word than irritate, is it?
20:28amalloyvex can mean puzzlement as well
20:28technomancyhmm... I think of vex as being along the lines of keeping one up at night, but I don't know if that's accurate.
20:28amalloyit's a pretty flexible word
20:29gfredericks,(let [vex inc] (vex 12))
20:29clojurebot13
20:29gfredericksindeed
20:29amalloythings seem to be okay now, but for a week or two 4clojure was having sporadic OOM issues (our fault, probably not lein's), and the extra memory of the lein jvm was problematic
20:30technomancyyou use "lein run" in production?
20:30amalloyour server deploy tools are embarrassingly primitive, yes
20:30technomancyI used to advise against that until mcgrana convinced me otherwise.
20:30technomancydo you know about LEIN_NO_DEV?
20:30amalloyno
20:30technomancyit'll keep dev deps and test off the classpath
20:30amalloydoes that matter?
20:31gfredericksfor class load latency maybe?
20:31technomancydepends on what you keep in test I guess =)
20:31technomancywe put lots of config in there that isn't appropriate for production
20:31amalloynobody who knows how to do deploys/admin better is interested in contributing, so we just use lein
20:31technomancyin test-resources, rather, but same idea
20:32technomancymaybe hugod would be interested in making it an example for pallet =)
20:32arohnertechnomancy: what are the arguments for and against lein run in production?
20:32technomancyarohner: well... they are mostly addressed by LEIN_NO_DEV and lein trampoline =)
20:32technomancythe arguments against, anyway
20:33technomancythe main remaining one is that dependency resolution happens at deploy time, so if remote repos go down or if new snapshots sneak in you lose repeatability.
20:33technomancyheroku solves that with the slug compiler, 4clojure probably solves it by not needing repeatability by virtue of having only a single server. =)
20:34arohnerI like to solve that one with a private maven repo
20:34technomancyyes, that's even better
20:34arohnersomeone needs to build a lein plugin for creating maven repos in S3...
20:35technomancyit can still let through newer snapshots, lein will try to talk you out of cutting releases that depend on snapshots anyway
20:35arohnerit'll probably be me that ends up making that...
20:35technomancyarohner: I've actually been considering making clojars store its artifacts on s3
20:37j941trying to convert (map second soaps (mapcat keys)) to thrush operator, but i failed...
20:37j941(-> (map second soaps) (mapcat keys))
20:37j941more like, (apply (partial conj #{}) (mapcat keys (map second records)))))
20:38amalloy->>
20:38j941I want to convert it so that its linear, thrush style... but it won't work :(
20:38amalloyoh, nm
20:38amalloy(->> (mapcat keys) (map second soaps))
20:39j941yay! --> 2nd arg, -> is the first ?
20:39amalloy->> is last
20:39amalloyalso, your partial there is unnecessary
20:39j941ok
20:39amalloy(apply conj #{} (...))
20:39j941im reverse engineering code from this post http://www.magpiebrain.com/2010/08/10/creating-sparse-tabular-data-with-clojure/
20:41amalloywow, why is he trying to turn this stuff into strings?
20:43amalloyoh, he's trying to...create a csv? man, this is so much more complicated than it would be if he flipped the table 90 degrees - a column per day, and a row per show
20:43j941yeah it seems nuts.
20:44amalloyi advise against reverse-engineering things which are nuts
20:45nappingshould this code be serving empty pages http://pastebin.com/CiTe3PLh ?
20:45j941haha well. i just want to tabulate this http://pastebin.com/Dy401Br6
20:46amalloy$google clojure csv
20:46lazybot[davidsantiago/clojure-csv - GitHub] https://github.com/davidsantiago/clojure-csv
20:46j941#
20:46brehautnapping: it shouldnt return a blank page
20:46nappingit works as expected if it's (run-jetty app {:port 8080})
20:46brehautnapping: also, you have c-itus with your closing braces and parens
20:47amalloynapping: loading your namespace has the side effect of trying to launch a jetty server
20:47amalloyand wrap-reload will load your namespace often
20:47nappingah
20:47j941oh wow i just saw clojure0csv that looks good.
20:47ibdknox_napping: noir would take care of all this basic stuff for you, if you're just trying to get started
20:47amalloyi don't know if that's the cause of your problem, but you shouldn't do it
20:47brehautnapping: (defonce server (run-jetty…
20:50j941but im wondering -- how can i transpose the data in clojure ?
20:50j941i will pastebin it ... hold on ...
20:51brehaut,(apply map vector [[:a 1] [:b 2] [:c 3]])
20:51clojurebot([:a :b :c] [1 2 3])
20:52brehautfor a simple case
20:53j941http://pastebin.com/8Sgb2AeN
20:54j941So the idea is, that, i want a lists columns to become headers in the file.
20:55j941so taking a list with several 4-tuples in it, and then turning it into a 2D list where the entire tuple is the value of any x,y point.
20:56nappingdefonce doesn't seem to work well enough - and it still comes up blank.
20:56nappingat least it gives me a server handle, I didn't realize there was a meaningful result
20:56brehautnapping: defonce just stops it being redefined on reload
20:57brehautnapping: are you testing this from a browser or a repl?
20:57nappingit seems C-c C-l does something more then
20:57j941are there 2d data structures in clojure?
20:57nappingtesting from a browser, running from slime
20:57j941like 2d lists ?
20:57j941or map w/ two keys ?
20:57brehaut,{[1,2] :a [4,5] :b}
20:57clojurebot{[4 5] :b, [1 2] :a}
20:58brehaut,[[1 2 3] [4 5 6] [7 8 9]]
20:58clojurebot[[1 2 3] [4 5 6] [7 8 9]]
20:58j941@brehaut , so [4 5] is a key pointing to "b" ?
20:58j941(thanks)
20:59brehautj941: to :b
20:59brehaut(keyword, rather than a symbol)
20:59nappingwhat's that about braces? some are where paredit put them, and some are there to make it easier to add more items
20:59j941ok but it could easily be {[1,2] "a" [4,5] "b"} , right ?
20:59brehautj941: yes
21:00brehautnapping: ok. just as long as you realise that its unidiomatic to have closing parens etc hanging on their own line
21:00j941cool. so is there a Lispy way to convert A_6546_p_100_c_10/final.pdb,CA,3.7584383 into such a list element ?
21:00j941or just roll up elbows and use java split it
21:01brehaut,(split "ab,c,d" #",")
21:01clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: split in this context, compiling:(NO_SOURCE_PATH:0)>
21:01nappingwhat do you do? C-M-f?
21:02j941oh ok cool clojure has a split . thanks.
21:02brehaut,(use 'clojure.string)
21:02clojurebotWARNING: replace already refers to: #'clojure.core/replace in namespace: sandbox, being replaced by: #'clojure.string/replace
21:02clojurebotWARNING: reverse already refers to: #'clojure.core/reverse in namespace: sandbox, being replaced by: #'clojure.string/reverse
21:02clojurebotnil
21:02duck1123,(clojure.string/split "ab,c,d" #",")
21:02clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox>
21:02gfredericksdoes clojurebot reboot regularly?
21:02brehautyikes im sorry
21:02duck1123whenever someone breaks it :)
21:03gfrederickshow does it know when it's been broken?
21:03gfredericksbrehaut: if you want to really have fun start setting functions to macros
21:03j941clojure bot doesnt like it.
21:04j941i guess because missing import? Thats cool that clojure bot ... does it run everything we type?
21:04gfredericksj941: prefixed with a comma
21:04brehautj941: no the bot is sandboxed, no eval, defs etc
21:04gfredericks,(str \: \- \D)
21:04clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox>
21:04gfredericks,(inc 38)
21:04clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox>
21:05brehautit also helps if some twit didnt break the bot first
21:05duck1123It's not going to do anything
21:05gfredericksif I knew my ns functions well enough I'd try to set them back
21:05gfredericks,(use 'clojure.core)
21:05clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox>
21:05amalloyhiredman: clojurebot needs someone to resurrect him
21:05gfredericksI would have guessed clojurebot would reboot itself every so often
21:05clojurebotI don't understand.
21:06gfredericksclojurebot: are you male?
21:06clojurebotCool story bro.
21:06duck1123clojurebot: reload
21:06clojurebot_seanc_: Your files don't get reloaded when a request is made.
21:08j941why the # in split ? why not just (clojure.string/split "a,b" ",") ... is # making the stirng a function ?
21:08gfredericksj941: makes it a regex
21:08brehautj941: split takes a regexp
21:08gfredericks&(type #"fubar")
21:08lazybot⇒ java.util.regex.Pattern
21:11duck1123Is there a flag that'll make lein re-fetch all of the snapshots? (similar to -U in maven)
21:15j941how to get the 1st and 3rd elements of a list ? (nth [ 1 2 3 4 ] 1 3) doesnt work
21:16brehaut(map #(nth [1 2 3 4] %) [1 2])
21:17brehauterr make that [1 3] at the end
21:17brehautor alternatively with destructuring (let [[a _ b] [1 2 3 4]] [a b])
21:17j941good call @brehaut
21:18j941why _ in the middle ?
21:18brehautso that you skip an element
21:18brehaut_ is bound but we dont care about it
21:19brehautactually thats slightly wrong because, thats 0 and 2 rather than 1 and 3
21:19j941yup could be x y z got it
21:19brehaut(let [[_ a _ b] [1 2 3 4]] [a b])
21:19joegallo,(vals (select-keys [1 2 3 4 5] [1 3]))
21:19clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox>
21:20joegallooh well, anyway, that works if you don't care what order they're in
21:20brehautj941: its hard to suggest a particular form without knowing what you are doing with it though
21:20gfredericks&(vals (select-keys [1 2 3 4 5] [1 3]))
21:21lazybot⇒ (4 2)
21:21gfrederickseven stranger that it comes back as a list...
21:22gfredericksoh never mind
21:22duck1123it's probably a lazy seq
21:22gfredericksit's a map actually
21:22gfredericks&(select-keys [1 2 3 4 5] [1 3])
21:22lazybot⇒ {3 4, 1 2}
21:23brehautselect-keys uses find under the hood, i dont know if that impacts its performance profile compared to nth though
21:24gfredericksbrehaut: my repl thinks nth and find on vectors are about the same
21:25duck1123isn't find special cased for vectors?
21:25brehautno idea, its in the RT
21:25brehautso source doesnt tell me
21:25gfredericksI think it'd have to be, if it only works for vectors and maps
21:26j941is there a way to target thrush to specific args ?
21:26j941(->X (f1 X) (f2 "hi" X) (f3 "hello" "again" X))
21:26brehaut-> isnt thrush, its a rewriting macro
21:27brehautif you want X to be threaded at the end of the forms, use ->>
21:28brehaut&[(macroexpand '(-> 1 (a b))) (macroexpand '(->> 1 (a b)))]
21:28lazybot⇒ [(a 1 b) (a b 1)]
21:29gfrederickswhat if ->> went to the second arg, and ->>> etc., and -< went to the last...
21:30amalloygfredericks: you can make it happen
21:30gfredericksamalloy: I know, I've seen amalloy-utils :P
21:30amalloyhar har
21:31duck1123I don't think I've ever wanted to thread multiple functions on the second arg
21:31gfredericksduck1123: me neither
21:31brehautgfredericks: im pretty sure you'll pronounce brehaut more incorrectly
21:31gfredericksduck1123: unless you were also talking about the last arg
21:31duck1123right
21:31gfredericksbrehaut: I always pronounce 'brehaut' as 'amalloy'
21:32brehautlol
21:32amalloyletter-A, muh, LOY
21:32gfredericksso not AH-muh-LOY
21:32amalloyhey, say whatever you want in the confines of your own head
21:32amalloyeveryone still calls you girlfrog anyway
21:33gfredericksit can't be helped
21:33amalloy(you're gfrlog, right?)
21:33gfredericksit's undeniable
21:33brehautlol
21:33gfrederickswho else interjects as much as I do?
21:34amalloywell
21:34amalloythere was that guy yesterday
21:34amalloywho put newlines every five words
21:34amalloyhe probly interjected more yesterday
21:34amalloythan you have in your life
21:34gfredericksglad I missed that
21:35gfredericksirc haiku
21:35amalloy~haiku
21:35clojurebotIt's greek to me.
21:35gfredericksan opportunity!
21:35amalloygfredericks: just /msg fsbot haiku, it's easier
21:36gfredericksthe things I don't know about
21:36gfredericksthey are numerous
21:37gfredericksI think I got this backwards
21:38amalloythat's not a haiku, is it??
21:38lazybotamalloy: What are you, crazy? Of course not!
21:38gfredericksthis isn't how you trigger lazybot, is it?
21:38amalloyevidently not
21:38gfredericksmust need the second question mark
21:39gfredericksamalloy: don't pretend you don't know all its secrets
21:39amalloygfredericks: you think i wrote the darn thing, or something???
21:39lazybotamalloy: Oh, absolutely.
21:40amalloy~guards
21:40clojurebotSEIZE HIM!
21:41gfredericksnow get them to fall in love
21:41amalloy~<3
21:41clojurebot<3 is </3
21:42amalloyi don't remember who taught him that, but it's sad that this is all he knows of love
21:42gfredericksis there a way to get him to return all values for a key?
21:42amalloy*shrug*
21:42amalloyprobably not, since it's not just k/v, it's search
21:42gfredericks~love
21:42clojurebotExcuse me?
21:43gfrederickswhat? no song references at least?
21:43amalloyclojurebot: tell us about python
21:43clojurebotpython is ugly
21:43brehautopinionated SOB isnt he
21:43gfredericksclojurebot: ~haskell
21:43clojurebotCool story bro.
21:43gfredericksonly picks on the weaklings
21:43amalloysee, he doesn't have any special treatment for "tell us about", and python is at the end; he does some kind of search in his db
21:43amalloygfredericks: i think this implies that you are the weakling
21:44gfredericksclojurebot: where can I buy a python?
21:44clojurebotpython is ugly
21:44amalloyclojurebot: what's the deal with haskell?
21:44clojurebot"you have to see features like that in the context of Haskell's community, which is something like Perl's community in the garden of Eden: detached from all shame or need to do any work." -- ayrnieu
21:48j941(-> (slurp "resources/hino.txt") (clojure.string/split "_") )
21:48j941(->> (slurp "resources/hino.txt") (clojure.string/split "_") )
21:48gfredericksj941: you want #"_" instead of "_"?
21:48j941also fails ? REPL Complains about Regex cast.
21:48j941ooops
21:50jeremyheilerclojurebot: tell us about ruby
21:50clojurebotChunky bacon!
21:50jeremyheilerlol
21:51amalloyhaha what
21:51amalloy~ruby
21:51clojurebotChunky bacon!
21:51amalloyfascinating
21:51gfredericksbetter than being ugly I guess
21:51brehaut~pascal
21:51clojurebotExcuse me?
21:51gfredericksat least it smells good
21:51duck1123makes perfect sense
21:51jeremyheiler(it's a reference to why's book i suppose)
21:52brehaut~java
21:52clojurebot
21:52brehauthaha
21:57j941do i need let for this ? (let [[a _ b] [1 2 3 4]] [a b])
21:58duck1123you need a place where you can do destructuring
21:58gfredericksif you had a function called 'third' then you could do (juxt first third)
22:00amalloydidn't we do this with select-keys a minute ago?
22:00amalloyoh, nm, wait
22:00amalloy&(map [1 2 3 4] [0 2])
22:00lazybot⇒ (1 3)
22:00gfredericksif he's got a vector
22:01amalloygfredericks: he just said he did :P
22:01gfrederickswell I didn't see it
22:01amalloyi mean, the question he asked has a vector
22:01gfredericks:P
22:01brehautamalloy: nah, he quoted my code
22:02brehauti think i might have assumed it was a vector
22:02brehautor just used it for example
22:02ZolrathThe examples for remote calls in pinot seem straightforward but even copying their example and trying to run it, none of the calls seem to actually happen
22:03j941oh ok @nm
22:03ZolrathI'm using the wrap-remotes middleware in Noir and I've tried defining the remote in multiple places
22:07j941hmmm ok almost working ... but .... still getting an error .
22:07j941(-> (slurp "resources/hino.txt") (clojure.string/split #"_") (map #(nth % 1) ))
22:07j941-> (slurp "resources/hino.txt") (clojure.string/split #"_") (map #(nth % 1) ))
22:07j941"Don't know how to create ISeq from: user$eval297$fn__298
22:13gfredericksj941: map takes the function first and the collection second
22:13gfredericksyour use of -> puts them in the wrong order
22:13brehautj941: its not haskell, you dont need to feel obligated to point free everything ;)
22:15j941what is point free
22:16j941i think the argument doesnt get into the map
22:16gfredericksj941: replace (map #(nth % 1)) with (->> (map #(nth % 1)))
22:17gfredericksthe argument gets into the map fine, just in the wrong spot
22:17gfredericksyou want it last
22:17j941oh ok.
22:18j941i didnt know you could have --> and -> together!
22:18gfredericksj941: also you could repcale #(nth % 1) with second
22:18j941i know... im not thinking functionally
22:18gfredericksj941: a trick hiredman taught me
22:18j941im thinking in syntax. <-- naughty boy
22:19gfredericksj941: the fact that you can use them together is just a result of how they work, not something that's intentionally built into it
22:19j941now its returning some kind of function
22:19j941(-> (slurp "resources/hino.txt") (clojure.string/split #"_") (->> map #(nth % 1) ) )
22:20gfredericksj941: you forgot a set of parens around map
22:20gfredericks(->> (map second))
22:22ibdknoxpyr: pushed a fix for the event stuff you were seeing yesterday
22:22j941o ok. thats odd.... what is the diff made by adding the parens
22:23j941i mean, shouldnt it "know" that im trying to run the map function ?
22:23gfredericks&(map macroexpand '[(->> coll map second) (->> coll (map second))])
22:23lazybot⇒ ((second (clojure.core/->> coll map)) (map second coll))
22:23ibdknoxyou have to tell it how to group the parameters
22:24gfredericksj941: (->> coll map second) simplifies to (second (map coll))
22:24gfrederickswhich is not what you want
22:24gfredericksyou want (map second coll)
22:24gfrederickswhich is what you get from (->> coll (map second))
22:29j941oh ok
22:30sridanyone wanting to participate in stanford's #ml-class?
22:30companion_cubewhat is it,
22:30companion_cube,
22:30clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox>
22:30companion_cubeoops
22:31duck1123great companion_cube you broke it :)
22:32companion_cube,(+ 2 2)
22:32clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox>
22:32Zolrathsrid: I'm planning on it! I've gone through a few of the videos that they have up right now in preparation.
22:33companion_cubeduck1123: no, i found a bug ;)
22:33duck1123no, someone tried to use clojure.string and killed him
22:35j941how can you have (->>) in the last function ? isnt the job of ->> to forward args?
22:36duck1123which one?
22:37Zolrath(-> thing (another one)) would result in (another thing one) but (->> thing (another one)) would be (another one thing)
22:38duck1123they both just rewrite the code
22:38brehautj941: -> and ->> just rewrite the forms; its really easy to see with macroexpand
22:38j941ok
22:38duck1123I was so happy when I discoverd my little debug logging macro still worked with -> and ->>
22:39amalloyduck1123: it actually works even better, i suspect
22:39amalloymine is named ?, for maximum concision, and you can just slam it into a pipeline without even putting in parens: (->> data (stage 1) (stage 2) ? output)
22:39duck1123https://github.com/duck1123/ciste/blob/master/src/ciste/debug.clj
22:40duck1123I like that name though
22:40amalloyduck1123: see also ##(doc pr-str)
22:40lazybot⇒ "([& xs]); pr to a string, returning it"
22:40amalloyyou really-really don't want to use print for debugging
22:41duck1123good point, I'll change that
22:41amalloymostly because ##(map print-string ['a "a" \a]) all look the same
22:41lazybotjava.lang.Exception: Unable to resolve symbol: print-string in this context
22:41amalloymostly because ##(map print-str ['a "a" \a]) all look the same
22:41lazybot⇒ ("a" "a" "a")
22:42duck1123well, the point is I usually wrap a variable, and it prints that name and the pretty-printed value
22:43amalloyduck1123: right. and if you want to know whether its value is a string or a symbol?
22:43amalloy&(map pr-str ['a "a" \a]) actually makes them print differently; you don't lose information
22:43lazybot⇒ ("a" "\"a\"" "\\a")
22:43duck1123fair enough
22:45devthcan anyone give me a little guidance here? i'm writing my first clojure app - a campfire chatbot - and my regular workflow is to write some code, send it to the repl and execute it. however, my listening handler is a blocking `with-open` expression that listens for chats, which takes over my repl and blocks all other input. i then need to ctrl+d, restart the repl, send all my code to it and proceed. suggestions?
22:47brehautdevth: im particularly familiar with with-open, but i think if you spawn a thread to contain that activity, and use #' (var quoting) to reference the functions that are going to be redefined
22:47brehautdevth: your repl shouldnt block that way
22:47devthbrehaut: ah, excellent. now i need to go learn how to spawn a thread :)
22:47brehautdevth: the cheating way is (future …)
22:48devthbrehaut: thanks for the tip.
22:48j941size of a list ?
22:48brehautdevth: dont chuck it into your NS without wrapping it in a fn or defonce
22:48devthok.
22:48j941i googled "length of list clojure" and it pulled up an article about tail-recursion. lol...
22:49jeremyheiler##(count '(1 2 3))
22:49lazybot⇒ 3
22:49j941duh count
22:50tomojI was thinking "why not make lists counted?".. but they are :)
22:51duck1123j941: do you know about clojureatlas.com ? It's good whan you know what you want to do, but not what it's called
22:53j941clojure needs better error messages. is this under way for next version ?
22:57j941clojureatlas never used it will check
22:58brehautj941: its an ongoing process. depending what you mean by 'better'
23:01devthbrehaut: worked like a charm :)
23:01brehautdevth: glad to hear :)
23:02brehauttheres not many languages where just throwing a thread at the problem makes things better
23:02j941is there an idiomatic way to "fork" a list into 3 different functions ? I have a big pipe im building. its getting bigger now,
23:02j941(-> (slurp "resources/hino.txt") (clojure.string/split #"\n") (->> (map #(clojure.string/split % #"_"))) (->> (map count) )) ;;
23:02brehautj941: 'fork' ?
23:03j941i want to do 3 functions to the output of the 2nd to last func (a->b->c1, a->b->c2, a->b->c3)
23:04duck1123save the step before they split? (ie. let)
23:04brehaut((juxt count (partial apply +)) [1 2 3])
23:04brehaut&((juxt count (partial apply +)) [1 2 3])
23:04lazybot⇒ [3 6]
23:04brehautlike that?
23:04j941what is juxt supposed to do i never really understood
23:05brehautit juxtaposes some functions; ie, count and sum in that example
23:05brehautjuxt returns a new function. the arguments to that function are passed to all the juxtaposed functions and a vector is returned with all the arguments
23:05j941processing <---
23:05j941oh wow
23:06brehauteg, (juxt inc dec) ~> (fn [x] [(inc x) (dec x)])
23:06j941well ... how come duck1123 didnt say juxt !
23:06j941thats cool
23:06brehautbecause your question was quite hard to follow?
23:06j941lol
23:06brehaut(i took a random guess)
23:06joegalloso, in this case, your example might resemble ((juxt c1 c2 c3) (b (a)))
23:06j941brehaut saves the day (again)
23:06j941excellent
23:07joegalloj941: and duck1123's way was totally fine, too
23:07j941im trying to wean myself off vars
23:07brehautjoegallo: lets do this properly :P ((comp (juxt c1 c2 c3) b a))
23:07duck1123I don't use juxt as much as I should
23:08j941comp
23:08j941not sure whats that do
23:08brehaut(comp a b) => (fn [& args] (a (apply b args)))
23:08brehautit composes some functions
23:08j941why compose ?
23:08brehautj941: this is 'point free' programming; writing programs in terms of functions but without reference to their arguments
23:09j941oh ok
23:09j941why "point" free
23:09duck1123use it when it feels right, but don't force yourself to it
23:09j941arg free
23:09brehautj941: because discrete math :P
23:09j941ok
23:10brehautits to do with fixed points of functions
23:10duck1123(comp a b) is easier than #(a (b %))
23:10brehautblah blah haskell blah blah
23:10joegallohttp://en.wikipedia.org/wiki/Tacit_programming
23:10j941less vars/args -> more logic -> cleaner data flow . makes sense.
23:10j941duck1123 what do you mean ? are those equivalent ?
23:11duck1123roughly, yes
23:11j941yeah your right they are. cool . comp must be really important.
23:11brehautj941: importantly point free programming describes the relationship between functions. there are situations where that makes things clearer (parser combinators are a great example). sometimes it just makes things messy though
23:12ZolrathOr maybe my issue is that I don't understand clojure/clojurescript interop
23:12ZolrathIf I define a remote call that returns a string it works
23:12ZolrathBut if I try to make the Clojure portion return a map and then call different portions of the map in clojurescript, no go
23:14duck1123Zolrath: is it picking it up as a map? or is it a string now?
23:15Zolrathduck1123: it doesn't seem to be returning anything when I send a map through the remote
23:16ZolrathIf I do (:title result) in the clojure side and send that as the result I get the title
23:16Zolrathbut if I just send the result to clojurescript and try calling (:title result) on that, nothing
23:16duck1123how are you sending it?
23:17j941it would be better if -> ->> could be order independant
23:17ZolrathThe pinot defremote/remote macros
23:17j941like binded to some keyword or variable
23:18brehautj941: i like to use -> and ->> as a seasoning rahter than a flavor. write small named functions to do various pieces, and then run then together with -> as needed
23:18duck1123isn't that what let is for?
23:18brehautor go properly point free
23:19j941oh ok. this can be done point free ?
23:19j941(-> (slurp "resources/hino.txt") (clojure.string/split #"\n") (->> (map #(clojure.string/split % #"_"))) (juxt (->> (map count) () )) ;;
23:19nappingare servlets notified in any way if the client closes the connection before they are done?
23:19j941forget about juxt part thats just a WIP
23:19brehautj941: just start with a let
23:19j941yeah let is what i normally do but i feel like if i overuse let, i might as well be programming in java.
23:20j941nevertheless i see ure point
23:21duck1123either that, or breik pieces of this off into higher level fns
23:21duck1123and then thread those
23:21duck1123man, my typing is bad tonight
23:22brehaut&(find-doc "read-lines")
23:22lazybot⇒ ------------------------- clojure.contrib.duck-streams/read-lines ([f]) Like clojure.core/line-seq but opens f with reader. Automatically closes the reader AFTER YOU CONSUME THE ENTIRE SEQUENCE. ------------------------- clojure.contrib.io/read-lines ([f]) L... https://gist.github.com/1246912
23:22nappingalso split-lines
23:23brehautyeah, ignore read-lines
23:24duck1123so if you have read-lines, but you only consume the first, does it leave that open once it goes out of scope?
23:24brehaut(you can trivially define it as (def read-lines (comp split-lines slurp)) if you find yourself repeating it)
23:25brehautduck1123: im going to pretend that given its in old contrib that it doesnt exist at all
23:25Zolrathduck1123: Figured it out, had a Date object as a value to one of the keys which did not please Clojurescript
23:25duck1123yeah, I globally exclude old contrib in my projects
23:26brehautmy projects still rely on it a bit, but im working on getting them off it
23:27duck1123Good to hear. Pinot wasn't ready to use when I last looked at it, and I havn't gotten back around to touching up my clojurescript yet
23:27brehautpinot is doing RPC?
23:27duck1123I had to patch just about every dependency I had at one point, but it's getting a lot better now
23:28brehautmy one publicly available (but thankfully not largely deployed as far as i know) library is still waiting on algo.monads
23:32nappinghow is (deliver blocked "Response!") not failing if other code has changed so blocked will always be a result of (ref "message")?
23:36icefoxAnyone already report that paypal isn't letting you register for the clojure-conf class/conference?
23:36brehauticefox: i did see something about them trying to organise more sets for the conj, so maybe its not letting you register atm because of that?
23:37amalloynapping: i don't think that's the case
23:37icefoxPaypal says it can't process the order because the account isn't accepting at this time or something like that
23:37amalloy&(deliver (ref "message") "Response!")
23:37lazybotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn
23:37icefoxpaypal didn't lock the account did they?
23:38nappinghttp://pastebin.com/w0hpStyt
23:39amalloynapping: i refuse to look at code with that much mutable state. that's gross
23:39nappingI see refs piling up in the collection, and "/release" reporting numbers
23:39amalloybut the issue is that for is lazy - you're not executing any actual code in the body
23:39nappingah, that would do it
23:43nappingworks much better with the doall
23:43amalloyugh
23:43amalloydoseq
23:44Apage43You could also just use doseq
23:44amalloyhm. i sound crabby, sorry. going to stop trying to be helpful for a bit
23:45nappingwell, I'm wondering if there is anything that delivers an exception to or otherwise eliminates servlet handlers if the client goes away while they haven't produced a response
23:46technomancynext time someone complains about how hard slime is to set up I am going to link them to http://ascarter.net/2011/09/25/modern-ruby-development.html
23:46technomancybecause *that* is complicated
23:46technomancyI used to do ruby full time and I only understand about half of it
23:46brehautwhoa
23:49Apage43how did node.js get in here
23:50brehautApage43: who doesnt need more javascript in their enviroment?
23:50technomancy"now you have 1.999999999999999999999998 problems"
23:52j941"
23:53j941Article Im reading about "juxt".
23:54Apage43just how much is there to say about it
23:55brehautj941: careful, too far down that rabbit-hole and you'll hit arrows
23:56technomancyow! my skin! http://p.hagelb.org/arrowed.jpg
23:56brehauthaha
23:56brehautPAN ASIAN CUISINE
23:56duck1123I'd worry more about my internal organs
23:57brehauttechnomancy: do you have an endless supply of arrows related comics?
23:58technomancybrehaut: haven't you heard? my super power is the ability to link to apropos comics at will.
23:58brehauti had not heard
23:58amalloyit's mostly either wondermark or haskell
23:59brehautwondermark confuses the crap out of me
23:59brehautthat sounds bad
23:59brehautthose kinds of storylines are riddled with teen angst
23:59technomancycould have been worse
23:59technomancycould have been a spider