2010-10-03
| 01:58 | sam1234 | j |
| 01:59 | amalloy | sam1234: k? |
| 01:59 | sam1234 | accidently pressed enter |
| 02:08 | shachaf | sam1234: Or perhaps ^J? |
| 02:53 | amalloy | technomancy: no more TeX? you get that problem figured out, then? |
| 04:02 | ashleyw_ | Hi, is there a way to expand a vector of values into the arguments of a method? e.g. something like this http://pastie.org/1196308 |
| 04:08 | LauJensen | ashleyw: Im not 100% sure what you're trying to do, but generally I'll recommend you to use reduce instead of apply if you want t communicate that you're doing some kind of accumulation (instead of spreading of args). If you simply want to add all of the numbers given in 2 vectors, you could |
| 04:09 | LauJensen | (defn addnums [[a b]] |
| 04:09 | LauJensen | (+ (reduce + a) |
| 04:09 | LauJensen | (reduce + b))) |
| 04:09 | LauJensen | Where the argumentlist itself is splitting the vector into 2 subvectors. Otherwise, make some kind of flattening operation |
| 05:53 | _ulises | morning all |
| 05:54 | raek | mornin' |
| 06:33 | zmyrgel` | how can I specify that I want symbols value? |
| 06:33 | zmyrgel` | I have defined some symbols as (def NORTH 1), (def SOUTH -1) etc. |
| 06:34 | _ulises | and you want the 1 for NORTH? |
| 06:34 | zmyrgel` | then I get error "can't cast Symbol to Number" in code like (map #(some-function x %) directions) |
| 06:34 | zmyrgel` | directions is a list of (NORTH SOUTH) |
| 06:35 | zmyrgel` | I assumed it would use the values of the symbols and not the symbols themselves |
| 06:35 | mrBliss | zmyrgel`: try a vector instead of a list |
| 06:36 | mrBliss | zmyrgel`: or (list NORTH SOUTH) |
| 06:36 | mrBliss | zmyrgel`: you're probably quoting your list, so the symbols don't get evaluated |
| 06:36 | zmyrgel` | mrBliss: yep, just noticed the quoting thing |
| 06:37 | raek | (def north 1) (def south -1) (def directions [north south]) (map #(some-function x %) directions) |
| 06:37 | _ulises | this seems to work for me: http://pastebin.com/1n8vxhjC |
| 06:37 | _ulises | but maybe I'm not understanding the question :/ |
| 06:37 | _ulises | (yes, I used a vector instead of a list) |
| 06:39 | raek | zmyrgel`: be sure that you understand the difference between (a b c), '(a b c) and (list a b c) |
| 06:39 | zmyrgel` | raek: yep, I know that. I just had made the error some time ago |
| 06:42 | zmyrgel` | is there any good method of profiling code in clojure? |
| 06:43 | mrBliss | zmyrgel`: visualvm is quite easy |
| 07:25 | LauJensen | How is the Clojure-Android story ? |
| 07:29 | kjeldahl | Is there a new story? The most up-to-date info I've found (with references to github etc) is here: http://stackoverflow.com/questions/973386/android-adverse-to-dynamic-languages |
| 07:30 | LauJensen | kjeldahl: I don't know what the official story is on GC, but I know its fixed in several proprietery alternatives to Dalvik |
| 07:49 | leafw | is there any lazy reverse fn? |
| 07:51 | LauJensen | not possible |
| 07:51 | leafw | I believe you, but is there any ratinale wy |
| 07:51 | leafw | why |
| 07:52 | leafw | also: why :^static fn can only accept ^long and ^double, and not ^int for example, in its args? |
| 07:55 | cemerick | leafw: because ^int doesn't give you anything beyond what ^long does. |
| 07:55 | leafw | cemerick: you mean performance-wise, they are identical? |
| 07:56 | leafw | I can believe that in 64-bit CPUs. Fair enough. |
| 07:56 | cemerick | Most JVMs are optimized for doubles and longs these days, yeah. |
| 07:56 | cemerick | But that's not the point. |
| 07:56 | leafw | math with float is faster than with double. Test it yourself. |
| 07:56 | leafw | (in java world, at least) |
| 07:58 | cemerick | the Sun jvm is biased towards doubles. Heard it from someone at Sun with my own ears. |
| 07:58 | cemerick | Regardless, that's not all that went into it. |
| 07:58 | LauJensen | leafw: If you have a sequence X which you want to reverse, you have to start with the last element in that list. To realize that last element, you also need to realize all the elements leading up to it, hence we're no longer lazy |
| 07:59 | leafw | cemerick: float is faster (and less accurate). That's a fact. |
| 07:59 | cemerick | Well, if *you* say so, then I guess so. :-P |
| 07:59 | leafw | LauJensen: but if one has a list of objects that are all realized, i.e. a non-lazy list, then reverse could be lazy, returning them as it goes. Or is it that what it does current? |
| 08:00 | LauJensen | leafw: Wouldn't change anything |
| 08:00 | leafw | LauJensen: ok |
| 08:00 | leafw | cemerick: YMMV. I work with float[] images ... math is about 1.5x faster than with double[]. |
| 08:02 | cemerick | leafw: This is an undecidable point with just the two of us dropping anecdotes. |
| 08:02 | cemerick | And entirely unrelated to the question of :^static's impl. |
| 08:02 | LauJensen | leafw: As I recall, Richs argument was that doubles on the JVM are now typically as fast, sometimes faster than floats |
| 08:04 | leafw | LauJensen: thanks. |
| 08:07 | LauJensen | np |
| 08:10 | kjeldahl | LauJensen: Regarding Dalvik, your information is probably more updated than mine. |
| 08:19 | _ulises | how can I dispatch mult-methods based on some property of their 2nd argument? i.e. if i do (defmulti foo :type) then :type is used on the first arg. passed to foo, not its second |
| 08:26 | AWizzArd | _ulises: (defmulti foo (fn [arg1 arg2] [(> arg1 arg2) (class arg2)])) |
| 08:27 | _ulises | oh! so I could just do (defmulti foo (fn [_ p2] (:type p2))) |
| 08:27 | _ulises | excellent! |
| 08:27 | AWizzArd | yes |
| 08:27 | _ulises | thanks :) |
| 08:28 | AWizzArd | first the defmulti is called, and its return value is compared with all defmethods that are available. The right one is selected and then this specific foo is called again with the original arguments |
| 08:30 | _ulises | so first the defmulti is called with all the arguments passed? |
| 08:30 | _ulises | and then the appropriate method is called, again, depending on the result of the dispatch-fn, with all the arguments passed? |
| 08:33 | tobiasraeder | is it possible to (deftype person [proxy firstname lastname] ...) and then do something like (person. "firstname" "lastname")? |
| 08:33 | leafw | tobiasraeder: use defrecord for that |
| 08:34 | tobiasraeder | @leafw i need to use deftype tho since defrecord doesnt support :volatile-mutable afaik |
| 08:35 | leafw | it doesn't :) that's why defrecord is so useful. With deftype and volatile-mutable, you are back into mutable java world. |
| 08:35 | leafw | but you knew that already, nm. |
| 08:35 | tobiasraeder | yeah, but since this is a huge java interop thing im working on i don't really have a way to bypass it :/ |
| 08:36 | LauJensen | tobiasraeder: Looks like its possible with a factory fn ? |
| 08:37 | tobiasraeder | @LauJensen yeah i guess so |
| 08:51 | LauJensen | Any tomcat buffs in here ? |
| 09:13 | raek | tobiasraeder: just out of curiosity: did you try the atom solution? if so, what lead you to your decision? |
| 09:30 | tobiasraeder | @raek im using deftype with :volatile-mutable now because it seems to fit what i need really |
| 09:32 | jaley | Hi guys, anyone able to help out a leiningen newb quickly? |
| 09:33 | tobiasraeder | just go ahead ;) |
| 09:33 | Bahman | Hi all! |
| 09:33 | jaley | i've created a projected added dependencies for compojure, enlive and ring, plus dev-dependencies for swank-clojure, when I run lein deps I get an exception for an attempt to use nth on a Symbol |
| 09:34 | tobiasraeder | @jaley can u put your project.clj into a gist or something of that sort? |
| 09:34 | jaley | sure, off to pastebin, brb |
| 09:36 | jaley | @tobiasraeder http://pastebin.com/Urh0x7SJ |
| 09:36 | raek | jaley: wrap [swank-clojure "1.2.0"] in another vector |
| 09:36 | tobiasraeder | you need a second pair of [] around your [swank-clojure "1.2.0"] |
| 09:37 | tobiasraeder | since the dev dependencies are a vector of dependencies aswell |
| 09:37 | tobiasraeder | so it should be :dev-dependencies [[swank-clojure "1.2.0"]]) |
| 09:37 | jaley | @raek @tobiasraeder that got it, thanks guys |
| 09:43 | tobiasraeder | is it possible to generate a vector of java object instances in a macro? |
| 09:44 | _ulises | is there an alternative to re-starting the swank process whenever one needs to redefine things such as multi-methods? |
| 09:45 | Raynes | (ns-unmap *ns* 'multi) |
| 09:46 | _ulises | thanks! :) |
| 09:50 | tobiasraeder | is there a way to have a function return (MyJavaClass. "parameter") ? |
| 09:52 | raek | tobiasraeder: you want the class to be given as an argument? |
| 10:00 | raek | tobiasraeder: (.newInstance (.getConstructor MyJavaClass (into-array Class [String])) "parameter") |
| 10:00 | Raynes | http://stackoverflow.com/questions/3748559/clojure-creating-new-instance-from-string-class-name |
| 10:01 | tobiasraeder | thanks :) i managed to get it to work a bit different, ill gist it real quick. comments are more than welcome |
| 10:03 | tobiasraeder | http://gist.github.com/608591 |
| 10:34 | tobiasraeder | if i have something along those lines (defn myfn [name] '(MyClass. name)) is there any way to get the value of name as first parameter to MyClass. without making it a macro? |
| 10:37 | _ulises | can I get your thoughts on "purely functional data structures" by Chris Okasaki? (if anybody has read it) |
| 10:50 | raek | tobiasraeder: with java's reflection API, I think you can |
| 10:51 | raek | either by doing something like what I posted before, or by using clojure.lang.Reflector/invokeConstructor |
| 10:52 | raek | that will not result in any Clojure code that uses the (MyClass. name) syntax, though |
| 10:52 | tobiasraeder_ | back |
| 10:53 | tobiasraeder_ | @raek the problem was the quoted form didnt evaluate the name parameter (obviously) |
| 10:53 | raek | tobiasraeder: http://pastebin.com/zWTU6NVf |
| 10:53 | tobiasraeder_ | @raek the (for me) easiest solution seems to be (defn myfn [name] `(MyClass. ~name)) |
| 10:54 | raek | yes, a macro solution would be one of the simplest ways, I think |
| 10:54 | tobiasraeder_ | well its a function since i wanna pass it to a map inside another macro |
| 10:54 | raek | `Integer |
| 10:54 | raek | ,`Integer |
| 10:54 | clojurebot | java.lang.Integer |
| 10:54 | tobiasraeder_ | i just didnt realize you could do `~ etc in fns aswell |
| 11:11 | jaley | can defrecord take a doc string? |
| 11:19 | raek | jaley: no. the doc strings goes on the protocols. |
| 11:20 | raek | just like docstrings goes on the defmulti rather than the defmethods |
| 11:20 | jaley | @raek right.. that makes me think perhaps i shouldn't use a record for plain old data? |
| 11:21 | raek | records are plain old data, with a type |
| 11:22 | raek | but if you don't need dynamic dispatch on type, records might be overkill |
| 11:22 | jaley | @reak ok.. as i was hoping - but it doesn't make sense to document them? |
| 11:22 | raek | what a method should do is defined by the protocol |
| 11:23 | jaley | @raek yeah, but I just wanted to note what a collection of fields represent. guess it's doesn't really matter |
| 11:24 | raek | I usually describe "data contracts" in the ns docs |
| 11:24 | tobiasraeder_ | can you define a macro that in turn defines a function like that: (defn create-<firstparameter-of-macro> [& args] (new <firstparameter-of-macro> args)) ? |
| 11:24 | tobiasraeder_ | i seem to fail horribly :/ |
| 11:24 | jaley | @raek that works - thanks |
| 11:25 | raek | for example, a x-map is a map that has the :a, :b and :c keys, which has the meaning... |
| 11:26 | raek | statically typed languages has the advantage that the type is the intuitive place to put the docs at |
| 11:26 | raek | but clojure does very much or most of it's things without types |
| 11:27 | jaley | @raek yeah that makes sense, i was just look for a sensible place to document what a bunch of fields meant. the ns docstring will be fine |
| 11:28 | raek | jaley: an example: http://github.com/raek/quirclj/blob/master/src/se/raek/quirclj/message.clj |
| 11:30 | mrBliss | tobiasraeder_: my try: (defmacro defn-create [x] (list 'defn (symbol (str "create-" x)) (vector '& 'args) (list 'new `~x 'args))) |
| 11:31 | raek | tobiasraeder_: the problem with the 'new' special form is that you cannot 'apply' it |
| 11:31 | mrBliss | tobiasraeder_: I wouldn't use it though ;-) |
| 11:32 | tobiasraeder_ | @raek in which sense "apply"? |
| 11:32 | raek | mrBliss: when calling (create-foo 1 2 3), wouldn't that try to call (new foo [1 2 3]) instead of (new foo 1 2 3)? |
| 11:33 | mrBliss | raek: that's what tobiasraeder_ asked |
| 11:34 | mrBliss | a better solution: http://gist.github.com/608662 (not mine) |
| 11:34 | raek | I think using java's reflection capabilities is the only general approach |
| 11:35 | raek | unless you have fixed arities for your constructors |
| 11:35 | tobiasraeder_ | well i know the arguments that will be passed to the ctor in the macro, yes |
| 11:36 | raek | if you have a seq s of arguments to a function f, you invoke the function with (apply f s) |
| 11:36 | Raynes | http://stackoverflow.com/questions/3748559/clojure-creating-new-instance-from-string-class-name I did the same thing in my answer. It doesn't work quite as well as I'd hoped though (read the comments). |
| 11:37 | raek | but with a special form like new, there is no such apply function |
| 11:37 | tobiasraeder_ | alright, thank you |
| 11:58 | _ulises | what's the best way of making a single parameter entirely optional? is it using ? |
| 11:58 | _ulises | or &? |
| 12:00 | raek | one way is (defn foo ([x] (foo x 0)) ([x y] (+ x y))) |
| 12:01 | raek | another way could be (defn foo [x & [y]] (+ x (or x 0))) |
| 12:03 | mrBliss | ,(binding [inc dec] (map inc [1 2 3])) |
| 12:03 | clojurebot | (0 1 2) |
| 12:03 | mrBliss | ,(binding [inc dec] (map #(inc %) [1 2 3])) |
| 12:03 | clojurebot | (2 3 4) |
| 12:03 | raek | or (defn foo [x & more] (+ x (get more 0 0))) |
| 12:04 | jaley | is there a quick way of sending an (in-ns <current namespace>) to the repl with swank? |
| 12:04 | raek | (some math operations are static functions, and are optimized by the compiler) |
| 12:04 | mrBliss | How can I make my second form do the same as the first? (difference: rebound var inside a anonymous function) |
| 12:04 | mrBliss | jaley: C-c M-p |
| 12:05 | jaley | mr8liss: merci beaucoup |
| 12:06 | mrBliss | solving my problem ^^ would make testing some functions a whole lot easier |
| 12:07 | raek | maybe something like (ns ... (:refer-clojure :exclude (inc))) (def inc clojure.core/inc) |
| 12:08 | _ulises | raek: thanks |
| 12:09 | mrBliss | raek: seems to work in my example, I'll try to incorporate it in my tests. Thanks |
| 12:09 | raek | _ulises: I think the first one is the most common |
| 12:10 | _ulises | excellent, thanks again. |
| 12:11 | rrc7cz` | how can you apply on a Java method? something like (apply (.fillRect gfx) [10 10 20 20])? |
| 12:11 | raek | mrBliss: some of the functions in clojure.core is allowed to be inlined. by making the ns of the var being something else than clojure.core, the compiler will not do any of those optimizations |
| 12:12 | mrBliss | raek: it was just an example, I only have to rebind my own functions |
| 12:12 | raek | then it should always work. |
| 12:13 | raek | ,(binding [first second] (map first [[1 2] [3 4]])) |
| 12:13 | clojurebot | (2 4) |
| 12:14 | raek | ,(binding [first second] (map #(first %) [[1 2] [3 4]])) |
| 12:14 | clojurebot | (1 3) |
| 12:14 | raek | hrm |
| 12:14 | raek | maybe this behaviour happens for all vars in clojure.core |
| 12:14 | raek | ,(binding [first second] (doall (map #(first %) [[1 2] [3 4]]))) |
| 12:14 | clojurebot | java.lang.StackOverflowError |
| 12:15 | mrBliss | raek: it's actually quite complicated: the functions I need to rebind are private, in another namespace and I need to use them in the functions that replace them. I might have some problems later when I'll have to rebind functions in futures and pmaps... |
| 12:16 | raek | private functions can be used from other namespaces with @#'the-fn |
| 12:16 | raek | very useful in testing... |
| 12:16 | mrBliss | I'm using with-private-fns for that |
| 12:17 | raek | anyway, lookout for binding things in clojure.core and using binding with lazy sequences |
| 12:18 | raek | if the lazy sequences escape out of the binding form, the any usage of the rebound var in the lazy seq will see the "outer" value |
| 12:19 | raek | mrBliss: also, have you seen this? http://github.com/marick/Midje |
| 12:22 | mrBliss | I only need it in my tests, so I don't think I'll run into that problem. Yes I've seen Midje and put it on my todo list. But I'd rather switch to lazy-test when that's final. Thanks for the help |
| 12:25 | solussd_ | hm. when did clojure start supporting metadata on functions? |
| 12:26 | raek | in 1.2 |
| 12:26 | solussd_ | neat |
| 12:34 | ldhanson2 | i've got a map on which I call (keys my-map), which gives me a clojure.lang.APersistentMap$KeySeq. I'm trying to use do/recur to loop through each key in the sequence, but calling 'first' on the key sequence gives "java.lang.ClassCastException: clojure.lang.PersistentHashMap cannot be cast to java.util.Map$Entry at clojure.lang.APersistentMap$KeySeq.first (APersistentMap.java:130)". Am I missing something? |
| 12:39 | mrBliss | ldhanson2: can you post the code? |
| 12:56 | ldhanson2 | mrBliss: i'm currently trying to isolate the code to reproduce it, it's not occurring in simple test scenarios. doing so may well help me discover the problem, but i was hoping it rang a bell for somebody |
| 12:59 | mrBliss | ldhanson2: rather strange error message |
| 13:02 | ldhanson2 | mrBliss: indeed. before I call first on it i even (assert (seq? keyseq)) so one would think that's not a problem |
| 13:09 | carkh | a question about protocols and namespaces : i have a protocol Matcher in namespace A, it has a single method "match". I want to use it from namespace B but i have reflection warnings. Is there a way to "import" the protocol into namespace B so that i don't have to type hint with the fully qualified and very long name of namespace A ? |
| 13:28 | carkh | so here is the answer to my question : do not use the namespace A as the Matcher name will be to the var created by the defprotocol form |
| 13:29 | carkh | inted i need to require the namespace, then import A.Matcher |
| 13:29 | carkh | instead* |
| 13:29 | carkh | which is quite a lot of work =/ |
| 13:31 | bhenry | carkh i'm pretty sure you can import just the matcher without the require, unless you need other stuff in namespace A. |
| 13:32 | carkh | i get a class not found |
| 15:16 | tobiasraeder_ | Anyone got an idea why i might get "Class clojure.lang.Reflector can not access a member of class MyObjectProxy with modifiers "public"" when i try to create an instance of MyObjectProxy? |
| 15:17 | tobiasraeder_ | it got a public constructor (whcih is pretty obvious i guess) which im trying to call |
| 15:19 | tobiasraeder_ | solved it |
| 16:01 | leafw | is zipmap lazy? |
| 16:02 | leafw | it's doing a loop/recur ... likely not |
| 16:02 | leafw | or is loop lazy? |
| 16:02 | AWizzArd | not lazy |
| 16:02 | AWizzArd | loop + recur = goto |
| 16:02 | leafw | thanks |
| 16:03 | leafw | I just blowed up 12 Gb of RAM, and I was wondering. zipmap looks like the problem |
| 16:03 | leafw | also: is (apply merge-with + ... not lazy either? I.e. will all maps be generated, and then apply applies? |
| 16:03 | AWizzArd | leafw: how much RAM do you have in your box? |
| 16:04 | leafw | this one has 16 Gb |
| 16:04 | AWizzArd | nice |
| 16:04 | leafw | useful :) |
| 16:04 | AWizzArd | ahead the average |
| 16:04 | leafw | oh no, this machine is actually small here. Standard is more like 24 or higher |
| 16:05 | hiredman | the only lazy thing in clojure is lazy-seqs |
| 16:05 | leafw | hiredman: map is lazy, reduce is lazy ... or arent' they? |
| 16:05 | hiredman | well my laptop has 8 gigs, so … |
| 16:05 | AWizzArd | also very nice |
| 16:05 | leafw | a laptop with 8 Gb is a treat |
| 16:05 | hiredman | map produces a lazy seq so it is lazy |
| 16:05 | hiredman | reduce is not lazy |
| 16:05 | leafw | hiredman: what about reduce? |
| 16:05 | leafw | ok |
| 16:05 | leafw | thanks |
| 16:05 | hiredman | the only lazy thing in clojure is lazy-seqs |
| 16:05 | AWizzArd | in 1990 a real good computer had maybe 8 mb of RAM, so we got a factor of 1000 in two decades :) |
| 16:06 | AWizzArd | every two years a doubling, which will give us average RAM of around 100 gb by the end of this decade |
| 16:06 | hiredman | to be fare I *had* to buy more ram because right now even with 8gigs I only have 90mb free |
| 16:06 | hiredman | fair |
| 16:06 | AWizzArd | uhm, what are you doin? :) |
| 16:07 | leafw | hiredman: "for" is also lazy |
| 16:07 | AWizzArd | Btw, a very good time to buy ram now, very nice price |
| 16:07 | hiredman | leafw: for produces a lazy-seq |
| 16:07 | leafw | I see |
| 16:07 | hiredman | the only lazy thing in clojure is lazy-seqs |
| 16:07 | leafw | hiredman: I get it :) |
| 16:07 | AWizzArd | for is built with lazy-seq's under the hood |
| 16:08 | leafw | do all fn that return a lazy-seq are labeled as lazy in their docs? |
| 16:08 | leafw | is there a list of lazy fn to look at? |
| 16:08 | AWizzArd | leafw: you can do (source your-fn) and have a quick look |
| 16:08 | leafw | AWizzArd: (find-doc "lazy") lists a few |
| 16:08 | AWizzArd | There is no regularity in the docs I think |
| 16:11 | jaley | hey guys - i was wondering.. what's the best way to organize test data files in a leiningen project? can i somehow avoid making assumptions about the working directory? |
| 16:13 | jk_ | AWizzArd: where does "source" come from? if i type (source _something_) in the repl, source is not found |
| 16:14 | freakazoid | has anyone built a transactional map yet? one where concurrent updates, including inserts and deletes, to different keys don't conflict? |
| 16:14 | freakazoid | I've thought of a way to do it but I wanted to make sure it hadn't already been done first |
| 16:18 | technomancy | jaley: usually you just have the same structure but with _test.clj tacked on to the end |
| 16:18 | technomancy | each implementation namespace corresponds to one test namespace |
| 16:22 | jaley | @technomancy yeah actually I wanted to have some extra text files with test data in them |
| 16:22 | technomancy | jaley: test-resources is for those |
| 16:22 | jaley | @technomancy and was wondering if there's a standard place to keep test data |
| 16:22 | leafw | ok, so it's clear: apply is evil ... realizes all sequences first, then applies. |
| 16:23 | jaley | @technomancy ah ok, in the root of the test folder? is there some documentation about this somewhere that i've missed? |
| 16:23 | technomancy | jaley: in the root of the project |
| 16:23 | jaley | @technomancy great - thanks! |
| 16:23 | technomancy | it's documented in sample.project.clj; I guess it should be in the tutorial too |
| 16:25 | jaley | @technomancy it's fine - i even had that open in another tab, just totally missed it (d'oh!). thanks again |
| 16:25 | technomancy | sure |
| 16:30 | chouser | leafw: just got here, but ... what? apply is lazy. |
| 16:30 | leafw | chouser: then I don't get it. Now it's churning away at 1 GB of RAM ... no more blowing up |
| 16:30 | chouser | that is, apply doesn't realize the seq you give it any more than is required by the function you're passing it to. |
| 16:31 | leafw | let me paste it somewhere |
| 16:32 | chouser | ,(let [f (fn [a b c & more] (+ a b c (first more)))] (apply f (range 10))) |
| 16:32 | clojurebot | 6 |
| 16:32 | chouser | er |
| 16:32 | chouser | ,(let [f (fn [a b c & more] (+ a b c (first more)))] (apply f (range))) |
| 16:32 | clojurebot | 6 |
| 16:32 | leafw | wasn't there a paste bin where #clojure was listed? not paste.lisp.org? |
| 16:32 | chouser | leafw: paste.lisp.org or gist.github.com |
| 16:33 | leafw | thanks |
| 16:35 | chouser | ah, apply on merge-with will consume the whole seq |
| 16:35 | leafw | http://gist.github.com/608905 |
| 16:36 | chouser | the problem there is merge-with, which returns a map, and maps aren't lazy. |
| 16:36 | technomancy | it's not that apply is lazy, it's that lazy functions can be applied |
| 16:36 | leafw | any nicer ways to write the second version? |
| 16:37 | chouser | if any link in the chain is eager, the input seq will be fully realized. apply won't do that, but something else (like merge-with) certainly can. |
| 16:37 | leafw | chouser: I was expecting merge-with to only care about two maps at a time |
| 16:37 | chouser | intersting. reduce will certainly realize the whole input seq to |
| 16:37 | leafw | and to forget all maps that it has already seen |
| 16:37 | chouser | too |
| 16:37 | chouser | hm |
| 16:38 | leafw | well, at least I have a solution, but it's not pretty to say the least |
| 16:39 | leafw | I'm computing node centrality in a tree (graph without loops) that represents a neuron ... looks way cool in 3D |
| 16:41 | chouser | :-) I'm sure |
| 16:47 | AWizzArd | leafw: how deep is your tree? |
| 16:52 | leafw | AWizzArd: about 3000 nodes |
| 16:52 | leafw | with 88 branch points |
| 16:54 | AWizzArd | so, do you mean the deepest point is 88 nestings? |
| 16:56 | AWizzArd | leafw: (reduce (fn [l _] (cons l ())) (range 88)) or range 3000? |
| 16:58 | leafw | no, deepest degree is about 500 or so |
| 16:59 | AWizzArd | ok |
| 17:06 | chouser | hm, well I don't see where merge-with would be holding the head of the seq. |
| 17:08 | alistairk | Can anyone point me (a Clojure newbie) in the right direction to install Clojure 1.2 with Emacs on Ubuntu 10.04 |
| 17:08 | alistairk | ? |
| 17:09 | leafw | chouser: no idea either. The whole script is here: http://github.com/acardona/Fiji-TrakEM2-scripts/blob/master/TrakEM2/backbone_.clj |
| 17:09 | AWizzArd | alistairk: the Emacs Starter Kit could be a good point to start |
| 17:09 | AWizzArd | alistairk: basically you download a folder .emacs.d and put it into your home, and make sure that there is no .emacs file in your home. |
| 17:10 | technomancy | alistairk: cljr is a nice place to start experimenting, then once you want to create a project look at leiningen |
| 17:10 | technomancy | also relevant: http://www.assembla.com/spaces/clojure/wiki?id=clojure&wiki_id=Getting_Started_with_Emacs |
| 17:12 | alistairk | Thanks guys - I'll check your suggestions out. The problem is specifically with Clojure 1.2 - I have Emacs and Clojure 1.1 working |
| 17:12 | alistairk | but obviously want to start playing with Clojure 1.2 |
| 17:12 | alistairk | ;-) |
| 17:12 | jaley | what would cause a NoSuchMethodError <init> when trying to instantiate a record? :s |
| 17:13 | technomancy | it should be easy to swap in 1.2 in your project.clj |
| 17:16 | leafw | good night all |
| 17:16 | leafw | thanks for the help and the company. |
| 17:26 | jaley | hm weird. i did a lein clean and recompiled and the problem went away |
| 17:26 | jaley | it's nice when that happens |
| 17:32 | florianjunker | Is there some way to use leiningen with a SOCKS proxy? |
| 17:40 | alistairk | (progn (load "/home/alistairk/.emacs.d/elpa/slime-20100404/swank-loader.lisp" :verbose t) (funcall (read-from-string "swank-loader:init")) (funcall (read-from-string "swank:start-server") "/tmp/slime.7839" :coding-system "iso-latin-1-unix")) |
| 17:40 | alistairk | Clojure 1.2.0 |
| 17:40 | alistairk | user=> java.lang.Exception: Unable to resolve symbol: progn in this context (NO_SOURCE_FILE:1) |
| 17:41 | technomancy | alistairk: you're launching slime in some way that assumes you're working with common lisp |
| 17:41 | technomancy | have you read the swank-clojure readme? |
| 17:41 | alistairk | Sorry, will do. Is Emacs Starter Kit 'compatible' with Clojure 1.2.0? |
| 17:42 | technomancy | sure; they're orthogonal |
| 17:42 | alistairk | Brilliant! Thanks for your patience... |
| 17:42 | alistairk | I'll get there ;-) |
| 17:45 | alistairk | technomany: by the way - I like how the Emacs Starter Kit configures Emacs - very nice |
| 17:46 | alistairk | Installing Leiningen... |
| 17:55 | lpetit | Hmmm |
| 17:57 | lpetit | I need help understanding Open source license issue |
| 17:58 | lpetit | Say I have written a program under the EPL. This program includes an antlr grammar for clojure. |
| 17:59 | lpetit | Now I see the antlr grammar has been included into another program. This program is not licensed under EPL at all. Sort of a BSD-like "own copyright without any guarantee, etc." |
| 17:59 | lpetit | A |
| 18:00 | lpetit | At least there's credit for my work in a ATTRIBUTION.txt file. |
| 18:00 | alistairk | Installed Leiningen. Added the swank-clojure "1.2.1" dependency to the project.clj file and ran 'lein swank [PORT=4005] [HOST=localhost]' |
| 18:00 | lpetit | Isn't this a violation of the EPL ? |
| 18:00 | lpetit | I'm referring to this : http://www.eclipse.org/legal/eplfaq.php#USEINANOTHER |
| 18:00 | alistairk | Exception in thread "main" java.lang.NumberFormatException: For input string: "[PORT=4005]" (NO_SOURCE_FILE:1) |
| 18:00 | carkh | lpetit: i think they can use your work, but need to include the license for that part |
| 18:00 | Chousuke | lpetit: well at least the antlr grammar should be licenced under the EPL AFAIK. |
| 18:01 | lpetit | it's part of ccw and ccw is licensed under EPL. |
| 18:01 | alistairk | Does that mean that I have to download the Swank Clojure source first (it doesn't download it?)??? |
| 18:01 | chouser | lpetit: I think that is a violation |
| 18:01 | alistairk | Guys, is this the right place for me to be asking these questions? |
| 18:01 | carkh | yep they cannot change the license of your code |
| 18:02 | lpetit | carkh: they did not, or it's very well hidden |
| 18:02 | chouser | lpetit: I'm sure they'd appreciate a friendly reminder to pay attention to license details. |
| 18:02 | chouser | alistairk: yep, right place. just hang on. :-) |
| 18:02 | lpetit | The ATTRIBUTION.txt file is just an acknowledgement of the provenance of the work, there's no mention of license |
| 18:03 | alistairk | thanks - no hurry |
| 18:03 | chouser | alistairk: ok, unfortunately I don't use emacs or swank and don't really know what to advise |
| 18:03 | lpetit | Well, I'll think about how to turn my answer. Don't necessarily want to get a new enemy on this little earth, just to make things clear :) |
| 18:04 | ansra | alistairk: the bit in brackets can be left out, those are showing default values for the port and host, running 'lein swank' should work |
| 18:04 | chouser | lpetit: sure. you could offer to grant them a custom license, if you own that whole file |
| 18:05 | chouser | lpetit: or just suggest they include an EPL license notice for that one file |
| 18:05 | lpetit | chouser: yeah, thanks for the advice. |
| 18:07 | alistairk | oops, just running 'lein swank' seems to be working :-) |
| 18:08 | chouser | lpetit: since they took your work without permission, it should be possible to be polite and undemanding and still generate a sense of guilt in them. :-) |
| 18:09 | alistairk | thanks ansra |
| 18:09 | alistairk | yep it seems to be working |
| 18:09 | alistairk | thanks guys |
| 18:09 | ansra | sure thing, have fun :0 |
| 18:10 | lpetit | chouser: hmm, last question. Would you ask this to him publicly ? (answering the email on #clojure ?). |
| 18:12 | carkh | huh i wouldn't (on the first try) |
| 18:18 | lpetit | too late :) |
| 18:18 | lpetit | but things were not as bad as I first thought |
| 18:20 | carkh | ohwell your message isn't too stern anyways =) |
| 19:10 | defn | greetings gents |
| 19:12 | Raynes | chouser: He was overreading the README. 'lein swank [PORT=4005] [HOST=localhost]' should have been 'lein swank 4005 localhost' |
| 19:12 | Raynes | In case you were wondering, and for future reference. I bet he read that command, and those were just vague placeholders. |
| 19:22 | AWizzArd | ~seen rhickey |
| 19:22 | clojurebot | rhickey was last seen quiting IRC, 4113 minutes ago |
| 19:22 | AWizzArd | ,(/ 4113 60.0) |
| 19:22 | clojurebot | 68.55 |
| 19:22 | Raynes | $seen rhickey |
| 19:22 | sexpbot | rhickey was last seen quitting 4113 minutes ago. |
| 19:22 | Raynes | sexpbot agrees |
| 19:23 | AWizzArd | (: |
| 19:23 | AWizzArd | good night |
| 19:23 | Raynes | Night. |
| 23:34 | notostraca | I am trying to find information on a nice deed the clojure community did -- a bunch of people paid for someone's airfare to a clojure conference, but I can't find anything using google |
| 23:35 | notostraca | (trying to evangelize a bit) |
| 23:43 | maravillas | notostraca: http://cemerick.com/2010/09/10/a-clojure-scholarship-lets-send-raynes-to-the-conj/ |
| 23:43 | maravillas | and the next post, http://cemerick.com/2010/09/10/anthony-simpson-will-receive-his-clojure-scholarship-thanks-to-you/ |
| 23:44 | notostraca | thanks a ton |
| 23:44 | maravillas | np |