2011-06-01
| 00:07 | scottj | is there a predicate for whether something will work with get? I didn't realize (System/getenv) would work with it. What about a predicate for whether seq will work on something? |
| 00:14 | dnolen | scottj: not yet, but you can provide the functionality for yourself via protocols, http://dosync.posterous.com/51626638 |
| 00:34 | scottj | dnolen: cool, would be a nice library |
| 01:15 | seancorfield__ | if i have a function and a collection, i can do (apply fn coll) to invoke the function with the elements of the collection as arguments... |
| 01:15 | seancorfield__ | ...but that doesn't work with a macro |
| 01:15 | seancorfield__ | if i have a macro and a collection, how can i do the equivalent of apply? |
| 01:16 | amalloy | seancorfield__: you can't, because the collection doesn't have a value when the macro is run - at *compile* time |
| 01:17 | amalloy | i mean, there are workarounds like (eval `(mymacro ~@mycoll)) |
| 01:17 | amalloy | but it's not really how macros are supposed to work |
| 01:18 | seancorfield__ | yeah, that's what i figured |
| 01:18 | seancorfield__ | i'm trying to use enlive to do stuff it clearly wasn't designed to do |
| 01:19 | seancorfield__ | enlive is nearly all macros... :( |
| 01:19 | seancorfield__ | i wish it were macros wrapping functions so i could use the functions |
| 01:21 | seancorfield__ | frankly, enlive is *really* hard to use outside the confines of its core design... |
| 01:21 | seancorfield__ | i've had to unroll so many macros to reuse the underlying code... |
| 01:22 | amalloy | yes, i've heard that about enlive |
| 01:22 | amalloy | but i don't use it, so i have no clever hacks for you |
| 01:22 | seancorfield__ | gee, thanx :) |
| 01:23 | seancorfield__ | when are you moving to LA? :D |
| 01:24 | seancorfield__ | btw, we went to production with our clojure code today! |
| 01:25 | Ownatik | seancorfield__ what did you build with clojure? |
| 01:25 | seancorfield__ | we have a small ORM built with clojure, as well as environment control (configuration per tier dev/qa/prod) and database logging |
| 01:26 | seancorfield__ | but our core business is all about members in our internet dating sites |
| 01:26 | seancorfield__ | and all members are handled by clojure now... along with page content, metadata, form metadata and a few other things |
| 01:27 | Ownatik | nice |
| 01:28 | seancorfield__ | we have four out of fifty sites live on the new platform... so it's early days... but i''m pleased with how it's going so far |
| 01:29 | amalloy | seancorfield__: tomorrow morning. pretty soon i'll have to shut down the desktop and pack it up too |
| 01:29 | Ownatik | good news |
| 01:29 | Ownatik | didn't know you were running dating sites |
| 01:31 | seancorfield__ | heh... vietvibe.com, latinromantico.com, lovingbbw.com, deafsinglesmeet.com are all on the new platform |
| 01:31 | seancorfield__ | we have a lot more to migrate |
| 01:31 | seancorfield__ | and we're very pleased with the code compression we're seeing with clojure |
| 01:31 | scottj | seancorfield__: are you using latest enlive? I thought cgrand's entire conj talk was about making macros in enive be functions |
| 01:32 | seancorfield__ | using enlive 1.0.0 |
| 01:33 | seancorfield__ | that seems to be the latest version? |
| 01:34 | scottj | yeah |
| 01:35 | amalloy | scottj: i thought his talk was about how the macros should have been functions and it's such a mess because they aren't |
| 01:35 | seancorfield__ | well, i'd agree with that |
| 01:36 | seancorfield__ | it's been an interesting learning experience, given where i am with clojure |
| 01:37 | scottj | amalloy: yeah maybe I'm probably misremembering I thought maybe with each version he made more of the macros be functions |
| 01:37 | seancorfield__ | that would be enlive 2.0.0 then :) |
| 01:37 | Ownatik | where you are ... ranked 66 on 4clojure :P |
| 01:38 | amalloy | scottj: well, i haven't seen the video, or used enlive. i'm just repeating what i've soaked up and corrupted while listening in #clojure |
| 01:38 | seancorfield__ | i haven't touched 4clojure for _weeks_ |
| 01:38 | seancorfield__ | i'm so behind! |
| 01:38 | Ownatik | hehe |
| 01:38 | Ownatik | did the 5 first couple minutes ago ... :P |
| 01:40 | seancorfield__ | i need to find some time to get back on 4clojure and get back to #1 :) |
| 01:40 | Ownatik | you were? |
| 01:45 | amalloy | new problem on 4clojure: do all of amalloy's work for the next month. solved: 0 times |
| 01:45 | seancorfield__ | pah! |
| 01:46 | seancorfield__ | yeah, i was #1 on 4clojure for a while... but work got in the way of doing the fun problems :) |
| 01:46 | seancorfield__ | well, i sent christophe an email about enlive |
| 01:48 | amalloy | seancorfield__: "a while"? i think our (totally arbitrary) secondary-sort happens to favor people who solved their last problem most recently |
| 01:49 | seancorfield__ | if i can port FW/1 to Clojure, i can do a lot more of my day-to-day work in Clojure :) |
| 01:49 | seancorfield__ | amalloy: a while = what? the first weekend it was released? the first 64 questions? :) :) |
| 01:50 | seancorfield__ | if i can find a weekend with nothing on where i can focus on 4clojure, i'll crack 'em all, i swear :) |
| 01:54 | amalloy | seancorfield__: perhaps that weekend would be better spent forking 4clojure and adding a secondary sort that *looks* innocuous but happens to favor seancorfield |
| 01:55 | seancorfield__ | i would never stoop so low |
| 01:56 | seancorfield__ | as my wife says, i'd rather be right than president :) |
| 02:02 | seancorfield__ | is there a nice clean shorthand for (if f (f x) y) |
| 02:04 | scottj | on 4clojure how do you see other ppl's solutions after solving a problem? |
| 02:04 | amalloy | scottj: you can't right now |
| 02:04 | seancorfield__ | it's weird, with clojure i see stuff and want to mercilessly refactor it all the time |
| 02:04 | amalloy | you can see the graph of how long their solution is, but it's still up to the user whether they want to share their stuff via twitter |
| 02:04 | seancorfield__ | i saw someone tweet something similar to that recently |
| 02:05 | scottj | amalloy: is there a hashtag or keywords to search twitter for solutions to a specific problem? |
| 02:05 | seancorfield__ | #4clojure |
| 02:05 | amalloy | scottj: uhhhh, before twitter started mercilessly converting everything to t.co you could search for the url of the problem |
| 02:06 | amalloy | and now that we're putting the title of the problem into the tweet text, you can try searching for that |
| 02:06 | scottj | ok that works |
| 02:13 | Jeffrey04 | @seancorfield__ you're on 4clojure too? |
| 02:14 | Jeffrey04 | do you know how to solve the questions involving graphs/trees?!? |
| 02:14 | amalloy | Jeffrey04: they're all well-known problems with sample algorithms on wikipedia |
| 02:14 | Jeffrey04 | @amalloy @.O |
| 02:15 | amalloy | eg, my horrible implementation of transitive-closure was: (1) define a transitive-once function to compute two-step availability, (2) iterate transitive-once until the graph stops changing |
| 02:17 | amalloy | a much more efficient solution would be to convert the edges into an NxN connectivity matrix, and raise it to the nth power; this is how imperative languages often do it |
| 02:17 | amalloy | anyway, i guess i've run out of ways to put it off; i'm going to pack up my computer for the move. night, folks |
| 02:18 | Jeffrey04 | @amalloy night |
| 02:23 | seancorfield__ | take care amalloy_ see you on the other side |
| 02:24 | seancorfield__ | poor sap, moving to LA :) |
| 02:57 | Jeffrey04 | i am trying https://4clojure.com/problem/95 , may I know why [1 [2 [3 [4 false nil] nil] nil] nil] should return false? |
| 03:09 | Chousuke | jeffrey: probably because false is a value but it doesn't have any child nodes |
| 03:10 | Chousuke | it should be [false nil nil] |
| 03:14 | clgv | I want to store standard clojure data structures via "pr" and read them via "read-string". the problem is that the data is tree-like and I'll get the leafs one by one and have to store them immediately to free memory. in XML I would simply write the parent opening tags followed by the leafs one by one and the finally add the closing parent tag. |
| 03:14 | thorwil | the entire difference between filter and keep is testing against false vs nil? |
| 03:16 | clgv | I guess there is no way to do that with pr. I'll have to store the parent-data independently and build the relation via an ID |
| 04:05 | Jeffrey04 | Chousuke: thanks... lol |
| 06:14 | Jeffrey04 | erm... does anyone know how to solve problem 82 @ #4clojure ? |
| 06:18 | clgv | Jeffrey04: the trivial approach: take the first element and check if any of the others has edit distance 1 to it, if not you are already done |
| 06:19 | clgv | if you find only one than you probably have one of the ends |
| 06:19 | Jeffrey04 | clgv: i am still thinking whether it is somehow similar to the transitive closure problem |
| 06:20 | clgv | maybe. you can build a graph between the words whose edges are defined by the edit distance of one |
| 06:22 | Jeffrey04 | yea, still thinking :( not really good in this kind of problems |
| 06:22 | mrBliss` | Jeffrey04: for 82 I wrote a function that returns the permutations of a seq. Checking if a permutation results in a continuous word chain is the fun part :-) |
| 06:23 | Jeffrey04 | mrBliss`: i like ur solution |
| 06:23 | Jeffrey04 | ahahahahahaha |
| 06:23 | mrBliss` | Jeffrey04: why is it so funny? |
| 06:23 | clgv | but n! times seems no reasonable running time complexity ;) |
| 06:23 | Jeffrey04 | mrBliss`: no offense, it just sounds fun |
| 06:24 | mrBliss` | clgv: I know, but n < 10, so it doesn't matter much ;-) |
| 06:24 | Jeffrey04 | ok... /me brain not functioning properly |
| 06:24 | Jeffrey04 | lol |
| 06:24 | fliebel | S basically jist permutations + levenschetein |
| 06:24 | clgv | they dont seem to track execution time so it's not worth it, I guess ;) |
| 06:26 | mrBliss` | My non-minimized solution (including comments) for 82 has a code golf score of 472, which is quite good according to the histogram! |
| 06:26 | clgv | ah problem 89 was corrected in the meantime |
| 06:26 | clgv | where do you get the statistics |
| 06:27 | mrBliss` | clgv: enable them in your account settings |
| 06:27 | Jeffrey04 | mrBliss`: lol, I always score super high, which is at the far end according to the histogram |
| 06:27 | mrBliss` | I only needed 34 chars for 98, it's quite trivial |
| 06:28 | Jeffrey04 | is golf score = # of characters? |
| 06:29 | mrBliss` | Jeffrey04: correct |
| 06:29 | Jeffrey04 | mrBliss`: i used 104 characters for that |
| 06:29 | Jeffrey04 | lol |
| 06:29 | Jeffrey04 | will probably revisit sometime in future |
| 06:29 | Jeffrey04 | lol |
| 06:30 | clgv | I have no account yet ;) |
| 06:30 | mrBliss` | knowing a lot of the functions in clojure.core helps a lot |
| 06:30 | Jeffrey04 | eee... my answer for problem 89 is gone |
| 06:30 | Jeffrey04 | :/ |
| 06:31 | clgv | problem 89's definition was wrong because they used sets |
| 06:31 | Jeffrey04 | iC |
| 06:31 | clgv | some of the written test cases were wrong because of that |
| 06:32 | Jeffrey04 | ooo |
| 06:32 | Jeffrey04 | yea, my code failed the unit test |
| 06:32 | Jeffrey04 | sigh |
| 06:32 | clgv | I noticed when answering someone |
| 06:32 | Jeffrey04 | oh... ouch, each edge needs to be visited exactly once |
| 06:32 | Jeffrey04 | :/ |
| 06:33 | clgv | yes and there multiple edges per node pair |
| 06:33 | mrBliss` | Somebody used 1500 chars for 89, wow. He probably constructed actual tours of the graph! My course in graph theory has been quite useful for 4clojure and projecteuler ;-) |
| 06:33 | Jeffrey04 | yea, gotta check again |
| 06:34 | Jeffrey04 | lol |
| 06:34 | clgv | gotta start coding some problem solutions in my spare time. |
| 06:36 | Jeffrey04 | hahahaha, my solution doesn't really answer the question |
| 06:36 | Jeffrey04 | sigh |
| 06:37 | Jeffrey04 | my last solution was submitted like half an hour ago |
| 06:37 | Jeffrey04 | lol |
| 06:37 | Jeffrey04 | now gotta re-do again |
| 06:37 | Jeffrey04 | :D |
| 06:38 | fliebel | (comp set #(map set %) vals group-by) Half of that was because of the sets... :( |
| 06:39 | clgv | fliebel: ? |
| 06:39 | mrBliss` | fliebel: Almost identical to my solution! (I used #( instead of comp though). |
| 06:40 | fliebel | *unresolved tension* |
| 06:41 | fliebel | To bad you can't run core.logic on 4clojure. |
| 06:42 | clgv | fliebel: you can. but you would have to copy and paste it everytime ;) |
| 06:42 | fliebel | clgv: How do you mean? |
| 06:42 | mrBliss` | clgv: say bye bye to a good code golf score ;-) |
| 06:43 | fliebel | Where can I see the golf score? |
| 06:43 | mrBliss` | fliebel: enable it in your account settings |
| 06:44 | fliebel | mrBliss`: Okay, and now? Everything still looks the same. |
| 06:45 | mrBliss` | fliebel: resubmit one of your solutions |
| 06:49 | Jeffrey04 | eh... now word chain and graph tour looks like the same problem |
| 06:50 | clgv | Jeffrey04: not in general |
| 07:21 | clgv | humm I cant get crane to be build with leiningen. it has strange dependency versions |
| 07:21 | clgv | this one: https://github.com/getwoven/crane |
| 07:26 | fliebel | Does anyone know how ratios work in Clojure? ##(/ 42 56) I mean, does it calculate the greatest common divisor somewhere? rationalize only points to a lot of BigDecimal stuff. |
| 07:26 | sexpbot | ⟹ 3/4 |
| 07:30 | clgv | fliebel: yeah it does |
| 07:31 | fliebel | clgv: You understand how? I only see some random casting and branching and then it does black magic to BigDecimal en the ratio comes roling out. |
| 07:31 | clgv | fliebel: I looked it up a while ago and saw that there are explicit calls to gcd computation |
| 07:33 | fliebel | clgv: Care to point out where? https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Numbers.java#L303 |
| 07:35 | clgv | fliebel: you can search for gcd in there and will find it in a lot of operations |
| 07:36 | fliebel | ah! |
| 07:38 | fliebel | &(clojure.lang.Numbers/gcd (long 4) (long 7)) |
| 07:38 | sexpbot | java.lang.IllegalArgumentException: No matching method: gcd |
| 07:39 | clgv | &(clojure.lang.Numbers/gcd 4 7) |
| 07:39 | sexpbot | java.lang.IllegalArgumentException: No matching method: gcd |
| 07:40 | clgv | it's in LongOps for example |
| 07:40 | clgv | &(clojure.lang.Numbers.LongOps/gcd (long 4) (long 7)) |
| 07:40 | sexpbot | java.lang.ClassNotFoundException: clojure.lang.Numbers.LongOps |
| 07:40 | clgv | and not public... |
| 07:43 | fliebel | hm, okay. I'm trying to save chars on 4clojure #100 by using ratios. They seem to have the info I need in a hidden place with ahidden relation between them. |
| 07:48 | fliebel | #(let [r (apply / %&)] (* (numerator r) (denominator r))) ; works for the first 2 |
| 07:57 | clgv | yay. my calculation returns "NaN" :/ |
| 07:58 | fliebel | clgv: Mine returns wrong stuff for ratios :( |
| 08:04 | clgv | lol found it. (log2 0.0) |
| 08:06 | fliebel | me too! #(reduce (fn [n r] (* r (numerator (/ n r)))) %&) |
| 08:07 | clgv | lol you dont want to calculate a gcd yourself? ;) |
| 08:09 | fliebel | clgv: I bet it takes more characters. |
| 08:09 | clgv | fliebel: shouldnt there be something in java's math? |
| 08:09 | fliebel | clgv: I couldn't find it. |
| 08:09 | clgv | it takes also more chars to call it? ;) |
| 08:10 | clgv | humm you could try to compress your code if there is a built-in decompress ;) |
| 08:11 | clgv | like: (eval (decompress "ABHOUIAHSSÖAKJPKM")) ;) |
| 09:42 | gfrlog | I recall sometimes "lein repl" would automatically switch into the project's core namespace. It doesn't seem to do that anymore though. Anybody know what it is? (i.e., an old/new feature, or something that requires special config...) |
| 09:58 | gfrlog | I find it strange that when I search clojuredocs for "refer-clojure" there are no results, but when I search for "refer" then I get "refer-clojure" as the first result |
| 10:00 | fliebel | gfrlog: Maybe it's when you specify :main? |
| 10:04 | brian | here's what i mentioned yesterday |
| 10:04 | brian | http://www.engadget.com/2011/05/29/nvidias-quad-core-kal-el-used-to-demo-next-gen-mobile-graphics/ |
| 10:04 | Guest13677 | err wrong chat sry |
| 10:09 | Fossi | damn. the vid doesnt even show blown brains |
| 10:39 | clgv | $findfn [1 2 3 4 5 6] 2 [2 4 6] |
| 10:41 | clgv | I want a function that returns every second value from a sequence |
| 10:41 | clgv | but I forgot its name... |
| 10:43 | wastrel | (first (rest s)) ? |
| 10:43 | clgv | lol no |
| 10:43 | fliebel | take-nth |
| 10:43 | clgv | yeqah take-nth was it |
| 11:09 | andrewclegg | hey, anybody here use maven to build mixed clojure/java projects? |
| 11:10 | andrewclegg | I can see the Java bits get compiled first, and they appear in target/classes ok, but then I get ClassNotFoundException when I try to compile Clojure code which refers to them |
| 11:17 | andrewclegg | stuartsierra: was kinda hoping you might have a suggestion for that ^^ ? :-) |
| 11:34 | stuartsierra | andrewclegg: sorry, haven't encountered that problem before |
| 11:35 | andrewclegg | np, thanks stuartsierra, will keep tinkering |
| 11:35 | andrewclegg | any other maven mavens around? |
| 11:37 | stuartsierra | it should just work |
| 11:37 | andrewclegg | yeah :-) |
| 11:42 | andrewclegg | may be complicated by the fact that the classes are generated by Thrift plugin in an earlier phase |
| 11:43 | wastrel | if you google recursion it asks if you meant to search for recursion |
| 11:49 | dpritchett` | didn't you? |
| 11:49 | dpritchett` | guess that's a tautology :( |
| 11:57 | wastrel | it's meant to be a joke :] |
| 12:03 | andrewclegg | argh, was a typo all along, my bad |
| 12:19 | ataggart | if anyone with jira admin privileges is on, please create a new tools.logging project. |
| 12:22 | cemerick | ataggart: any idea what the key should be? |
| 12:22 | ataggart | TLOG ? |
| 12:23 | ataggart | there's already TBRENCH for tools.benchmark |
| 12:23 | ataggart | erm test.benchmark |
| 12:23 | ataggart | so maybe not |
| 12:23 | ataggart | yeah TLOG is fine with me |
| 12:24 | technomancy | sounds vulcan |
| 12:24 | cemerick | That seems to fit http://dev.clojure.org/display/design/JIRA+project+key+conventions |
| 12:24 | cemerick | I don't think Rich had stated a preference before I created an NREPL project. :-/ |
| 12:26 | cemerick | ataggart: http://dev.clojure.org/jira/browse/TLOG |
| 12:26 | ataggart | great, thanks |
| 12:26 | cemerick | np |
| 12:27 | mrBliss` | Is it normal that clojure.contrib.lazy-xml requires over 1GB of heap to process a 16MB xml file (iTunes Music Library)? |
| 13:25 | manutter | ,(doc reductions) |
| 13:25 | manutter | Ack, no bots? |
| 13:25 | manutter | &(doc reductions) |
| 13:25 | Raynes | Hrm. |
| 13:25 | manutter | ~botsnack |
| 13:25 | Raynes | I'll get him back up. |
| 13:26 | manutter | shhh, I'm trying to lure him out with botsnacks |
| 13:26 | manutter | :) |
| 13:26 | gfrlog | that is strange that they're both down |
| 13:26 | gfrlog | or maybe they're off together somewhere |
| 13:27 | Raynes | gfrlog: Coincidental, of course. |
| 13:27 | Raynes | $botsnack |
| 13:27 | sexpbot | Raynes: Thanks! Om nom nom!! |
| 13:27 | manutter | :) |
| 13:27 | manutter | thanks |
| 13:27 | Raynes | ~botsnack |
| 13:27 | manutter | ,(doc reductions) |
| 13:27 | clojurebot | "([f coll] [f init coll]); Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init." |
| 13:27 | clojurebot | Thanks! Can I have chocolate next time |
| 13:27 | manutter | ,(doc reduce) |
| 13:27 | clojurebot | "([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val i... |
| 13:27 | manutter | (reduce + [1 2]) |
| 13:27 | manutter | oops |
| 13:28 | manutter | ,(reduce + (range 2)) |
| 13:28 | clojurebot | 1 |
| 13:28 | hiredman | I need multiple clojurebots and master election for failover |
| 13:28 | manutter | ,(reductions + (range 2)) |
| 13:28 | clojurebot | (0 1) |
| 13:28 | Raynes | Strange that we both rebotted #clojure at the same time. |
| 13:29 | manutter | hmm, so if reduce takes the first 2 terms and applies the function, why isn't "1" the first and only term in (reductions + [0 1])? |
| 13:29 | manutter | Is that a known quirk? |
| 13:30 | hiredman | reductions may call the function you give it with no args first |
| 13:30 | gfrlog | ,(reductions + (range 5)) |
| 13:30 | clojurebot | (0 1 3 6 10) |
| 13:31 | manutter | hmm, that seems odd |
| 13:31 | gfrlog | ,(let [plus (fn [a b] (+ a b))] (reductions + (range 5))) |
| 13:31 | clojurebot | (0 1 3 6 10) |
| 13:31 | gfrlog | whops |
| 13:31 | manutter | ,(reductions #(vector % %2) [0 1]) |
| 13:31 | clojurebot | (0 [0 1]) |
| 13:31 | gfrlog | ,(let [plus (fn [a b] (+ a b))] (reduction plus (range 5))) |
| 13:31 | clojurebot | java.lang.Exception: Unable to resolve symbol: reduction in this context |
| 13:31 | gfrlog | garg |
| 13:32 | manutter | there's another mind thoroughly boggled |
| 13:32 | gfrlog | ,(let [plus (fn [a b] (+ a b))] (reductions plus (range 5))) |
| 13:32 | clojurebot | (0 1 3 6 10) |
| 13:32 | stuartsierra | `reductions` returns the init value first. If no init value is supplied, it uses the first element of the sequence. |
| 13:32 | gfrlog | yeah I was about to conclude that |
| 13:33 | manutter | fair enough, but I'm confused as to why it does so |
| 13:33 | gfrlog | it makes sense to me. If you don't need it, call rest I guess |
| 13:33 | gfrlog | (def manutter-reductions (comp rest reductions)) |
| 13:33 | manutter | eh |
| 13:33 | manutter | heh |
| 13:34 | manutter | It doesn't bother me per se, I'm just not seeing the connection between the stated purpose of the function and its actual behavior |
| 13:34 | gfrlog | not that I've ever used reductions before, but it seems like the initial value ought to be part of the sequence |
| 13:34 | gfrlog | what were you going to use it for? |
| 13:34 | manutter | I'm not using it per se, I'm doing the 4clojure exercise where you define your own "reductions" func from scratch |
| 13:35 | manutter | Mine didn't include the init value as the first term, and I was curious as to why it was supposed to. |
| 13:35 | gfrlog | oh. Well then neither of us are entitled to an opinion I guess :) |
| 13:35 | manutter | :) |
| 13:36 | gfrlog | looks like 5clojure.com is available for all you squatters |
| 13:36 | manutter | lol |
| 13:37 | chouser | reduce on a collection with just one value in it returns that value |
| 13:37 | hiredman | dnolen: does the unifier have some way to match the rest of a sequence, like [foo & bar] ? |
| 13:37 | chouser | so the first item in the seq returned by reductions is always the first item in the input seq |
| 13:37 | gfrlog | ,(reduce assoc [10]) |
| 13:37 | clojurebot | 10 |
| 13:37 | gfrlog | (def identity (comp (partial reduce assoc) (vector))) |
| 13:38 | manutter | chouser: Ok, that begins to make sense |
| 13:39 | manutter | so reductions returns [(reduce f [1]) (reduce f [1 2]) (reduce f [1 2 3]) ...], given (reductions f [1 2 3 ... n]) |
| 13:40 | manutter | conceptually, anyway |
| 13:40 | chouser | yeah, I think that's right. |
| 13:41 | manutter | cool, I can dig it :) |
| 13:41 | gfrlog | ,(reduce assoc []) |
| 13:41 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args (0) passed to: core$assoc |
| 13:55 | dnolen | hiredman: I had that feature a long time ago but I haven't revisited it. Are you unifying a vector, list? |
| 13:58 | hiredman | dnolen: either, I want to be able to match the equiv of v :: nil |
| 14:03 | dnolen | hiredman: I'll look into it, should be too hard. |
| 14:03 | dnolen | s/should/shouldn't |
| 14:03 | sexpbot | <dnolen> hiredman: I'll look into it, shouldn't be too hard. |
| 14:56 | markoman | how do these differ: (-> 1) and ((fn [x] x) 1) |
| 14:56 | markoman | or even (# 1) |
| 14:57 | stuartsierra | #(1) won't work. |
| 14:58 | ohpauleez | (fn [x] x) is the identity function, the last one is an anonymous function doing the same thing |
| 14:58 | ohpauleez | the threading form essentially is the same thing, but is a macro |
| 15:01 | markoman | (# 1) returns 1 but gives some extra warnings |
| 15:07 | Chousuke | huh |
| 15:07 | Chousuke | ,(# 1) |
| 15:07 | clojurebot | No dispatch macro for: |
| 15:08 | hiredman | # means "dispatch on the next character" |
| 15:08 | stuartsierra | yes |
| 15:08 | hiredman | the next character is |
| 15:08 | hiredman | \space |
| 15:36 | markoman | Ok, just wondering these "special forms" |
| 15:38 | hiredman | markoman: you always ask all these involved questions, with the amount of time you put in to it, why don't you just read the source? |
| 15:39 | markoman | conversation and interaction may give more |
| 15:39 | hiredman | like, if you've written a lisp (takes a few hours to a few days depending) the anwsers are all right there |
| 15:39 | S11001001 | I wonder if you could put an arrow into an arrow, or vice versa. |
| 15:40 | hiredman | why not? the arrow is just a transform of a datastructure, and an arrow is a datastructure |
| 15:41 | markoman | i think clojure is much different than common lisp, icarus or scheme I slightly studied before |
| 15:45 | scottj | what's the rational for having tests that use "are" and give too few args not raise errors? |
| 15:45 | hiredman | right, but the design space, the roadsystem is the same, just different turns |
| 15:45 | tufflax | I want to serialize clojure data structures to byte arrays. Should I use java's ByteArrayOutputStream or is there a more convenient way in clojure? |
| 15:45 | hiredman | scottj: no one uses are? |
| 15:45 | scottj | (deftest test-+ [] (are [a b] (+ a b) 1)) <-- won't fail or give error |
| 15:46 | scottj | oh wait, this might be me not using =, one sec :) |
| 15:47 | scottj | nope I think it's real, (deftest test-+ [] (are [a b c] (= (+ a b) c) 1 2)) |
| 15:48 | hiredman | I went to use (are ...) in a test at work once, then someone said "why, all the other tests use is" so all our tests use is |
| 15:48 | stuartsierra | The point of `are` was to make it easy to repeat the same test with different inputs. The implementation isn't all that great. |
| 15:49 | scottj | stuartsierra: is the problem I'm talking about clear/known? |
| 15:50 | stuartsierra | I don't think it's common enough to be a problem. |
| 15:51 | scottj | where someone forgets a parameter? |
| 15:51 | hiredman | like I said, not one uses 'are', so no one has ever run into the corner cases |
| 15:52 | raek | tufflax: I think that would be the most obvious way of doing it, yes (let [baos (ByteArrayOutputStream.)] (binding [*out* (io/writer baos)] (pr some-data-structure))) |
| 15:52 | stuartsierra | `are` was only for cases where you have multiple sets of parameters. If you leave one out, your test should fail. |
| 15:53 | scottj | stuartsierra: yeah, the point is it doesn't fail. |
| 15:53 | raek | tufflax: here the byte array will contain the UTF-8 encoded string representation of the data structure, which may or may not be what you were looking for |
| 15:54 | tufflax | raek ok, thank you... again :) |
| 15:55 | scottj | stuartsierra: (deftest test-+ [] (are [a b c] (= (+ a b) c) 1 2 3 2 2)) ; note missing 4 at end {:type :summary, :pass 1, :test 1, :error 0, :fail 0} |
| 15:56 | stuartsierra | yes I see |
| 15:57 | stuartsierra | that's worth catching |
| 15:57 | stuartsierra | Please make a JIRA ticket. |
| 15:58 | symbole | What are some options right now when it comes to Clojure and comet? Is it to wrap exiting Java solutions? |
| 15:58 | raek | tufflax: oh, you probably need a (flush) call after that (pr ...) call, otherwise the data might not show up... :-) |
| 16:08 | dnolen | symbole: see Aleph |
| 16:15 | symbole | dnolen: Thanks. |
| 16:22 | dpritchett` | does Chris Granger (ibdknox) frequent #clojure? |
| 16:23 | redinger | $seen ibdknox |
| 16:23 | sexpbot | I have never seen ibdknox. |
| 16:24 | dpritchett` | I liked the look of https://github.com/ibdknox/noir and wanted to say hi |
| 16:24 | redinger | If so, not with that nick I'd say |
| 16:29 | hiredman | clojurebot: ping |
| 16:29 | clojurebot | PONG! |
| 16:39 | hiredman | dnolen: so it was pretty simple to modify it to turn '(cons ?foo ?bar) into (lcons … …) using replace-lvar, so [(cons ?a ?b)] unifies with [(1 2)] but (cons ?a ?b) doesn't unify with (1 2) because lcons can't carry metadata |
| 16:40 | hiredman | similarly ?a will throw exceptions instead of unifying with anything because lvars can't carry metadata |
| 16:43 | tufflax | (alength (to-byte-array '(1 2 3 4 "arstarst"))) => 779, (alength (to-byte-array (str '(1 2 3 4 "arstarst")))) => 27. Hehe. Hmm, I'm trying to make a multiplayer game, and I thougth representing messages as clojure data structures was a good idea. Maybe it still is. Any tips or comments? |
| 17:00 | lnostdal | hm, slime-insert-balanced-comments .. i miss #| multi-line comments |# :) |
| 17:00 | lnostdal | ..out, test, back in ... out something else .. test, back in .. etc. etc. etc. etc. |
| 17:03 | raek | amalloy: I'm trying to use Piped{Input,Output}Stream... did you find anything with them that was strange? |
| 17:11 | dnolen | hiredman: interesting ... I'm not against opening up LVar and LCons to metadata to allow for such experiments |
| 17:12 | hiredman | actually |
| 17:12 | hiredman | match.core> (binding-map '?a [1 [2 4] 3]) |
| 17:12 | hiredman | {} |
| 17:12 | hiredman | not sure what the deal is with that |
| 17:12 | dnolen | hiredman: probably some bad assumptions, I don't use binding-map or unifier myself, feel free to open tickets in JIRA. |
| 17:13 | hiredman | *sigh* sure, if I have time this evening |
| 17:45 | Borkdude | I have a clojure project that I didn't use for some time, it got started with a script in folder script/run.clj |
| 17:46 | Borkdude | but apparently lein run script/run.clj doesn't work anymore |
| 17:46 | Borkdude | what's the best way to fix? |
| 17:46 | bdesham | Borkdude: it's an old leiningen project? |
| 17:47 | Borkdude | bdesham: what is old? |
| 17:48 | bdesham | uh... incompatible, I guess :) |
| 17:48 | Borkdude | it worked until recently |
| 17:48 | Borkdude | I don't know what happened to it actually |
| 17:48 | technomancy | the built-in "lein run" is for namespaces on the classpath |
| 17:49 | technomancy | probably you were using the plugin before |
| 17:49 | raek | Borkdude: lein run is now a part of leiningen (and behaves a bit differently), but you the old plugin should be used if you have it as a dev-dependency in your project |
| 17:49 | Borkdude | technomancy: ah, that's it I guess, let me check |
| 17:50 | raek | Borkdude: if you before had (ns foo.bar) (start) and started it with "lein run src/foo/bar.clj", you would now do (ns foo) (defn -main [] (start)) and start with "lein run -m foo.bar" |
| 17:51 | raek | (or add :main foo.bar to the project.clj and skip the -m foo.bar part) |
| 17:53 | Borkdude | technomancy: if I put the plugin back into the dev-dependencies should "lein run <file>" work? |
| 17:56 | technomancy | it should |
| 18:02 | technomancy | but it would be best to move the code to a -main function on the classpath |
| 18:06 | Borkdude | ok, well the old behavior isn't working anymore with the lein-run plugin, but I'll move it to a -main, tnx |
| 18:07 | technomancy | there was briefly a version of 1.4.x that had built-in tasks shadow plugins, but it was fixed pretty quickly. |
| 18:08 | Borkdude | I'm using 1.5.2 |
| 18:24 | kencausey | I'm trying to get technomancy's new easy clojure-mode to work on cygwin on xp but lein seems to use USERPROFILE when it should be using HOME |
| 18:25 | kencausey | specifically lein plugin install is putting the files in the wrong place |
| 18:25 | technomancy | kencausey: ah, I had some bug reports on that earlier but they didn't include enough detail |
| 18:25 | technomancy | so is (System/getProperty "user.home") wrong? |
| 18:25 | kencausey | OK, I would be happy to help provide info, a moment... |
| 18:26 | kencausey | I've got to figure out how to start clojure first ;) |
| 18:26 | offby1 | that's the hard part, in my experience |
| 18:27 | technomancy | java -cp ~/.lein/self-installs/TAB clojure.main |
| 18:28 | kencausey | all that's in self-installs is leiningen-1.5.2-standalone.jar |
| 18:28 | technomancy | that'll do |
| 18:28 | kencausey | oh right |
| 18:28 | kencausey | java.lang.NoClassDefFoundError: clojure/main |
| 18:29 | kencausey | I need a CLASSPATH or something? |
| 18:30 | kencausey | absolutely |
| 18:30 | technomancy | no, -cp should do it. suspect that jar is not what it claims to be |
| 18:30 | kencausey | perhaps the issue is a cygwin/dos thing? |
| 18:31 | technomancy | quick workaround fix would be to symlink $USERPROFILE/.lein to $HOME/.lein I guess |
| 18:32 | kencausey | trying that |
| 18:33 | __name__ | or to use a proper os |
| 18:34 | kencausey | I normally do, but development of projects from multiple systems requires using less preferred systems sometimes |
| 18:35 | kencausey | technomancy: oh your blog mentioned 1.4.0 in the video but 1.3.1 in the text, does it matter which is used? |
| 18:35 | technomancy | kencausey: either will do |
| 18:35 | technomancy | 1.3.1 is preferred if you want a stable version, while 1.4.0-SNAPSHOT has new debugger features |
| 18:35 | kencausey | I'm willing to bleed a bit to start with anyway |
| 18:39 | Borkdude | I'm trying out the clojure app on heroku thing |
| 18:39 | kencausey | I think java doesn't like my symlink |
| 18:39 | Borkdude | I wonder where I can find documentation about the cedar stack and support of clojure |
| 18:39 | kencausey | Installing shell wrapper to C:\Documents and Settings\Ken\.lein\bin\swank-clojure |
| 18:39 | kencausey | Exception in thread "main" java.io.FileNotFoundException: C:\Documents and Settings\Ken\.lein\bin\swank-clojure (The system cannot find the path specified) (NO_SOURCE_FILE:0) |
| 18:40 | Borkdude | and also: someone maybe has a clue why this goes wrong? https://gist.github.com/1003529 |
| 18:49 | technomancy | Borkdude: maybe a timeout? there could be a limit on how long processes may take to launch? |
| 18:54 | seancorfield | oddness... i had a (ns) decl where i accidentally missed the : off the require keyword... but it still seemed to work...? known undocumented behavior? |
| 18:58 | ataggart | could you reference vars in the other ns? |
| 19:02 | Borkdude | technomancy: could be... |
| 21:44 | hiredman | dnolen: cond-m used to create a pattern matchy fn equiv used to implement a secd machine https://gist.github.com/1003761 |
| 21:46 | dnolen | hiredman: wow cool! :) |
| 21:48 | hiredman | I have been hacking on various incarnations of a clojure compiler in clojure and lately have been leaning towards something like a secd for code generation and the nicest descriptions are all written with pattern matching |
| 21:53 | dnolen | hiredman: I think the pattern matching stuff I'm working on will be better suited for this kind of thing, but until then core.logic unification will have to do. |
| 21:53 | hiredman | it's all I've got |
| 21:53 | danlarkin | THAT'S NOT TRUE HIREDMAN |
| 21:54 | danlarkin | YOU HAVE ME |
| 21:54 | hiredman | I certainly don't want to implement pattern matching, I just want to use it |
| 21:54 | hiredman | danlarkin: thanks dude |
| 21:54 | hiredman | there are a number of other implementations for clojure, but they all seem to be disgusting |
| 21:55 | hiredman | one of them uses eval to generate fns so it destroys the ability to recur |
| 21:55 | hiredman | ugh |
| 21:57 | chouser | is there any way to get clojure maven plugin to include the test files in the classpath for clojure:repl ? |
| 21:58 | dnolen | hiredman: I plan on implementing plain pattern matching first, predicate dispatch will come later. Yeah I don't like the syntax of what's out there. I want to stick very closely to Clojure idioms. |
| 21:58 | danlarkin | chouser: I'm going to BM and say why the heck are you using the clojure maven plugin |
| 22:00 | chouser | I'm working on clojure.data.xml |
| 22:00 | hiredman | lein needs a way to ingest a pom.xml and spit out a project.clj |
| 22:00 | danlarkin | ah, so because SS likes maven |
| 22:01 | danlarkin | sorry, I know that's not helpful. No I don't know how :-/ |
| 22:04 | chouser | merely out of curiosity, do you know the answer to the equivalent lein question? |
| 22:05 | hiredman | I believe tests are on the classpath for lein repl and lein swank |
| 22:05 | danlarkin | I think they're on the classpath for lein repl already |
| 22:06 | hiredman | they definitly are for lein swank, but I never use lein repl |
| 22:30 | chouser | bleh. I don't see how it's possible |
| 22:32 | chouser | ah. symlink. well, that'll do. *sigh* |
| 22:35 | chouser | slander! |
| 22:35 | chouser | clojure:repl does include tests by default, no symlink needed. |
| 22:35 | chouser | I had a typo. :-P |
| 22:41 | hiredman | I'd like to blame clojure maven plugin for your typo, so I will |
| 23:17 | technomancy | danlarkin: BM? |
| 23:18 | hiredman | business machines? |
| 23:18 | danlarkin | bad manner, a common term used to describe poor sportsmanship in electronic sports, often abbreviated to "bm" |
| 23:19 | technomancy | so not bowel movement then. that's good. |
| 23:19 | technomancy | github needs to support the <blink> tag |
| 23:21 | technomancy | is there a reasonable use case for setting user-level mvn repositories? |
| 23:21 | technomancy | seems like it's just a recipe for http://www.codeodor.com/images/works-on-my-machine-starburst.png |
| 23:24 | technomancy | hrm; I'll just stash this until someone talks me into it |
| 23:51 | kornys | Hi - anyone played with Heroku's clojure support? I'm trying to work out if it's free for small apps, like it is for ruby apps |
| 23:52 | kornys | I seem to have been allocated a single worker, which is costing me 5c an hour... |
| 23:53 | kornys | pretty cheap for a simple demo, but not something I'd like to leave up for a long time. |
| 23:56 | kornys | &(* 0.05 24 30) |
| 23:56 | sexpbot | ⟹ 36.00000000000001 |