2011-09-27
| 00:23 | andar__ | How can I improve this function? Is there a way to use doto with a sequence of args? http://pastebin.com/PnnCDcK7 |
| 00:25 | amalloy | andar__: off the top of my head it looks like you could simplify to (loop [[[x y] & others] xy-coll] (... (recur others))) |
| 00:26 | amalloy | or probably turn the whole thing into a doseq with a similar binding |
| 00:27 | amalloy | ie, more like https://gist.github.com/1244341 |
| 00:27 | brehaut | andar__: also, nil is one of the two falsy values in clojure, so you dont need to test (nil? x) |
| 00:29 | andar__ | thanks amalloy and brehaut |
| 00:32 | brehaut | andar__: more generally you use a reduce just about anywhere you would use primitive recursion with loop / recur. |
| 00:32 | brehaut | andar__: although doseq is clearer in this case because its indicative of side effecting code |
| 00:32 | amalloy | brehaut: i don't know that i would say that. in many cases you would use map, not reduce, for example |
| 00:33 | amalloy | ie, loop/recur can implement a lot of patterns, and while of course so can reduce, it's not always the right "upgrade" |
| 00:33 | brehaut | andar__: but (reduce (fn [series [x y]] (doto series (.add x y)) (XYSeries. name) xy-coll) |
| 00:33 | brehaut | amalloy: thats why i set primative recursion |
| 00:33 | brehaut | which is the case that reduce is equivalent to |
| 00:33 | amalloy | uhh |
| 00:34 | brehaut | i think is probably more haskell assery |
| 00:35 | amalloy | *chuckle* |
| 00:35 | amalloy | brehaut: i mean, you can implement map as a reduce, provided you either have a lazy language or don't mind strictness |
| 00:35 | brehaut | im also having a typing fail today. sorry about that |
| 00:35 | brehaut | amalloy: definately, map in a lazy language is fairly trivial example of primative recursion |
| 00:36 | amalloy | no worries, my comparative languages class in college had a section on "sleepy typos" |
| 00:36 | brehaut | hah |
| 00:36 | brehaut | its for the best |
| 00:38 | brehaut | i should go cook dinner |
| 00:39 | amalloy | huh, 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:39 | amalloy | taking advantage of the multi-arity versions of < *and* map, neither of which i ever use |
| 00:39 | technomancy | that is really slick EXCEPT for how every? requires a predicate. that part is dumb. |
| 00:40 | amalloy | technomancy: isn't a change to that on the horizon? |
| 00:40 | technomancy | amalloy: open ticket; chouser approves, but no discussion so far |
| 00:40 | technomancy | I guess I could give it a poke again now that 1.3 is out |
| 00:40 | amalloy | chouser approves! it's practically 1.0 already |
| 00:41 | technomancy | well... he suggested the same thing like two years ago. I guess that doesn't imply he still approves. |
| 00:41 | amalloy | *laugh* |
| 00:42 | amalloy | technomancy: i forget, did you want to extend any of these things to 3+ args as well, or just allow a 1-arg version? |
| 00:42 | technomancy | amalloy: just using identity as the default predicate |
| 00:43 | technomancy | 3+ args would be map-style for multiple-argument predicates? |
| 00:43 | amalloy | technomancy: 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:44 | amalloy | eg, 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:44 | technomancy | haven't thought that through all the way |
| 00:45 | amalloy | then i wouldn't even need a default predicate - i could write (every? < [-1 -1] [y x] [h w]) |
| 00:45 | technomancy | handy for that, but I'm not sure how generally-applicable it'd be |
| 00:45 | amalloy | nor am i |
| 00:45 | technomancy | the 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:46 | technomancy | but that's certainly not a hard-and-fast rule |
| 00:49 | amalloy | i think a hard-and-fast rule should be that when you write (every? true? ...) you have to try to pronounce it out loud |
| 00:52 | technomancy | in Mandarin, question-ness is indicated by appending "ma" to the sentence since you can't use tonality. |
| 00:52 | technomancy | CL's whatever-p always reminded me of that for some reason. |
| 00:53 | technomancy | if I ever invent a joke lisp dialect I will be sure to use -ma as the convention for predicate naming. |
| 00:53 | technomancy | or should I say... WHEN I invent a joke lisp dialect. |
| 01:18 | TheBusby | just FYI, it's "ka" for Japanese... |
| 01:18 | TheBusby | anyone have any luck in getting clj-http to ignore self-signed certs? |
| 02:11 | amalloy | technomancy: link to the ticket? i might as well kick the tires |
| 03:10 | cark | anybody knows how to type hint for an array of objects ? |
| 03:15 | cark | ah there it is : ^"[Ljava.awt.Color;" |
| 03:15 | cark | was missing the last ; |
| 03:16 | michaelr525 | kool |
| 03:46 | pyr | ibdknox: still around ? |
| 03:48 | ibdknox | pyr: for a min, what's up? |
| 03:51 | pyr | ibdknox: pe/on has a very weird behavior |
| 03:51 | pyr | ibdknox: for me in pinot |
| 03:51 | pyr | ibdknox: most of the time it doesn't catch events |
| 03:52 | pyr | ibdknox: setting aside my own code, if you take the todo code for instance |
| 03:53 | pyr | ibdknox: it will only remove the last item which usually gets 3 calls |
| 03:54 | pyr | ibdknox: (using the snapshot you posted yesterday) |
| 04:27 | ibdknox | pyr: hm, I just tried it locally and it worked fine |
| 04:27 | pyr | ah |
| 04:27 | ibdknox | pyr: to confirm, the call looks like this, right?: (pe/on todo-item :click ... |
| 04:28 | pyr | yep |
| 04:28 | ibdknox | and what is it doing for you? |
| 04:28 | pyr | (pe/on (dom/query ...) rather) |
| 04:29 | pyr | (pe/on (dom/query foo) :click some-func) |
| 04:29 | pyr | rather |
| 04:29 | ibdknox | yeah |
| 04:29 | ibdknox | that doesn't delegate |
| 04:29 | ibdknox | https://github.com/ibdknox/pinot/blob/master/examples/todo.cljs |
| 04:29 | ibdknox | you wanna do it like that |
| 04:30 | ibdknox | with it that way, anything ever created using the todo-item partial |
| 04:30 | ibdknox | will have that event bound on it |
| 04:30 | pyr | so i need to create partial even for my links |
| 04:30 | ibdknox | you don't have to, no |
| 04:31 | pyr | binding to dom/query doesn't seem to work right |
| 04:31 | ibdknox | mkay |
| 04:31 | pyr | the array return and handled in nodelist->coll seems to be empty |
| 04:32 | pyr | i'll try with partials |
| 04:32 | pyr | (also, wasn't i supposed to use the reorg branch ?) |
| 04:33 | ibdknox | I merged it all into master :) |
| 04:33 | pyr | ah, ok |
| 04:33 | pyr | will switch |
| 04:33 | ibdknox | pyr: yeah I'm seeing weird behavior. I'll debug it tomorrow, I'm dead tired |
| 04:33 | pyr | np |
| 04:33 | pyr | cool to have it confirmed :) |
| 04:34 | ibdknox | thanks for the catch :) I'll let you know when it's fixed! |
| 04:35 | Blafasel | Hmm.. Is clooj usable? |
| 04:35 | michaelr525 | what is clooj? |
| 04:35 | Blafasel | Just started the latest version (eclipse/ccw is not helpful) and it seems to do ~nothing~ |
| 04:35 | Blafasel | michaelr525: One of the 'IDE' options linked to from GettingStarted |
| 04:36 | Blafasel | A clojure ~ide~ develped in clojure it seems. |
| 04:36 | amalloy | Blafasel: i have heard of people using it with every indication of enjoyment |
| 04:37 | amalloy | when i turned it on just for fun, it seemed to work okay, but i'm happy with emacs |
| 04:37 | michaelr525 | yeah, i'm happy to learn emacs, it really gives me satisfaction ;) |
| 04:38 | Blafasel | amalloy: 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:38 | michaelr525 | yesterday started stabbing paredit - and this kind of completes the picture |
| 04:40 | robermann | about Emacs / paredit: is it possible to have matching parentesis of different colors? |
| 04:41 | raek | there is a rainbow-paren-mode |
| 04:41 | robermann | wow - where is it? |
| 04:42 | raek | could be this one http://dishevelled.net/elisp/rainbow-parens.el |
| 04:42 | kjeldahl | robermann: I'm on emacs24, and it looks like they are "rainbow" colored by default... |
| 04:42 | raek | I tried it, but I don't use it. |
| 04:43 | robermann | kjeldahl: I'm on GNU Emacs 23.1.50 |
| 04:44 | robermann | for Windows... :) Also Aquamacs does not color them |
| 04:44 | amalloy | i used rainbow-parens for a while. it looked reasonably nice but wasn't actually very useful |
| 04:44 | xian | Hi. 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:44 | xian | Upon inspecting the jar I found out that there was no class named match1.core in the jar. |
| 04:45 | robermann | kjeldahl: I mean in the REPL |
| 04:45 | Pupeno | Any recommendation on a body of Clojure samples to use to test syntax highlighting? |
| 04:46 | robermann | amalloy: 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:46 | kjeldahl | robermann: In repl, I'm not seeing rainbows either... |
| 04:47 | amalloy | yeah, 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:48 | kjeldahl | robermann: 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:48 | kzar | Is there a way to have clojure.repl used by default when you're connecting to the REPL with Emacs? |
| 04:49 | michaelr525 | i also found this, but did't try it: http://stackoverflow.com/questions/2413047/how-do-i-get-rainbow-parentheses-in-emacs |
| 04:49 | robermann | kjeldahl : how do I turn on highlight-parenthesis-mode? M-x + tab does not show it |
| 04:50 | kjeldahl | kzar: Add a ":repl-init my-namespace.clj" in project.clj which pulls it in... |
| 04:50 | kjeldahl | kzar: Oops, minus the .clj extension (just the namespace name, not filename). |
| 04:50 | kjeldahl | robermann: Could be emacs24... Shows up automatically here. |
| 04:51 | michaelr525 | robermann: i have it being loaded from .emacs. found it somewhere on the internetz. do you want it? |
| 04:52 | kzar | kjeldahl: Ah right thanks |
| 04:52 | kjeldahl | kzar: I was wrong. It's in my elisp directory. Points to http://nschum.de/src/emacs/highlight-parentheses/ |
| 04:53 | kjeldahl | kzar: Should work fine for your version as well. |
| 04:53 | michaelr525 | robermann: http://pastie.org/2598687 |
| 04:54 | kjeldahl | Ha ha, mixed up kzar and robermann. Sorry guys, but you got it I guess. |
| 04:54 | robermann | thank you all men, I'm going to try :) |
| 04:54 | kjeldahl | robermann: Prepare for unicorn land! |
| 04:56 | robermann | :) |
| 05:42 | robermann | kjeldahl: now I'm in the unicorn land! |
| 05:43 | robermann | michaelr525: about this script http://pastie.org/2598687 |
| 05:43 | robermann | I had to remove the load-path stuff |
| 05:44 | robermann | and copy highlight-parentheses.el into d:/mannai/ClojureBox/emacs/EmacsW32/lisp/ |
| 05:44 | robermann | (clojurebox laod it: "Adding d:/mannai/ClojureBox/emacs/EmacsW32/lisp/ to load-path") |
| 05:45 | robermann | BTW michaelr525 , 'load-path can also load single files, aside from directories ? |
| 06:09 | robermann | I tried also http://www.emacswiki.org/emacs/RainbowDelimiters, now I'm using that |
| 06:10 | cark | robermann: isn't it slowing down your emacs too much ? |
| 06:11 | robermann | mmm no |
| 06:11 | robermann | I compiled it: M-x byte-compile-file <location of rainbow-delimiters.el> |
| 06:11 | cark | cool |
| 06:11 | cark | i might try that some day |
| 06:11 | robermann | yes, nice setup instructions: http://www.emacswiki.org/emacs/RainbowDelimiters#toc2 |
| 06:12 | robermann | they work for me too, a newbie on Emacs |
| 06:13 | cark | i was just worried about performance |
| 06:13 | cark | it's already slow enough as it is =P |
| 06:14 | robermann | well, as for now it is the best IDE for clojure (holy war starts.. :D ) |
| 06:14 | robermann | IMHO (stop war) |
| 06:14 | cark | agreed |
| 06:27 | srid | can I make 'cake deps' automatically reload swank? |
| 06:27 | srid | (so there is no need to reconnect from emacs) |
| 06:38 | miclorb_ | hrm... can you use multi methods as a way to dispatch based on literal values? |
| 06:38 | miclorb_ | (thinking like erlang def's and matching) |
| 06:41 | clgv | miclorb_: well, you can dispatch via a custom function |
| 06:41 | miclorb_ | clgv: oh? |
| 06:42 | miclorb_ | I am dealing with command line args (ie single word - whihc kinda matches up with function name) |
| 06:52 | clgv | miclorb_: can you give an example for what you want to do? |
| 06:53 | miclorb_ | clgv: hrm.. it is as simple as a string (from user) "foo" - to dispatch to a function (defn foo ...) |
| 06:53 | cemerick | kzar: FYI, a new clutch 0.2.5-SNAPSHOT has been pushed that should resolve the issue you hit yesterday |
| 06:53 | kzar | cemerick: Awesome, thanks :) |
| 06:53 | miclorb_ | I thought I should learn multimethods (reading about them - I still don't get what they are about - so it was a stab) |
| 06:53 | cemerick | kzar: let me know if it works or not; I'd like to do a 0.2.5 release today or tomorrow if possible |
| 06:54 | kzar | cemerick: How do I make sure lein re-downloads it? |
| 06:54 | clgv | miclorb_: ok then have a look at multimethod examples first ;) |
| 06:54 | cemerick | kzar: just `lein deps` should do it — I think it always checks for new snapshots |
| 06:55 | miclorb_ | clgv: - it looks close, will play a bit more, my spider sense tells me they are pretty cool |
| 07:01 | TallAdam | hi guys - any reason that (class (Integer/parseInt "1")) returns java.lang.Long in Clojure 1.3 |
| 07:02 | cemerick | TallAdam: because starting in 1.3, Clojure boxes all primitive integers as Long, and all primitive decimals as Double. |
| 07:02 | TallAdam | cemerick: is that for performance reasons? |
| 07:03 | cemerick | TallAdam: Mostly, it simplifies the numerics model in Clojure-land. |
| 07:03 | TallAdam | cemerick: thanks for that |
| 07:04 | cemerick | Well, I was going to explain further, but… |
| 07:04 | robermann | explain explain please |
| 07:04 | robermann | :) |
| 07:05 | zoldar | yes, we're all ears |
| 07:05 | robermann | I read the 1.3 changelog, but this news surprise me |
| 07:06 | cemerick | robermann: you have to keep going, and read the links linked in the changelog: https://github.com/clojure/clojure/blob/master/changes.txt#L75 :-) |
| 07:07 | cemerick | Basically, 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:09 | cemerick | You 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:11 | cemerick | The 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:14 | kzar | cemerick: 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:15 | cemerick | kzar: 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:15 | cemerick | Thanks for verifying the new build fixes that problem for you. :-) |
| 07:15 | cemerick | FYI, I'm hoping to get an 0.3.0 release out that will replace the libraries that cause those warnings. |
| 07:15 | cemerick | s/out/out soon |
| 07:15 | lazybot | <cemerick> FYI, I'm hoping to get an 0.3.0 release out soon that will replace the libraries that cause those warnings. |
| 07:16 | Zolrath | I'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:20 | kzar | cemerick: Gotya OK |
| 07:27 | Zolrath | Hm maybe the version on clojars isn't compiled properly, that file is missing from the .jar |
| 07:33 | michaelr525 | sleepy afternoon |
| 08:27 | manutter | lovely, 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:33 | michaelr525 | manutter: the rest is going to be great! |
| 09:24 | crazyFox | hi 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:25 | crazyFox | ok. never mind. the file name is misleading. it DOES contain version 24. tss... |
| 09:29 | robermann | thanks to you :) I even didn't know there was such a "starter kit" |
| 09:44 | Blafasel | Hmm.. I find myself in need of a 'yield' of some sorts. Probably doing it wrong again. |
| 09:46 | Menthy | In clojure.set there's a join fn, is there any support for other joins than natural (left, right, cross, outer?) |
| 09:57 | joegallo | you can do a cartesian product with for, i suppose |
| 09:57 | clgv | Blafasel: what do you mean` |
| 09:58 | fdaoud | Blafasel: as in call the function you were passed as arg? Just call it :) |
| 09:58 | fdaoud | as in (defn something [passed-in-fn] (if true (passed-in-fn) "or else")) |
| 09:59 | duck1123 | Is there any official guide as to when you're supposed to use vectors and when you use lists within a ns form? |
| 09:59 | kzar | Blafasel: Yield runs the given block, in Clojure you would just pass a function as a parameter and then call it |
| 09:59 | kzar | Blafasel: You could even call the parameter yield if you wanted |
| 09:59 | neotyk | Good morning everyone |
| 10:00 | fdaoud | duck1123: my understanding is that you could use lists, just that vectors look nicer |
| 10:00 | Blafasel | yield as in C#/F# lazily generating values. Trying to wrap my head around lazy-cat right now.. |
| 10:00 | neotyk | can you help us spreading word about clj meetup? https://twitter.com/#!/amsclj/status/118684755804946432 |
| 10:01 | clgv | Blafasel: lazy-seq could be what you are looking for |
| 10:02 | kzar | Blafasel: Sorry I thought you meant in the Ruby sense |
| 10:02 | clgv | duck1123: 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:03 | Blafasel | clgv: 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:04 | clgv | Blafasel: lazy-seq is used to build a lazy sequence via a recursive description |
| 10:05 | Blafasel | Okay. Learning :) |
| 10:10 | shep-home | technomancy: sorry, was asleep :-) |
| 10:11 | shep-home | do you mean, where did I get clojure-mode? or where dif I get the error? or ... ? |
| 10:11 | shep-home | did* |
| 10:14 | crazyFox | roberman: 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:22 | fdaoud | kzar: me too |
| 10:35 | robermann | BTW: 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:14 | timvisher | hey all |
| 11:14 | timvisher | anyone know what happened to clojure-jack-in in emacs 24? |
| 11:14 | timvisher | well, emacs HEAD? |
| 11:15 | timvisher | specifically, it used to use locate-dominating-file but now it appears not to |
| 11:28 | TimMc | robermann: Cartesian Product being, in your view, harder or easier? |
| 11:29 | robermann | very easier |
| 11:29 | TimMc | ok |
| 11:30 | robermann | just one-line |
| 11:30 | TimMc | yeah |
| 11:31 | robermann | the other, well, I had to think about it :) |
| 11:33 | TimMc | robermann: OK, yeah -- Pascal's Triangle involves actually using recursion (or doing some math!) |
| 11:33 | TimMc | I suppose it depends on where the cut-off between Easy and Medium is. |
| 11:35 | nkoza | mm.. kilim + clojure will make a better erlang than erlang |
| 11:37 | TimMc | robermann: amalloy solved it with math, I solved it with recursion. |
| 11:38 | robermann | I used recursion, too |
| 11:50 | robermann | see you people, bye |
| 11:58 | technomancy | shep-home: I mean where did you get clojure-mode |
| 12:08 | pyr | ibdknox: around ? |
| 12:25 | shep-home | technomancy: package.el (says version 1.10.0) |
| 12:33 | shep-home | I just updated to 1.11.1 (but package still lists the old version as obsolete) |
| 12:42 | shep-home | but the same issue exists |
| 12:52 | shep-home | I /do/ have the getRoot / getRawRoot hack added manually for clojure 1.3 |
| 12:53 | technomancy | did it happen before you upgraded clojure-test-mode? |
| 12:55 | shep-home | technomancy: 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:56 | shep-home | I swear that the "change" that caused it was just writing more code :-) |
| 12:58 | kzar | Can exceptions inside futures stall them? So that we're waiting for this thread to come back but it just never will |
| 13:09 | technomancy | derefing should re-throw the in-future exception |
| 13:09 | technomancy | ,@(future (/ 1 0)) |
| 13:09 | clojurebot | #<RuntimeException java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.ArithmeticException: Divide by zero> |
| 13:12 | kzar | technomancy: Would there be any ways that the exception wouldn't be re-thrown? |
| 13:13 | wink | anyone got a sample project on github or whatever where I can have a look regarding test layout (which files where, etc) |
| 13:14 | manutter | wink: you mean just how the test dirs are set up and stuff? |
| 13:15 | joegallo | lein new this-is-an-example |
| 13:15 | joegallo | :) |
| 13:15 | wink | hmm, yeah |
| 13:17 | manutter | Pick almost any of the clojure tools at clojure-toolbox and look at their github repos, should be a good guide |
| 13:17 | manutter | I'm partial to midje testing myself |
| 13:17 | joegallo | here's one that's built up on that a bit: https://github.com/dakrone/cheshire |
| 13:17 | wink | thanks |
| 13:17 | kzar | technomancy: (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:17 | manutter | I was geeking out last night: figured out how to integrate midje testing with slingshot exception handling |
| 13:17 | kzar | gotta run anyway |
| 13:18 | manutter | I'm like "Dang, it's this easy? Seriously?" |
| 13:19 | wink | think I'm switchin languages too fast lately. I don't even have clojure on this machine... |
| 13:20 | wink | plus I had written tests already. counterclockwise just ignored the test dir. doh |
| 13:28 | neotyk | Has anyone used clache successfully ? |
| 13:28 | neotyk | I'm having problems getting FIFOCache to work |
| 13:29 | neotyk | I initialize it with: (FIFOCache. {} [] 100) |
| 13:29 | shep-home | technomancy: could I be causing myself problems by trying to use clojure 1.3.0 when swank-clojure pulls in 1.2.1? |
| 13:30 | neotyk | and get 'Can't pop empty vector' in clache.clj:62 |
| 13:34 | technomancy | shep-home: it should be ok; swank pulls 1.2 only for standalone swank sessions outside a project |
| 13:36 | neotyk | now it works: (FIFOCache. {} clojure.lang.PersistentQueue/EMPTY 100) |
| 13:37 | shep-home | technomancy: sure enough, I moved the version down and still see the same issue |
| 13:37 | technomancy | shep-home: something about process filter arguments? |
| 13:41 | shep-home | technomancy: error in process filter: Wrong number of arguments: nil, 11 |
| 13:44 | pyr | getting the gist of cljs and pinot |
| 13:44 | pyr | cool stuff |
| 13:47 | dnolen | pyr: yes it is. |
| 13:49 | pyr | i had feared i would be trapped in google closure layout hell |
| 13:51 | dnolen | pyr: nah, it seems so far that google closure is good about providing functionality a la carte. |
| 13:51 | pyr | yep, was able to reintegrate my previous layout quite easily |
| 13:52 | duck1123 | So with pinot, can you define your view once and use it in both places? |
| 13:52 | pyr | you can do that |
| 13:52 | pyr | although |
| 13:52 | pyr | i just do client-side hiccup now |
| 13:52 | duck1123 | I converted all of my views to soy, but haven't used them from js yet |
| 13:53 | duck1123 | so you're sending hiccup over the wire? |
| 13:53 | ibdknox | you *could* send hiccup over the wire |
| 13:53 | ibdknox | but you don't need to |
| 13:53 | ibdknox | it depends on how you organize your web app |
| 13:54 | duck1123 | oh, I get it. You're doing all your generation client side, right? |
| 13:56 | pyr | ibdknox: does my dom/replace make sense ? |
| 13:56 | ibdknox | pyr: it does, though it needs to be a bit more complicated, sadly |
| 13:56 | ibdknox | pyr: take for instance, being in the middle of a list |
| 13:57 | pyr | ah, yeah |
| 13:57 | pyr | it would not retain the position |
| 13:57 | pyr | i use it for changing "pages" |
| 13:57 | pyr | my pinot fork now has dom/toggle-class too |
| 13:58 | ibdknox | pyr: yeah, I need to add those functions too :) |
| 13:58 | pyr | useful for modals, menus, stuff like that |
| 13:58 | ibdknox | pyr: definitely |
| 13:58 | ibdknox | dnolen: did I miss any discussion on how we could make a file readable as both clj and cljs? |
| 13:59 | ibdknox | that would solve duck1123 issue completely |
| 13:59 | ibdknox | you could just use the same file with partials in it in both places |
| 14:01 | duck1123 | That would be nice |
| 14:02 | duck1123 | Actually, using Closure Templates hasn't been that bad. It's a lot slower to type, but easier to just move things around |
| 14:02 | ibdknox | another nice solution would be to wrap mustache.js |
| 14:03 | ibdknox | and use stencil on the server |
| 14:03 | duck1123 | It'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:03 | ibdknox | then you can just use mustache templates both client-side and server side |
| 14:03 | ibdknox | duck1123: good to hear you're using lein :) |
| 14:04 | duck1123 | most 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:05 | dnolen | ibdknox: I haven't heard any progress on that front. Anything interesting would require changes to Clojure. |
| 14:06 | ibdknox | dnolen: why not just meta-data in the ns decl of .clj files? |
| 14:06 | ibdknox | dnolen: then the cljs compiler reads any .clj that has that meta in it |
| 14:08 | duck1123 | You 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:08 | ibdknox | that's true regardless of the solution |
| 14:08 | shep-home | technomancy: Created a new project with lein, it doesn't have the same problem |
| 14:08 | shep-home | so it must be something about my code |
| 14:09 | shep-home | time to binary-comment things out :-) |
| 14:11 | amalloy | TimMc: i've also solved it with lazy seqs; i have a gist somewhere |
| 14:12 | amalloy | https://gist.github.com/1140970 |
| 14:14 | ibdknox | amalloy: pascal's triangle I assume? |
| 14:14 | amalloy | ibdknox: quite a coincidental output if not |
| 14:14 | ibdknox | haha |
| 14:15 | ibdknox | bah, should've looked at the name of the file :-p |
| 14:15 | ibdknox | neat solution |
| 14:16 | amalloy | yeah, it was kinda neat not to have to treat the outer edges specially, just shove some imaginary 0s in there |
| 14:16 | shep-home | technomancy: narrowed down the cause |
| 14:16 | shep-home | https://gist.github.com/1245810 |
| 14:16 | shep-home | well, a reproducible case |
| 14:16 | shep-home | who knows why it's really wrong :-) |
| 14:17 | dnolen | nice, http://scriptstoprograms.wordpress.com/2011/09/27/javascript-shared-state/ |
| 14:17 | technomancy | shep-home: cool; can you open an issue on clojure-test-mode? |
| 14:18 | shep-home | technomancy: sure thing, it is the same git repo, as clojure-mode, right? |
| 14:18 | technomancy | right |
| 14:21 | shep-home | technomancy: done |
| 14:21 | shep-home | thanks :-) |
| 14:22 | technomancy | great |
| 14:33 | TimMc | amalloy: Nice use of "for partition" in there. |
| 14:34 | TimMc | I also used the imaginary zeros, but mapped + across the two colls. |
| 14:34 | amalloy | *nod* |
| 14:35 | TimMc | Three? I thought you less than three. |
| 14:36 | amalloy | er |
| 14:36 | amalloy | so did i |
| 14:41 | wink | back 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:41 | technomancy | ~radagast |
| 14:41 | clojurebot | I don't understand. |
| 14:42 | technomancy | ~radagast is a simplistic test coverage tool: https://github.com/seajure/radagast/ |
| 14:42 | clojurebot | Ok. |
| 14:42 | wink | thanks |
| 14:42 | technomancy | it's not particularly good |
| 14:44 | wink | my code's most probably worse :) |
| 14:45 | seanm_ | 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:45 | amalloy | any package starting with "java" is already in the jre |
| 14:46 | hiredman | not so for javax |
| 14:46 | seanm_ | yeah not for javax =) |
| 14:46 | amalloy | hiredman: really? i guess it's been too long since i did that |
| 14:47 | hiredman | lein uses [groupid/artifactid "version"] which you can get from the maven info |
| 14:47 | amalloy | eg, javax.swing *is* in the jre; i thought the javax packages were "standard extensions" or something |
| 14:47 | hiredman | javaxmail is not |
| 14:48 | seanm_ | hiredman: thanks!! It's working now |
| 14:48 | joegallo | many javax packages are available in the jre by default |
| 14:49 | joegallo | in 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:49 | TimMc | It may depend on whether you have JRE or JDK, I think. |
| 14:50 | jeremyheiler | Much of the javax packages are in Java EE |
| 14:50 | jeremyheiler | Which is completely separate from the JDK/JRE |
| 14:51 | jeremyheiler | http://java.sun.com/javaee/6/docs/api/ |
| 14:53 | joegallo | in 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:54 | amalloy | they got added in 1.4, i think. kinda weird that you could have an environment without them |
| 14:56 | jeremyheiler | seanm_: The javax.xml.xpath package is in the JRE |
| 14:56 | foodoo | how can I create a string from a list of chars using only the functions in clojure.core? (4clojure) |
| 14:56 | jeremyheiler | amalloy: it makes sense to keep the EE stuff separate, as not all environments need JPA, mail, servlets, etc. |
| 14:57 | jeremyheiler | You can even pick and choose what parts of EE you need |
| 14:57 | tsdh | Is it intended that clojure allows symbols containing whitespace? |
| 14:57 | tsdh | ##(symbol "faa bar") |
| 14:57 | lazybot | ⇒ faa bar |
| 14:57 | tsdh | ##(type (symbol "faa bar")) |
| 14:57 | lazybot | ⇒ clojure.lang.Symbol |
| 14:57 | hiredman | foodoo: why use 4clojure at all if you are not going to figure it out? |
| 14:57 | technomancy | tsdh: I think it's intentional |
| 14:58 | foodoo | hiredman: I suppose there is some built-in function for that. But I can't seem to find it |
| 14:58 | technomancy | there was an open issue for it for a while, I had a patch that got rejected. |
| 14:59 | foodoo | hiredman: and I suppose that's really not part of the main challenge. But I could be wrong |
| 14:59 | tsdh | technomancy: I know that CL does (|foo bar|), but I don't see a way to use such a symbol in, say, def... |
| 14:59 | amalloy | tsdh: macros would work. but don't :P |
| 15:00 | tsdh | btw, the print representation is ("foo bar") here at my 1.3 repl... |
| 15:00 | tsdh | So there's no way for the reader to distinguish a symbol with whitespace from a list with a string... |
| 15:00 | foodoo | hiredman: 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:02 | TimMc | foodoo: 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:02 | tsdh | amalloy: Yeah, I don't. :-) |
| 15:03 | foodoo | TimMc: 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:04 | foodoo | I mean it doesn't seem to work this time |
| 15:04 | technomancy | ,(let [x (bean [])] (prn (class x)) (:foo x)) |
| 15:04 | clojurebot | clojure.core.proxy$clojure.lang.APersistentMap$0 |
| 15:04 | clojurebot | #<NullPointerException java.lang.NullPointerException> |
| 15:04 | technomancy | ...! |
| 15:04 | fdaoud | foodoo: why not just (str foo) |
| 15:05 | ibdknox | fdaoud: you mean (apply str foo) |
| 15:05 | TimMc | well, there's the answer |
| 15:05 | fdaoud | ibdknox: yes, you're right, to concat.. I meant instead of (. foo toString) |
| 15:05 | amalloy | ~source bean |
| 15:06 | fdaoud | ,(apply str [\b \o \n \j \o \u \r]) |
| 15:06 | clojurebot | "bonjour" |
| 15:06 | foodoo | fdaoud: (= "foobar" (str (concat "foo" "bar"))); is false |
| 15:06 | foodoo | (using 1.3 if that matters) |
| 15:06 | TimMc | foodoo: concat takes colls |
| 15:06 | TimMc | ,(concat "foo" "bar") |
| 15:06 | clojurebot | (\f \o \o \b \a ...) |
| 15:07 | TimMc | Erm, I guess it takes seq-ables. |
| 15:07 | ibdknox | yeah |
| 15:07 | ibdknox | ~source concat |
| 15:07 | fdaoud | ,(apply str (concat "foo" "bar")) |
| 15:07 | clojurebot | "foobar" |
| 15:07 | TimMc | ,(str "foo" "bar") |
| 15:07 | clojurebot | "foobar" |
| 15:07 | foodoo | thank you all :) |
| 15:08 | TimMc | ,(ancestors (class {})) |
| 15:08 | clojurebot | #{java.util.concurrent.Callable clojure.lang.Counted clojure.lang.IObj clojure.lang.IPersistentMap java.util.Map ...} |
| 15:08 | tsdh | Can't I test if a fns :pre fails? (is (thrown? AssertionError (foo "bad input"))) errors with an AssertionError... |
| 15:08 | TimMc | &(ancestors (class {})) |
| 15:08 | lazybot | ⇒ #{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:12 | pyr | ibdknox: i have a nicer alternative |
| 15:12 | pyr | ibdknox: to replace |
| 15:13 | ibdknox | pyr: oh? |
| 15:14 | ibdknox | fwiw, I think replace should exist no matter what |
| 15:19 | pcavs | what's the way to use rest args in a shorthand anonymous function? like #(apply + %&) but %& doesn't work... |
| 15:19 | bhenry | but %& does work... |
| 15:19 | pcavs | or nvm, it does =\ |
| 15:20 | ibdknox | lol |
| 15:20 | amalloy | ...have you actually tried %&? |
| 15:20 | pcavs | <— stupid |
| 15:20 | pyr | ibdknox: let me prepare a gist |
| 15:20 | pcavs | thank you thank you, I'm hear all week, try the lamb |
| 15:20 | ibdknox | pyr: okidoke |
| 15:20 | pyr | https://gist.github.com/1245966 |
| 15:21 | pyr | (I love emacs gist-mode!) |
| 15:21 | pyr | it's a different approach |
| 15:21 | ibdknox | pyr: yeah, that's basically the same as JQuery's html() |
| 15:21 | pyr | yup |
| 15:22 | pyr | but it doesn't use innerHTML (so no wiping out of the event binding tree) |
| 15:22 | TimMc | pcavs: I bet you used &% by accident. I keep typoing it. |
| 15:22 | pcavs | TimMc: I think the fact I'm dumb is a simpler more elegant explanation |
| 15:22 | ibdknox | pyr: mhm |
| 15:22 | TimMc | >_< |
| 15:22 | ibdknox | lol |
| 15:23 | tsdh | Ah, stupid me. The assertion error was in another test... |
| 15:23 | hugod | pyr: which gist mode? |
| 15:23 | pyr | https://github.com/defunkt/gist.el |
| 15:23 | hugod | thanks |
| 15:23 | pyr | you get gist-region and gist-buffer |
| 15:24 | pyr | with private alternatives |
| 15:24 | pyr | very useful |
| 15:24 | ibdknox | off to lunch |
| 15:24 | amalloy | yep. gist.el: useful enough to get one of my C-c bindings |
| 15:26 | Blafasel | *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:28 | amalloy | Blafasel: you forgot the arglists to a function |
| 15:28 | amalloy | (defn foo (letfn ...)) instead of (defn foo [x y] (letfn...)) |
| 15:30 | Blafasel | It'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:30 | Blafasel | And especially not in the line mentioned.. |
| 15:30 | TimMc | The error *should* say, "expected a vector, found symbol 'letfn" |
| 15:30 | amalloy | TimMc: that's not accurate though |
| 15:30 | TimMc | +param decl |
| 15:30 | amalloy | "expected a vector, found list beginning with symbol letfn" |
| 15:30 | TimMc | ah, right |
| 15:31 | Blafasel | Ah.. Got that. Now I just need to make lazy-seq happy.. |
| 15:31 | hiredman | amalloy: well (fn [] ...) and (fn ([] ...)) are both legal |
| 15:32 | scode | Is the order preservation of literal maps co-incidental or a documented guarantee? |
| 15:32 | amalloy | ah, interesting point. i hadn't thought of it from that perspective |
| 15:32 | hiredman | scode: implementation detail for literal maps with less than N entries where N maybe 8 right now |
| 15:32 | Blafasel | I'm trying something like (letfn [(foo [args]) ...... (lazy-seq (cons something (foo newargs))]) and foo cannot be resolved. Stupid Ben? |
| 15:33 | scode | hiredman: Thanks! |
| 15:34 | amalloy | hiredman: i think it's 10 |
| 15:34 | Blafasel | On a sidenote: Thanks for this (patient, friendly) place to get started.. Helps a lot to lurk around here or cry for help, occasionally. |
| 15:34 | Vinzent | Blafasel, should it be (letfn [(foo [args] ...... ...)? |
| 15:35 | Blafasel | Vinzent: Ah. It is. My bad. |
| 15:36 | Blafasel | Vinzent: Method, couple things, branch to a) recur or b) (lazy-seq (cons computedThingy callToSelfHere)) |
| 15:37 | Blafasel | I hope that makes sense... |
| 15:41 | dans | is everyone who uses vim still using vimclojure or is there a better option? |
| 15:42 | foodoo | dans: I'm still using vimclojure. But the REPL ist broken for 1.3 |
| 15:42 | dans | ok foodoo |
| 15:58 | babilen | dans: same here (although I am still on 1.2) |
| 15:59 | babilen | dans: You might want to take a look at slimv though (or at least use its paredit implementation in vimclojure) |
| 15:59 | elderling | ,(clojure-version) |
| 15:59 | clojurebot | "1.3.0-master-SNAPSHOT" |
| 16:02 | dans | babilen, thanks |
| 16:02 | dans | actually im doing just that, installing both with vundle |
| 16:03 | dans | for some reason :set ft? still returns filetype= (not recognising clj files) so syntax highlighting isnt working |
| 16:06 | Blkt | good evening everyone |
| 16:11 | babilen | dans: Same setup here, but ft works for me. (cf. https://github.com/babilen/dotfiles/blob/master/vim/vimrc) |
| 16:14 | tsdh | Is there something that helps writing complex argument destructuring for macros like defmacro itself? |
| 16:14 | tsdh | I mean, where you have optional docstrings, option maps, plus varargs parameters... |
| 16:16 | srid | I 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:16 | dnolen | tsdh: no but it's come up before and other people are interested in it. Just need someone to actually do the work. |
| 16:16 | amalloy | clojure.contrib is not clojure-contrib? |
| 16:17 | chouser | amalloy: hey, you around? I have a proposition for you. |
| 16:17 | amalloy | well, i just betrayed my presence, i guess |
| 16:17 | tsdh | dnolen: Ok, thanks. |
| 16:18 | chouser | oh, indeed. so, what if 4clojure used a different golf scoring method? |
| 16:18 | khaliG | i'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:19 | amalloy | chouser: counting number of forms, i bet? |
| 16:19 | chouser | yessir. http://groups.google.com/group/clojure/msg/0ff2be94aef767dd |
| 16:20 | chouser | granted: any kind of golf will have goals that diverge from what you use when writing "real code" |
| 16:21 | amalloy | *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:21 | chouser | but if golf is to have any real value at all, it would be to encourage learning the target platform. |
| 16:21 | amalloy | when i built the charts, i actually wanted to have "count characters" and "count forms" scores separate, both on the graph |
| 16:21 | khaliG | all 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:21 | chouser | amalloy: what would be fantastic! |
| 16:22 | chouser | of course then you'd want to be able to submit two (or more) solutions. :-) |
| 16:22 | hiredman | real value? |
| 16:22 | hiredman | of golf? |
| 16:22 | chouser | hiredman: right. for learning. |
| 16:22 | hiredman | sure |
| 16:22 | hiredman | *eyeroll* |
| 16:22 | chouser | :-P |
| 16:22 | amalloy | chouser: have you played spacechem? i wanted to mimic their charts exactly, since they look great and score you on multiple axes |
| 16:23 | chouser | amalloy: no, I haven't. |
| 16:23 | amalloy | i put up a screenshot somewhere but sadly it's not in my logs at work and i can't produce another one |
| 16:23 | amalloy | but 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:24 | chouser | amalloy: ok |
| 16:24 | amalloy | i'd love to accept a patch, though, from any interested parties, such as yourself |
| 16:25 | Blafasel | Any 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:27 | amalloy | chouser: aha, of course someone else has put up a screenshot already. http://downwithshooters.blogspot.com/2011/05/not-chemistry-i-remember.html |
| 16:28 | amalloy | Blafasel: this is mis-indented |
| 16:29 | amalloy | newTable should be new-table |
| 16:29 | dans | hmm everything works fine if i :set ft=clojure, i wonder why it doesnt automatically recognise .clj |
| 16:29 | amalloy | (assoc m k (conj (get m k) v)) is just (update-in m [k] conj v) |
| 16:31 | rata_ | hi |
| 16:31 | Blafasel | amalloy: indentation is something I have to learn from scratch for lisps, I guess. Any guides, specific remarks? (and thanks for the rest!) |
| 16:32 | terom | Blafasel: I believe the docstring should be before (empty) argument vector. |
| 16:33 | amalloy | Blafasel: https://gist.github.com/1246161 is a stylistic rewrite |
| 16:34 | amalloy | i added a number of newlines you might not agree with, but i think it helps to clarify what goes with what |
| 16:34 | Blafasel | I've no trouble with the formatting. In fact, I've no clue how to format these things yet. |
| 16:34 | Blafasel | just read about update-in: Didn't know that at all. And you're right of course, exactly what I do there. |
| 16:35 | Blafasel | terom: Thanks! He fixed that as well :) |
| 16:36 | shep-home | Blafasel: If you find a good reference on idiomaticness, I'd love to see it :-) |
| 16:36 | shep-home | In a protocol, can you declare a method twice, with different arguments? |
| 16:36 | Blafasel | shep-home: Heh. Guess this channel is as close as I could get to anything clojure so far, so... |
| 16:37 | technomancy | ~style guide? |
| 16:37 | clojurebot | style is http://paste.lisp.org/display/81021 |
| 16:37 | technomancy | what |
| 16:37 | amalloy | $google mumble scheme style |
| 16:37 | lazybot | [Riastradh's Lisp Style Rules - mumble.net main page] http://mumble.net/~campbell/scheme/style.txt |
| 16:37 | technomancy | there we go |
| 16:38 | technomancy | Blafasel: ^^ |
| 16:38 | shep-home | technomancy: no big differences for Clojure-specific whatnot? |
| 16:38 | technomancy | not much |
| 16:39 | technomancy | clojurebot: 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:39 | clojurebot | Alles klar |
| 16:40 | Blafasel | Funny response, clojurebot.. |
| 16:40 | ibdknox_ | he's half German |
| 16:40 | Blafasel | technomancy: amalloy: Thanks a lot! Reading material :) |
| 16:40 | Blafasel | ibdknox_: ;) |
| 16:41 | technomancy | and half gaelic, and half greek, and half... |
| 16:41 | shep-home | technomancy: you lost your 'c' in "closing" |
| 16:43 | Blafasel | Looking 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:44 | Blafasel | Weird. New. |
| 16:50 | srid | duck1123: i noticed that you ported aleph to clojure 1.3; may I ask how you would specify your fork as a lein dependency? |
| 16:53 | Blafasel | Is there any way to get a diff between gists? That webinterface is confusing... |
| 16:54 | Blafasel | The 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:54 | amalloy | Blafasel: sorry, i messed up the update-in |
| 16:54 | amalloy | should be [key], not key |
| 16:55 | Blafasel | Ahhh.. Makes sense now. |
| 16:55 | Blafasel | Thanks |
| 16:55 | amalloy | you 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:56 | amalloy | and 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:56 | Blafasel | Ah, ok. Loaded a file into a repl, but probably the tool in use just pipes text, 'pastes' or something |
| 16:58 | Blafasel | I 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:59 | Blafasel | Not 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:01 | cfa | hey 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:01 | cfa | (apologies if i'm missing something really obvious here) |
| 17:01 | technomancy | cfa: currently no way to do that |
| 17:01 | technomancy | just M-x clojure-jack-in again |
| 17:01 | cfa | will clojure-jack-in safely kill off the old swank? (i've been manually killing the swank buffer so far) |
| 17:02 | technomancy | it will if you have the latest version |
| 17:02 | cfa | i believe i do; installed from the official instructions last week |
| 17:02 | amalloy | Blafasel: that's correct |
| 17:02 | amalloy | usually if you put a newline immediately after the function/macro/operator, you indent the next form by only once space |
| 17:03 | amalloy | and that's how emacs does it automatically, of course |
| 17:03 | Blafasel | Heh.. |
| 17:03 | Blafasel | Okay, thanks for the patience. No, emacs is not an option right now :) |
| 17:10 | mabes | arg.. 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:11 | technomancy | marmalade is ... not the most stable |
| 17:12 | mabes | I 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:12 | mabes | I don't think I'll try and fix it though |
| 17:12 | cfa | technomancy: thanks |
| 17:13 | cfa | hmm, the second time i did this: "error in process filter: Symbol's value as variable is void: java\.lang\.RuntimeException:" |
| 17:13 | technomancy | cfa: sounds like an old version of clojure-mode |
| 17:14 | cfa | hmm, let me check how i fetched it |
| 17:14 | technomancy | cfa: if you reinstall without updating the package list you will pull in old versions |
| 17:14 | technomancy | M-x package-refresh-contents; analogous to apt-get update |
| 17:14 | cfa | i might have forgotten to do that |
| 17:14 | cfa | currently running 1.10.0 |
| 17:15 | technomancy | 1.11.1 is the latest |
| 17:16 | cfa | right, fetched |
| 17:18 | cfa | is it safe to M-x unload-feature? |
| 17:18 | technomancy | great question; I've never tried that |
| 17:18 | technomancy | or even heard of it, actually =) |
| 17:19 | technomancy | it's probably safe |
| 17:19 | cfa | :) trying now |
| 17:19 | cfa | i explicitly called package-load-all-descriptors and -archive-contents |
| 17:19 | cfa | so hopefully the new version will get picked up |
| 17:20 | cfa | also, for reference: i've unloaded -autoloads too |
| 17:22 | Blkt | good night everyone |
| 17:22 | cfa | hmm |
| 17:22 | cfa | not only did that not work; starting a fresh emacs is still pulling in 1.10 (even though 1.11 is downloaded) |
| 17:23 | cfa | oh, wait |
| 17:23 | cfa | clojure-mode-version returns "1.10.0" in v1.11 :/ |
| 17:23 | technomancy | cfa: oh no; oops! |
| 17:24 | cfa | now i'm very confused |
| 17:24 | cfa | well, might as well try clojure-jack-in again |
| 17:24 | technomancy | M-x package-list-packages is the one you should trust |
| 17:25 | cfa | same error when i try to jack in, but who knows which version i'm using :) |
| 17:25 | cfa | okay -- the elpa dir is definitely 1.11 |
| 17:25 | cfa | perhaps i should just restart emacs |
| 17:27 | technomancy | just reloading the defun for clojure-jack-in would do it |
| 17:29 | technomancy | I wonder if the byte-compilation isn't overriding the old version that's already loaded |
| 17:32 | cfa | technomancy: so 1.11 will re-use the old repl unlike 1.10, right? |
| 17:33 | duck1123 | srid: you still around? I just noticed your question |
| 17:34 | technomancy | cfa: there's still a bug where sometimes it opens *slime-repl nil* that I haven't tracked down yet |
| 17:34 | duck1123 | My fork isn't on clojars, but I push a copy to my repository at build.jiksnu.com |
| 17:35 | cfa | technomancy: ah okay. well, thanks for the help. |
| 17:47 | carllerche | Is there a way to apply a java static function that takes varargs to a vector? |
| 17:47 | amalloy | dump the vector into an array |
| 17:49 | Clojurific | Is anyone here actively contributing to the Leiningen project? |
| 17:50 | technomancy | Clojurific: sure |
| 17:50 | amalloy | technomancy claims to be, but he's a tricky one |
| 17:50 | technomancy | clojurebot: are all cretans liars? |
| 17:50 | Clojurific | Cool :] technomancy, what are your future plans for Lein? |
| 17:50 | clojurebot | Cool story bro. |
| 17:51 | technomancy | Clojurific: here's a thread discussing the plans for 2.0: http://groups.google.com/group/leiningen/browse_thread/thread/1223cd092b83f007 |
| 17:52 | cfa | night all |
| 17:52 | technomancy | there 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:53 | Clojurific | Very nice |
| 17:53 | Clojurific | No, boring is very necessary sometimes |
| 17:53 | Clojurific | It's an awesome tool; thank you for all your work |
| 17:54 | technomancy | great; glad it's helpful |
| 17:55 | gfredericks | Let'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:55 | gfredericks | I've nearly never used custom metadata. |
| 17:55 | dnolen | gfredericks: sounds like a use case for memoization |
| 17:55 | dnolen | ,(doc memoize) |
| 17:55 | clojurebot | "([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:56 | gfredericks | dnolen: I know about memoization. What if I don't want to worry about the memoization map hogging the memory? |
| 17:56 | dnolen | gfredericks: hook up your own memoize to unk |
| 17:56 | dnolen | https://github.com/fogus/unk |
| 17:57 | cark | btw, is there a memoization like function that would only remember one set of arguments and only one result value ? |
| 17:57 | gfredericks | dnolen: so you think metadata is such a bad idea that using an entire library is better? |
| 17:57 | gfredericks | I don't mean that critically, I'm just trying to figure out what metadata is good for |
| 17:58 | kharrington | cark: memoize on the clojure.org/atoms page with an if statement? |
| 17:59 | amalloy | gfredericks: i dunno, seems like a reasonable case for metadata. i don't think memoization is a great choice |
| 17:59 | cark | yes i guess that's an easy one, just wanted to make sure it's not already in the bow |
| 17:59 | dnolen | gfredericks: 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:59 | technomancy | cark: unk can do that with fifo of depth 1 |
| 17:59 | cark | box* |
| 18:00 | dnolen | gfredericks: metadata is cool, though I've found it most powerful in conjunction w/ macros. |
| 18:00 | amalloy | eg, 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:00 | gfredericks | amalloy: ah hah! excellent point :) |
| 18:00 | gfredericks | dnolen wants to double my computation :) |
| 18:00 | technomancy | gfredericks: 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:00 | amalloy | ie, memoization doesn't do (all of) what you want, because you have special knowledge about what (f (f x)) is |
| 18:01 | gfredericks | technomancy: I figured that might be the case |
| 18:01 | jedahu | The 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:02 | gfredericks | dnolen: amalloy: technomancy: thanks for the thoughts |
| 18:02 | technomancy | jedahu: that's expected; clojure 1.3.0 should never be a dev dependency with lein 1.x. |
| 18:02 | dnolen | amalloy: seems like you could do 7 - 8 as part of the cache policy, no? |
| 18:02 | jedahu | so upgrade to lein 2? |
| 18:02 | gfredericks | dnolen: that must be a special feature of unk? |
| 18:02 | technomancy | jedahu: if only. it hasn't been written yet. =( |
| 18:03 | technomancy | try to find what's placing 1.3.0 in lib/dev |
| 18:03 | dnolen | gfredericks: https://github.com/fogus/unk/blob/master/src/fogus/unk.clj#L41 |
| 18:03 | dnolen | seriously, unk should get promoted to contrib ASAP |
| 18:03 | gfredericks | technomancy: so for now it's (not (and 1.3 lein))? |
| 18:03 | technomancy | dnolen: why? |
| 18:03 | technomancy | gfredericks: you can use 1.3 in your projects, just not in your plugins |
| 18:04 | dnolen | technomancy: because tweaking memoization is not uncommon, and the protocol is something everyone can standardize against. |
| 18:04 | gfredericks | technomancy: ah ha -- sense it makes |
| 18:04 | jedahu | technomancy: so I should make any leiningen plugin I write depend on clojure 1.2? |
| 18:04 | gfredericks | ~second |
| 18:04 | clojurebot | Motion seconded and carried. Next agenda item. |
| 18:04 | gfredericks | dnolen: ^ |
| 18:05 | gfredericks | clojurebot: so that means you just promoted it to contrib? |
| 18:05 | clojurebot | Pardon? |
| 18:05 | technomancy | jedahu: all plugins implicitly depend on everything leiningen depends upon, so don't declare any additional dependencies unless they aren't in lein already |
| 18:05 | gfredericks | dnolen: I've often thought core/memoize's unconfigurability was a bit ugly. |
| 18:06 | technomancy | jedahu: you should read Leiningen's doc/PLUGINS.md |
| 18:06 | dnolen | gfredericks: many people have complained - yr not the first. |
| 18:06 | technomancy | it's like two lines to expose the memoization atom, but it got shot down |
| 18:06 | gfredericks | technomancy: as metadata? |
| 18:06 | jedahu | technomancy: thanks, will do |
| 18:06 | technomancy | gfredericks: yep |
| 18:08 | amalloy | isn'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:08 | gfredericks | amalloy: maybe it's an unfortunate name then? |
| 18:08 | hiredman | amalloy: I concur |
| 18:08 | technomancy | amalloy: it's not about configuration as much as it is about reversibility |
| 18:09 | amalloy | technomancy: reversibility? |
| 18:09 | hiredman | gfredericks: memoizing is exactly what it does |
| 18:09 | technomancy | irreversible memoization makes tests very difficult |
| 18:09 | amalloy | ah |
| 18:09 | gfredericks | hiredman: right, I mean it should do something more useful |
| 18:09 | hiredman | it is useful |
| 18:09 | gfredericks | hiredman: and perhaps therefore be called something else as well |
| 18:09 | gfredericks | hiredman: I didn't say it wasn't. I said it should do something _more_ useful :) |
| 18:10 | hiredman | you want caching, what is a very complex issue, and there are libraries like unk which provide it |
| 18:10 | gfredericks | hiredman: as technomancy said, it'd be a two line change to make the memoize function be a mildly more useful caching function |
| 18:10 | amalloy | technomancy: 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:11 | technomancy | a common pattern is (alter-var-root #'my-fn memoize) immediately following a defn |
| 18:11 | cark | haha ok i didn't understand that unk is a library name, just thought technomancy was having keyboard mishaps |
| 18:11 | technomancy | heh |
| 18:12 | amalloy | technomancy: 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:12 | dnolen | gfredericks: 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:12 | dnolen | gfredericks: exposing it means encouraging people to using a broken cache policy by default. |
| 18:12 | technomancy | amalloy: it should always[1] be memoized. [1] - for certain values of always which do not include the test suite. |
| 18:13 | technomancy | there are lots of things you should never[2] do [2] - for certain values of never which do not include the test suite |
| 18:13 | amalloy | technomancy: so make a :private non-memoized function, and (def public-version (memoize private-version)) |
| 18:13 | technomancy | what, with no docstring? |
| 18:13 | amalloy | feh |
| 18:14 | amalloy | but i see where you're going, yes |
| 18:15 | jedahu | When 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:16 | gfredericks | dnolen: hiredman: you are both persuasive. |
| 18:18 | cark | allright this hunk library is golden |
| 18:19 | gfredericks | cark: it would let me cache in a DB? |
| 18:19 | hiredman | cache in sunyata! |
| 18:19 | cark | gfredericks: i'm not yet done reading the code |
| 18:20 | cark | but looks like you can plug any memoization scheme you want |
| 18:21 | hiredman | https://github.com/hiredman/sunyata |
| 18:21 | gfredericks | hiredman: ah hah. I expect that will be much more informative than http://en.wikipedia.org/wiki/%C5%9A%C5%ABnyat%C4%81 |
| 18:21 | hiredman | or, like, I guess you could just use inifinispan |
| 18:21 | dnolen | gfredericks: the whole is built ontop of well defined protocols, so swapping in a DB won't be much work. |
| 18:21 | hiredman | without the training wheels |
| 18:23 | hiredman | it's a joke, cause "what are you relying on to store your data?" "nothing" |
| 18:23 | gfredericks | :) |
| 18:23 | hiredman | it's much funnier in sanskrit |
| 18:23 | gfredericks | what isn't? |
| 18:24 | srid | duck1123: I'm thinking of using your fork, but I cannot fetch the dependencies from your maven repo: https://gist.github.com/1246439 |
| 18:24 | technomancy | the ineffable emptiness of the void... is it or is it not web scale? |
| 18:24 | srid | duck1123: btw, have you considered opening a pull request for ztellman to merge your 1.3 support? |
| 18:24 | technomancy | srid: ding! correct question. |
| 18:25 | srid | ,+1 srid |
| 18:25 | clojurebot | 1 |
| 18:25 | srid | ,+1 srid |
| 18:25 | clojurebot | 1 |
| 18:25 | duck1123 | He's merged some of my changes, I need to send another one for the rest |
| 18:25 | technomancy | (inc srid) |
| 18:25 | lazybot | ⟹ 1 |
| 18:25 | srid | always 1? |
| 18:25 | gfredericks | srid: not if it happens again |
| 18:25 | technomancy | clojurebot doesn't handle karma, and lazybot won't let you inc yourself |
| 18:26 | Moominpapa | Hi, I wanted to ask about scope. |
| 18:26 | gfredericks | (inc gfredericks) |
| 18:26 | lazybot | You can't adjust your own karma. |
| 18:26 | gfredericks | hmm |
| 18:27 | Moominpapa | I've been trying to write a hook that adds to #'leiningen.ring/ring |
| 18:27 | gfredericks | maybe the tilde got ignored |
| 18:27 | Moominpapa | And it works. |
| 18:27 | Moominpapa | Unless I remove lein-ring from the lib directory |
| 18:27 | Moominpapa | Then it stops deps from working, which is rather bad. |
| 18:28 | Moominpapa | Can anyone tell me how to get around this? |
| 18:28 | srid | duck1123: n/m i fixed the deps issue by browsing the repo; wrong lamina version |
| 18:28 | srid | i hope it gets merged to upstream soon. |
| 18:29 | duck1123 | I'm about to push out a new copy, and then I'll put in a pull request |
| 18:29 | srid | excellent |
| 18:29 | duck1123 | of lamina at least, need to check aleph |
| 18:31 | technomancy | Moominpapa: sounds like you need to wrap with some try/catch |
| 18:32 | technomancy | Moominpapa: although hook loading is already wrapped in try/catch if you use :hooks in project.clj |
| 18:33 | Moominpapa | Ah, that's cool. I'll look that up. |
| 18:33 | Moominpapa | I was hoping there was a way to detect if "require" would throw. |
| 18:33 | technomancy | hm; elisp has that |
| 18:34 | technomancy | optional noerror arg |
| 18:34 | technomancy | clojure does not |
| 18:34 | Moominpapa | But even then, I can get compilation errors. Thinking I need to wrap more stuff in eval. |
| 18:34 | Moominpapa | Pity. |
| 18:34 | Moominpapa | Thank you! :) |
| 18:36 | hiredman | ugh, really? |
| 18:36 | hiredman | why are you wrapping stuff in eval? |
| 18:38 | Moominpapa | OK, simplest version |
| 18:38 | Moominpapa | (add-hook #'leiningen.ring/ring (myns.watch/watch)) |
| 18:39 | Moominpapa | Problem is, if my deps aren't there, myns.watch doesn't compile and everything falls over in a heap. |
| 18:39 | hiredman | (when-let [v (resolve 'lein....ring)] (add-hook v ...)) |
| 18:39 | technomancy | :hooks loading actually has a special case where it doesn't even report errors if lib/ is empty |
| 18:47 | Moominpapa | ok, so :hooks specifies a list of namespaces that add hooks? |
| 18:49 | technomancy | yup |
| 18:49 | Moominpapa | Cool, I will try this tomorrow. Thankyou very much :) |
| 18:59 | duck1123 | srid: 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:59 | duck1123 | looks like a ratio vs. floats issue |
| 18:59 | srid | duck1123: yea, just saw them :-) i've been using your fork, except for one lamina "closed channel" warning everything is working. |
| 19:00 | duck1123 | yeah, I've been getting that one too. Not sure what's up on that. |
| 19:02 | srid | your snapshot releases are based on ztellman's HEAD or his latest public release? |
| 19:02 | duck1123 | off of head |
| 19:03 | duck1123 | I can push a rebased version if you want. It's the same few commits over and over again |
| 19:05 | duck1123 | When 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:16 | shep-home | Is there a common meaning for a function that ends in a hyphen? |
| 19:17 | dnolen | shep-home: like what? |
| 19:17 | gfredericks | clojure.core/- :) |
| 19:17 | shep-home | Well, now I'm worried I'm imagining things |
| 19:17 | dnolen | heh |
| 19:18 | dnolen | shep-home: there's defn- |
| 19:18 | shep-home | I felt I had seen some function pairs like foo and foo- |
| 19:18 | technomancy | it means someone was typing a function name and paused to think of the right word and forgot to start typing again |
| 19:18 | gfredericks | if I saw it I would imagine it's similar to foo and foo* |
| 19:18 | duck1123 | actually, I just saw on in gloss, let me find it |
| 19:18 | shep-home | gfredericks: what would that mean then? |
| 19:19 | dnolen | shep-home: foo will often be defined in terms of foo*. |
| 19:19 | gfredericks | shep-home: My interpretation is that foo- is a private simpler version of the function and foo is some wrapper around it |
| 19:19 | gfredericks | shep-home: also what dnolen said |
| 19:19 | shep-home | and it would be unexpected for an outside user to call the * or - version |
| 19:19 | gfredericks | yes |
| 19:20 | gfredericks | shep-home: I ofter have a macro-function pair where the function ends in * |
| 19:20 | gfredericks | s/ofter/often |
| 19:20 | lazybot | <gfredericks> shep-home: I often have a macro-function pair where the function ends in * |
| 19:20 | gfredericks | shep-home: I suppose in that case it wouldn't be unheard of to call the * version |
| 19:20 | shep-home | but it would still be more of a "you know what you are doing by calling this" |
| 19:21 | gfredericks | yeah. not the standard interface. |
| 19:24 | shep-home | defn- nicely answers the related question I was going to ask, so thanks for pointing it out :-) |
| 19:24 | gfredericks | in #clojure we always try to answer your current question and your next question in one go |
| 19:25 | napping | are there any examples of long polling with ring? |
| 19:25 | shep-home | gfredericks: is your *answer-seq* of length 2, or do i need to take more? |
| 19:25 | shep-home | :-) |
| 19:26 | gfredericks | shep-home: nil |
| 19:26 | gfredericks | napping: is aleph not appropriate? |
| 19:26 | napping | never heard of it, thanks |
| 19:26 | gfredericks | np |
| 19:27 | napping | I found https://github.com/mmcgrana/picard |
| 19:28 | gfredericks | you'd think if I search for "mmcgrana picard" in github's search box that something would come up :| |
| 19:28 | duck1123 | Aleph works great for that |
| 19:29 | duck1123 | in aleph, you get a channel. When you're ready to send, just enqueue the channel |
| 19:30 | ibdknox_ | the reason aleph is good for long polling is primarily that it's built on netty |
| 19:30 | ibdknox_ | which is important for long running connections |
| 19:40 | gfredericks | I'm using aleph TCP and frequently get nil messages coming through the channels...does anybody know what that means? |
| 19:53 | Zolrath | I'm trying to use pinot to add elements to the DOM but nothing I try seems to actually… do anything? |
| 19:54 | Zolrath | (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:54 | ibdknox_ | Zolrath: are you including the script file after the body tag is loaded? |
| 19:54 | Zolrath | If I do a (js/alert "Test") it appears so the javascript is getting loaded |
| 19:54 | Zolrath | oooooh |
| 19:54 | Zolrath | No I'm not |
| 19:54 | ibdknox_ | :) |
| 19:54 | Zolrath | Thank you very much |
| 19:54 | ibdknox_ | that got me too |
| 19:54 | ibdknox_ | lol |
| 19:55 | gfredericks | what's all this? the <script> goes after the <body>? |
| 19:56 | ibdknox_ | <body>..content... <script> </body> |
| 19:56 | ibdknox_ | it's a common pattern in JS |
| 19:56 | gfredericks | presumably just barely uncommon enough that I've never heard of it |
| 19:56 | gfredericks | is that an alternative to the dom:ready event? |
| 19:57 | ibdknox_ | there is no dom ready in gclosure |
| 19:57 | ibdknox_ | sadly |
| 19:57 | gfredericks | thus the <script> positioning? |
| 19:57 | ibdknox_ | yessir |
| 19:57 | brehaut | gfredericks: older browsers would also wait for scripts to load and compile before loading other resources |
| 19:57 | ibdknox_ | though there are other benefits |
| 19:57 | ibdknox_ | yeah |
| 19:57 | brehaut | which would block images and css |
| 19:58 | ibdknox_ | it allows all your content to come in before the script loads/runs |
| 19:58 | gfredericks | in the newer browsers it would slightly delay the request for the script? |
| 19:59 | brehaut | modern browsers have much more sophisticated heuristics on how and when to load scripts |
| 19:59 | brehaut | i dont tihnk you could make a blanket statement about them |
| 20:00 | gfredericks | brehaut: I just meant that it wouldn't even know about the script until it had at least read through the page |
| 20:00 | brehaut | sure |
| 20:00 | gfredericks | I'm sure it's not a big deal though |
| 20:00 | gfredericks | thx for educate |
| 20:00 | gfredericks | I learn something new every time I asks questions about topics I'm ignorant of. |
| 20:00 | ibdknox_ | gfredericks: http://stackoverflow.com/questions/2024018/using-domcontentready-considered-anti-pattern-by-google |
| 20:01 | gfredericks | ibdknox_: thx |
| 20:02 | brehaut | i think yahoo's yslow agrees with that too |
| 20:02 | upwardindex | Yes, I'm pretty sure I read putting scripts at the very end in yahoo's recommendation for web dev |
| 20:03 | gfredericks | From now on I'm doing <script> ...content... <body></script>, just to be controversial |
| 20:03 | gfredericks | I'm sure the browsers will figure it out |
| 20:04 | upwardindex | gfredericks: http://developer.yahoo.com/performance/rules.html might want to check this (also "Put scripts at the bottom" section |
| 20:11 | gfredericks | I'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:11 | amalloy | gfredericks: one of those uses lein |
| 20:11 | amalloy | ~rimshot |
| 20:11 | clojurebot | Badum, *ching* |
| 20:12 | napping | Is there some way to pick up new dependencies in project.clj without restarting slime? |
| 20:12 | gfredericks | I'll switch to make immediately! |
| 20:12 | amalloy | seriously though, there's something i don't understand which makes it hard to get stdin when running through lein or cake |
| 20:12 | napping | I've run lein deps in a shell, which copied in more files, but they don't seem to be visible in the repl |
| 20:12 | amalloy | napping: no |
| 20:13 | amalloy | (sorry, that's just the way it is) |
| 20:13 | technomancy | gfredericks: try lein trampoline run |
| 20:14 | napping | Ok, that's what I was doing anyway |
| 20:15 | technomancy | amalloy: tempted to add code to swank that shells out and runs add-classpath or something absurd like that |
| 20:15 | gfredericks | technomancy: that totally worked. |
| 20:15 | gfredericks | (inc technomancy) |
| 20:15 | lazybot | ⟹ 14 |
| 20:15 | technomancy | gfredericks: finally, a use for that task! =) |
| 20:16 | gfredericks | well wuddayaknow. |
| 20:18 | ibdknox_ | what does lein trampoline do? |
| 20:19 | gfredericks | ibdknox_: 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:19 | gfredericks | ^ quoted from lein readme |
| 20:20 | ibdknox_ | I see |
| 20:20 | technomancy | it's like clojure.core/trampoline, but operating on tasks instead of functions |
| 20:20 | technomancy | sorta |
| 20:20 | gfredericks | technomancy: if my task returns a function, will it launch another jvm? |
| 20:20 | ibdknox_ | is read-line really the only use for it? |
| 20:20 | technomancy | gfredericks: no |
| 20:20 | technomancy | well |
| 20:21 | technomancy | really 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:21 | technomancy | and the shell script can invoke java with the project's own classpath directly |
| 20:21 | technomancy | ibdknox_: so you can also use it to save memory since it allows leiningen's own java process to exit |
| 20:22 | ibdknox_ | technomancy: gotcha |
| 20:22 | technomancy | basically it's to make up for the fact that java's posix support is a joke and it doesn't implement exec. |
| 20:25 | amalloy | mmmm, trampoline. sounds super. i've been vexed recently by that extra jvm sticking around forever |
| 20:26 | technomancy | actually vexed or just a bit irritated? |
| 20:27 | amalloy | technomancy: i don't think vex is inherently a stronger word than irritate, is it? |
| 20:28 | amalloy | vex can mean puzzlement as well |
| 20:28 | technomancy | hmm... 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:28 | amalloy | it's a pretty flexible word |
| 20:29 | gfredericks | ,(let [vex inc] (vex 12)) |
| 20:29 | clojurebot | 13 |
| 20:29 | gfredericks | indeed |
| 20:29 | amalloy | things 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:30 | technomancy | you use "lein run" in production? |
| 20:30 | amalloy | our server deploy tools are embarrassingly primitive, yes |
| 20:30 | technomancy | I used to advise against that until mcgrana convinced me otherwise. |
| 20:30 | technomancy | do you know about LEIN_NO_DEV? |
| 20:30 | amalloy | no |
| 20:30 | technomancy | it'll keep dev deps and test off the classpath |
| 20:30 | amalloy | does that matter? |
| 20:31 | gfredericks | for class load latency maybe? |
| 20:31 | technomancy | depends on what you keep in test I guess =) |
| 20:31 | technomancy | we put lots of config in there that isn't appropriate for production |
| 20:31 | amalloy | nobody who knows how to do deploys/admin better is interested in contributing, so we just use lein |
| 20:31 | technomancy | in test-resources, rather, but same idea |
| 20:32 | technomancy | maybe hugod would be interested in making it an example for pallet =) |
| 20:32 | arohner | technomancy: what are the arguments for and against lein run in production? |
| 20:32 | technomancy | arohner: well... they are mostly addressed by LEIN_NO_DEV and lein trampoline =) |
| 20:32 | technomancy | the arguments against, anyway |
| 20:33 | technomancy | the 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:33 | technomancy | heroku solves that with the slug compiler, 4clojure probably solves it by not needing repeatability by virtue of having only a single server. =) |
| 20:34 | arohner | I like to solve that one with a private maven repo |
| 20:34 | technomancy | yes, that's even better |
| 20:34 | arohner | someone needs to build a lein plugin for creating maven repos in S3... |
| 20:35 | technomancy | it can still let through newer snapshots, lein will try to talk you out of cutting releases that depend on snapshots anyway |
| 20:35 | arohner | it'll probably be me that ends up making that... |
| 20:35 | technomancy | arohner: I've actually been considering making clojars store its artifacts on s3 |
| 20:37 | j941 | trying to convert (map second soaps (mapcat keys)) to thrush operator, but i failed... |
| 20:37 | j941 | (-> (map second soaps) (mapcat keys)) |
| 20:37 | j941 | more like, (apply (partial conj #{}) (mapcat keys (map second records))))) |
| 20:38 | amalloy | ->> |
| 20:38 | j941 | I want to convert it so that its linear, thrush style... but it won't work :( |
| 20:38 | amalloy | oh, nm |
| 20:38 | amalloy | (->> (mapcat keys) (map second soaps)) |
| 20:39 | j941 | yay! --> 2nd arg, -> is the first ? |
| 20:39 | amalloy | ->> is last |
| 20:39 | amalloy | also, your partial there is unnecessary |
| 20:39 | j941 | ok |
| 20:39 | amalloy | (apply conj #{} (...)) |
| 20:39 | j941 | im reverse engineering code from this post http://www.magpiebrain.com/2010/08/10/creating-sparse-tabular-data-with-clojure/ |
| 20:41 | amalloy | wow, why is he trying to turn this stuff into strings? |
| 20:43 | amalloy | oh, 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:43 | j941 | yeah it seems nuts. |
| 20:44 | amalloy | i advise against reverse-engineering things which are nuts |
| 20:45 | napping | should this code be serving empty pages http://pastebin.com/CiTe3PLh ? |
| 20:45 | j941 | haha well. i just want to tabulate this http://pastebin.com/Dy401Br6 |
| 20:46 | amalloy | $google clojure csv |
| 20:46 | lazybot | [davidsantiago/clojure-csv - GitHub] https://github.com/davidsantiago/clojure-csv |
| 20:46 | j941 | # |
| 20:46 | brehaut | napping: it shouldnt return a blank page |
| 20:46 | napping | it works as expected if it's (run-jetty app {:port 8080}) |
| 20:46 | brehaut | napping: also, you have c-itus with your closing braces and parens |
| 20:47 | amalloy | napping: loading your namespace has the side effect of trying to launch a jetty server |
| 20:47 | amalloy | and wrap-reload will load your namespace often |
| 20:47 | napping | ah |
| 20:47 | j941 | oh wow i just saw clojure0csv that looks good. |
| 20:47 | ibdknox_ | napping: noir would take care of all this basic stuff for you, if you're just trying to get started |
| 20:47 | amalloy | i don't know if that's the cause of your problem, but you shouldn't do it |
| 20:47 | brehaut | napping: (defonce server (run-jetty… |
| 20:50 | j941 | but im wondering -- how can i transpose the data in clojure ? |
| 20:50 | j941 | i will pastebin it ... hold on ... |
| 20:51 | brehaut | ,(apply map vector [[:a 1] [:b 2] [:c 3]]) |
| 20:51 | clojurebot | ([:a :b :c] [1 2 3]) |
| 20:52 | brehaut | for a simple case |
| 20:53 | j941 | http://pastebin.com/8Sgb2AeN |
| 20:54 | j941 | So the idea is, that, i want a lists columns to become headers in the file. |
| 20:55 | j941 | so 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:56 | napping | defonce doesn't seem to work well enough - and it still comes up blank. |
| 20:56 | napping | at least it gives me a server handle, I didn't realize there was a meaningful result |
| 20:56 | brehaut | napping: defonce just stops it being redefined on reload |
| 20:57 | brehaut | napping: are you testing this from a browser or a repl? |
| 20:57 | napping | it seems C-c C-l does something more then |
| 20:57 | j941 | are there 2d data structures in clojure? |
| 20:57 | napping | testing from a browser, running from slime |
| 20:57 | j941 | like 2d lists ? |
| 20:57 | j941 | or map w/ two keys ? |
| 20:57 | brehaut | ,{[1,2] :a [4,5] :b} |
| 20:57 | clojurebot | {[4 5] :b, [1 2] :a} |
| 20:58 | brehaut | ,[[1 2 3] [4 5 6] [7 8 9]] |
| 20:58 | clojurebot | [[1 2 3] [4 5 6] [7 8 9]] |
| 20:58 | j941 | @brehaut , so [4 5] is a key pointing to "b" ? |
| 20:58 | j941 | (thanks) |
| 20:59 | brehaut | j941: to :b |
| 20:59 | brehaut | (keyword, rather than a symbol) |
| 20:59 | napping | what's that about braces? some are where paredit put them, and some are there to make it easier to add more items |
| 20:59 | j941 | ok but it could easily be {[1,2] "a" [4,5] "b"} , right ? |
| 20:59 | brehaut | j941: yes |
| 21:00 | brehaut | napping: ok. just as long as you realise that its unidiomatic to have closing parens etc hanging on their own line |
| 21:00 | j941 | cool. 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:00 | j941 | or just roll up elbows and use java split it |
| 21:01 | brehaut | ,(split "ab,c,d" #",") |
| 21:01 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: split in this context, compiling:(NO_SOURCE_PATH:0)> |
| 21:01 | napping | what do you do? C-M-f? |
| 21:02 | j941 | oh ok cool clojure has a split . thanks. |
| 21:02 | brehaut | ,(use 'clojure.string) |
| 21:02 | clojurebot | WARNING: replace already refers to: #'clojure.core/replace in namespace: sandbox, being replaced by: #'clojure.string/replace |
| 21:02 | clojurebot | WARNING: reverse already refers to: #'clojure.core/reverse in namespace: sandbox, being replaced by: #'clojure.string/reverse |
| 21:02 | clojurebot | nil |
| 21:02 | duck1123 | ,(clojure.string/split "ab,c,d" #",") |
| 21:02 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox> |
| 21:02 | gfredericks | does clojurebot reboot regularly? |
| 21:02 | brehaut | yikes im sorry |
| 21:02 | duck1123 | whenever someone breaks it :) |
| 21:03 | gfredericks | how does it know when it's been broken? |
| 21:03 | gfredericks | brehaut: if you want to really have fun start setting functions to macros |
| 21:03 | j941 | clojure bot doesnt like it. |
| 21:04 | j941 | i guess because missing import? Thats cool that clojure bot ... does it run everything we type? |
| 21:04 | gfredericks | j941: prefixed with a comma |
| 21:04 | brehaut | j941: no the bot is sandboxed, no eval, defs etc |
| 21:04 | gfredericks | ,(str \: \- \D) |
| 21:04 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox> |
| 21:04 | gfredericks | ,(inc 38) |
| 21:04 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox> |
| 21:05 | brehaut | it also helps if some twit didnt break the bot first |
| 21:05 | duck1123 | It's not going to do anything |
| 21:05 | gfredericks | if I knew my ns functions well enough I'd try to set them back |
| 21:05 | gfredericks | ,(use 'clojure.core) |
| 21:05 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox> |
| 21:05 | amalloy | hiredman: clojurebot needs someone to resurrect him |
| 21:05 | gfredericks | I would have guessed clojurebot would reboot itself every so often |
| 21:05 | clojurebot | I don't understand. |
| 21:06 | gfredericks | clojurebot: are you male? |
| 21:06 | clojurebot | Cool story bro. |
| 21:06 | duck1123 | clojurebot: reload |
| 21:06 | clojurebot | _seanc_: Your files don't get reloaded when a request is made. |
| 21:08 | j941 | why the # in split ? why not just (clojure.string/split "a,b" ",") ... is # making the stirng a function ? |
| 21:08 | gfredericks | j941: makes it a regex |
| 21:08 | brehaut | j941: split takes a regexp |
| 21:08 | gfredericks | &(type #"fubar") |
| 21:08 | lazybot | ⇒ java.util.regex.Pattern |
| 21:11 | duck1123 | Is there a flag that'll make lein re-fetch all of the snapshots? (similar to -U in maven) |
| 21:15 | j941 | how to get the 1st and 3rd elements of a list ? (nth [ 1 2 3 4 ] 1 3) doesnt work |
| 21:16 | brehaut | (map #(nth [1 2 3 4] %) [1 2]) |
| 21:17 | brehaut | err make that [1 3] at the end |
| 21:17 | brehaut | or alternatively with destructuring (let [[a _ b] [1 2 3 4]] [a b]) |
| 21:17 | j941 | good call @brehaut |
| 21:18 | j941 | why _ in the middle ? |
| 21:18 | brehaut | so that you skip an element |
| 21:18 | brehaut | _ is bound but we dont care about it |
| 21:19 | brehaut | actually thats slightly wrong because, thats 0 and 2 rather than 1 and 3 |
| 21:19 | j941 | yup could be x y z got it |
| 21:19 | brehaut | (let [[_ a _ b] [1 2 3 4]] [a b]) |
| 21:19 | joegallo | ,(vals (select-keys [1 2 3 4 5] [1 3])) |
| 21:19 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox> |
| 21:20 | joegallo | oh well, anyway, that works if you don't care what order they're in |
| 21:20 | brehaut | j941: its hard to suggest a particular form without knowing what you are doing with it though |
| 21:20 | gfredericks | &(vals (select-keys [1 2 3 4 5] [1 3])) |
| 21:21 | lazybot | ⇒ (4 2) |
| 21:21 | gfredericks | even stranger that it comes back as a list... |
| 21:22 | gfredericks | oh never mind |
| 21:22 | duck1123 | it's probably a lazy seq |
| 21:22 | gfredericks | it's a map actually |
| 21:22 | gfredericks | &(select-keys [1 2 3 4 5] [1 3]) |
| 21:22 | lazybot | ⇒ {3 4, 1 2} |
| 21:23 | brehaut | select-keys uses find under the hood, i dont know if that impacts its performance profile compared to nth though |
| 21:24 | gfredericks | brehaut: my repl thinks nth and find on vectors are about the same |
| 21:25 | duck1123 | isn't find special cased for vectors? |
| 21:25 | brehaut | no idea, its in the RT |
| 21:25 | brehaut | so source doesnt tell me |
| 21:25 | gfredericks | I think it'd have to be, if it only works for vectors and maps |
| 21:26 | j941 | is there a way to target thrush to specific args ? |
| 21:26 | j941 | (->X (f1 X) (f2 "hi" X) (f3 "hello" "again" X)) |
| 21:26 | brehaut | -> isnt thrush, its a rewriting macro |
| 21:27 | brehaut | if you want X to be threaded at the end of the forms, use ->> |
| 21:28 | brehaut | &[(macroexpand '(-> 1 (a b))) (macroexpand '(->> 1 (a b)))] |
| 21:28 | lazybot | ⇒ [(a 1 b) (a b 1)] |
| 21:29 | gfredericks | what if ->> went to the second arg, and ->>> etc., and -< went to the last... |
| 21:30 | amalloy | gfredericks: you can make it happen |
| 21:30 | gfredericks | amalloy: I know, I've seen amalloy-utils :P |
| 21:30 | amalloy | har har |
| 21:31 | duck1123 | I don't think I've ever wanted to thread multiple functions on the second arg |
| 21:31 | gfredericks | duck1123: me neither |
| 21:31 | brehaut | gfredericks: im pretty sure you'll pronounce brehaut more incorrectly |
| 21:31 | gfredericks | duck1123: unless you were also talking about the last arg |
| 21:31 | duck1123 | right |
| 21:31 | gfredericks | brehaut: I always pronounce 'brehaut' as 'amalloy' |
| 21:32 | brehaut | lol |
| 21:32 | amalloy | letter-A, muh, LOY |
| 21:32 | gfredericks | so not AH-muh-LOY |
| 21:32 | amalloy | hey, say whatever you want in the confines of your own head |
| 21:32 | amalloy | everyone still calls you girlfrog anyway |
| 21:33 | gfredericks | it can't be helped |
| 21:33 | amalloy | (you're gfrlog, right?) |
| 21:33 | gfredericks | it's undeniable |
| 21:33 | brehaut | lol |
| 21:33 | gfredericks | who else interjects as much as I do? |
| 21:34 | amalloy | well |
| 21:34 | amalloy | there was that guy yesterday |
| 21:34 | amalloy | who put newlines every five words |
| 21:34 | amalloy | he probly interjected more yesterday |
| 21:34 | amalloy | than you have in your life |
| 21:34 | gfredericks | glad I missed that |
| 21:35 | gfredericks | irc haiku |
| 21:35 | amalloy | ~haiku |
| 21:35 | clojurebot | It's greek to me. |
| 21:35 | gfredericks | an opportunity! |
| 21:35 | amalloy | gfredericks: just /msg fsbot haiku, it's easier |
| 21:36 | gfredericks | the things I don't know about |
| 21:36 | gfredericks | they are numerous |
| 21:37 | gfredericks | I think I got this backwards |
| 21:38 | amalloy | that's not a haiku, is it?? |
| 21:38 | lazybot | amalloy: What are you, crazy? Of course not! |
| 21:38 | gfredericks | this isn't how you trigger lazybot, is it? |
| 21:38 | amalloy | evidently not |
| 21:38 | gfredericks | must need the second question mark |
| 21:39 | gfredericks | amalloy: don't pretend you don't know all its secrets |
| 21:39 | amalloy | gfredericks: you think i wrote the darn thing, or something??? |
| 21:39 | lazybot | amalloy: Oh, absolutely. |
| 21:40 | amalloy | ~guards |
| 21:40 | clojurebot | SEIZE HIM! |
| 21:41 | gfredericks | now get them to fall in love |
| 21:41 | amalloy | ~<3 |
| 21:41 | clojurebot | <3 is </3 |
| 21:42 | amalloy | i don't remember who taught him that, but it's sad that this is all he knows of love |
| 21:42 | gfredericks | is there a way to get him to return all values for a key? |
| 21:42 | amalloy | *shrug* |
| 21:42 | amalloy | probably not, since it's not just k/v, it's search |
| 21:42 | gfredericks | ~love |
| 21:42 | clojurebot | Excuse me? |
| 21:43 | gfredericks | what? no song references at least? |
| 21:43 | amalloy | clojurebot: tell us about python |
| 21:43 | clojurebot | python is ugly |
| 21:43 | brehaut | opinionated SOB isnt he |
| 21:43 | gfredericks | clojurebot: ~haskell |
| 21:43 | clojurebot | Cool story bro. |
| 21:43 | gfredericks | only picks on the weaklings |
| 21:43 | amalloy | see, 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:43 | amalloy | gfredericks: i think this implies that you are the weakling |
| 21:44 | gfredericks | clojurebot: where can I buy a python? |
| 21:44 | clojurebot | python is ugly |
| 21:44 | amalloy | clojurebot: what's the deal with haskell? |
| 21:44 | clojurebot | "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:48 | j941 | (-> (slurp "resources/hino.txt") (clojure.string/split "_") ) |
| 21:48 | j941 | (->> (slurp "resources/hino.txt") (clojure.string/split "_") ) |
| 21:48 | gfredericks | j941: you want #"_" instead of "_"? |
| 21:48 | j941 | also fails ? REPL Complains about Regex cast. |
| 21:48 | j941 | ooops |
| 21:50 | jeremyheiler | clojurebot: tell us about ruby |
| 21:50 | clojurebot | Chunky bacon! |
| 21:50 | jeremyheiler | lol |
| 21:51 | amalloy | haha what |
| 21:51 | amalloy | ~ruby |
| 21:51 | clojurebot | Chunky bacon! |
| 21:51 | amalloy | fascinating |
| 21:51 | gfredericks | better than being ugly I guess |
| 21:51 | brehaut | ~pascal |
| 21:51 | clojurebot | Excuse me? |
| 21:51 | gfredericks | at least it smells good |
| 21:51 | duck1123 | makes perfect sense |
| 21:51 | jeremyheiler | (it's a reference to why's book i suppose) |
| 21:52 | brehaut | ~java |
| 21:52 | clojurebot | ☕ |
| 21:52 | brehaut | haha |
| 21:57 | j941 | do i need let for this ? (let [[a _ b] [1 2 3 4]] [a b]) |
| 21:58 | duck1123 | you need a place where you can do destructuring |
| 21:58 | gfredericks | if you had a function called 'third' then you could do (juxt first third) |
| 22:00 | amalloy | didn't we do this with select-keys a minute ago? |
| 22:00 | amalloy | oh, nm, wait |
| 22:00 | amalloy | &(map [1 2 3 4] [0 2]) |
| 22:00 | lazybot | ⇒ (1 3) |
| 22:00 | gfredericks | if he's got a vector |
| 22:01 | amalloy | gfredericks: he just said he did :P |
| 22:01 | gfredericks | well I didn't see it |
| 22:01 | amalloy | i mean, the question he asked has a vector |
| 22:01 | gfredericks | :P |
| 22:01 | brehaut | amalloy: nah, he quoted my code |
| 22:02 | brehaut | i think i might have assumed it was a vector |
| 22:02 | brehaut | or just used it for example |
| 22:02 | Zolrath | The 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:03 | j941 | oh ok @nm |
| 22:03 | Zolrath | I'm using the wrap-remotes middleware in Noir and I've tried defining the remote in multiple places |
| 22:07 | j941 | hmmm ok almost working ... but .... still getting an error . |
| 22:07 | j941 | (-> (slurp "resources/hino.txt") (clojure.string/split #"_") (map #(nth % 1) )) |
| 22:07 | j941 | -> (slurp "resources/hino.txt") (clojure.string/split #"_") (map #(nth % 1) )) |
| 22:07 | j941 | "Don't know how to create ISeq from: user$eval297$fn__298 |
| 22:13 | gfredericks | j941: map takes the function first and the collection second |
| 22:13 | gfredericks | your use of -> puts them in the wrong order |
| 22:13 | brehaut | j941: its not haskell, you dont need to feel obligated to point free everything ;) |
| 22:15 | j941 | what is point free |
| 22:16 | j941 | i think the argument doesnt get into the map |
| 22:16 | gfredericks | j941: replace (map #(nth % 1)) with (->> (map #(nth % 1))) |
| 22:17 | gfredericks | the argument gets into the map fine, just in the wrong spot |
| 22:17 | gfredericks | you want it last |
| 22:17 | j941 | oh ok. |
| 22:18 | j941 | i didnt know you could have --> and -> together! |
| 22:18 | gfredericks | j941: also you could repcale #(nth % 1) with second |
| 22:18 | j941 | i know... im not thinking functionally |
| 22:18 | gfredericks | j941: a trick hiredman taught me |
| 22:18 | j941 | im thinking in syntax. <-- naughty boy |
| 22:19 | gfredericks | j941: 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:19 | j941 | now its returning some kind of function |
| 22:19 | j941 | (-> (slurp "resources/hino.txt") (clojure.string/split #"_") (->> map #(nth % 1) ) ) |
| 22:20 | gfredericks | j941: you forgot a set of parens around map |
| 22:20 | gfredericks | (->> (map second)) |
| 22:22 | ibdknox | pyr: pushed a fix for the event stuff you were seeing yesterday |
| 22:22 | j941 | o ok. thats odd.... what is the diff made by adding the parens |
| 22:23 | j941 | i mean, shouldnt it "know" that im trying to run the map function ? |
| 22:23 | gfredericks | &(map macroexpand '[(->> coll map second) (->> coll (map second))]) |
| 22:23 | lazybot | ⇒ ((second (clojure.core/->> coll map)) (map second coll)) |
| 22:23 | ibdknox | you have to tell it how to group the parameters |
| 22:24 | gfredericks | j941: (->> coll map second) simplifies to (second (map coll)) |
| 22:24 | gfredericks | which is not what you want |
| 22:24 | gfredericks | you want (map second coll) |
| 22:24 | gfredericks | which is what you get from (->> coll (map second)) |
| 22:29 | j941 | oh ok |
| 22:30 | srid | anyone wanting to participate in stanford's #ml-class? |
| 22:30 | companion_cube | what is it, |
| 22:30 | companion_cube | , |
| 22:30 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox> |
| 22:30 | companion_cube | oops |
| 22:31 | duck1123 | great companion_cube you broke it :) |
| 22:32 | companion_cube | ,(+ 2 2) |
| 22:32 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox> |
| 22:32 | Zolrath | srid: I'm planning on it! I've gone through a few of the videos that they have up right now in preparation. |
| 22:33 | companion_cube | duck1123: no, i found a bug ;) |
| 22:33 | duck1123 | no, someone tried to use clojure.string and killed him |
| 22:35 | j941 | how can you have (->>) in the last function ? isnt the job of ->> to forward args? |
| 22:36 | duck1123 | which one? |
| 22:37 | Zolrath | (-> thing (another one)) would result in (another thing one) but (->> thing (another one)) would be (another one thing) |
| 22:38 | duck1123 | they both just rewrite the code |
| 22:38 | brehaut | j941: -> and ->> just rewrite the forms; its really easy to see with macroexpand |
| 22:38 | j941 | ok |
| 22:38 | duck1123 | I was so happy when I discoverd my little debug logging macro still worked with -> and ->> |
| 22:39 | amalloy | duck1123: it actually works even better, i suspect |
| 22:39 | amalloy | mine 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:39 | duck1123 | https://github.com/duck1123/ciste/blob/master/src/ciste/debug.clj |
| 22:40 | duck1123 | I like that name though |
| 22:40 | amalloy | duck1123: see also ##(doc pr-str) |
| 22:40 | lazybot | ⇒ "([& xs]); pr to a string, returning it" |
| 22:40 | amalloy | you really-really don't want to use print for debugging |
| 22:41 | duck1123 | good point, I'll change that |
| 22:41 | amalloy | mostly because ##(map print-string ['a "a" \a]) all look the same |
| 22:41 | lazybot | java.lang.Exception: Unable to resolve symbol: print-string in this context |
| 22:41 | amalloy | mostly because ##(map print-str ['a "a" \a]) all look the same |
| 22:41 | lazybot | ⇒ ("a" "a" "a") |
| 22:42 | duck1123 | well, the point is I usually wrap a variable, and it prints that name and the pretty-printed value |
| 22:43 | amalloy | duck1123: right. and if you want to know whether its value is a string or a symbol? |
| 22:43 | amalloy | &(map pr-str ['a "a" \a]) actually makes them print differently; you don't lose information |
| 22:43 | lazybot | ⇒ ("a" "\"a\"" "\\a") |
| 22:43 | duck1123 | fair enough |
| 22:45 | devth | can 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:47 | brehaut | devth: 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:47 | brehaut | devth: your repl shouldnt block that way |
| 22:47 | devth | brehaut: ah, excellent. now i need to go learn how to spawn a thread :) |
| 22:47 | brehaut | devth: the cheating way is (future …) |
| 22:48 | devth | brehaut: thanks for the tip. |
| 22:48 | j941 | size of a list ? |
| 22:48 | brehaut | devth: dont chuck it into your NS without wrapping it in a fn or defonce |
| 22:48 | devth | ok. |
| 22:48 | j941 | i googled "length of list clojure" and it pulled up an article about tail-recursion. lol... |
| 22:49 | jeremyheiler | ##(count '(1 2 3)) |
| 22:49 | lazybot | ⇒ 3 |
| 22:49 | j941 | duh count |
| 22:50 | tomoj | I was thinking "why not make lists counted?".. but they are :) |
| 22:51 | duck1123 | j941: do you know about clojureatlas.com ? It's good whan you know what you want to do, but not what it's called |
| 22:53 | j941 | clojure needs better error messages. is this under way for next version ? |
| 22:57 | j941 | clojureatlas never used it will check |
| 22:58 | brehaut | j941: its an ongoing process. depending what you mean by 'better' |
| 23:01 | devth | brehaut: worked like a charm :) |
| 23:01 | brehaut | devth: glad to hear :) |
| 23:02 | brehaut | theres not many languages where just throwing a thread at the problem makes things better |
| 23:02 | j941 | is there an idiomatic way to "fork" a list into 3 different functions ? I have a big pipe im building. its getting bigger now, |
| 23:02 | j941 | (-> (slurp "resources/hino.txt") (clojure.string/split #"\n") (->> (map #(clojure.string/split % #"_"))) (->> (map count) )) ;; |
| 23:02 | brehaut | j941: 'fork' ? |
| 23:03 | j941 | i want to do 3 functions to the output of the 2nd to last func (a->b->c1, a->b->c2, a->b->c3) |
| 23:04 | duck1123 | save the step before they split? (ie. let) |
| 23:04 | brehaut | ((juxt count (partial apply +)) [1 2 3]) |
| 23:04 | brehaut | &((juxt count (partial apply +)) [1 2 3]) |
| 23:04 | lazybot | ⇒ [3 6] |
| 23:04 | brehaut | like that? |
| 23:04 | j941 | what is juxt supposed to do i never really understood |
| 23:05 | brehaut | it juxtaposes some functions; ie, count and sum in that example |
| 23:05 | brehaut | juxt 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:05 | j941 | processing <--- |
| 23:05 | j941 | oh wow |
| 23:06 | brehaut | eg, (juxt inc dec) ~> (fn [x] [(inc x) (dec x)]) |
| 23:06 | j941 | well ... how come duck1123 didnt say juxt ! |
| 23:06 | j941 | thats cool |
| 23:06 | brehaut | because your question was quite hard to follow? |
| 23:06 | j941 | lol |
| 23:06 | brehaut | (i took a random guess) |
| 23:06 | joegallo | so, in this case, your example might resemble ((juxt c1 c2 c3) (b (a))) |
| 23:06 | j941 | brehaut saves the day (again) |
| 23:06 | j941 | excellent |
| 23:07 | joegallo | j941: and duck1123's way was totally fine, too |
| 23:07 | j941 | im trying to wean myself off vars |
| 23:07 | brehaut | joegallo: lets do this properly :P ((comp (juxt c1 c2 c3) b a)) |
| 23:07 | duck1123 | I don't use juxt as much as I should |
| 23:08 | j941 | comp |
| 23:08 | j941 | not sure whats that do |
| 23:08 | brehaut | (comp a b) => (fn [& args] (a (apply b args))) |
| 23:08 | brehaut | it composes some functions |
| 23:08 | j941 | why compose ? |
| 23:08 | brehaut | j941: this is 'point free' programming; writing programs in terms of functions but without reference to their arguments |
| 23:09 | j941 | oh ok |
| 23:09 | j941 | why "point" free |
| 23:09 | duck1123 | use it when it feels right, but don't force yourself to it |
| 23:09 | j941 | arg free |
| 23:09 | brehaut | j941: because discrete math :P |
| 23:09 | j941 | ok |
| 23:10 | brehaut | its to do with fixed points of functions |
| 23:10 | duck1123 | (comp a b) is easier than #(a (b %)) |
| 23:10 | brehaut | blah blah haskell blah blah |
| 23:10 | joegallo | http://en.wikipedia.org/wiki/Tacit_programming |
| 23:10 | j941 | less vars/args -> more logic -> cleaner data flow . makes sense. |
| 23:10 | j941 | duck1123 what do you mean ? are those equivalent ? |
| 23:11 | duck1123 | roughly, yes |
| 23:11 | j941 | yeah your right they are. cool . comp must be really important. |
| 23:11 | brehaut | j941: 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:12 | Zolrath | Or maybe my issue is that I don't understand clojure/clojurescript interop |
| 23:12 | Zolrath | If I define a remote call that returns a string it works |
| 23:12 | Zolrath | But if I try to make the Clojure portion return a map and then call different portions of the map in clojurescript, no go |
| 23:14 | duck1123 | Zolrath: is it picking it up as a map? or is it a string now? |
| 23:15 | Zolrath | duck1123: it doesn't seem to be returning anything when I send a map through the remote |
| 23:16 | Zolrath | If I do (:title result) in the clojure side and send that as the result I get the title |
| 23:16 | Zolrath | but if I just send the result to clojurescript and try calling (:title result) on that, nothing |
| 23:16 | duck1123 | how are you sending it? |
| 23:17 | j941 | it would be better if -> ->> could be order independant |
| 23:17 | Zolrath | The pinot defremote/remote macros |
| 23:17 | j941 | like binded to some keyword or variable |
| 23:18 | brehaut | j941: 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:18 | duck1123 | isn't that what let is for? |
| 23:18 | brehaut | or go properly point free |
| 23:19 | j941 | oh ok. this can be done point free ? |
| 23:19 | j941 | (-> (slurp "resources/hino.txt") (clojure.string/split #"\n") (->> (map #(clojure.string/split % #"_"))) (juxt (->> (map count) () )) ;; |
| 23:19 | napping | are servlets notified in any way if the client closes the connection before they are done? |
| 23:19 | j941 | forget about juxt part thats just a WIP |
| 23:19 | brehaut | j941: just start with a let |
| 23:19 | j941 | yeah let is what i normally do but i feel like if i overuse let, i might as well be programming in java. |
| 23:20 | j941 | nevertheless i see ure point |
| 23:21 | duck1123 | either that, or breik pieces of this off into higher level fns |
| 23:21 | duck1123 | and then thread those |
| 23:21 | duck1123 | man, my typing is bad tonight |
| 23:22 | brehaut | &(find-doc "read-lines") |
| 23:22 | lazybot | ⇒ ------------------------- 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:22 | napping | also split-lines |
| 23:23 | brehaut | yeah, ignore read-lines |
| 23:24 | duck1123 | so if you have read-lines, but you only consume the first, does it leave that open once it goes out of scope? |
| 23:24 | brehaut | (you can trivially define it as (def read-lines (comp split-lines slurp)) if you find yourself repeating it) |
| 23:25 | brehaut | duck1123: im going to pretend that given its in old contrib that it doesnt exist at all |
| 23:25 | Zolrath | duck1123: Figured it out, had a Date object as a value to one of the keys which did not please Clojurescript |
| 23:25 | duck1123 | yeah, I globally exclude old contrib in my projects |
| 23:26 | brehaut | my projects still rely on it a bit, but im working on getting them off it |
| 23:27 | duck1123 | Good 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:27 | brehaut | pinot is doing RPC? |
| 23:27 | duck1123 | I had to patch just about every dependency I had at one point, but it's getting a lot better now |
| 23:28 | brehaut | my one publicly available (but thankfully not largely deployed as far as i know) library is still waiting on algo.monads |
| 23:32 | napping | how is (deliver blocked "Response!") not failing if other code has changed so blocked will always be a result of (ref "message")? |
| 23:36 | icefox | Anyone already report that paypal isn't letting you register for the clojure-conf class/conference? |
| 23:36 | brehaut | icefox: 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:37 | amalloy | napping: i don't think that's the case |
| 23:37 | icefox | Paypal says it can't process the order because the account isn't accepting at this time or something like that |
| 23:37 | amalloy | &(deliver (ref "message") "Response!") |
| 23:37 | lazybot | java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn |
| 23:37 | icefox | paypal didn't lock the account did they? |
| 23:38 | napping | http://pastebin.com/w0hpStyt |
| 23:39 | amalloy | napping: i refuse to look at code with that much mutable state. that's gross |
| 23:39 | napping | I see refs piling up in the collection, and "/release" reporting numbers |
| 23:39 | amalloy | but the issue is that for is lazy - you're not executing any actual code in the body |
| 23:39 | napping | ah, that would do it |
| 23:43 | napping | works much better with the doall |
| 23:43 | amalloy | ugh |
| 23:43 | amalloy | doseq |
| 23:44 | Apage43 | You could also just use doseq |
| 23:44 | amalloy | hm. i sound crabby, sorry. going to stop trying to be helpful for a bit |
| 23:45 | napping | well, 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:46 | technomancy | next 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:46 | technomancy | because *that* is complicated |
| 23:46 | technomancy | I used to do ruby full time and I only understand about half of it |
| 23:46 | brehaut | whoa |
| 23:49 | Apage43 | how did node.js get in here |
| 23:50 | brehaut | Apage43: who doesnt need more javascript in their enviroment? |
| 23:50 | technomancy | "now you have 1.999999999999999999999998 problems" |
| 23:52 | j941 | " |
| 23:53 | j941 | Article Im reading about "juxt". |
| 23:54 | Apage43 | just how much is there to say about it |
| 23:55 | brehaut | j941: careful, too far down that rabbit-hole and you'll hit arrows |
| 23:56 | technomancy | ow! my skin! http://p.hagelb.org/arrowed.jpg |
| 23:56 | brehaut | haha |
| 23:56 | brehaut | PAN ASIAN CUISINE |
| 23:56 | duck1123 | I'd worry more about my internal organs |
| 23:57 | brehaut | technomancy: do you have an endless supply of arrows related comics? |
| 23:58 | technomancy | brehaut: haven't you heard? my super power is the ability to link to apropos comics at will. |
| 23:58 | brehaut | i had not heard |
| 23:58 | amalloy | it's mostly either wondermark or haskell |
| 23:59 | brehaut | wondermark confuses the crap out of me |
| 23:59 | brehaut | that sounds bad |
| 23:59 | brehaut | those kinds of storylines are riddled with teen angst |
| 23:59 | technomancy | could have been worse |
| 23:59 | technomancy | could have been a spider |