2009-05-23
| 00:00 | danlarkin | greetings clojurecrats |
| 00:08 | cads | how do I represent a lexical context, where I have a set of co-recursive functions defined in terms of each other, and I'd like to store the bindings in a structure and possibly manipulate them later? |
| 00:11 | cads | I can represent a list of mutually non-recursive functions as a map of [:fname fn] |
| 00:11 | cads | and I guess that in the case of co-recursive functions a trampoline can be used |
| 00:12 | cads | brb |
| 00:17 | durka42 | what's the best way to make {:a 1, :b 2} into [:a 1 :b 2] (order immaterial of course) |
| 00:17 | durka42 | #(vec (flatten (seq %))) seems a little excessive |
| 00:18 | durka42 | #(vec (interleave (keys %) (vals %))) works too |
| 00:20 | danlarkin | the second one, I guess |
| 00:29 | unlink | ,(reduce concat {:a 1 :b 2}) |
| 00:29 | clojurebot | (:a 1 :b 2) |
| 00:30 | danlarkin | I like that better |
| 00:35 | durka42 | me too |
| 00:36 | durka42 | ,(apply concat {:a 1 :b 2}) |
| 00:36 | clojurebot | (:a 1 :b 2) |
| 00:38 | danlarkin | concat might reduce internally |
| 00:38 | durka42 | it does something clever that looks sort of like a reduce |
| 00:38 | durka42 | but i would have to study it to understand |
| 00:38 | durka42 | ~def concat |
| 00:47 | Raynes | XMonad is awesome. |
| 00:53 | danlarkin | hooray, pushed http://github.com/danlarkin/clojure-couchdb/ |
| 01:44 | Guest34615 | hey, how do I flatten a nested sequence? |
| 01:45 | cgrand | Guest34615: flatten in contrib or (tree-seq seq? seq '((1 2 (3)) (4))) which gives you more options |
| 01:48 | Guest34615 | ,(tree-seq seq? seq '((1 2 (3)) (4)) |
| 01:48 | clojurebot | EOF while reading |
| 01:48 | Guest34615 | ,(tree-seq seq? seq '((1 2 (3)) (4))) |
| 01:48 | clojurebot | (((1 2 (3)) (4)) (1 2 (3)) 1 2 (3) 3 (4) 4) |
| 01:50 | cgrand | hmmm no coffee yet, please wait, brain is booting |
| 01:50 | cgrand | ,(remove seq? (tree-seq list? seq '((1 2 (3)) (4)))) |
| 01:50 | clojurebot | (1 2 3 4) |
| 01:51 | Guest34615 | ,(filter #(not seq?% ) (tree-seq seq? seq '((1 2 (3)) (4)))) |
| 01:51 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args passed to: core$not |
| 01:51 | Guest34615 | ,(filter #(comp not seq? ) (tree-seq seq? seq '((1 2 (3)) (4)))) |
| 01:51 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--1679$fn |
| 01:51 | Guest34615 | ,(filter (comp not seq? ) (tree-seq seq? seq '((1 2 (3)) (4)))) |
| 01:51 | clojurebot | (1 2 3 4) |
| 01:51 | Guest34615 | heh |
| 01:54 | Guest34615 | actually I think I can use reduce concat in this case because they're nested only one level deep |
| 01:59 | xolus | Anyone out there have any experience using clojure in .NET via IKVM? I got some clojure code that I compiled to a jar, but only see the main method in the generated library from ikvmc. I want to call my other clojure functions but don |
| 01:59 | xolus | *dont see them |
| 02:11 | cgrand | Guest34615: (mapcat identity ...) or (apply concat ...) are lazy (reduce concat ...) isn't |
| 02:40 | Guest34615 | check it out http://paste.lisp.org/display/80698 |
| 02:43 | Guest34615 | by wrapping the notion of a pairwise operation between two maps of :keyword Number pairs, I'm able to create vector space operators |
| 02:45 | Guest34615 | so if I had a map of {:word frequency-of-use}, I could represent a vector of words associated to a numerical value |
| 02:45 | Guest34615 | which I could extract from a document, for example |
| 02:46 | Guest34615 | then, it would be possible to compare the distance between two document word vectors |
| 02:46 | Guest34615 | or search in a collection of documents for documents that have the same word usage profile |
| 02:52 | cgrand | Guest34615: how odes this differ from merge-with? |
| 02:52 | cgrand | (merge-with + {:a 23, :b 2, :c 6, :d 5} {:b 2, :c 6, :f 5, :g 9}) |
| 02:52 | cgrand | ,(merge-with + {:a 23, :b 2, :c 6, :d 5} {:b 2, :c 6, :f 5, :g 9}) |
| 02:52 | clojurebot | {:g 9, :f 5, :a 23, :b 4, :c 12, :d 5} |
| 02:53 | Guest34615 | oo, that's nice |
| 02:54 | cads | ,(merge-with * {:a 23, :b 2, :c 6, :d 5} {:b 2, :c 6, :f 5, :g 9}) |
| 02:54 | clojurebot | {:g 9, :f 5, :a 23, :b 4, :c 36, :d 5} |
| 02:55 | cads | ,(merge-with * {:a 23, :b 2, :c 6, :d 5} {:b 0, :c 0, :f 0, :g 0}) |
| 02:55 | clojurebot | {:g 0, :f 0, :a 23, :b 0, :c 0, :d 5} |
| 02:57 | cads | in multiplication, you'd like to take all the pairs in the maps that have the same key value, and multiply their two values. If there's only one value for a given key, or if the multiplication of the two values yields zero, then drop that key |
| 03:00 | cgrand | cads: it depends, but if you are using maps as sparse vectors then you certainly want this |
| 03:31 | cads | cgrand check this out: http://paste.lisp.org/display/80698#1 |
| 03:31 | cads | they're a kind of sparse vector |
| 03:34 | cads | how could I read a string into a map where each unique word in the string is associated to the number of times the word was in the string? |
| 03:35 | cgrand | cads: quick tip, (or (a %) 0) can be written (a % 0) |
| 03:37 | cgrand | ,(apply merge-with + (map (fn [w] {w 1}) (.split "Returns a map that consists of the rest of the maps conj-ed onto" "\\s+"))) |
| 03:37 | clojurebot | {"a" 1, "Returns" 1, "conj-ed" 1, "that" 1, "the" 2, "rest" 1, "of" 2, "maps" 1, "onto" 1, "consists" 1, "map" 1} |
| 03:38 | cads | nice |
| 03:39 | cgrand | see http://clj-me.blogspot.com/2009/04/counting-occurences-solution-to.html |
| 03:43 | cads | haha, according to my program, the above map was about 0.5 radians closer to a map extracted from the doc string of another function than it was to {"a" 3 "b" 12 "c" 10 } |
| 03:44 | cads | of course, the latter is nearly perpendicular to your map, as the only shared element is "a" |
| 03:47 | cads | the neat thing is that if we change things to (def op #(fn [a b] map % a b) (def zero (repeat 0)) (defn dot [a b] (reduce + ((op *) a b))), then we get normal vectors |
| 03:49 | cads | so that (add [1 2 3] [3 4 5 6]) => [4 6 8] or (dot (repeat 1) [0 1 1]) => 2 |
| 03:50 | cads | in this case, operations between vectors of different dimension are automatically truncated |
| 03:52 | cads | cgrand, cool post |
| 03:56 | cads | with my code, I'm trying to see how much can be factored out of the code required to represent a general linear space, so that I can generate linear space operations from a few basic parameters |
| 04:01 | cads | for example, (def op #(fn [a b] (fn [x] (% (a x) (b x))))) (def zero (fn [x] 0)) lets you add and subtract functions |
| 04:02 | cads | but the definition of dot suddenly becomes a lot more complex |
| 04:03 | cads | because the inner product between two functions is defined as an integral of the product of the functions |
| 04:04 | cads | hehe, I think prod breaks down here too |
| 05:30 | unlink | ... |
| 05:30 | unlink | this works: java -Dclojure.compile.path=$PWD/classes -classpath $HOME/Lib/clojure.jar:src:classes clojure.lang.Compile hello |
| 05:31 | unlink | but this doesn't: java -Dclojure.compile.path=classes -Djava.ext.dirs=$HOME/Lib -classpath src:classes clojure.lang.Compile hello |
| 05:31 | unlink | why? |
| 05:59 | noidi | is there a shorthand for (:require [foobar.baz.xyzzy :as xyzzy]) ? |
| 05:59 | noidi | I keep doing that a lot... |
| 06:03 | StartsWithK | unlink: do you get any error messages? |
| 06:04 | StartsWithK | noidi: i don't think there is |
| 07:20 | cemerick | shouldn't this return 5? |
| 07:21 | cemerick | ,(let [{a :a :or {:a 5}} {}] a) |
| 07:21 | clojurebot | nil |
| 08:00 | cgrand | cemerick: (let [{a :a :or {a 5}} {}] a) |
| 08:00 | cgrand | ,(let [{a :a :or {a 5}} {}] a) |
| 08:00 | clojurebot | 5 |
| 08:19 | rhickey | gnuvince: where's that node counter code? |
| 08:27 | cgrand | rhickey: http://paste.lisp.org/display/80683 ? |
| 08:28 | rhickey | thanks |
| 09:19 | minciue | hi, is anyone here using compojure with emacs and slime and clojure-mode? I was wondering if someone could help me with setting that up |
| 09:47 | gnuvince_ | rhickey: the code cgrand linked to is the one. |
| 11:57 | eliantor | hi i'm try to use parallel, but when i try to load the file parallel.clj it throws an exception |
| 11:58 | eliantor | ClassNotFoundException jsr166y.forkjoin.ParallelArray |
| 11:59 | StartsWithK | eliantor: you will need forkjoin lib |
| 11:59 | eliantor | i downloaded jsr166y.jar and added it to the claspath |
| 11:59 | eliantor | but still no luck |
| 11:59 | StartsWithK | hmm |
| 11:59 | eliantor | i also downloaded the extra jar |
| 12:00 | eliantor | because looking at the javadoc it tells that ParallelArray is in that jar |
| 12:00 | eliantor | but it doesn't work |
| 12:01 | StartsWithK | you are right, just tried it |
| 12:02 | eliantor | i'll try to give a look at parallel but i'm really new to clojure |
| 12:02 | StartsWithK | eliantor: http://is.gd/CHki |
| 12:03 | eliantor | oh thanks |
| 12:10 | lisppaste8 | durka42 pasted "fix the forkjoin imports" at http://paste.lisp.org/display/80715 |
| 12:10 | durka42 | eliantor: ^^ |
| 12:11 | eliantor | thanks durka |
| 12:34 | quidnunc | Is there a "drop-nth"? |
| 13:52 | cgrand | quidnunc: I saw you were struggling against Enlive selectors some days ago |
| 13:53 | dnolen | speaking of which ... :) ... cgrand: I guess it not possible to select a text node yet based on it's content? |
| 13:54 | cgrand | dnolen: you can... if you write your own predicate |
| 13:56 | dnolen | and it's possible to make a pred that compares the content of a node to any string? |
| 13:56 | quidnunc | cgrand: Thanks, I mostly got it sorted out. I was surprised though that for class="foo bar" you need to do (has-class "foo" "bar"). |
| 13:57 | dnolen | [:div (text= "foobar")] is possible? |
| 13:57 | cgrand | dnolen: (def match [re] (sm/pred #(and (-> % z/node string?) (re-matches re %)))) ; or something like that |
| 13:58 | cgrand | (def match [re] (sm/pred #(and (-> % z/node string?) (re-matches re (z/node %))))) ; or something more like that |
| 13:59 | kotarak | StartsWithK: Hi. I think, one cannot specify the dependencies between artifacts in Ivy. One has to use configurations to model this. Or one has to do one module per contrib module. |
| 13:59 | cgrand | quidnunc: I annotated your paste back then http://paste.lisp.org/display/80388#1 |
| 13:59 | quidnunc | Thanks cgrand. |
| 14:00 | dnolen | thanks, does it make sense to include something like this Enlive, since matching in XML documents usually requires text node matching? |
| 14:01 | cgrand | dnolen: why not, I don't know which one to include |
| 14:02 | dnolen | of the two that you just wrote? :) |
| 14:02 | cgrand | the one that works maybe? :-) |
| 14:07 | quidnunc | cgrand: How is "chaining" selectors different from intersection of the results of selectors? |
| 14:13 | cgrand | [[:div :.foo]] matches <div class="foo"> while [:div :.foo] doesn't |
| 14:16 | eliantor | join #vimclojure |
| 14:17 | eliantor | :) |
| 14:17 | eliantor | does anyone use vimclojure? |
| 14:18 | cgrand | quidnunc: [:div :.foo] matches the span <div><span class="foo"></span></div> or in <div><p><span class="foo"></span></p></div> |
| 14:18 | kotarak | yep |
| 14:18 | eliantor | is it possible to use a user.clj file to store things for the repl? |
| 14:19 | kotarak | eliantor: not at the moment. |
| 14:19 | kotarak | I can add that. |
| 14:19 | eliantor | kotarak: no other solution to reload configurations? |
| 14:19 | kotarak | eliantor: (load-file "/your/user.clj") |
| 14:20 | eliantor | yep |
| 14:20 | eliantor | ok |
| 14:20 | eliantor | anyway i really like it |
| 14:20 | cgrand | dnolen: would you be happy with (text-matches pattern-or-string)? |
| 14:21 | eliantor | i'm trying to learn clojure, and it's really a pleasure to write code in that environment |
| 14:24 | kotarak | eliantor: :) |
| 14:33 | cemerick | rhickey: it's a small thing, but: a type hint should be added to the multifn arg in defmethod, to avoid the spurious warnings when warn-on-reflection is true (it's the only multimethod-related fn that isn't type-hinted). |
| 14:41 | cgrand | dnolen: added text-pred for now |
| 14:49 | dnolen | cgrand: sounds good! |
| 16:07 | unlink | What's the idiom for transforming a seq of 2-tuples into a map? |
| 16:09 | cmvkk | (into {} ...) |
| 16:36 | dmiles | about once a week i google for "pipe stderr" and RSchulz is the first entry :) |
| 16:37 | RSchulz | My ears are ringing... |
| 16:37 | dmiles | http://www.google.com/search?q=pipe+stderr |
| 16:38 | RSchulz | Yeah. I own piping to standard error. That's from my Cygwin days. |
| 16:39 | dmiles | indeed |
| 16:40 | dmiles | hrrm clojure over IKVM is pretty nice.. however have ot make it think more in .NET types for the basic primitives |
| 16:46 | unlink | What is http://github.com/kevinoneill/clojure-contrib/tree/master ? |
| 16:48 | Chousuke | unlink: "what"? an unofficial git mirror of clojure-contrib |
| 16:49 | unlink | ok |
| 16:49 | unlink | What's the proper place to suggest patches to clojure-contrib? |
| 16:50 | Chousuke | the google group. but be aware that you need a CA to contribute patches :/ |
| 16:50 | unlink | certificate authority? |
| 16:50 | Chousuke | contributor agreement :p |
| 16:51 | unlink | oh, how do I do that? |
| 16:51 | kotarak | http://clojure.org/contributing IIRC |
| 16:51 | Chousuke | yeah. |
| 16:53 | unlink | I grant him perpetual, irrevocable, worldwide, royalty-free license to all my patents? |
| 16:54 | kotarak | *shrug* Don't have any patents and probably will never anyway... |
| 16:55 | unlink | oh |
| 16:56 | unlink | clojure and clojure-contrib is what he means by project name? |
| 16:57 | Chousuke | unlink: concerning the code you contribute, anyway |
| 16:58 | tashafa | #^Ifn |
| 16:58 | tashafa | is id #^IFn or #^Function? |
| 16:58 | tashafa | is it* |
| 16:59 | unlink | tashafa: depending on what you mean, #^clojure.lang.IFn or #^clojure.lang.Fn |
| 16:59 | unlink | Fn means (fn ...), IFn includes {}, keywords, etc |
| 16:59 | tashafa | ah |
| 16:59 | tashafa | thanks |
| 17:00 | tashafa | im trying to enforce some strong typing... is there a reference for this |
| 17:01 | tashafa | for maps, vecs, sets, etc..? |
| 17:01 | unlink | tashafa: Clojure already does enforce strong typing...if you're looking for static typing, Clojure doesn't have that. |
| 17:02 | kotarak | There is no such thing as string typing. Type hints are just hints. The compiler does not *enforce* the type, but believes the programmer that the object is actually of that type. |
| 17:02 | unlink | tashafa: Return-value tags and type hints don't enforce types, either. They only perform casts, and then only when needed. |
| 17:02 | tashafa | ah |
| 17:02 | tashafa | so when i have (defn f [#^String s]... it's just a type hint |
| 17:03 | unlink | ,((fn [#^String x] x) 1) |
| 17:03 | clojurebot | 1 |
| 17:03 | kotarak | tashafa: yes |
| 17:03 | kotarak | It's also not a cast. |
| 17:03 | unlink | however: ,((fn [#^String x] (.toUpperCase x)) 1) |
| 17:03 | tashafa | cool thanks |
| 17:03 | unlink | er... |
| 17:04 | unlink | that would give: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String |
| 17:04 | unlink | tashafa: The only purpose for those type annotations is to avoid having to reflect on objects for method/field access |
| 17:05 | tashafa | unlink: gotcha |
| 17:05 | unlink | tashafa: If you do (.foo bar), and you didn't tell clojure what type bar is, it doesn't make any effort to statically infer the type, and simply looks it up at runtime |
| 17:06 | unlink | tashafa: This comes with a big performance penalty, so you can annotate parameters and return values with a type, so instead of having to look up the type, it casts to that type at runtime. |
| 17:06 | unlink | tashafa: However this gives you only minimal type safety over reflection. It is 99% an optimization. |
| 17:14 | tashafa | i wonder why i was thinking type hints did static typing |
| 17:16 | dreish | The difference is somewhat subtle. |
| 17:24 | StartsWithK | kotarak: yes, one artifact (inside a module) can't depends on another |
| 17:24 | StartsWithK | kotarak: you will need to split modules by name to something like contrib.xml contrib.def ... and create relation between them |
| 17:24 | kotarak | StartsWithK: so one has to use either configurations or one module per contrib module. |
| 17:25 | StartsWithK | kotarak: one module |
| 17:25 | StartsWithK | so module can have artifacts like contrib-def.jar contrib-def-sources.jar contrib-def-docs.jar .. |
| 17:26 | StartsWithK | in another module you will then depend on contrib.def and only on let say aftiract sources |
| 17:27 | kotarak | -.- ant needs a for loop .... |
| 17:27 | StartsWithK | btw, i just pushed to my cloak fork new action clojurec that works like (clojurec [src-dirs] dest-dir) |
| 17:28 | StartsWithK | it scans a src-dirs for clojure namespaces definitions in clj files and compiles them |
| 17:28 | kotarak | Cool. |
| 17:28 | StartsWithK | so, not it has somethink like <javac srcdir='' destdir=''/> |
| 17:28 | StartsWithK | now* |
| 17:29 | StartsWithK | for a 'for' loop, there is a solution, in a way |
| 17:29 | StartsWithK | you could create module.xml that will have a generic build for every module (i guess they have a same build) |
| 17:30 | StartsWithK | then by using a ivy:buildlist you can construct a list of subant builds (it will order them by there deps in ivy.xml) |
| 17:30 | StartsWithK | and execute them with subant |
| 17:33 | kotarak | Yes. I know. But this was rather arkward with the current setup of contrib. |
| 17:33 | kotarak | But this was also my first experiment with Ivy. |
| 17:33 | kotarak | So maybe I should revisit this approach. |
| 17:33 | StartsWithK | yes, contrib will need to split modules in separate directories for this to work |
| 17:34 | StartsWithK | but thats a standard practice for multi-module projects any way |
| 17:34 | kotarak | Hmm.. I don't want to mess with the directory structure too much. |
| 17:35 | kotarak | At the moment it seems, that maven will be the main distribution way for clojure. |
| 17:35 | kotarak | So I think it's not an option to mangle the dir structure for an approach, which will probably not be used anyway..... |
| 17:36 | StartsWithK | i don't think it can work without it, you'll get mixed compilation units in the same directory, and there is no way to split them up later |
| 17:36 | kotarak | That's what I do now.... |
| 17:36 | StartsWithK | but maven will need a directory split too |
| 17:36 | StartsWithK | and it will go even deeper |
| 17:36 | kotarak | Ok. I don't know maven... |
| 17:37 | StartsWithK | like clojure/contrib/contrib-defs/main/src/clojure/clojure/contrib/def.clj |
| 17:37 | StartsWithK | from the top of the project tree |
| 17:37 | kotarak | I wrote an email to Rich, but haven't received an answer, yet. So I don't know what his plans are at the moment. |
| 17:37 | kotarak | I think, he's avoiding this question at the moment. |
| 17:38 | StartsWithK | if it is just about generating a .pom, ivy can generate one too |
| 17:38 | StartsWithK | if its a maven based build.. god save us all :) |
| 17:39 | kotarak | Maybe this could work: compile is it is done now. Build jars as it is done now. Provide different ivy-bla.xml files for the different modules. Loop through the ivy-bla.xml files on publish. |
| 17:41 | StartsWithK | if you don't do a aot, just sources, it could be easyer to leave current directory structure |
| 17:42 | StartsWithK | i don't know how to separate (proxy) once compiled |
| 17:42 | StartsWithK | it dosn't generates .class in clojure.xxx namespace |
| 17:42 | StartsWithK | is that a problem in contrib? |
| 17:43 | kotarak | StartsWithK: as I said: at the moment the jars are separated from the common compilation directory. The proxy things is ugly, though. It a special jars which is included in all configurations which need it... |
| 17:44 | kotarak | Oh dear.... It is a special jar .... |
| 17:44 | StartsWithK | that could be a problem on the consumer side |
| 17:44 | StartsWithK | lest say i dep on common.jar v1.0 from defs v1.0 and on common.jar v1.1 for xml v1.1 |
| 17:45 | StartsWithK | no need for me to have all modules in sync in my project |
| 17:46 | kotarak | Well. Here some resolution is needed anyway, no? xml v1.1 might also depend on defs v1.1... What now? So this is a general problem which will happen anyway. |
| 17:48 | StartsWithK | yes, but if defs v1.0 and xml v1.0 don't share any deps (take miglayout and xml), but they have a new commons.jar they are now tied together for no reason |
| 17:50 | kotarak | That's an ugliness of proxy.... |
| 17:51 | StartsWithK | and not only proxy, java has Proxy class that will do something like that (not used in contrib) and anything can use asm lib to generate bytecode (not used in contrib) |
| 17:53 | StartsWithK | i was plangin to do a ant wrapper for cloak first then ivy one, but, maybe ivy should go first |
| 17:53 | StartsWithK | planing* |
| 17:53 | StartsWithK | i know it won't be used to build a contrib |
| 17:54 | StartsWithK | but, most clojure build will be simple like get-deps -> clojurec-my-src-dir |
| 17:54 | StartsWithK | only thing that is needed is jar task from ant, more or less |
| 17:56 | StartsWithK | this is a simple build http://paste.pocoo.org/show/118763/ based on cloak clojurec that i created for some experiment yesterday |
| 17:57 | StartsWithK | it compiles a src dir and generates completitions file |
| 17:57 | StartsWithK | so, my first all clojure build :) |
| 17:57 | kotarak | hehe :) |
| 18:07 | StartsWithK | hmm.. ok, maybe a solution |
| 18:07 | StartsWithK | to preserve current directory structure |
| 18:07 | StartsWithK | in build create alternative directory strucutre just for modules |
| 18:08 | StartsWithK | so, it is as it is, but when you build it, rearange it to beat proxy problem |
| 18:08 | kotarak | Hmm.. That would be a possibility. But it would require several clojure.lang.Compile calls. |
| 18:08 | clojurebot | clojure is a very attractive hammer with a nice heft to it |
| 18:09 | StartsWithK | sure, and in a way, thas just what you want |
| 18:10 | StartsWithK | so you can compile different modules to different classes/ dirs |
| 18:10 | StartsWithK | no proxy proble, and real structure is at it was |
| 18:10 | kotarak | Hmm... |
| 18:10 | kotarak | Let's see... |
| 18:11 | Guest40739 | hey, you guys know if konrad hinsen chats here? |
| 18:12 | kotarak | Not that I am aware of it.... |
| 18:14 | dreish | Anyone have an example of using :reload-all with (ns x (:require [...]))? |
| 18:14 | dreish | I keep getting the error "No value supplied for key: true" |
| 18:15 | kotarak | (require :reload-all 'my.name.space) |
| 18:15 | dreish | Ah, thanks, outside the square brackets. That works. |
| 18:15 | slashus2 | I was trying to do the programming problem http://www.haskell.org/haskellwiki/Programming_performance and my solution seems to be very slow for some reason. Any pointers? http://paste.lisp.org/display/80730 |
| 18:17 | dreish | What does the profiler show? |
| 18:17 | slashus2 | Running it now. |
| 18:19 | slashus2 | How should I run the profiler just -Xprof ? |
| 18:19 | dreish | I see two things: 1. (map vector closing-prices ...) -- I don't see why that's needed; 2. destructuring is handy, but not optimally fast. |
| 18:19 | slashus2 | I wanted a way to easily get at the previous closing price. |
| 18:20 | dreish | Oh, I see, I was misreading that. Still, that doesn't look like the fastest way to do that. |
| 18:21 | dreish | I think something like (map #(take 2 %) (take-while identity (iterate rest closing-prices))) might be faster. |
| 18:21 | slashus2 | I tried with destructuring and without. It didn't seem to make much difference. |
| 18:22 | dreish | man java gives some examples for using the profiler. |
| 18:22 | slashus2 | I just did -Xrunhprof |
| 18:22 | slashus2 | It gave a lot |
| 18:23 | dreish | Actually, I guess it just has a URL with some more extensive documentation. |
| 18:24 | slashus2 | I cut it down quite a bit just type hinting a few strings. |
| 18:24 | cads | what is the lisp ide that has that feature where the code is turned into a mini-bitmap that lets you scroll through large amounts of code while still seeing the code's shape? |
| 18:26 | StartsWithK | cads: i don't know a name, but maybe you are refering to a demo for scheme language where they manipulate a code with a mouse as different shapes? |
| 18:26 | cads | I think it's in dr-scheme, actually |
| 18:27 | cads | moving code around like that would be scary to me :) |
| 18:27 | StartsWithK | we need something like that :) |
| 18:28 | cads | I want something that takes one of my one-liners and converts it to multi-line indented code of the type that I write for quick understanding |
| 18:28 | StartsWithK | cads: pprint in contrib maybe? |
| 18:28 | cads | it's wierd how I can parse code by shape now |
| 18:30 | cads | lisp is such a blessing with no delimiters in lists or hashes, and the square braces for vectors really make things like function definitions and lets very easy to read |
| 18:31 | cads | i'll try it out |
| 18:55 | replaca | cads: if you use pprint, use *code-dispatch* for code |
| 19:08 | kotarak | StartsWithK: it seems to work :) |
| 19:08 | StartsWithK | kotarak: :) |
| 19:09 | kotarak | added module subdir with subdirs for every module contain a small build.xml sourcing the common.xml at toplevel as well as an ivy.xml giving the deps. |
| 19:09 | StartsWithK | kotarak: will you paste your build on ml soon? |
| 19:10 | StartsWithK | i would like to look at that, so i can model cloak based on it |
| 19:10 | kotarak | StartsWithK: Hopefully. It works only partially but I will move the whole thing. I'm pretty busy tomorrow, but maybe I can hack something up for tomorrow evening. |
| 19:11 | StartsWithK | ne rush, i don't think i can add a ivy wrapper in a day |
| 19:11 | kotarak | Currently c.c.def, lazy-seqs and lazy-xml work. |
| 19:11 | kotarak | proxy is tamed with this setup. :) |
| 19:11 | StartsWithK | :) |
| 19:13 | kotarak | Oerk. Now comes all the moisture for providing custom ivy.xml and build.xml for each module..... :/ |
| 19:15 | StartsWithK | maybe you could use clojure.xml for that |
| 19:16 | StartsWithK | like alldeps.clj with clojure encoded ivy descriptions, and just emit them to right places before you build modules |
| 19:16 | StartsWithK | (def def-deps [{:org o :name n :rev r :arfifacts []}]) |
| 19:16 | kotarak | Hmmm... yeah. That would be a possibility. |
| 19:17 | StartsWithK | it will be much shorter than xml files, and not scatered all around |
| 19:27 | blbrown | is clojure.lang.Script in clojure 1.0 |
| 19:27 | kotarak | I think it's superseded by clojure.main |
| 19:42 | StartsWithK | kotarak: http://paste.pocoo.org/show/118780/ something like this maybe (unfinished) |
| 19:45 | kotarak | Ok. This is more sophisticated. (and probably the Right Way). Was about to use format, but you are right. Thanks for the snippet. |
| 20:27 | Raynes | One of the HWN quote's of the week: "roconnor: Damn it, I don't know how to make this as slow as python." |
| 20:52 | chessguy | anybody know of a good example of using proxy to create an instance of an interface? particularly an interface with a function that returns void |
| 20:54 | StartsWithK | (gen-interface :name my.org.ISomething :methods [[foo [] void]]) (proxy [my.org.ISomething] [] (foo [] (println "I think this will work"))) |
| 20:57 | chessguy | ,(proxy [(gen-interface :name ns :methods [[foo [] void]])] [] (foo [] (println "test"))) |
| 20:57 | clojurebot | java.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol |
| 21:02 | Chouser | no, gen-interface is compile-time only |
| 21:03 | Chouser | you have an inteface already? |
| 21:03 | Chouser | clojurebot doesn't let you use proxy anyway |
| 23:28 | blbrown | http://paste.lisp.org/display/80734 what is wrong with this code, referencing a member of an object |
| 23:28 | durka42 | the evt/gc syntax is for static members |
| 23:28 | clojurebot | for is a loop...in Java |
| 23:28 | durka42 | you want (.gc evt) |
| 23:28 | blbrown | cool |