2010-11-17
| 00:00 | talios | oh man this maven release is still running - must remove all those javadoc generations from running. |
| 00:02 | livingston | hey talios - thanks again for that patch |
| 00:03 | talios | oh hai ;-) |
| 00:03 | livingston | talios: hi |
| 00:06 | talios | how goes? |
| 00:07 | livingston | alright - kinda - I refactored my project into a half dozen smaller maven modules (and I'm realize my api needs a bit of help too) so I'm just going a little crazy trying to humpty dumpty back together again |
| 00:08 | talios | fun :) build refactoring :) |
| 00:09 | livingston | yeah it's telling me I'm bringing in one of my symbols from two different places but I'm sure I'm not |
| 00:10 | livingston | it's right of course, but i wish it was more helpful ;) |
| 00:11 | sandGorgon | has anyone run a clojure webapp (or anything non trivial) on an EC2 Micro instance ? I'm asking for rough opinions .. for example I know that a Rails app just croaks on it |
| 00:12 | livingston | sandGorgon: is that the level that they are giving away free right now? |
| 00:12 | sandGorgon | livingston, caught me ;) |
| 00:13 | rata_ | slyrus: yeah, parsers written in fnparse look as simple as EBNF... it's amazing =) |
| 00:14 | livingston | talios: I was bringing in the symbol too much, in my cutting I ended up with two filed that were using the same stuff and one using the other... etc. |
| 00:14 | livingston | sandGorgon: hey whatever man, if they're giving something away, take it |
| 00:14 | rata_ | slyrus: any other parser I've written looks horrible in comparison |
| 00:15 | slyrus | agreed |
| 00:15 | slyrus | I know there are other nice approaches to the problem, but I'm a fan of fnparse |
| 00:15 | sandGorgon | livingston, ack that |
| 00:15 | rata_ | yeah, me too |
| 00:18 | talios | livingston: doh :) |
| 00:18 | rata_ | also it was a good idea to wait until the profiling phase to move into fnparse3, because I figured out how to recicle some data that the parser had available to avoid calling a fn to recompute it afterwards (calling that fn took much more time I'd have expected) |
| 00:18 | talios | livingston: seems every day I see a reason why a compilation step is still really handy, even in dynamic languages |
| 00:19 | livingston | talios: it was the compiler doing the complaining - or is that what you mean?j |
| 00:20 | talios | thats what I mean. it revealed something wrong. |
| 00:20 | talios | better a build die than a production server at midnight |
| 00:22 | Derander | I do wish there was some way to do static checking in ruby |
| 00:24 | livingston | (offtopic: anyone now how to make emacs stop associating buffers with windows and let me move any buffer to any window - everything i want to look at is associated with the same window) |
| 00:26 | talios | Right - time to leave work, find some dinner, watch some tv, hack! |
| 00:26 | talios | back in an hour or so :) |
| 00:27 | livingston | have fun, i need diner too but once I'm out I'm out for the night |
| 01:41 | Derander | (into) is an amazing funciton. Why didn't I know about it before? |
| 02:14 | LauJensen | Good morning all |
| 02:26 | sthuebner | good morning, LauJensen |
| 02:26 | talios | Evening |
| 02:28 | sthuebner | It's a cold and rainy autumn day here in Berlin |
| 02:29 | LauJensen | Same in the DK |
| 02:32 | sthuebner | LauJensen: how's Conj Labs London coming along? |
| 02:32 | LauJensen | sthuebner: Postponed until 2011 |
| 02:33 | sthuebner | Lack of interest? |
| 02:34 | LauJensen | Among other things. I think Christophe and I were being a little too ambitious with our schedules, so we would come under big pressure and we didnt have time to market it properly. Add the pieces together and I'd rather wait until february and put on a great Labs event at that time |
| 02:36 | sthuebner | sounds good. |
| 04:24 | bartj | is there a date library in Clojure ? |
| 04:25 | bartj | clj-time ? |
| 08:13 | tape_dispencer | In the documentation, I haven't been able to find any reference on how to declare a static field with def-class. Is there something I missed? |
| 08:14 | neotyk | Is there simpler version of this? |
| 08:14 | neotyk | ,(let [a '([:a 1] [:b 2])] (zipmap (map first a) (map second a))) |
| 08:14 | clojurebot | {:b 2, :a 1} |
| 08:15 | neotyk | tape_dispencer: I've seen some docs on it |
| 08:15 | tape_dispencer | Do you remember where? I have seen references to accessing a field, but I want to declare one. |
| 08:16 | hiredman | ,(into {} '([:a 1] [:b 2])) |
| 08:16 | clojurebot | {:a 1, :b 2} |
| 08:17 | neotyk | this is great, thank you hiredman! |
| 08:17 | hiredman | neotyk: will only work with two element vectors |
| 08:18 | hiredman | tape_dispencer: never heard of "def-class" |
| 08:18 | tape_dispencer | I'm sorry. I miss typed. I mean gen-class. Sorry for the confusion. |
| 08:18 | neotyk | tape_dispencer: http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/gen-class |
| 08:19 | neotyk | check :methods |
| 08:19 | neotyk | and once you figure out how to make method static do share, I |
| 08:19 | neotyk | didn't manage to do so |
| 08:19 | tape_dispencer | I saw that. But it only refers to declaring a static method |
| 08:20 | tape_dispencer | I want to declare a static field. In java it would be public static String KEY = "keyValue"; |
| 08:20 | neotyk | ok, miss read your question |
| 08:21 | neotyk | and if you do (def -field-name ...) |
| 08:21 | tape_dispencer | hmm... I never thought to try that. |
| 08:22 | neotyk | hth |
| 08:33 | tape_dispencer | After some trial and error, (def -field-name ...) doesn't seem to work either. It compiles fine, but I don't see any reference to the static field in the generated bytecode. |
| 08:42 | tape_dispencer | Has anyone been able to declare a static field when gen-class? |
| 08:45 | fogus_ | tape-dispenser: on the gen-class declaration do you have ^{:static true} ? |
| 08:45 | fogus_ | tape_dispencer: ^^^ |
| 08:45 | tape_dispencer | Where would I add that? |
| 08:46 | tape_dispencer | In the documentation, I only see where that is applicable with static methods. |
| 08:46 | tape_dispencer | I want to declare a static field, ie public static final String KEY = "keyValue"; |
| 08:51 | stuartsierra | gen-class doesn't create fields |
| 08:52 | stuartsierra | or, it doesn't create more than one field, which is a public final instance field |
| 08:53 | tape_dispencer | but no way of declaring a static field? |
| 08:53 | stuartsierra | no |
| 08:54 | tape_dispencer | Thank you |
| 08:54 | tape_dispencer | Is there a way to declare a java enum in clojure? |
| 08:55 | AWizzArd | tape_dispencer: last time I asked about this there wasn't. |
| 08:55 | AWizzArd | This is +/- 3 months ago. |
| 08:55 | tape_dispencer | Thank you |
| 08:58 | fogus_ | tape_dispenser: Sorry, I didn't read far enough in the thread to gather your precise question. My bad |
| 08:59 | Raynes | fogus_: You should be ashamed of yourself. |
| 09:01 | fogus_ | I am |
| 09:03 | unwissender | hello all, I have a question concerning clojure.contrib.mock: it seems not to be possible to build a mock within an expect statement for a method of a deftype |
| 09:03 | unwissender | can I get that to work somehow? |
| 10:02 | AWizzArd | I have a sequence [:a :b :c 5000 'hi] and want ==> {:a 0, :b 1, :c 2, 5000 3, 'hi 4} - that is: I understand the seq as a map and want to reverse keys/vals and store that result in a HM. Any clever tricks for that? |
| 10:03 | AWizzArd | Seq: a map where the index represents the keys. |
| 10:04 | AWizzArd | One can do it with indexed, with dotimes, etc. But maybe there is a neat way to do it. |
| 10:05 | joegallo | (zipmap (vals orig) (keys orig)) Might do it. |
| 10:05 | joegallo | Or something along those lines. |
| 10:05 | joegallo | ,(let [foo {:a :b, :c :d}] (zipmap (vals foo) (keys foo))) |
| 10:05 | clojurebot | {:d :c, :b :a} |
| 10:05 | Licenser | We have to reach cost reliability to improve end to end reliability! |
| 10:06 | Licenser | thank you clojure :D |
| 10:06 | joegallo | That'll get you the reversing, I suppose. |
| 10:07 | studybot_ | >>AWizzArd: (reduce #(assoc %1 %2 (inc (%1 %2 0))) {} coll) |
| 10:07 | AWizzArd | joegallo: zipmap would work nice if my input already were a map. But it can be a list, or array or vector. |
| 10:07 | joegallo | ,(let [foo [:a :b :c]] (zipmap foo (iterate inc 0))) |
| 10:07 | clojurebot | {:c 2, :b 1, :a 0} |
| 10:08 | joegallo | Is that what you wanted? |
| 10:08 | AWizzArd | Yes, that is a good idea. |
| 10:08 | AWizzArd | ,(doc range) |
| 10:08 | clojurebot | "([] [end] [start end] [start end step]); Returns a lazy seq of nums from start (inclusive) to end (exclusive), by step, where start defaults to 0, step to 1, and end to infinity." |
| 10:08 | AWizzArd | ,(zipmap [:a :b :c 5000 'hi] (range)) |
| 10:08 | clojurebot | {hi 4, 5000 3, :c 2, :b 1, :a 0} |
| 10:08 | AWizzArd | great, nice trcik |
| 10:09 | AWizzArd | thx |
| 10:09 | joegallo | Good call with range. |
| 10:45 | Licenser | http://manager.licenser.net/ - nonsense powered by clojure! |
| 10:47 | cemerick | Licenser: auto-generated managerial aphorisms? |
| 10:47 | Licenser | cemerick: yap |
| 10:47 | cemerick | nice :-) |
| 10:47 | Licenser | during my last tele meeting I realized how simple it is to be a manager |
| 10:48 | cemerick | heh |
| 10:48 | cemerick | well, it's simple to be a *bad* manager, of course ;-) |
| 10:48 | Licenser | heh |
| 10:48 | Licenser | true |
| 10:49 | stuartsierra | Licenser: mind if I tweet that? |
| 10:49 | Licenser | Sad thing is, I was done with the code faster then the telco was over |
| 10:49 | Licenser | stuartsierra please be my guest |
| 10:50 | Raynes | Licenser: It lives! |
| 10:51 | Licenser | Raynes: jup |
| 10:51 | fogus_ | "We have to enhance synergy reliability." |
| 10:51 | AWizzArd | What about: "You need to make a bold move"? |
| 10:51 | Raynes | "End to end drive is the ultimate pattern." |
| 10:52 | AWizzArd | Reminds me of the generator for scientific papers: http://pdos.csail.mit.edu/scigen/ |
| 10:54 | Licenser | AWizzArd: yup a friend showed me that when I told him about the program |
| 10:56 | AWizzArd | An all-time classic (: |
| 11:06 | ivey | have any of you done the chef/opscode CLA? |
| 11:06 | ivey | it's all online with Echosign. took me 2 minutes. so cool. |
| 12:02 | dnolen | LauJensen: pong |
| 12:33 | mattmitchell_ | what's the most clojure-like way to create a hash-map from another, but only by a limited set of keys? |
| 12:34 | stuartsierra | (doc select-keys) |
| 12:34 | clojurebot | "([map keyseq]); Returns a map containing only those entries in map whose key is in keys" |
| 12:44 | _fogus_ | ,(let [m {:a 1 :b 2 :c 3} k [:a :b]] (select-keys m k)) |
| 12:44 | clojurebot | {:b 2, :a 1} |
| 12:57 | jsanda | what's the best/preferred way to something to the classpath to an already running app? |
| 12:58 | stuartsierra | jsanda: restart the app |
| 12:58 | Raynes | Not doing so. |
| 12:58 | stuartsierra | or use a Java IDE that manages classloaders for you |
| 12:59 | jsanda | i want to consume clj scripts but the location may not be known statically |
| 12:59 | stuartsierra | oh, then you can just load the file |
| 12:59 | jsanda | the path is determined at runtime |
| 12:59 | Raynes | &(doc load-file) |
| 12:59 | sexpbot | ⟹ "([name]); Sequentially read and evaluate the set of forms contained in the file." |
| 13:00 | jsanda | i'm running into - java.lang.IllegalAccessError: Context classloader is not a DynamicClassLoader |
| 13:00 | Raynes | Also: http://github.com/ninjudd/classlojure |
| 13:00 | Raynes | For doing multiple classloader stuff. |
| 13:01 | jsanda | i'm running inside a plugin container system that manipulates classloaders already |
| 13:01 | jsanda | i've tried setting *use-context-classloader* to false and it didn't help |
| 13:01 | imade | Hello, I am trying to connect to H2 database, but I get an error "Could not load properties /home/imade/clojure-dev/hours/jdbc:h2:tcp:/localhost/~/test.lock.db", it seems to point to wierd place |
| 13:02 | stuartsierra | jsanda: you'll probably need to use the classloader system of your container |
| 13:03 | imade | anyone ever tried clojure with h2? |
| 13:04 | jsanda | ok. i was starting to think that i'll have to add the paths to the parent class loader from the container. i will pursue that avenue. thx |
| 13:05 | mattmitchell_ | stuartsierra: thanks! |
| 13:17 | kotarak | imade: haven't tested it extensively, but seems to tork quite well |
| 13:18 | imade | I don't doubt that it doesn't work, it's me who's silly :) |
| 13:19 | imade | (def db {:classname "org.h2.Driver" |
| 13:19 | imade | :subprotocol "h2" |
| 13:19 | imade | :subname "jdbc:h2:tcp://localhost/~/test" |
| 13:19 | imade | :user "tester" |
| 13:19 | imade | :password "tester"}) |
| 13:19 | imade | (defn test-db [] |
| 13:19 | imade | (with-connection db |
| 13:19 | imade | (with-query-results rs ["select * from TEST"] |
| 13:20 | imade | (dorun (map #(println (:name %)) rs))))) |
| 13:20 | imade | that's my connection properties and test method |
| 13:21 | imade | I'm thinking my subname is wrong, I have tried the one written in http://en.wikibooks.org/wiki/Clojure_Programming/Examples/JDBC_Examples#H2Database, but also no luck |
| 13:25 | kumarshantanu | imade: you can try clj-dbcp if you want -- it's tested and works (shameless plug though) |
| 13:27 | imade | kumarshantanu, thanks, I am investigating it now |
| 13:29 | kumarshantanu | imade: okay, do ping me if there's something unclear about it |
| 13:43 | mrSpec | Hello, I have very lame question. How can I write in clojure something like: gm.setMode(ModalGraphMouse.Mode.TRANSFORMING); ? I'm trying: (.setMode gm 'ModalGraphMouse.Mode.TRANSFORMING) but it's wrong :/ |
| 13:43 | chouser | try (.setMode gm ModalGraphMouse$Mode/TRANSFORMING) |
| 13:43 | amalloy | try ModalGraphMouse$Mode$TRANSFORMING (no ') |
| 13:43 | amalloy | oh, that's probably more right |
| 13:44 | chouser | I'm not sure |
| 13:44 | amalloy | no, i think you're right |
| 13:44 | mrSpec | chouser: unfortunately: No such namespace: ModalGraphMouse$Mode |
| 13:45 | amalloy | mrSpec: have you imported ModalGraphMouse from whatever package it lives in? |
| 13:46 | Raynes | $google ModalGraphMouse |
| 13:46 | sexpbot | First out of 32 results is: ModalGraphMouse (jung2 2.0 API) |
| 13:46 | sexpbot | http://jung.sourceforge.net/doc/api/edu/uci/ics/jung/visualization/control/ModalGraphMouse.html |
| 13:46 | mrSpec | hm, I'll check this :) |
| 13:46 | Raynes | It lives there. |
| 13:46 | Raynes | edu.uci.ics.jung.visualization.control.ModalGraphMouse |
| 13:46 | Raynes | Seriously? |
| 13:47 | chouser | (import 'edu.uci.ics.jung.visualization.control.ModalGraphMouse$Mode) |
| 13:47 | chouser | then try mine again :-) |
| 13:47 | Raynes | Those people should be executed by firing squad. :\ |
| 13:47 | mrSpec | chouser: Thx |
| 13:47 | mrSpec | I didnt have $Mode |
| 13:47 | amalloy | Raynes: sigh, i'm writing similar package names at work |
| 13:49 | Raynes | amalloy: For a while, it looked like the group of clojurians supporting really long convoluted namespaces was going to win, but then Leiningen's default made the papers and took over the world. |
| 13:49 | Raynes | I don't think I could have tolerated it, even if it is 'better' for some reason. If this is wrong, I don't want to be right. |
| 13:49 | amalloy | Raynes: i think i would have supported them if i'd been around |
| 13:50 | amalloy | global uniqueness is a nice property |
| 13:50 | Raynes | I disagree when it's at the expense of three word wraps per namespace. |
| 13:51 | LOPP | what's the problem, you can alias that |
| 13:51 | Raynes | You still have to type it. |
| 13:51 | amalloy | and someone would have added a way to create abbreviations within your own project. eg, define mr.* as an alias to com.hubpages.cassandra.mapreduce.* throughout the project |
| 13:51 | LOPP | once per file |
| 13:51 | Raynes | And remember it. |
| 13:51 | amalloy | so that you only type it once per project, not file |
| 13:52 | amalloy | eg, put that in project.clj. not that hard |
| 13:52 | amalloy | i'm happy with the short namespaces, but if clojure takes off there will be conflicts and we'll have to switch back to java style |
| 13:53 | Raynes | Or more unique project names. |
| 13:54 | LOPP | not to mention when you have a generic class name |
| 13:54 | LOPP | you usually get 5 same ones when you try autocomplete in eclipse |
| 13:54 | KirinDave | You know... |
| 13:54 | Raynes | If so, I promise to be the last person to bite the bullet and start using the nonsensical domain.project.file style. |
| 13:54 | LOPP | it's nice to have company name in namespace |
| 13:55 | KirinDave | Objective-C has this problem 1000x worse and they really, really rarely have a collision problem. |
| 13:55 | KirinDave | I think this collision/package problem is one of those things where people are *convinced* it's a nightmare but in practice, humans just Deal With It™. |
| 13:56 | Raynes | I'm of the opinion that if you create a project of the same name as another person's popular project, you have more collision problems than just namespace ones. |
| 13:57 | KirinDave | Agreed. |
| 13:58 | Raynes | But I digress. |
| 14:12 | bobo_ | whats the simplest way to have one method that handles different types? ie converting Date to long before continuing. |
| 14:13 | amalloy | bobo_: multimethod is one way |
| 14:14 | kumarshantanu | bobo_: duck typing (as-date xxx) is another option |
| 14:14 | kumarshantanu | in fact that is coercion |
| 14:15 | bobo_ | yes, but what way should one use when its only one tiny method and most likely just two types |
| 14:16 | tonyl | make a multimethod or just a fn that hangles both types to the resulting type |
| 14:17 | kumarshantanu | I prefer coercing personally (because it stays within the function) |
| 14:17 | amalloy | and i prefer a multimethod. i don't think it much matters |
| 14:18 | tonyl | does arity works with type? like (defn myfn ([^Date d] ... ) ([^Long n] ...)) |
| 14:18 | tonyl | *work |
| 14:18 | tonyl | well i guess there is multimethods for that |
| 14:18 | bobo_ | hm ok, doesnt realy mather i guess |
| 14:18 | amalloy | tonyl: no |
| 14:18 | kumarshantanu | tonyl: doesn't -- the number of args matters |
| 14:19 | amalloy | clojure functions dispatch strictly on arity: no type overloading |
| 14:19 | tonyl | yeah figured kinda late |
| 14:30 | lazy1 | How do I write the char literal for space? |
| 14:30 | chouser | \space |
| 14:30 | lazy1 | Thanks |
| 14:33 | lazy1 | One sign that Clojure is well designed is that whenever someone answers me, there's a loud "doh" inside my head |
| 14:35 | chouser | heh. well, that may be, but I don't personally think its consistency around char and string prepresentation is particularly strong. |
| 14:35 | chouser | but at least you can ask it questions like that. |
| 14:35 | chouser | & (first " ") |
| 14:36 | sexpbot | ⟹ \space |
| 14:45 | lazy1 | I come from Python where they did away with chars, there are only strings |
| 14:45 | chouser | yeah. That would be clumsy to try to do on top of JVM |
| 14:46 | lazy1 | As abstractions goes, there is some different between a char and a string. But not that much |
| 14:46 | lazy1 | difference that is |
| 14:47 | klang | .. must make something cool, to be able to use dk.lang.clojure.cool-stuff as the package name .. |
| 15:02 | dpro | hi |
| 15:03 | dpro | I was just checking out incanter, but when I run a simple example - from (doc view) - for example, I only get a blank window and no plots or graphics show up ... any ideas why that happens ? (I use a tiling WM if that matters) |
| 15:04 | chouser | that might matter |
| 15:04 | dpro | oh, and there are no errors of course |
| 15:04 | chouser | yeah |
| 15:04 | chouser | just a sec, finding a link |
| 15:05 | chouser | dpro: http://www.haskell.org/haskellwiki/Xmonad/Frequently_asked_questions#Problems_with_Java_applications.2C_Applet_java_console |
| 15:05 | chouser | you might try one of those |
| 15:06 | chouser | actually, this page may be easier to follow: http://awesome.naquadah.org/wiki/Problems_with_Java |
| 15:13 | dpro | chouser: cheers now it works ... aargh |
| 15:44 | dnolen | hmm does anyone know how to get Enlive to not emit the surrounding <html> <body> when rendering snippets and/or templates ? |
| 15:48 | defn | Raynes: how's the rewrite of sandbox going? |
| 15:55 | amalloy | defn: sexpbot has been using the rewrite for a while now. if you haven't seen him broken or hacked, it's going well |
| 16:06 | Raynes | defn: It wasn't really a rewrite as much as a total rethinking. I have to give clj-sandbox credit because I absolutely did not start totally from scratch, but I can't call it a 'rewrite'. |
| 16:06 | Raynes | But yeah, what amalloy said. |
| 16:06 | Raynes | :) |
| 16:39 | mattmitchell_ | i have a hash map, and would like to change all keys to have new keys (name becomes name_ss and name_text) -- is there a sweet clojure way to do this? |
| 16:41 | tonyl | just change the keywords by appending that? |
| 16:42 | mattmitchell_ | tonyl: the only thing is that i have a bunch of keys per/hash i need to change to that same format |
| 16:42 | tonyl | &(into {} (map (fn [[k v]] [(keyword k "_ss") v]) {:a 1, :b 2})) |
| 16:42 | sexpbot | java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.String |
| 16:43 | tonyl | &(into {} (map (fn [[k v]] [(keyword (str k) "_ss") v]) {:a 1, :b 2})) |
| 16:43 | sexpbot | ⟹ {::a/_ss 1, ::b/_ss 2} |
| 16:43 | rata_ | hi all |
| 16:43 | neotyk | ,(let [m {:a 1 :b 2}] (zipmap (map #(str % "_text") (keys m)) (vals m))) |
| 16:43 | clojurebot | {":b_text" 2, ":a_text" 1} |
| 16:43 | mattmitchell_ | interesting thanks |
| 16:49 | amalloy | mattmitchell_: i think tony's is the clearest, once you adjust it to make it work: ##&(into {} (map (fn [[k v]] [(keyword (str k "_ss")) v]) {:a 1, :b 2})) |
| 16:49 | sexpbot | java.lang.Exception: Unable to resolve symbol: & in this context |
| 16:49 | mister_roboto | Is it normal to get errors on the tests while building clojure-contrib 1.2? |
| 16:49 | amalloy | ##(into {} (map (fn [[k v]] [(keyword (str k "_ss")) v]) {:a 1, :b 2})) |
| 16:49 | sexpbot | ⟹ {::a_ss 1, ::b_ss 2} |
| 16:49 | freakazoid | hmm, double colon |
| 16:50 | mattmitchell_ | freakazoid: yeah i was just going to ask about that :) |
| 16:50 | amalloy | oh, sure |
| 16:50 | amalloy | ##(into {} (map (fn [[k v]] [(keyword (str (name k) "_ss")) v]) {:a 1, :b 2})) |
| 16:50 | sexpbot | ⟹ {:a_ss 1, :b_ss 2} |
| 16:50 | freakazoid | it could make extra long poo with that double colon. |
| 16:50 | joegallo | ,(name :foo) |
| 16:50 | clojurebot | "foo" |
| 16:50 | joegallo | Oh, you beat me to it. |
| 16:50 | mattmitchell_ | awesome :) thanks |
| 16:50 | Raynes | &(into {} (for [[k v] {:a 1, :b 2}] [(keyword (str (name k) "_ss")) v])) |
| 16:50 | sexpbot | ⟹ {:a_ss 1, :b_ss 2} |
| 16:50 | tonyl | name eluded me |
| 16:51 | amalloy | Raynes: dude, i just did that |
| 16:51 | Raynes | amalloy: Don't tell me I'm going to have to start tidying up YOUR code, now. ;) |
| 16:51 | Raynes | Did not. |
| 16:51 | tonyl | Raynes did it with the for macro |
| 16:51 | amalloy | oh. you and your for nonsense |
| 16:51 | tonyl | lol |
| 16:52 | tonyl | i love map, what can i say |
| 16:52 | amalloy | i don't mind for, i guess, but i almost always use map when i'm writing my own stuff. why use a macro when a function will do, etc etc |
| 16:52 | Raynes | I don't always destructure, but when I do, I prefer for. Stay concise my friends. |
| 16:52 | amalloy | he is...the most nitpicky man in the world |
| 16:53 | Raynes | Coming from the guy who brought in a deprecated contrib lib just so he wouldn't have to not use -> |
| 16:53 | Raynes | ;p |
| 16:53 | defn | Raynes: what's the name of your "rethinking"? |
| 16:54 | Raynes | defn: clojail |
| 16:54 | amalloy | $google clojail |
| 16:54 | sexpbot | First out of 14 results is: Planet Clojure |
| 16:54 | sexpbot | http://planet.clojure.in/ |
| 16:54 | Raynes | Man, how does my stuff still end up on planet clojure. :o |
| 16:54 | amalloy | sexpbot: srsly? you can't give us github? |
| 16:54 | Raynes | s/./?/ |
| 16:54 | sexpbot | <Raynes> ????????????????????????????????????????????????????????? |
| 16:54 | amalloy | lol |
| 16:55 | amalloy | good try man |
| 16:55 | Raynes | Oh, intertweets. |
| 16:55 | Raynes | I forgot that it was in the intertweets. |
| 16:55 | Raynes | http://github.com/Raynes/clojail |
| 16:56 | mister_roboto | s/\./?/ |
| 16:56 | sexpbot | <mister_roboto> Is it normal to get errors on the tests while building clojure-contrib 1?2? |
| 16:56 | Raynes | Man, that makes it an entirely different question. |
| 16:58 | amalloy | $sed -Raynes s/.*/whine whine whine |
| 16:58 | sexpbot | <Raynes> whine whine whinewhine whine whine |
| 16:59 | amalloy | hm, that's weird. i wonder why it matched twice |
| 16:59 | Raynes | Because it's regex. |
| 16:59 | amalloy | s/.+/1 |
| 16:59 | sexpbot | <amalloy> 1 |
| 16:59 | Raynes | I need to learn elisp. |
| 16:59 | amalloy | s/.*/1 |
| 16:59 | sexpbot | <amalloy> 11 |
| 16:59 | Raynes | I desire an Emacs mode for atomo. |
| 16:59 | amalloy | huh |
| 17:04 | Raynes | defn: Have any uses for a sandbox these days? |
| 17:05 | Thorn | it looks like it can actually be easier to deal with parentheses in lisp than in javascript |
| 17:06 | Thorn | I've got something like )])])]}])])]} in my javascript code |
| 17:06 | Raynes | My eyes! |
| 17:06 | dnolen | Thorn: not unusual. Especially in Node.js programs. |
| 17:06 | hiredman | paredit actually sort of works for javascript in emacs |
| 17:06 | Thorn | I'm an ext js user |
| 17:07 | dnolen | Thorn: never messed w/ that - a MooTools, jQuery+Underscore.js person myself. |
| 17:08 | hiredman | in clojure you can write macros to turn normal looking code in to a series of callbacks |
| 17:09 | Thorn | also, neither netbeans nor eclipse actually help you if you get those unbalanced |
| 17:09 | Thorn | haven't tries emacs, though |
| 17:10 | dnolen | Thorn: hmm, I thought Counter Clockwise had paredit support now |
| 17:10 | hiredman | https://github.com/hiredman/die-geister/blob/master/test/die_geister/test/core.clj#L13 the async macro form is rewritten as a series of callbacks that depend on the result of the previous callback |
| 17:12 | dnolen | hiredman: hey, that looks pretty cool. Will need to digest that. |
| 17:16 | Thorn | ext js has these config objects which specify UI layout, see e.g. http://www.java2s.com/Code/JavaScript/Ext-JS/MulticolumnsNotitlesdoublestack.htm |
| 17:16 | Thorn | I wonder if this could be made more elegant if we could use lisp |
| 17:16 | hiredman | dnolen: inspired by http://player.microsoftpdc.com/Session/1b127a7d-300e-4385-af8e-ac747fee677a |
| 17:17 | hiredman | new composable async tasks for c# an vb.net |
| 17:21 | mister_roboto | Is it normal to get errors on the tests while building clojure-contrib 1.2? |
| 17:29 | mister_roboto | No? Yes? |
| 17:29 | technomancy | mister_roboto: well... it's not normal to build contrib in the first place. |
| 17:29 | technomancy | unless your name is Hudson |
| 17:29 | mister_roboto | It is, actually! |
| 17:29 | Raynes | It is if you intend to contribute to it. |
| 17:30 | dnolen | hiredman: not gonna install Silverlight, but that the Rx stuff right? |
| 17:30 | mister_roboto | If u get the zip from github, that's what u get, a maven project |
| 17:30 | mister_roboto | So the test failures are normal then? |
| 17:30 | tonyl | it didn't happen to me |
| 17:31 | amalloy | mister_roboto: there's no reason to get the zip from github though |
| 17:31 | tonyl | I only followed the directions from the README file |
| 17:31 | amalloy | just put dependency on contrib into your lein/cake project.clj, and they go get the jar for you |
| 17:32 | mister_roboto | Dude, I am not using lein/cake. Why not just answer the question? I don't get the reluctance. |
| 17:32 | amalloy | because i haven't built it |
| 17:32 | Raynes | Because everybody uses lein and cake, and nobody builds contrib or clojure unless they plan to contribute to it. |
| 17:33 | mister_roboto | No, everyone doesn't. :) |
| 17:33 | Raynes | If you aren't building it to test your own changes, use lein, cake, or cljr to get a REPL and start using lein or cake for dependency management in projects. That's the best way to go about this. There is no point in building contrib unless you have a reason for doing so other than "I want to." |
| 17:33 | Raynes | Lein, cake, or maven. |
| 17:33 | mister_roboto | I'm just using ccw in eclipse. Not worried about distribution yet of a jar war or whatever |
| 17:34 | tonyl | I don't use lein or cake or any other tool like that |
| 17:34 | tonyl | I just built it from the zip |
| 17:34 | tonyl | but there was no error output |
| 17:35 | mister_roboto | thanks tony for your direct answer :) this was on the 1.2 release zip on the download page, btw |
| 17:36 | tonyl | that is the one I used, but if by 'download page' you mean the one in github |
| 17:37 | mister_roboto | Raynes, I would just use a prebuilt jar if there was one to directly d/l |
| 17:37 | mister_roboto | Yes tony, the github page for clojure |
| 17:37 | tonyl | i can send you mine |
| 17:37 | mister_roboto | There is no prebuilt contrib jar there |
| 17:38 | tonyl | nope |
| 17:38 | tonyl | you have to build it |
| 17:39 | mister_roboto | Thanks tony but that's ok. I'm on my phone now anyway. |
| 17:39 | tonyl | ok |
| 17:39 | raek | mister_roboto: http://build.clojure.org/releases/org/clojure/ |
| 17:39 | raek | these are the jars that the clojure build tools would download |
| 17:40 | tonyl | that is a good link raek, never found it before |
| 17:40 | raek | contrib is there too |
| 17:40 | Raynes | No, you don't have to build it. You can get it from the maven repository. And no, you don't even have to use a build tool to do so, though that's the general work flow. If you just want a REPL, you can use the build tools for that, and to manage that REPL's classpath. I can't think of a really good reason to not do so if you aren't contributing to Clojure or contrib. I'm not trying to be an asshole, but merely trying to put you on the right track rath |
| 17:40 | Raynes | er than just answer your questions when you're inherently doing something that might be bad for you in the long run. |
| 17:40 | mister_roboto | Thanks! Never saw that before raek |
| 17:40 | Raynes | Rest assured, I only wish to help. |
| 17:41 | mister_roboto | I understand all of that. Been developing java with maven for like 6 years, use hudson etc etc. I only wanted to know about the errors |
| 17:42 | mister_roboto | Actually, I checked out the src from git a while ago and compiled that with no prob at all, pulling from master |
| 17:42 | mister_roboto | I was just curious. I know the "dangers" :) |
| 17:44 | Raynes | Not necessarily dangerous as much as not using build tooling can quickly end up being painful and disastrous in the long run. Too many people go that route and end up turning away from Clojure because of it. However, you're familiar with the Java ecosystem (apparently), so I'm sure you understand. :> |
| 17:44 | mister_roboto | I actually love clojure. |
| 17:50 | raek | sorry for bombaring you with all this "use the build tools" propaganda, but beginners tend to complicate things. compared with other languages, it's not very obvious how to get started with other libs that clojure and contrib... |
| 17:51 | Raynes | raek: I'm writing up a blog post about all of this because of what just transpired. |
| 17:51 | Raynes | To try to make sense of things for new people. I'll let you read it before I publish it, if you'd like. |
| 17:52 | raek | sure |
| 17:53 | mister_roboto | I understand, raek. but the 4 test failures are there in test_io.clj and test_profile.clj on win 7, maven 2.2.1 and jdk 1.6 |
| 17:53 | mister_roboto | I appreciate that you're trying to be helpful. I do have a perfectly fine working env using ccw in eclipse |
| 18:07 | mister_roboto | raek I know I want something like lein for packaging if I ever get around to distributing something. Something to uberjar all my deps or build me a war or whatever. I'm too busy learning basic clojure to care at this point :) |
| 18:08 | raek | if what you have work, then great :) |
| 18:10 | raek | I find lein useful, because it downloads not only the jars of the deps, but the jars of the deps of the deps, etc... |
| 18:10 | raek | also it makes managing the classpath a bit simpler (neat if you have more than one projec) |
| 18:11 | raek | this is why *I* use it... |
| 18:11 | mister_roboto | The ccw plugin works very well except that once in a great while the repl will hang on something related to laziness that always runs fine from the commandline (like clojure file.clj, or from a standalone repl) |
| 18:11 | raek | strange |
| 18:12 | mister_roboto | Raek, u can do that easily in eclipse too (managing classpath) |
| 18:13 | raek | yes, but not in emacs... :) |
| 18:13 | raek | in emacs, you usually let lein or cake take care of that... |
| 18:14 | raek | I guess there is less need for leiningen in eclipse... |
| 18:15 | mister_roboto | Raek, oh for the transitive deps... yes, I usually rely on maven or grape in groovy for that. I haven't had that problem yet in my simple clojure experiments. I can add jars easily but not the nice transitive dep mgmt of maven or lein |
| 18:16 | mister_roboto | That's a good point for using lein |
| 18:16 | raek | btw, can one send a single defn for evaluation in CCW (without restarting the clojure instance), like one can with C-M-x in slime? (open question to everyone in #clojure) |
| 18:16 | mister_roboto | Easier than a clojure plugin and just maven |
| 18:17 | Derander | raek: yes |
| 18:17 | Derander | wait |
| 18:17 | Derander | ccw? |
| 18:17 | clojurebot | ccw is http://github.com/laurentpetit/ccw |
| 18:17 | Derander | .. thanks clojurebot |
| 18:17 | mister_roboto | Raek yes u can. Highlight, right click and select run selected in repl |
| 18:17 | mister_roboto | Will use the running repl |
| 18:18 | raek | ok. neat |
| 18:18 | raek | I have a friend who used to restart the clojure instance each time he changed something |
| 18:18 | mister_roboto | I didn't know that for a long time :O |
| 18:18 | mister_roboto | That's what I was doing initially |
| 18:18 | raek | my reaction was that "sure there must be a way to do interactive developmen?" |
| 18:19 | raek | mister_roboto: thanks for the hint |
| 18:19 | mister_roboto | Then I started copy pasting into the repl, which was still a pita |
| 18:19 | mister_roboto | Finally I read the contxt menu :) |
| 18:21 | raek | interactive development in clojure rocks. |
| 18:22 | mister_roboto | Raek I agree... it's so quick to experiment. That's why I like the groovy console too, even to think through a java thing |
| 18:22 | mister_roboto | But that console is not as nice due to the crappy editor |
| 18:32 | alexyk | how do you merge two sets? |
| 18:33 | technomancy | into? |
| 18:33 | tonyl | union |
| 18:38 | amalloy | &(clojure.set/union #{:a :b} #{:b :c}) |
| 18:38 | sexpbot | ⟹ #{:a :c :b} |
| 18:38 | amalloy | alexyk: ^ |
| 18:38 | alexyk | thx |
| 18:45 | Raynes | technomancy: ping |
| 18:46 | Raynes | technomancy: You know how 'cake repl' runs in cake's global project, so that all dependencies of the global project are on the classpath of that REPL, providing functionality similar to that offered by cljr? I'm writing a blog post about some things and some other things, and before I'm totally wrong, I'd like to confirm whether or not Leiningen has anything similar. |
| 18:47 | Derander | wtf do I do if contrib.profile has an integer overflow when it profiles my code? |
| 18:47 | Derander | garrgh. |
| 18:47 | raek | 1.3? |
| 18:47 | Derander | checking |
| 18:48 | Derander | 1.2 |
| 18:48 | raek | hrm strange. |
| 18:48 | raek | ,(clojure-version) |
| 18:48 | clojurebot | "1.2.0" |
| 18:49 | Derander | it works usually |
| 18:49 | raek | ,(reduce + (rest (range 100))) |
| 18:49 | clojurebot | 4950 |
| 18:49 | raek | ,(reduce * (rest (range 100))) |
| 18:49 | Derander | but I try it on a really big number |
| 18:49 | clojurebot | 933262154439441526816992388562667004907159682643816214685929638952175999932299156089414639761565182862536979208272237582511852109168640000000000000000000000 |
| 18:49 | Derander | long code* and it implodes |
| 18:49 | Derander | I'm going to do it again, gimme a little bit. |
| 18:49 | raek | integers shouldn't overflow in Clojure 1.2 :/ |
| 18:49 | technomancy | Raynes: david has talked about adding that cljr-ish functionality to lein, but nothing's come of it so far. I guess people who want that just use cljr |
| 18:50 | Raynes | technomancy: Cool. I'll add a note that it's being considered. |
| 18:55 | Derander | can't reproduce it anymore |
| 18:55 | Derander | weird. |
| 18:57 | Derander | oh there is goes again |
| 18:57 | Derander | Value out of range for int: 55560780000" in clojure.lang.RT.intCast after clojure.contrib.profile |
| 18:58 | Derander | (that's the number of nanoseconds it takes to execute this slow piece of shit) |
| 18:59 | tonyl | what is the code? |
| 19:01 | tonyl | or a simpler version if it is too big |
| 19:40 | Derander | tonyl: sorry, had to drive home. |
| 19:45 | Derander | tonyl: runs sub-1 second (usually around 800ms) for most web pages that I slam through this; I found one website with 1700 divs on it that eats this code alive. runtime is ~25 seconds. |
| 19:45 | Derander | tonyl: https://gist.github.com/704448 |
| 19:45 | Derander | 1) I'm not very good at clojure |
| 19:46 | Derander | 2) it doesn't have a problem profiling things until I put a prof in (find-content) |
| 19:46 | Derander | after that I get that number out of range error |
| 19:46 | Derander | this code is inspired by webmine, but I started before that was publicized so it has some differences |
| 19:46 | Derander | I couldn't get webmine running to check its performance on the same webpage, some weird dependency issue. |
| 19:46 | Derander | http://www.core77.com/blog/columns/design_without_designers_17587.asp <-- this is the sample website |
| 19:47 | Derander | I was starting to try to type hint it, but I don't understand fully how to do that. I'll figure it out though. |
| 19:54 | hiredman | dnolen: I am not sure if it is part of Rx, but async tasks certainly play well with the observable collections from Rx |
| 20:06 | bhenry | is there something that will always round division up if it's not evenly divisible? |
| 20:06 | bhenry | or do i have to write my own? |
| 20:10 | hiredman | http://download.oracle.com/javase/1.4.2/docs/api/java/lang/Math.html#ceil(double) |
| 20:12 | bhenry | nice! thanks |
| 20:15 | Derander | oh interesting |
| 20:15 | Derander | profiling hsows that it's spending 99% of the time in one spot |
| 20:19 | rata_ | hi |
| 20:24 | amalloy | bhenry: clojure.contrib.math/ceil also |
| 20:28 | rata_ | which is the function that returns [(filter f coll) (remove f coll)] ? |
| 20:38 | amalloy | ((juxt filter remove) f coll) :P |
| 20:38 | amalloy | or c.c.seq-utils/separate |
| 20:39 | bhenry | rata_ clojure.contrib.seq-utils/separate |
| 20:39 | rata_ | oh thanks |
| 20:41 | gertalot | hey all, I'm trying to sum a large number of vectors, but this gives me a stack overflow: |
| 20:41 | gertalot | (reduce (fn [a b] (map + a b)) (repeat 10000 [1 1])) |
| 20:41 | gertalot | (in reality the vectors aren't simply [1 1] btw) |
| 20:41 | gertalot | how should I be doing this instead? |
| 20:44 | Derander | gertalot: (reduce + (flatten [[1 2] [3 4]])) seems to work |
| 20:45 | Derander | that assumes that the vectors are in list-ish thing |
| 20:45 | gertalot | that's not what I'm after though |
| 20:45 | Derander | dinner time |
| 20:45 | Derander | what are you trying to do? |
| 20:45 | gertalot | I have a large list of vectors, the results of calculations using a random normal distribution |
| 20:45 | Derander | oh |
| 20:46 | gertalot | and I'm trying to average them |
| 20:46 | Derander | are you trying to get a collection of sums of bectors? |
| 20:46 | gertalot | I' |
| 20:46 | Derander | vectors* |
| 20:46 | gertalot | I'm expecting (10000 10000) to be the result of my example above |
| 20:46 | Derander | oh, I see |
| 20:46 | Derander | so all of the first elements + all of the second |
| 20:46 | gertalot | yes! |
| 20:47 | Derander | interesting |
| 20:47 | gertalot | so [1 2 3] + [4 5 6] == [5 7 9] |
| 20:47 | gertalot | that sort of thing |
| 20:47 | Derander | definitely reduce |
| 20:47 | Derander | trying to think of a way to structure it |
| 20:47 | Derander | (reduce (magic) (coll of vectors)) |
| 20:48 | gertalot | why would it overflow the stack though? |
| 20:48 | Derander | I don't know |
| 20:49 | Derander | (reduce (fn [[a b] [c d]] (identity [(+ a c) (+ b d)])) (repeat 10 [1 2])) returns [10 20] |
| 20:49 | bhenry | gertalot does every vector contain two items? |
| 20:49 | tomoj | huh? |
| 20:49 | Derander | (reduce (fn [[a b] [c d]] [(+ a c) (+ b d)]) (repeat 10 [1 2])) <-- so does this |
| 20:49 | Derander | and doesn't overflow the stack after 10,000 iterations |
| 20:50 | Derander | repeats |
| 20:50 | Derander | whatever |
| 20:50 | gertalot | not all vectors contain 2 elements though |
| 20:50 | Derander | oh, darn. |
| 20:50 | gertalot | :) |
| 20:50 | Derander | is it regular? |
| 20:50 | tomoj | then how can you add them? |
| 20:50 | bhenry | how would you add? |
| 20:50 | Derander | you don't have [1 2] + [ 1 2 3] ever? |
| 20:51 | gertalot | all vectors contain the same number of items, but not necessarily 2 |
| 20:51 | gertalot | this should also work: (reduce (fn [a b] (map + a b)) (repeat 10000 [1 1 1])) |
| 20:51 | tomoj | it blows the stack because you end up with (map + (map + (map + (map + ...)))) |
| 20:51 | gertalot | hm. |
| 20:52 | tomoj | something like that |
| 20:52 | tomoj | ( ... (map + (map + (map + [1 1 1]) [1 1 1]) [1 1 1]) ...) |
| 20:52 | tomoj | dammit |
| 20:52 | tomoj | you get the idea |
| 20:52 | gertalot | yeah :) |
| 20:52 | bhenry | (apply map + (repeat 1000 [1 1 1])) |
| 20:52 | bhenry | &(apply map + (repeat 1000 [1 1 1])) |
| 20:52 | sexpbot | ⟹ (1000 1000 1000) |
| 20:53 | bhenry | &(apply map + (repeat 10000 [1 1 1])) |
| 20:53 | sexpbot | ⟹ (10000 10000 10000) |
| 20:53 | gertalot | hey! |
| 20:53 | gertalot | awesome |
| 20:53 | bhenry | &(apply map + (repeat 100000 [1 1 1])) |
| 20:53 | sexpbot | ⟹ (100000 100000 100000) |
| 20:53 | bhenry | boo ya |
| 20:53 | gertalot | that makes me happy |
| 20:53 | Derander | lol |
| 20:54 | bhenry | gertalot, watch your heap space though |
| 20:55 | gertalot | I'm alright with heap space - we need a lot, but we have quite a lot :) |
| 20:55 | gertalot | stack consumption I'm worried about |
| 20:55 | bhenry | cool. |
| 20:56 | gertalot | I wouldn't have thought that reduce should eat the stack though, but I'm sure there's a good reason for it? :) |
| 20:57 | garytr25 | function call stack? |
| 20:57 | tomoj | it's not reduce eating the stack |
| 20:58 | tomoj | reduce builds up a lazy seq which has an unrealized chain of maps |
| 20:58 | tomoj | as soon as you try to consume an element, it blows the stack by realizing all those maps |
| 20:58 | tomoj | try (def foo <version that blew the stack>) |
| 20:58 | gertalot | ahh I see |
| 20:58 | tomoj | maybe something causes it to try to realize anyway |
| 20:58 | tomoj | but I"m betting that won't blow the stack |
| 20:58 | tomoj | until you get an element out of foo |
| 20:59 | gertalot | you're right |
| 20:59 | gertalot | interesting. I learn something new every day! :) |
| 21:26 | jarpiain | ,(reduce (fn [a b] (doall (map + a b))) (repeat 10000 [1 1])) |
| 21:26 | clojurebot | (10000 10000) |
| 21:26 | jarpiain | gertalot: that works also |
| 21:30 | Derander | I have a list of things that I want to count in a string. Right now I'm doing (count (re-seq #"[!\"#$%&\'()*+,-./:;<=>?@\[\][\\]^_`{|}~]" string)) to count punctuation. This is pretty slow in large strings though. Is there a better way? |
| 21:31 | gertalot | thanks jarpiain |
| 21:31 | gertalot | that forces evaluation so the lazy seq doesn't build up, right? |
| 21:32 | tonyl | Derander: why not just look for not alpha-nums #"[^A-Za-z0-9]" |
| 21:33 | Derander | tonyl: I'll try, will that make a difference in exectution speed though? |
| 21:34 | jk_ | there has to be an easier way to reverse a string as a string, right? (apply str (reverse "1234")) |
| 21:34 | tonyl | mm probably, but low one |
| 21:34 | Derander | tonyl: the problem (I think) is more to do with the number of items in the seq |
| 21:34 | Derander | because it occurs to some extent when I'm just counting commas |
| 21:35 | tonyl | jk_: maybe clojure.string.reverse ? |
| 21:36 | tonyl | Derander: so it has to be able to handle big strings |
| 21:36 | Derander | yeah |
| 21:36 | Derander | the problem is that I am trying to parse article content |
| 21:36 | Derander | I suppose it's not that valuable |
| 21:37 | Derander | I could just axe these areas altogether and probably see no difference |
| 21:37 | Derander | but they're still decent indicators of where the article is |
| 21:37 | Derander | (in a website) |
| 21:37 | tomoj | the regex is just a character class? |
| 21:37 | Derander | no, no. I'm doing it similar to how webmine does it |
| 21:37 | Derander | sec |
| 21:38 | tonyl | have you try seeing webmine, to see how it does it? |
| 21:38 | tomoj | just counting occurrences of particular characters? |
| 21:38 | Derander | https://github.com/clj-sys/webmine/blob/master/src/webmine/readability.clj#L45 |
| 21:38 | Derander | tonyl: it doesn't |
| 21:38 | Derander | hm |
| 21:38 | tonyl | or maybe partition-all the string seq and deal with each partition |
| 21:38 | Derander | well, they have a different way of checking for commas |
| 21:39 | Derander | hm |
| 21:39 | Derander | yeah |
| 21:39 | Derander | looks like they tried to implement the punctuation counter and killed it |
| 21:39 | Derander | perhaps for the same reason |
| 21:39 | Derander | looking for info in commit lgo |
| 21:39 | Derander | log |
| 21:39 | tomoj | I don't understand |
| 21:40 | Derander | I'm sorry. I'm not being very clear |
| 21:40 | tomoj | (count (filter #{\, \. ...} coll)) ? |
| 21:40 | tomoj | er, s/coll/s/ |
| 21:40 | tomoj | you're not just counting character occurrences like that? |
| 21:41 | Derander | no, I have a character class regex that I'm using re-seq w/ |
| 21:41 | Derander | I will try filter |
| 21:41 | tomoj | I mean, is your regex equivalent to that |
| 21:41 | Derander | yes |
| 21:41 | tomoj | dunno if hash set will be faster |
| 21:41 | Derander | I think it's just going to be slow |
| 21:47 | Derander | oh. looks like the problem isn't in clojure, but lies more with the java library I'm relying on |
| 21:48 | tonyl | the regex class in java? |
| 21:48 | Derander | nah, w3c's document |
| 21:48 | Derander | the whole dom thing |
| 21:49 | Derander | .getTextContent |
| 21:49 | Derander | sorry, I'm not really sure which class I'm operating on |
| 21:49 | Derander | it's an element. not sure if it's xerxes or w3c's, but it's a Node |
| 21:52 | tonyl | ok |
| 21:53 | Derander | head imploding |
| 21:54 | tonyl | got something |
| 21:54 | tonyl | (let [ls (partition-all 32 longstr)] (apply sorted-set (reduce #(re-seq #"[^a-zA-Z0-9]" (str %1 %2)) ["hello, world!", "wej,wep! oijer?"]))) |
| 21:54 | Derander | tonyl: I will be back in ~5 minutes to try that out |
| 21:54 | tonyl | not that |
| 21:54 | tonyl | (let [ls (partition-all 32 longstr)] (apply sorted-set (reduce #(re-seq #"[^a-zA-Z0-9]" (str %1 %2)) ls))) this |
| 21:54 | tonyl | ok |
| 21:55 | amalloy | &(count (filter #{\,} (repeatedly 1e6 (comp char #(rand-int 255))))) |
| 21:55 | sexpbot | ⟹ 3881 |
| 21:55 | tonyl | scratch that, not good performance |
| 21:56 | amalloy | &(time (count (filter #{\,} (repeatedly 1e7 (comp char #(rand-int 255)))))) |
| 21:56 | sexpbot | ⟹ "Elapsed time: 6982.28 msecs" 38920 |
| 21:56 | tonyl | amalloy: sorry meant to my code |
| 21:56 | amalloy | sure i know |
| 21:57 | amalloy | i was just demonstrating that this one is probably fast enough, right? |
| 21:57 | Derander | amalloy: not sure. I don't have a feel for how fast java/clojure is yet |
| 21:57 | Derander | in ruby I'd be fine with that |
| 21:57 | Derander | I don't think I could go that fast in ruby |
| 21:57 | tonyl | probably |
| 21:57 | Derander | I don't know if it's fast or slow for java though |
| 21:57 | Derander | it's a background threaded process though so it's not a huge deal if it's slow |
| 21:57 | Derander | I just don't want to have shitty performance because of shitty code |
| 21:58 | amalloy | Derander: well, it took 7 seconds to create ten million random numbers and count up the commas |
| 21:58 | Derander | yeah |
| 21:58 | Derander | I know |
| 21:58 | Derander | good enough |
| 21:58 | amalloy | that shouldn't be hard to write in java, right? to compare? |
| 21:58 | Derander | well, I didn't mean java vs clojure, I meant clojure vs ruby really |
| 21:58 | Derander | I know that it'll be ridiculously slow in ruby |
| 21:59 | amalloy | *chuckle* |
| 21:59 | Derander | I just don't know what slow looks like in clojure |
| 21:59 | jk_ | (:slow) |
| 21:59 | Derander | jk_: har :-) |
| 21:59 | amalloy | Derander: i'll hack it up in java for you and compare |
| 21:59 | Derander | amalloy: only if you want to. not worrying about it |
| 22:00 | Derander | okay, now the slow parts of the code are where I expected -- checking children nodes for various things |
| 22:00 | Derander | that's reasonablyt |
| 22:00 | Derander | there are 1700 nested divs |
| 22:03 | gstamp | Quick macro question if anyone can help: https://gist.github.com/704567 |
| 22:04 | amalloy | gstamp: i'll look in a sec, but before that, let me suggest fewer macros. it's usually the right answer :) |
| 22:05 | amalloy | ah, okay, not this time |
| 22:05 | amalloy | p# is a symbol that only exists within the quoted context. you can't refer at compile-time to a thing that doesn't exist until runtime |
| 22:06 | Derander | amalloy: not sure why, but (p/prof :commas (count (filter #{\,} text-content))) takes 53 seconds |
| 22:06 | Derander | compared to around 6 with re-seq |
| 22:07 | tomoj | getTextContent returns a String? |
| 22:07 | amalloy | what you really want is (println "hi" ~@(list 1 2) p#). of course using ~@ for just some constants is silly here, but i assume you know that and are using it to demonstrate some other problem you're having |
| 22:07 | Derander | tomoj: yes |
| 22:07 | tomoj | then I guess regex is faster |
| 22:07 | tomoj | not very surprising I guess |
| 22:07 | amalloy | Derander: fwiw on my machine clojure takes 26 seconds and java takes 1.2s |
| 22:07 | tomoj | seq of characters is slow |
| 22:08 | Derander | amalloy: interesting |
| 22:08 | Derander | amalloy: think there is any way to improve that performance? |
| 22:08 | Derander | would dropping to java classes help? |
| 22:08 | amalloy | *shrug* i don't do a lot of performance tuning in either language |
| 22:09 | Derander | okay |
| 22:09 | tonyl | what do you have now Derander |
| 22:09 | Derander | (p/prof :commas (count (filter #{\,} text-content))) where text-content is a string |
| 22:09 | Derander | java string |
| 22:09 | dnolen | Derander: do you have a gist of yr code? |
| 22:10 | Derander | https://gist.github.com/704571 |
| 22:10 | Derander | there is all of it |
| 22:10 | Derander | of interest are weight-div |
| 22:10 | Derander | and find-content-div |
| 22:10 | Derander | (this is my first clojure project, I'm sure there is lots wrong.) |
| 22:11 | dnolen | that's quite a bit of code have you identified the slow spots? |
| 22:12 | Derander | if you refresh the gist it has profiling |
| 22:12 | Derander | it's all in weight-div |
| 22:12 | Derander | well |
| 22:12 | Derander | those prof markers are mostly all in weight-div |
| 22:12 | dnolen | Derander: so commas is slow? |
| 22:12 | Derander | yes |
| 22:12 | Derander | (that was from before when :commas was commented out in weight-div) |
| 22:13 | Licenser | for you night people: http://manager.licenser.net/ - an application for high level management featured by clojure |
| 22:14 | dnolen | Derander: one problem is that count is linear to size of the result of filter |
| 22:14 | Derander | yeah |
| 22:14 | dnolen | filter doesn't return some you can get the count of quickly, it must be traversed |
| 22:15 | amalloy | dnolen: well, of course counting the number of commas in N characters will be O(N). the same is true of java |
| 22:15 | dnolen | amallaoy: yeah sorry I wasn't look at it closely enough, |
| 22:17 | Derander | at this point I think the issue is if it's a clojure vs java issue, or just fundemental slowness that can't be avoided |
| 22:17 | Derander | I don't know how much better the algorithm can get |
| 22:17 | dnolen | Derander: there are some tricks, gotta go tho. |
| 22:17 | Derander | okay |
| 22:18 | Derander | there is a countMatches method in StringUtils |
| 22:18 | Derander | going to try that |
| 22:18 | amalloy | Derander: it can't possibly be better than O(n), but there are probably plenty of ways to reduce the constant factor |
| 22:18 | Derander | amalloy: right, that's what i'm going for. |
| 22:18 | amalloy | eg, partition the input into four equally-sized chunks and count them each in parallel |
| 22:18 | gstamp | amalloy: Thanks very much. That all makes sense. You're right about the example just being for demonstration purposes. I didn't want to confuse anyone with the real version. |
| 22:19 | amalloy | but the regex engine is probably pretty well tuned for literal-character matches, so that's likely to be the best you can do for a given chunk |
| 22:20 | Derander | amalloy: that's an interesting idea |
| 22:20 | Derander | I hadn't even though of multithreading |
| 22:21 | Derander | honestly this entire operation could be heavily parallelized if need be. |
| 22:23 | Derander | okay, StringUtils/countMatches does it in 1.5 seconds vs. around 7 seconds for the best implementation I've done in clojure so far |
| 22:26 | amalloy | oh, in apache commons? |
| 22:26 | Derander | yeah |
| 22:26 | Derander | grabbing dinner now. contemplating parallization. |
| 23:27 | joshua__ | Hi, I'm using emacs, swank and slime and had a question. I want to send code from a window to my slime buffer, how can I do that? |
| 23:29 | joshua__ | Probably a pretty noobie question, but I've been struggling with it. I've found ways like C-cC-x which will eval a command, but it doesn't eval it in the slime window as far as I can tell, since if I do something like (ns some-ns) it doesn't actually change the ns from user> to some-ns>. |
| 23:31 | bhenry | is that all you're looking to do or do you have another purpose to send it to slime? |
| 23:31 | bhenry | the slime buffer * |
| 23:32 | amalloy | joshua__: C-c C-c evaluates the current top-level form |
| 23:32 | amalloy | if you want specifically namespace changes, C-c M-p changes the repl to the ns of the current buffer |
| 23:33 | joshua__ | It pops up saying compilation finished when I do that amalloy (C-cC-c) |
| 23:34 | amalloy | joshua__: clojure, unlike CL, doesn't have a concept of eval vs compile |
| 23:34 | amalloy | if it's been compiled, it's been evaled in the repl |
| 23:34 | joshua__ | Okay. |
| 23:34 | amalloy | it doesn't paste the results, but if you eval eg a defn, that function will have changed |
| 23:35 | joshua__ | Oh, I thought it wasn't doing anything this whole time. |
| 23:35 | joshua__ | I was going to check for .jars and stuff haha |
| 23:35 | amalloy | C-c C-k evals the whole file |
| 23:39 | amalloy | joshua__: problem solved? |
| 23:39 | joshua__ | No actually. |
| 23:39 | joshua__ | It still doesn't seem to be evaluating it. Just in case it matters I'm trying to do this with something I went to using slime-connect, and I'm in clojure-mode. |
| 23:41 | amalloy | so just to isolate the interesting part, try making a new file with (ns foo) (def bar 1) |
| 23:41 | amalloy | C-c C-k that, then switch to the repl; (ns foo) <RET> bar should eval to 1 |
| 23:42 | joshua__ | Oh, your right it works. |
| 23:42 | joshua__ | =) |
| 23:43 | amalloy | hurrah! |
| 23:43 | joshua__ | For some reason I was thinking I could access the equivalent of bar from the user namespace. |
| 23:43 | joshua__ | =) |
| 23:43 | joshua__ | Thanks amalloy! |
| 23:46 | joshua__ | I'm like dancing irl at my chair because of how much fun being able to send code between a buffer and swank is. |
| 23:46 | joshua__ | So awesome. |
| 23:48 | jk_ | raek: ? |
| 23:48 | amalloy | haha, that's great joshua__ |
| 23:51 | amalloy | jk_: fyi, if you instead say "raek: ping", sexpbot will /msg you when raek gets back |
| 23:52 | jk_ | amalloy: ahh, thanks. i'm getting ready to leave very soon. but i'll make a note of that |
| 23:52 | jk_ | raek: ping |