2011-12-02
| 00:00 | devn | technomancy: i'm not sure what you mean by referencing 12factor |
| 00:01 | devn | technomancy: i was referring to heroku allowing for the end-user to decide how their app should be built via lein, etc. |
| 00:03 | devn | technomancy: i mean, yes, there are some overlaps in what i'm asking about, but specifically i am curious about heroku letting someone choose to use lein whether or not it fits the normal criteria of a lein app |
| 00:11 | technomancy | oh, yeah. you can alter the buildpack now; it's all open source |
| 00:11 | technomancy | (kind of a soft launch thing) |
| 00:11 | technomancy | https://github.com/heroku/heroku-buildpack-clojure |
| 00:33 | devn | technomancy: awesome! thanks. |
| 00:34 | devn | man, I have to say I've been a little vigilant lately. I'm getting impatient. Clojure "won". It's fantastic. Why not use it at this point? |
| 00:34 | devn | I'm sick of dancing around it. It's better in so many ways than previous languages I've used. |
| 01:15 | notsonerdysunny | when I did a C-c C-z on my emacs on a remote file (using tramp ofcourse) .. It automatically tried to launch lisp on the remote machine .. which is a nice thing .. but I would like to know how to make it work with the swank running on the remote machine . can somebody help? |
| 01:16 | tensorpudding | well, slime can connect to swank on other hosts can't it |
| 01:20 | technomancy | notsonerdysunny: you have to tunnel it over SSH |
| 01:23 | notsonerdysunny | technomancy: can you may be tell me how to do that..? |
| 01:24 | technomancy | same as you'd tunnel any protocol really; using the -L argument |
| 01:24 | technomancy | http://www.revsys.com/writings/quicktips/ssh-tunnel.html |
| 01:52 | hiredman | technomancy: so I've started on a roundtripping reader and some code to edit and re-align code using zippers |
| 01:53 | hiredman | (you end up with these whitespace nodes all over the place you want to skip over) |
| 01:54 | hiredman | I have some code that can take a let form, and walk it widening or shrinking the whitespace between names and bindings so everything lines up |
| 02:18 | zerokarmaleft | that's cool, i'd love to have bindings reformatted like that at the press of a button |
| 02:23 | spoon16 | technomancy |
| 02:23 | spoon16 | you around? |
| 03:04 | wiseen | are :pre and :post conditions always executed or only in debug mode ? |
| 03:10 | spoon16 | in leiningen is it possible to change the :library-path for dev dependencies? |
| 03:45 | bartj | while using send-off, is there a default first parameter ? |
| 04:40 | Borkdude | morning. |
| 04:41 | kzar | G'mornin' |
| 04:42 | ejackson | wotcha |
| 04:44 | Borkdude | I was puzzled by this question on SO and wondered, why doesn't (defn my-doc [s] (doc s)) work if you give it a symbol... because a function evaluates its arguments and a symbol evaluates to itself right? |
| 04:45 | Borkdude | So how go about it then? |
| 04:45 | Borkdude | sorry symbol evaluates to its value I mean |
| 04:45 | Borkdude | the value it is currently bound to |
| 04:47 | Borkdude | this clearly isn't possible: (my-doc +), because + would evaluate to the value, a function |
| 04:48 | Chousuke | Borkdude: you need a macro |
| 04:48 | Borkdude | but how would you make (my-doc '+) work? |
| 04:48 | raek | Borkdude: your description is accurate - for a function |
| 04:48 | raek | Borkdude: 'doc' is a macro, so the usual rules of evaluation do not have to apply |
| 04:49 | Borkdude | raek: I see that, but doc expects a "name", is that a symbol? |
| 04:49 | Chousuke | yes. |
| 04:49 | Chousuke | but since it's a macro it treats its arguments literally, ie. without evaluating them |
| 04:49 | raek | Borkdude: it requires that the code literal at that place is a symbol |
| 04:50 | Borkdude | Can we make a function that expects a symbol and just passes it to doc? |
| 04:50 | Chousuke | not without trickery. |
| 04:50 | raek | Borkdude: now you see why macros are contagious. to reuse a macro, you might need to make the calling code a macro too |
| 04:50 | Chousuke | you need eval for that |
| 04:51 | Chousuke | eg (defn my-fn-doc [s] (eval (list 'doc s))) |
| 04:51 | Chousuke | but that's bad. don't do that :P |
| 04:52 | Borkdude | hehe, it was the accepted answer on SO |
| 04:52 | raek | but since there is no function version of 'doc', does Borkdude have any other alternative? |
| 04:52 | Wild_Cat | why is doc a macro, btw? |
| 04:53 | Chousuke | for nicer syntax I guess |
| 04:53 | raek | Wild_Cat: probably for user convenience. you don't have to use it like (doc #'some-fn) |
| 04:54 | raek | the implementors should have made a function version too |
| 04:54 | Borkdude | Chousuke: I don't see why you need eval here. Why doesn't (defn my-doc [s] (doc s)) work, if you pass it for example '+ ? |
| 04:54 | Chousuke | Borkdude: because then doc looks up the documentation for s |
| 04:54 | Chousuke | as in, the literal s |
| 04:54 | Wild_Cat | raek: hmm... Why would I need to #' a function whose doc I want? |
| 04:54 | raek | Borkdude: (doc s) will always get the same argument: the symbol s |
| 04:54 | Wild_Cat | (note: I'm an extreme noob to both Clojure and Lisps in general, my questions may seem dumb) |
| 04:54 | raek | Wild_Cat: because the doc string is not stored in the value of the var, but in the var itself |
| 04:55 | Wild_Cat | raek: ah! |
| 04:55 | raek | ,(:doc (meta #'conj)) |
| 04:55 | clojurebot | "conj[oin]. Returns a new collection with the xs\n 'added'. (conj nil item) returns (item). The 'addition' may\n happen at different 'places' depending on the concrete type." |
| 04:55 | Borkdude | Chousuke: this makes sense |
| 04:55 | raek | ,(:doc (meta conj)) |
| 04:55 | clojurebot | nil |
| 04:55 | Wild_Cat | raek: so you mean that given a documented function f and (def g f), (doc g) wouldn't give me anything? |
| 04:55 | raek | Wild_Cat: yes. |
| 04:56 | Wild_Cat | I see. |
| 04:56 | Wild_Cat | that's an important difference from Python, I guess (where docstrings are stored in the __doc__ attribute of whatever it is you're documenting) |
| 04:56 | raek | this is one reason it is hard to do a namespace that "forwards" to another |
| 04:59 | raek | when writing a "sugar macro" it is also a good idea to make a function version available too. these macros and functions are often named like "foo" and "foo*". |
| 05:01 | Borkdude | raek: can you give a real example of this? |
| 05:02 | raek | bound-fn and bound-fn* |
| 05:02 | Fossi | let let* |
| 05:02 | raek | future and future-call |
| 05:02 | Borkdude | ,(doc bound-fn) |
| 05:02 | clojurebot | "([& fntail]); Returns a function defined by the given fntail, which will install the same bindings in effect as in the thread at the time bound-fn was called. This may be used to define a helper function which runs on a different thread, but needs the same bindings in place." |
| 05:02 | Borkdude | ,(doc bound-fn*) |
| 05:02 | clojurebot | "([f]); Returns a function, which will install the same bindings in effect as in the thread at the time bound-fn* was called and then call f with any given arguments. This may be used to define a helper function which runs on a different thread, but needs the same bindings in place." |
| 05:03 | Borkdude | same docs? no info on macro of fn? |
| 05:04 | raek | you use bound-fn* like this (bound-fn* (fn [x y] (+ x y))) and bound-fn like this (bound-fn [x y] (+ x y)) |
| 05:04 | Borkdude | ah, i see |
| 05:04 | Borkdude | ,(doc let*) |
| 05:04 | clojurebot | excusez-moi |
| 05:05 | raek | fn* and let* are not examples of this |
| 05:05 | raek | they are "the real" special forms |
| 05:05 | raek | fn and let are actually macros |
| 05:05 | Fossi | oh, k |
| 05:05 | Borkdude | ok |
| 05:05 | raek | I think it has to do with where destructuring happends |
| 05:06 | raek | also: (future (x)) == (future-call (fn [] (x))) |
| 05:06 | raek | (which also explains how 'recur' behaves in the body of 'future') |
| 05:15 | tscheibl | ,(->> ["Hello" "world"] (#(if (< 0.5 (rand)) (replace {"world" "underworld"} %1) %1)) (clojure.string/join " ")) |
| 05:15 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.string> |
| 05:15 | tscheibl | :p |
| 05:15 | tscheibl | outsmarting the threading operators |
| 05:41 | biallym | So I am writing a library, and I want the ability to pass symbols so that I gain the ability to use the redefined symbols without having to put it in user code. I have a few different ideas for this, but is there an idiomatic way for a library to do this? |
| 05:43 | biallym | (i.e. pass a defn to a library as a callback, and when that is later defn'd (Say through slime) I wan the callback to gain the new value. I can do this with wrapping fn's, but is there an idiomatic way?) |
| 05:44 | raek | biallym: this is usually solved by passing #'foo instead of foo |
| 05:45 | raek | vars implement IFn by delegating to their current value |
| 05:45 | biallym | Awesome! |
| 05:45 | biallym | that is a very acceptable solution! |
| 05:46 | biallym | Did I mention that I love's clojure's design more and more every day |
| 05:46 | biallym | (And java's less and less) |
| 05:46 | biallym | (Not that I have ever used java, but java interop is always a pain for me) |
| 05:46 | tscheibl | same goes for me :) |
| 05:47 | tscheibl | i'm beginning to forget about the java syntax... |
| 05:47 | AWizzArd|work | Fast Leiningen question: I told lein to :omit-default-repositories and added under :repositories my "Artifactory" repo. Now "lein deps" will show me sometimes an entry beginning with [INFO]. Does maven do this after some period of time, to tell the user that it is looking for updates? |
| 05:48 | AWizzArd|work | One thing that I noticed was: [INFO] artifact org.clojure:clojure: checking for updates from sonatype-snapshots |
| 05:48 | AWizzArd|work | But I did not specify the repo "sonatype-snapshots". I want Leiningen to only lookup everything ever on "Artifactory", the one repo that I specified, and which is typically used. |
| 05:49 | biallym | I have a leiningen question related to native dependencies, but it's not pressing, just throwing that out there if a leiningen guru answears that question ^ :p |
| 05:50 | tscheibl | @raek: vars implement IFn? |
| 05:50 | tscheibl | ,(#(%) #'a) |
| 05:50 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)> |
| 05:51 | tscheibl | ,(let [a 42] (#(%) #'a)) |
| 05:51 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)> |
| 05:51 | tscheibl | ,(def a 42) (#(%) #'a) |
| 05:51 | clojurebot | #<Exception java.lang.Exception: SANBOX DENIED> |
| 05:51 | tscheibl | arghh |
| 05:52 | tscheibl | , (let [a 42] (#(%) #'a)) |
| 05:52 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)> |
| 05:53 | tscheibl | throws this in my 1.3 repl: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn> |
| 05:53 | Borkdude | tscheibl: if you want to know, you can also just look at the source of Var: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Var.java |
| 05:54 | Borkdude | it does implement IFn |
| 05:54 | Borkdude | but a long doesn't |
| 05:54 | Borkdude | so probably you're getting the value of a var and not the var itself? |
| 05:54 | biallym_ | ,(let [a (var #(identity %)] (#'a :foo)) |
| 05:54 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: ]> |
| 05:54 | tscheibl | but i'm passing the var... |
| 05:54 | biallym_ | ,(let [a (var #(identity %))] (#'a :foo)) |
| 05:54 | clojurebot | #<CompilerException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol, compiling:(NO_SOURCE_PATH:0)> |
| 05:55 | biallym_ | ,(let [a (var #(identity %))] (a :foo)) |
| 05:55 | clojurebot | #<CompilerException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol, compiling:(NO_SOURCE_PATH:0)> |
| 05:55 | biallym_ | I give up >.> |
| 05:55 | Borkdude | biallym you are getting the var of an anonymous function, does that make sense ? |
| 05:55 | tscheibl | why? |
| 05:55 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IPersistentStack> |
| 05:55 | biallym_ | I was trying to make a var |
| 05:55 | biallym_ | >.> |
| 05:55 | biallym_ | obviously not working |
| 05:55 | Borkdude | ,(doc var) |
| 05:55 | clojurebot | No entiendo |
| 05:56 | tscheibl | ,(let [a 42] (fn [a*] (a*)) (var a)) |
| 05:56 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)> |
| 05:56 | tscheibl | outputs the var in my 1.3 rwpl |
| 05:56 | tscheibl | #'at.hauptversammlung.backoffice.server.api.core/a |
| 05:56 | tscheibl | like thios |
| 05:56 | Borkdude | biallym_: var takes a symbol |
| 05:57 | tscheibl | ok wrong... hehe |
| 05:57 | biallym_ | Yea I know that now... I thought it was like ref :p |
| 05:57 | biallym_ | obviously I failed miserably |
| 05:57 | tscheibl | ,(let [a 42] ((fn [a*] (a*)) (var a))) |
| 05:57 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)> |
| 05:58 | tscheibl | outputs: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn> |
| 05:58 | tscheibl | .. in my repl |
| 05:58 | biallym_ | ,*1 |
| 05:58 | clojurebot | #<Unbound Unbound: #'clojure.core/*1> |
| 05:58 | tscheibl | ,(let [a 42] ((fn [b] (b)) (var a))) |
| 05:58 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)> |
| 05:58 | biallym_ | ,(binding [*1 (fn [x] (identity x))] (*1 :foo)) |
| 05:58 | clojurebot | :foo |
| 05:59 | biallym_ | thats what I was trying to do |
| 05:59 | biallym_ | &*1 |
| 05:59 | lazybot | ⇒ #<Unbound Unbound: #'clojure.core/*1> |
| 05:59 | tscheibl | yep... but obviously I cannot execute a var as a function... |
| 05:59 | Borkdude | tscheibl: let doesn't use vars |
| 06:00 | biallym_ | look at how I did |
| 06:00 | biallym_ | it |
| 06:00 | biallym_ | tscheilb, you are doing it wrong >.> |
| 06:00 | biallym_ | binding manipulates vars |
| 06:00 | biallym_ | vars are not an object you can create |
| 06:00 | tscheibl | that's obvious, too |
| 06:00 | biallym_ | they are a pseudo construct of the symbol table |
| 06:00 | tscheibl | hmm |
| 06:01 | biallym_ | let me use a better example |
| 06:01 | tscheibl | (let [a 42] ((fn [a*] (var-get a*)) (var a))) |
| 06:01 | tscheibl | this works.... but I have to use var-get |
| 06:02 | biallym_ | Thats because var implements IFn by returning the value, 42 doesn't implement IFn |
| 06:03 | biallym_ | A better example: |
| 06:04 | biallym_ | &(binding [*1 (fn [x] (identity x))] ((var *1) :foo)) |
| 06:04 | lazybot | java.lang.SecurityException: You tripped the alarm! pop-thread-bindings is bad! |
| 06:05 | biallym_ | &(binding [*1 (fn [x] (identity x))] (#'*1 :foo)) |
| 06:05 | lazybot | java.lang.SecurityException: You tripped the alarm! pop-thread-bindings is bad! |
| 06:05 | tscheibl | damn bots ;) |
| 06:05 | biallym_ | &(binding [*1 (fn [x] (identity x))] (*1 :foo)) |
| 06:05 | lazybot | java.lang.SecurityException: You tripped the alarm! pop-thread-bindings is bad! |
| 06:05 | biallym_ | ,(binding [*1 (fn [x] (identity x))] (*1 :foo)) |
| 06:05 | clojurebot | :foo |
| 06:05 | biallym_ | ,(binding [*1 (fn [x] (identity x))] ((var *1) :foo)) |
| 06:05 | clojurebot | :foo |
| 06:05 | biallym_ | btw identity is broken |
| 06:06 | biallym_ | actually . is broken |
| 06:06 | biallym_ | but w/e |
| 06:06 | biallym_ | which just makes java interop so much more painful |
| 06:07 | tscheibl | ,(binding [*1 (fn [x] x)] ((var *1) :foo)) |
| 06:07 | clojurebot | :foo |
| 06:07 | tscheibl | why do u use identity at all? |
| 06:07 | biallym_ | Oh because I was using the #(fn %) |
| 06:07 | biallym_ | form, which requires a fn on the front |
| 06:07 | tscheibl | ahh |
| 06:08 | tscheibl | .. ok now I'm beginning to grasp... |
| 06:09 | tscheibl | the vars IFn implementation calls the underlying value as a function |
| 06:09 | biallym_ | Yes |
| 06:10 | biallym_ | Oh I did not fully grasp this the first time around.. so much mroe awesome, so many problems fixed |
| 06:10 | tscheibl | ... before i thought it would return the vars value .. like var-get |
| 06:10 | biallym_ | so many fewer macros to write |
| 06:10 | biallym_ | it's 3am, I can have horrible english >.> |
| 06:11 | tscheibl | .. no prob :) |
| 06:11 | tscheibl | ... i wouldn't recognize |
| 06:12 | tscheibl | ..i'm austrian.. we speak mountain english |
| 06:12 | tsdh | Is there something to tell the clojure reader/compiler "ignore the following if (foo) evaluates to false"? |
| 06:12 | tscheibl | macro |
| 06:12 | tsdh | tscheibl: Or, right. :-) |
| 06:34 | tsdh | Why was clojure.parallel deprecated instead of adapting it to the final ForkJoin stuff that comes with JDK 1.7? The relevant ticket (CLJ-216) says it moved to the par branch, but that hasn't been updated for years... |
| 06:35 | kzar | Is there a way to proxy certain requests through to somewhere else using ring? I wanted to have certain requests go through to couchDB API but I need to have control about which ones |
| 06:49 | tscheibl | kzar: maybe this way https://github.com/mmcgrana/clj-http |
| 06:50 | kzar | tscheibl: Yea I thought of that, so a request comes in and you pull it appart and if it's OK you use a library like that to do your own request and then return the response |
| 06:50 | tscheibl | exactly |
| 06:50 | kzar | tscheibl: But it seems like a PITA and a hack when HTTP has support for proxies? |
| 06:51 | tscheibl | how would http support proxies? |
| 06:51 | tscheibl | without a proxy server? |
| 06:52 | tscheibl | ..someone will have to do the proxying |
| 06:57 | kzar | tscheibl: I probably mispoke, but writing it myself using clj-http seems like the wrong approach. Perhaps I'm wrong there too, seems longwinded though |
| 07:03 | tscheibl | kzar: maybe you could take advantage of this when using ring together with jetty: http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/server/handler/ConnectHandler.html |
| 07:03 | tscheibl | this is a jetty proxy handler |
| 07:03 | tscheibl | .. but you would have to do some java interop |
| 07:07 | kzar | tscheibl: cheers |
| 07:15 | daniel | I have a map like this: {"Lx5r1" 10102, "ydwD0" 5644, "f2)d@" 11043, "8Z&*U" 13953, "o_E-." 10028} I'm trying to write a function which returns two strings from the map with a probability proportional to 1/the values |
| 07:15 | daniel | i.e. the lower the value, the more chance it has of being selected |
| 07:15 | daniel | in the above case "ydwD0" and "o_E-." would be the most likely to be returned |
| 07:17 | daniel | currently it's extremely inefficient: https://gist.github.com/1423043 |
| 07:17 | daniel | popfitness would be the above map |
| 07:19 | Fossi | how do you want to map "fitness" to your randomization? linear like in the above? |
| 07:19 | ejackson | daniel: you should assign a value to each entry, normalize by the total and then use inversion sampling |
| 07:19 | ejackson | http://en.wikipedia.org/wiki/Inverse_transform_sampling |
| 07:20 | ejackson | if you sample without replacement you will need to renorm after the first sample |
| 07:21 | daniel | Fossi, I would like to test different possibilities ideally |
| 07:22 | kephale | ejackson: for evolutionary computation this is standard practice |
| 07:22 | daniel | thanks ejackson |
| 07:22 | kephale | daniel: look up roulette wheel selection, there are algorithms for it online |
| 07:22 | daniel | kephale: cheers |
| 07:22 | ejackson | kephale: yeah, its bread and butter across the board :) |
| 07:23 | kephale | daniel: basically you make a vector of pairs of *cumulative* normalized fitness and individuals, then in O(n) you search for the (rand) |
| 07:24 | kephale | of course tournament selection is better than fitness proportional anyway |
| 07:27 | ejackson | kephale: I'm not sure I understand your jargon (not used perjoratively), what do you mean by tournament selection and fitness proportional ? |
| 07:28 | daniel | kephale: does it need to be a vector or can i use the above map? i then divide the values by the total and then its the random sampling i need to get my head around |
| 07:28 | daniel | so i generate a random number between 0 and 1 |
| 07:29 | ejackson | then choose that value form the vector of cumulative probabilities that is the lowest value greater than your random number |
| 07:29 | ejackson | bobs your uncle |
| 07:30 | daniel | how do i make the probabilities cumulative? |
| 07:30 | kephale | daniel: like ejackson said. you can't use a map because you need to keep the individuals sorted by their cumulative fitness |
| 07:31 | ejackson | ,(reductions + 0 [1 2 3]) |
| 07:31 | clojurebot | (0 1 3 6) |
| 07:31 | ejackson | take (rest ...) of that |
| 07:32 | kephale | ejackson: this is all evolutionary computation lingo (which puts bread on my table). i think you get the idea of fitness proportional selection. in tournament selection you choose a random subset, sort it, and return the individual with best fitness |
| 07:33 | daniel | ,(reductions + 0 [1 2 4]) |
| 07:33 | clojurebot | (0 1 3 7) |
| 07:33 | kephale | basically tournament selection is the sampling-based alternative to fitness proportional, and when used for problem solving it turns out to be better for the search process |
| 07:33 | daniel | kephale: isn't that a poor model for reality? |
| 07:33 | ejackson | kephale: is it reduced variance or something ? |
| 07:34 | kephale | daniel: which is the "that" in this case? individuals in reality are localized, a mating tournament doesn't take place across all individuals on Earth. |
| 07:34 | ejackson | kephale: aaaah, its domain optimisation thing. |
| 07:35 | ejackson | makes sense |
| 07:35 | kephale | mmm, its fun stuff |
| 07:35 | Fossi | "a mating tournament doesn't take place across all individuals on Earth" ah, that's what went wrong when somebody invented the internet :> |
| 07:35 | daniel | kephale: that being tournament selection |
| 07:35 | kephale | Fossi: lol |
| 07:36 | raek | tscheibl: did you get your question answered? |
| 07:37 | kephale | daniel: so i think the realism argument is fairly clear just because of spatial locality, but in terms of problem solving the issue with fitness proportional selection is that a randomly generated individual that is better than the rest, but suboptimal and located near a local but not global maxima can dominate the population early on and prevent convergence |
| 07:40 | daniel | kephale: for me putting a heavy bias on the fitter individuals being selected still seems more realistic than simply ordering them and picking from the top |
| 07:41 | kephale | daniel: that is fine, but doing it over a tournament instead of the entire population is the key idea there. |
| 07:41 | daniel | im still having trouble getting my head around the cumulativeness - for me this seems like discrete outcomes and i keep thinking how does that work with a continuous cumulative pd |
| 07:42 | daniel | ah no |
| 07:42 | daniel | ok, i got it :) |
| 07:44 | kephale | daniel: out of curiosity, is this for a class? |
| 07:44 | daniel | nope |
| 07:44 | daniel | just me playing about with stuff |
| 07:44 | kephale | ah cool, all the better |
| 07:46 | daniel | trying to learn me some clojure and it seemed like a fun little program to write |
| 07:47 | daniel | also trying to fill my github page with as many little projects as possible in the hope of finding better employment |
| 07:48 | kephale | CS research FTW |
| 07:48 | biallym_ | Any leiningen gurus know how native deps work? |
| 07:49 | biallym_ | Because I am having trouble getting them to work and I think it is conceptual problem |
| 07:50 | daniel | kephale: wouldnt be any point where im living |
| 07:50 | daniel | so now i have a vector like this, on the right track? [["{x:I{" 4289] [".^t#c" 9616] ["072!^" 16186] ["P`VQx" 2569] ["t3x.g" 6014]] |
| 07:50 | AWizzArd|work | Do we have a Windows 7 user here who also uses Leiningen and works with emacs and uses M-x clojure-jack-in to start a project? Would you be so kind and add :warn-on-reflection true to your project.clj and tell me if you can load it? I see in the minibuffer the warning: Symbol's value as variable is void: Reflection |
| 07:51 | kephale | yeah, now normalize the second value of each element by the total sum then use reductions like ejackson mentioned and replace the second's with that result |
| 07:54 | daniel | kephale: so instead of 9616, i'd have 9616 + 4289 ? |
| 07:54 | daniel | and so on |
| 07:54 | daniel | first i need to sort them right? |
| 07:55 | kephale | daniel: well i tend to normalize the fitness values, but you technically don't have to as long as you use (rand-int total-fitness) |
| 07:55 | kephale | and yes, first sort by the values returned by reductions |
| 07:55 | daniel | sorry, assuming they are normalised |
| 07:56 | daniel | i dont understand the reasoning behind the reductions. also, a lower value in my case means a higher fitness (i dont know if this is taking that into account) |
| 07:57 | daniel | i need to normalize (total - value) i think |
| 07:57 | daniel | so they are all inverted |
| 07:57 | kephale | reductions is to get the cumulative fitness. i also generally have fitness correspond to error, in which case you sort the other way |
| 07:58 | daniel | dont i have to sort before taking the reductions? |
| 07:59 | kephale | no, you just need the order to be based on the cumulative sum |
| 08:00 | kephale | in theory you miiight get a slight performance bump by sorting before calling reductions |
| 08:01 | daniel | my understanding is: sort from lowest to highest value, normalize, reductions |
| 08:02 | daniel | so once they are normalized they should be sorted from highest to lowest probability |
| 08:02 | daniel | and then picking a random number between 0-1 will tell me where in the order to select from |
| 08:02 | kephale | feel free to try with and without the initial sort, but it shouldn't be necessary, by using reductions you are cutting the pie into proportional slices |
| 08:03 | kephale | then you spin the wheel, and probabilistically you will land on the individuals of appropriate fitness regardless of the initial sort |
| 08:05 | daniel | kephale: i can't see how i would sort after reductions... if i use reductions each value will be greater than the last and therefore already in ascending order?? :/ |
| 08:06 | daniel | you're saying i can do without sort altogether? |
| 08:06 | kephale | yeah |
| 08:06 | kephale | ,(let [ppl [["{x:I{" 4289] [".^t#c" 9616] ["072!^" 16186] ["P`VQx" 2569] ["t3x.g" 6014]] fits (map second ppl) tot-fit (reduce + fits) cum-fits (rest (reductions + 0 fits)) roulette (for [k (range (count ppl))] [(first (nth ppl k)) (float (/ (nth cum-fits k) tot-fit))])] roulette) |
| 08:06 | clojurebot | (["{x:I{" 0.11090138] [".^t#c" 0.3595439] ["072!^" 0.77806795] ["P`VQx" 0.844495] ["t3x.g" 1.0]) |
| 08:07 | kephale | sorry i said sort initially, but you don't actually need it. technically you don't have to normalize, but that is standard practice. |
| 08:07 | daniel | in the above, "P`VQx" 0.844495 should be most likely |
| 08:08 | daniel | however i dont see how selecting a random number between 0 and 1 would yield that with most likelihood |
| 08:08 | kephale | and if you have negative fitness values it can get hairy, so normalizing is best (also note that this wont work with negative fitness |
| 08:08 | kephale | in the above the most likely would be 072... |
| 08:08 | daniel | i dont have negative fitness (0 is perfectly matching target) |
| 08:08 | kephale | any value of rand between 0.359 and 0.778 matches 072!^ |
| 08:09 | daniel | i see, so yeah i need it the other way |
| 08:09 | kephale | yeah i know, but i got lazy |
| 08:09 | daniel | i need to normalize (total - val) so that higher = better |
| 08:09 | kephale | and didnt want to take your fun : P |
| 08:11 | daniel | anyway, i've grilled you enough :) i have more than enough to be getting on with |
| 08:11 | daniel | thanks a lot |
| 08:11 | kephale | cheers and enjoy |
| 08:56 | tscheibl | raek: yep, thx |
| 09:36 | ilyak | hi * |
| 09:36 | ilyak | I have a long 3585395648 |
| 09:36 | ilyak | how do I make int -709571648 from it in clojure? |
| 09:37 | ilyak | in java ((int) Long.parseLong("3585395648") & 0xffffffff) does the trick |
| 09:37 | ilyak | ,(int (bit-and 0xffffffff (Long/parseLong "3585395648"))) |
| 09:37 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Value out of range for int: 3585395648> |
| 09:37 | raek | ilyak: 3585395648 does not fit in an int |
| 09:38 | ilyak | raek: Therefore I want -709571648 |
| 09:38 | ilyak | Which does :) |
| 09:38 | clgv | ,(int (bit-and (long 0xffffffff) (Long/parseLong "3585395648"))) |
| 09:38 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Value out of range for int: 3585395648> |
| 09:38 | raek | ,(bit-and 0xffffffff 3585395648) |
| 09:38 | clojurebot | 3585395648 |
| 09:39 | raek | ,(bit-and 0x0ffffffff 3585395648) |
| 09:39 | clojurebot | 3585395648 |
| 09:40 | ilyak | , (- 0xffffffff 3585395648) |
| 09:40 | clojurebot | 709571647 |
| 09:40 | ilyak | I guess I can use this but still |
| 09:40 | ilyak | ,(- 3585395648 0xffffffff) |
| 09:40 | clojurebot | -709571647 |
| 09:40 | ilyak | ,(- 3585395648 0x100000000) |
| 09:40 | clojurebot | -709571648 |
| 09:41 | raek | ah, you want to sign extend the 32-bit part into 64 bits (yielding a negative number) and then put that in an int... |
| 09:43 | ilyak | exactly |
| 09:51 | raek | ,(.intValue 3585395648) |
| 09:51 | clojurebot | -709571648 |
| 09:52 | raek | ilyak: that does not use the dedicated JVM instruction, but is short at least |
| 09:59 | ilyak | :) |
| 09:59 | ilyak | cool |
| 10:01 | raek | ,(unchecked-int 3585395648) |
| 10:01 | clojurebot | -709571648 |
| 10:01 | raek | there it is! |
| 10:01 | raek | ilyak: ^ :-) |
| 10:01 | fdaoud | raek, you rock |
| 10:01 | raek | I knew it had to be there |
| 10:02 | clgv | $findfn 3585395648 -709571648 |
| 10:02 | lazybot | [clojure.core/unchecked-int clojure.core/hash] |
| 10:09 | daniel | ,(repeat 2 (rand)) |
| 10:09 | clojurebot | (0.8713460673000076 0.8713460673000076) |
| 10:09 | daniel | how can i get that to calculate rand twice instead of repeating the outcome? |
| 10:09 | daniel | ,(repeatedly 2 (rand)) |
| 10:09 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.ClassCastException: java.lang.Double cannot be cast to clojure.lang.IFn> |
| 10:10 | clgv | ,(repeatedly 2 rand) |
| 10:10 | clojurebot | (0.9786849028024637 0.03287114030092053) |
| 10:10 | daniel | hmm |
| 10:10 | clgv | repeatedly expects a function with zero arguments |
| 10:10 | daniel | and if it's more complicated than rand |
| 10:12 | clgv | if it's still simple use an anonymous function e.g. #(f ... ) e.g. ##(repeatedly 2 (rand (rand))) |
| 10:12 | lazybot | java.lang.ClassCastException: java.lang.Double cannot be cast to clojure.lang.IFn |
| 10:12 | clgv | &(repeatedly 2 #(rand (rand))) |
| 10:12 | lazybot | ⇒ (0.044365083534149696 0.1420443694132764) |
| 10:12 | clgv | if it's complex define a function via defn for it |
| 10:13 | daniel | ah i need to wrap it in #() |
| 10:13 | daniel | cheers |
| 10:14 | ihodes | does anyone on here have any experience with using clojure to process time series? i want to extract periodic anomonlies from a time series |
| 10:15 | ihodes | not extract, but mark |
| 10:16 | clgv | ihodes: sounds more like an algorithmic problem than a language specific one. ;) |
| 10:16 | ihodes | it is :) |
| 10:16 | ejackson | ihodes: how are these anomalies defined ? |
| 10:17 | clgv | so what is the clojure related portion of the question? |
| 10:18 | ihodes | ejackson: they're usually significantly deviated from the normalized mean, but sometimes (when there is more noise; this is signal data) they're not as differentiated. they're generally just 2 data points (signal is sampled at 2khz) high and low, and the frequency for a given time period is usually known. the problem is the noise in parts, and when the baseline deviates from 0 (data collectionm problem, maybe) |
| 10:19 | ihodes | clgv: not too much :) i just idle here a lot, and clojure is pretty sweet for dealing with signal data, so thought it was worth a try! |
| 10:20 | clgv | ihodes: I know that incanter has some statistic tools - but I am not sure if they are enough for you since I dont know your algorithm ;) |
| 10:20 | licenser | I'd have a question to clojureql |
| 10:20 | TimMc | ihodes: If you take the same seq x of signal data and compare matching points along x, (drop 1 x), and (drop 2 x) you might be able to get something useful. |
| 10:20 | ihodes | clgv: the trick is figuring out the algorithm! what i have done in the past is very basic. i do use incanter, as well as R, so i have access to a lot. |
| 10:20 | licenser | actually I don't thank non the less :P |
| 10:20 | TimMc | That's a cheap way of getting a window. |
| 10:21 | ihodes | TimMc: what do you mean, matching points? compared (nth x 1) to (nth x 2) and keep sliding? |
| 10:21 | ihodes | or some kind of autoconvolution? |
| 10:23 | ejackson | do you have an estimation of the noise ? |
| 10:23 | TimMc | &(let [x (range), x+1 (drop 1 x), x+2 (drop 2 x)] (map #(nth % 5) [x x+1 x+2])) |
| 10:23 | lazybot | ⇒ (5 6 7) |
| 10:24 | ejackson | it seems that you want an adaptive filter with the cutoff dependent on a noise estimate ? |
| 10:24 | ihodes | ejackson: the noise is both true noise (perform fft, get a low amplitude amount of each reading in the powerspectrum) as well as harmonics of the "signal" we're looking to isolate, as WELL as natural frequencies (from the spinal cord) that we aren't sure about |
| 10:25 | ejackson | oh dear lord |
| 10:25 | ihodes | *reading of each FREQUENCY not ready -- typo, my bad |
| 10:25 | ihodes | ejackson: yeah, it's pretty rough |
| 10:25 | ejackson | have you tried a model dependent filter ? |
| 10:25 | ejackson | something kalman like ? |
| 10:25 | ihodes | and the signal i'm trying to mark in the time series is a digital signal, so we can't do a bandpass filter |
| 10:25 | ihodes | because it pulses, it doesn't oscillate |
| 10:26 | ejackson | seems that you have a filtering problem, where you have a source and measurement model, so is a natural attack |
| 10:26 | ihodes | it's a really fun problem, but automating more of it is tough. right now we have like 5 people manually using a program i wrote a while ago marking these pulses, with a little assitance from my program |
| 10:27 | TimMc | ihodes: What are you studying? |
| 10:29 | ihodes | TimMc: http://insiderlouisville.com/news/2011/05/20/u-of-l-paralyzed-man%E2%80%99s-spinal-cord-neural-networks-retrained-completely-changes-his-life/ |
| 10:29 | ihodes | data from this kind of study |
| 10:30 | ihodes | from electrodes on different muscle groups, and inside the back |
| 10:30 | TimMc | ihodes: "Anomalies" being neuronal signals traveling along the cord, above and beyond the normal chatter? |
| 10:31 | ihodes | here is some example data, mostly clean: need to mark each point (the end result is a single array of timestamps where a pulse is at) http://imgur.com/zVSRU,TNxeX and here is messier data http://imgur.com/zVSRU,TNxeX#1 notice how it's not centered at 0. still, here a simple threshold would work. but sometime the noise approaches the amplitude of the signal |
| 10:32 | ihodes | TimMc: well, in this particular case, i'm trying to mark the stimulous being given to the guy, as measured by the paraspinal electrodes. the noise is both from the stimulator, and from normal/abnormal biological activity |
| 10:32 | TimMc | So... a sliding FFT would be nice. :-) |
| 10:32 | ihodes | marking the muscles' response is another issue entirely... looking like signal analysis is working a little more more there |
| 10:33 | ejackson | ihodes: aah, if you low pass filter either of those, take a 'derivative' at each point and look for changes in sign you should win |
| 10:33 | ihodes | TimMc: if only! the issue being that the pulse, while regular, isn't a signal. it's just an instantanious pulse. so the fft picks up the harmonics of it, but not the signal itself. so MAYBE a bandpass, leaving a band around the pulse freq, and then IFFT back to timeseries and see what you get.... but FFT hasn't been too useful yet |
| 10:33 | ejackson | LPF either with a moving average, or a wavelet, should work, |
| 10:34 | ihodes | *but not the pulse itself |
| 10:34 | ejackson | actually just point where signal - LPF(signal) > thresh should work no ? |
| 10:34 | TimMc | ihodes: Oh, I see! FFT isn't great with non-repeating stuff, right. |
| 10:35 | ihodes | TimMc: FFT isn't great with regular pulses, is the issue; the stimulous isn't realllly a signal: it doesn't look anything like a sin wave, basically. just an instantaneous high and low |
| 10:36 | ihodes | ejackson: e.g., LPF everything greater than the supposed signal? |
| 10:36 | ihodes | ejackson: er, HPF i suppose |
| 10:36 | ejackson | you're looking for the position of the giant spikes ? |
| 10:36 | ihodes | ejackson: yes |
| 10:37 | ejackson | so you need a normalised signal |
| 10:37 | ejackson | in order that the threshold makes sense across signals |
| 10:37 | ihodes | yes |
| 10:37 | ejackson | the big problem you have here is the offset from zero |
| 10:37 | TimMc | Two separate problems. |
| 10:37 | ejackson | and the changes in noise |
| 10:37 | ihodes | that's the most common usual one, though noise can be another |
| 10:38 | TimMc | ihodes: Noise can swamp the pulses? |
| 10:38 | ihodes | ah, yes, that's about it. the counfounding factor, but it can be managed reasonable manually, is the [periods of silence (just noise, no signal) and the sometimes varying frequencies... but don't worry about that |
| 10:38 | ihodes | TimMc: sometimes. maybe not a case worth worrying about... |
| 10:38 | TimMc | OK. |
| 10:39 | ihodes | TimMc: but it often does approac the amplitude, which is worth worrying about |
| 10:39 | ejackson | in that case signal - LPF(signal) > thresh(noise) will sort you |
| 10:39 | ejackson | if the spikes are beneath the noise floor you have a harder problem |
| 10:39 | TimMc | ihodes: So you can't necesarily use the expectation of regular-ish pulses to dynamically adjust the threshold. |
| 10:40 | ihodes | TimMc: right, amplitude changes periodically *and* randomly |
| 10:41 | ihodes | ejackson: so you're saying move into the frequency domain, and wipe out everything except for a band around the frequency of the pulse we're looking for, and then back into the time domain? |
| 10:41 | ejackson | naaaah, do the LPF implicitly with something like an n-period moving average |
| 10:42 | ihodes | ejackson: hmmm, how is that functionally different from doing it in the freq domain? |
| 10:42 | ejackson | its easier to think about |
| 10:42 | ejackson | but is the same thing |
| 10:43 | ihodes | ah, okay. i think the problem here (but i should expirement and actually check) is that because the pulse is not sinusoidal, but just a regular impulse, it's not really a "low freqency signal" that we can be sure we're preserving when using a LPF |
| 10:44 | ihodes | but it could be preserved....it's definitely worth a shot. |
| 10:44 | ejackson | no the LPF is specifically trying to remove these pulses |
| 10:45 | ihodes | the pulses *are* those big spikes you see on the screenshots |
| 10:45 | ejackson | so you compare your original signal to the LPF'd signal, and the pulses will comprise most of the differente |
| 10:45 | ihodes | interesting--let me run that |
| 10:46 | ihodes | thanks all for helping me think this out, too :) |
| 10:54 | TimMc | ihodes: Sounds like awesome research -- I wish that was my job. :-) |
| 10:55 | TimMc | (sort of... signal processing scares me a bit) |
| 10:56 | ihodes | TimMc: haha me too--i'm still trying to understand it. there's a LOT of different things you can do with a signal. the trick is matching the right operations with the kind of signal and the kind of data you're looking to get out of it... |
| 11:09 | ihodes | ejackson: that looks like it's working really well. here's a pic, red is the sig-lpf(sig) and i'm using arbitrary parameters right now, too, as i don't fully understand it (ripped algo off wikipedia, rather than spend more time on it now) http://imgur.com/hyFin |
| 11:10 | ejackson | that's great news |
| 11:10 | ihodes | the next step is understanding the parameters/algorithm and how i need to change them, and then making it fast in clojure for a million or so datapoints at a time :) |
| 11:11 | ejackson | clojure excels at this |
| 11:11 | ejackson | I'd be happy to help you offline, if you like |
| 11:11 | ihodes | ejackson: thanks so much. any other tips? what's your background in sig processing? |
| 11:11 | ihodes | ejackson: you live in the area? |
| 11:12 | ejackson | I just meant not in IRC, this is a bit off-topic really :) |
| 11:12 | TimMc | or in privmsg |
| 11:12 | ejackson | don't want to incur the wrath of the Clojure mob. |
| 11:12 | ejackson | TimMc: zakly. |
| 11:12 | prs` | are videos from the second conj available somewhere? |
| 11:12 | TimMc | although I wouldn't mind hearing more about how you solve it. :-) |
| 11:12 | ihodes | ejackson: haha definitely is, i figured it was quiet so i'd throw it out there; but you're right, they're a tyrranical bunch and this is quite off-topic |
| 11:13 | TimMc | The "making it fast" part would be on topic, of course. |
| 11:13 | ihodes | TimMc: i'll definitely update you; ping me next time you see me on IRC if i forget. it looks like this low pass filter is working pretty well though |
| 11:14 | ejackson | prs`: not yet, but they will be. |
| 11:14 | ejackson | i guess, given that its quiet... |
| 11:14 | ihodes | TimMc: true that; first i need to implement it in clojure and get it displaying nicely. unfortunately incanter can't handle navigating huge amounts of plotted data, so i wrote my own program to display it. the downside is how long it takes me to add things to the program. never got a chance to generalize it... still don't have that chance. but i'll be working on that. |
| 11:15 | prs` | ejackson: thanks, i was kinda expecting that answer, theyll probably be on blip when ready |
| 11:15 | TimMc | prs`: It took a while for the first Conj's videos to go up. |
| 11:15 | ihodes | by the way, as a side-note, R is really nice to work in. |
| 11:16 | prs` | TimMc: March of this year in fact, so im not holding my breath |
| 11:16 | TimMc | Yeah, my fiancée used it for her PHd work and said it was good stuff. |
| 11:16 | ihodes | TimMc: you haven't convinced her to use Clojure instead? :P |
| 11:17 | ejackson | here is a fast-ish SMA for clojure: https://gist.github.com/1423801 |
| 11:17 | TimMc | She did it in Python, and started before I was into Clojure. :-) |
| 11:18 | ejackson | i dug it out of an old codebase... hope its not horrendous |
| 11:19 | ejackson | so consider your input data as a seq, then map that SMA over it giving you another seq, substract the two and you're mustard |
| 11:20 | ihodes | ejackson: haha, looks similar to mine from an old codebase ;) |
| 11:20 | ejackson | yeah, only so many ways to skin that cat |
| 11:23 | ejackson | anyway, now finding your spikes should be easy, no, just take a rolling var estimate, and flag anything > n stdevs out. If you wan't to to be super cunning try a robust estimator to remove the spikes from the vol estimate (but that's kindof circular) |
| 11:49 | kzar | How can I convert a ByteArrayOutputStream to an InputStream? |
| 11:49 | gtrak | kzar, you can either stream it or copy it |
| 11:50 | raek | kzar: if you have the underlying byte array, you can create a ByteArrayInputStream |
| 11:51 | gtrak | kzar, this is how i know to do it: http://webcache.googleusercontent.com/search?q=cache:HRHsyLVxWf8J:ostermiller.org/convert_java_outputstream_inputstream.html&hl=en&gl=us&strip=1 |
| 11:53 | raek | kzar: what objects to you have access to, and what are their types? |
| 11:54 | raek | *do you |
| 11:56 | kzar | Well I'm possibly going about it all the wrong way but I'm writing a little proxy for my webapp that sends some requests through to couchDB. Works fine but for pages like _changes that stream a lot of stuff over a long time it doesn't work to provide the body as a string. Looking at the ring spec you can also provide it as an Inputbuffer so I figured that was the way to go. Using clj-http and forcing it to give me a |
| 11:56 | kzar | byte array and making an input buffer from that worked but didn't help me with the _changes page. So I'm trying to the asynchronous http client, hoping if I can turn what it gives me into a Inputstream it will work better |
| 11:57 | kzar | If you use streaming mode you a have a function that each time you call it gives you more of the body, if you use async mode you get a ByteArrayOutputStream. I tried taking the streaming mode function, wrapping it in lazy-seq as Ring can also accept sequences of strings apparently but it didn't work |
| 11:58 | kzar | So my last idea was to take the ByteArrayOutputStream and use that somehow, I bet there's a simpler solution anyway. I'm not even sure that making the proxy stuff myself manually is the right approach |
| 11:59 | tscheibl | is it somehow possible to have a no arguments constructor on a deftype which initializes it's fields ... according to my research: NO |
| 12:28 | tscheibl | ..arhhh gen-class |
| 12:28 | TeXnomancy | hiredman: so you've started a reader! interesting. |
| 12:28 | TeXnomancy | is it based on your old reader? |
| 12:28 | tscheibl | deftype would have been more elegant |
| 12:28 | hiredman | TeXnomancy: no |
| 12:30 | hiredman | https://github.com/hiredman/swank-clojure/commit/1d30e467b10ffb9846e352e1a8edd24e17d7995e |
| 12:31 | TeXnomancy | sweet. what's implemented so far? |
| 12:32 | hiredman | it can read a big chunk of its own file |
| 12:32 | hiredman | read* at the bottom is the function I have been using for testing |
| 12:33 | hiredman | pass it an inputstream, you can back a seq of Nodes, that may change |
| 12:33 | hiredman | err, you get back a single node actually |
| 12:33 | hiredman | anyway, you have Nodes that represent whitespace so you can round trip, needs comment support, etc |
| 12:34 | TeXnomancy | slick! |
| 12:34 | TeXnomancy | does it piggyback on the main reader at all? |
| 12:34 | Chousuke | hiredman: you probably shouldn't call end-of-list EOL :P I got confused at first |
| 12:34 | hiredman | Chousuke: yeah :) |
| 12:34 | hiredman | TeXnomancy: no |
| 12:35 | hiredman | needs metadata support and lots of other stuff |
| 12:35 | hiredman | (oh god, does this mean I need to implement syntax quote again?) |
| 12:35 | clojurebot | http://en.wikipedia.org/wiki/Lisp_%28programming_language%29#Self-evaluating_forms_and_quoting |
| 12:37 | technomancy | hiredman: were you at seajure last night? |
| 12:37 | Chousuke | I did a syntax-quote implementation |
| 12:37 | Chousuke | it was pretty awful |
| 12:37 | hiredman | technomancy: no |
| 12:37 | Chousuke | I probably still have that stuff on github :P |
| 12:37 | technomancy | that's how you were able to get so much done I guess? =) |
| 12:38 | hiredman | Chousuke: I did one in my first reader, and more recently I have a project to replace it with a macro |
| 12:38 | Chousuke | hiredman: I tried a macro approach too but it got very hairy |
| 12:38 | Chousuke | with nesting |
| 12:38 | hiredman | technomancy: yeah, I had other plans, but they ended up falling through |
| 12:38 | hiredman | https://github.com/hiredman/syntax-quote |
| 12:41 | Chousuke | https://github.com/Chousuke/clojure/blob/clojure-reader/src/clj/clojure/lang/reader/internal.clj#L63 brr, scary code. |
| 12:42 | hiredman | Chousuke: did you come up with tests for it? |
| 12:42 | Chousuke | no |
| 12:42 | hiredman | :/ getting tests has been my issue |
| 12:43 | Chousuke | though I think it passes clojure's tests |
| 12:45 | notostraca | OK, I have given up on creating a Clojure class that replaces some nasty Java code, and I am going to create a Java-consumable library, written in Clojure -- is there a good way to convert a Clojure hash-map or sorted-map to a Java HashMap ? |
| 12:45 | notostraca | or can the Clojure sorted-map be used directly from Java? |
| 12:45 | hiredman | yeah, if I drop my syntax quote macro into core.clj just above the comment indicating full support for syntax quote exists, and patch the reader to emit calls to my macro instead of doing syntax quoting, I still get a few failures from clojure's tests |
| 12:45 | Chousuke | yes |
| 12:47 | notostraca | Chousuke, what is the type (in Java) of a sorted-map from Strings to hash-maps of Strings? |
| 12:47 | Chousuke | Map |
| 12:48 | notostraca | no type parameters? |
| 12:49 | Chousuke | that's compile-time only, it's optional |
| 13:29 | zakwilson | https://gist.github.com/1424294 <-- I'm failing to get even a basic select working with Korma. Throws NPE on every select and insert I've tried. |
| 15:24 | TimMc | notostraca: The generics fall away, but the base type is still there. If you call it a Map, "Map" is put in the bytecode. If it's called HashMap, then "HashMap". |
| 15:25 | notostraca | thanks TimMc |
| 15:25 | TimMc | You probably want to expose it as a Map. |
| 15:26 | TimMc | Chousuke: Hmm, how does compiled Java code represent its use of generics in an API? |
| 15:26 | Chousuke | it doesn't AFAIK. |
| 15:26 | TimMc | Hum... |
| 15:27 | Chousuke | or well, not as a requirement. probably there's some sort of metadata though |
| 15:27 | TimMc | There has to be, yeah? |
| 15:27 | Chousuke | I suppose |
| 15:27 | TimMc | At least on method signatures, not on locals. |
| 15:28 | Chousuke | at the bytecode level it's all Objects though |
| 15:29 | hiredman | javac inserts casts |
| 15:30 | hiredman | clojurebot: java generics |are| http://en.wikipedia.org/wiki/Generics_in_Java |
| 15:30 | clojurebot | In Ordnung |
| 15:36 | TimMc | hiredman: A JVM object doesn't know its parameterization, but the original .class file surely advertises the generics, yes? |
| 15:42 | devn | bah...jira has forsaken me -- how do you get to design docs from the dashboard? |
| 15:43 | devn | nevermind, found it |
| 15:45 | Bahman | Hi all! |
| 15:45 | devn | anyone know where the ^:static and ^:dynamic docs are hiding? |
| 15:46 | dnolen | devn: ^:static doesn't do anything |
| 15:46 | pauldoo | when I write (.foo bar) in closurescript, it compiles down to "bar.foo;" |
| 15:46 | devn | dnolen: either way, looking for notes on ^:dynamic |
| 15:46 | pauldoo | how do I get "bar.foo();" ? |
| 15:46 | dnolen | pauldoo: known issue, (. bar (foo)) |
| 15:47 | pauldoo | dnolen: ahh ok - so it's a bug? |
| 15:47 | TimMc | pauldoo: It's a translation dilemma. |
| 15:48 | pauldoo | dnolen: is what you suggest the supported way to make the call? If I know the prototype is there another way I could do it? (Type/foo bar) for instance.. ? |
| 15:48 | TimMc | pauldoo: With Java, . is not ambiguous, since you can't ask for a method as an object. |
| 15:48 | pauldoo | would ((.foo bar)) also work then? |
| 15:50 | TimMc | pauldoo: Try it and let me know, I don't have cljs set up. |
| 15:51 | pauldoo | TimMc: I can't get either syntax to work currently. I certainly have other errors to fix. Ill get back to you.. |
| 15:56 | dnolen | pauldoo: we're waiting to see if (.-prop foo) gets adopted, then (.method foo) becomes unambiguous |
| 15:56 | dnolen | pauldoo: it requires a change to Clojure. |
| 15:57 | dnolen | pauldoo: ClojureScript has a prop-lookup branch. Try it out. If you care about this vote up these tickets - http://dev.clojure.org/jira/browse/CLJ-872, http://dev.clojure.org/jira/browse/CLJS-89 |
| 15:59 | devn | If I juxt keys on a map am I guaranteed the order? |
| 15:59 | devn | ,((juxt :foo :bar) {:foo 1 :bar 2}) |
| 15:59 | clojurebot | [1 2] |
| 15:59 | devn | yes, right? |
| 16:00 | dnolen | palentine: (. foo (bar)) should definitely work |
| 16:00 | dnolen | pauldoo: oops that was for you |
| 16:01 | pauldoo | dnolen: ahh yes, it does indeed. I didn't notice the space after the period. or that you swapped foo and bar from my query |
| 16:01 | pauldoo | dnolen: so (. instance (method)) works perfectly - thanks |
| 16:01 | jeremyheiler | ,((juxt :foo :bar) {:bar 2 :foo 1}) |
| 16:01 | clojurebot | [1 2] |
| 16:02 | jeremyheiler | devn: juxt applies the functions in the order given |
| 16:02 | jeremyheiler | (doc juxt) |
| 16:02 | clojurebot | "([f] [f g] [f g h] [f g h & fs]); Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, and returns a vector containing the result of applying each fn to the args (left-to-right). ((juxt a b c) x) => [(a x) (b x) (c x)]" |
| 16:03 | jeremyheiler | devn: in particular "applying each fn to the args (left-to-right)" |
| 16:04 | tsally | can a function created via #() be a recur target from within the body ? |
| 16:05 | TimMc | yup, try it |
| 16:06 | tsally | that's awesome |
| 16:06 | TimMc | tsally: #() is just reader sugar for a fn |
| 16:06 | TimMc | &`#(recur) |
| 16:06 | lazybot | ⇒ (fn* [] (recur)) |
| 16:07 | TimMc | &(#(recur)) |
| 16:07 | lazybot | Execution Timed Out! |
| 16:08 | tsally | nice |
| 16:10 | TimMc | &(#(if (= % 1) %2 (if (even? %) (recur (/ % 2) (inc %2)) (recur (inc (* 3 %)) (inc %2)))) 27 0) |
| 16:10 | lazybot | ⇒ 111 |
| 16:11 | TimMc | ^ Collatz with counter. |
| 16:12 | TimMc | tsally: I don't know if recur in #() ever happens in the real world. |
| 16:13 | TimMc | recur usually indicates a sufficiently complicated operation is being written that it deserves to be named. |
| 16:14 | TimMc | Maybe you might see it in a function that returns a closure. |
| 16:30 | gtrak | does clj-growl work on windows? |
| 16:34 | hiredman | /win 15 |
| 16:34 | TimMc | SANBOX DENIED |
| 16:35 | duck1123 | gtrak: looks like it's just calling out to growlnotify |
| 16:35 | duck1123 | so no |
| 16:35 | duck1123 | unless there's a growl for windows now? |
| 16:35 | gtrak | there is |
| 16:36 | Raynes | There is. |
| 16:36 | gtrak | I want to get rid of some browser windows |
| 16:36 | gtrak | like tweetdeck |
| 16:40 | pauldoo | so on previous discussion about (.foo bar) in clojurescript, what is the recommended way to access a property in cljs? |
| 16:40 | pauldoo | (recommended as in unlikely to break when the above is "fixed" for methods) |
| 16:43 | stuartsierra | there's a wiki page about that somewhere |
| 16:52 | jweiss | how does one access a protected static field in the superclass on an object? doesn't seem to be accessible via the object's class, the object, or the superclass. |
| 16:52 | jweiss | i figured it should be accessible via the class |
| 16:52 | clojurebot | You can't add things (libraries, dependencies) to a running JVM process. Java doesn't like it, and we just have to live with that. |
| 16:57 | jeremyheiler | jweiss: you could use reflection and call setAccessible(true), but hopefully there's a better way. |
| 16:59 | jweiss | jeremyheiler: wow really? i was hoping it'd be simpler than that. the object in question has access to this field, shouldn't i? |
| 16:59 | dnolen | pauldoo: it will be an unavoidable breaking change. I'm hoping Clojure/core moves on it sooner not later. |
| 17:03 | stuartsierra | jweiss: with gen-class you can expose it |
| 17:04 | jweiss | meh, it's easier for me to just change the java class. but that doesn't bode well for next time when it's not code i control :) |
| 17:05 | stuartsierra | you can always subclass it |
| 17:06 | jeremyheiler | jweiss: what i suggested was using reflection. did it not work for you? |
| 17:07 | jweiss | jeremyheiler: oh, your suggestion was to make it permanently accessible, i just want to get the value once |
| 17:09 | devinus_ | trying to get up and running with clojure in the most modern way possible with swank, emacs, lein, whatever tools clojure devs are using these days on OS X |
| 17:09 | devinus_ | anybody got a guide for this somewhere? |
| 17:09 | technomancy | devinus_: http://emacsformacosx.com plus the swank readme should get you 90% of the way there |
| 17:10 | jweiss | i see an end-around in the API so i can skirt this issue for now jeremyheiler but i'll keep that suggestion in mind for next time |
| 17:10 | devinus_ | technomancy: keep in mind all i have is emacs right now |
| 17:10 | devinus_ | technomancy: dont have clojure or lein or anything |
| 17:11 | devinus_ | emacs and a java vm |
| 17:11 | devinus_ | bout all i have |
| 17:11 | technomancy | devinus_: installing leiningen takes like five seconds; you don't need much documentation for that |
| 17:11 | devinus_ | ok sweet |
| 17:11 | technomancy | but once you've got it maybe reading "lein help tutorial" would be good |
| 17:12 | jeremyheiler | jweiss: cool. i am now curious about the scope of the reflected objects. it makes sense that setAccessible is permenant, but is it for that particular field/method on that object, or all objects for that class? |
| 17:25 | notostraca | Hmm, I get a java.lang.UnsupportedOperationException when I try to call a Clojure function from Java... Any ideas on what could cause that? I don't get that when I call it from Clojure |
| 17:27 | notostraca | The exact exception is |
| 17:27 | notostraca | Exception in thread "main" java.lang.UnsupportedOperationException: loadTSV (net.myexperiments.viciouscycle.util.TSVReader/-loadTSV not defined?) |
| 17:30 | jeremyheiler | how are you calling it from java? |
| 17:30 | notostraca | jeremyheiler, as a static function of the class TSVReader (declared with a gen-class) |
| 17:30 | notostraca | In my clojure ns, I have: :methods [^{:static true} [loadTSV [String] java.util.Map] |
| 17:31 | notostraca | and it is possible the typing is screwed up |
| 17:32 | notostraca | oh sorry, that :methods is part of a :gen-class with: :name "net.myexperiments.viciouscycle.util.TSVReader" :load-impl-ns false |
| 17:33 | notostraca | and I don't really know what load-impl-ns does either |
| 17:40 | notostraca | OK, when I get rid of :load-impl-ns I get a different error -- it can't find an init function I think |
| 17:40 | notostraca | but the class should be just static functions... |
| 17:41 | jeremyheiler | Are you trying to make it a java-friendly? |
| 17:41 | notostraca | jeremyheiler, yes |
| 17:44 | jeremyheiler | maybe you need to wrap all your methods (in this case 1) in a vector: :methods [^{:static true} [[loadTSV [String] java.util.Map]] |
| 17:44 | jeremyheiler | the clojure doc shows there being an outer vector |
| 17:45 | jeremyheiler | nevermind, sorry |
| 17:48 | devinus_ | technomancy: quick question. on clojure-jack-in i'm getting "Could not start swank server: %s" "zsh: command not found: lein" it's obvious my ~/bin is not in my zsh path even though it's added to my path in .zshrc. any idea how i can add it to the executable load path somewhere swank can see it? |
| 17:49 | hiredman | the environment where your emacs is launched doesn't have your PATH set |
| 17:49 | hiredman | you can use getenv and setenv to figure it out |
| 17:50 | hiredman | you launched your emacs from a gui or something, and it didn't source you .zshrc |
| 17:50 | devinus_ | hiredman: you're right i start emacs from a gui |
| 17:50 | devinus_ | which makes sense why it wouldnt source |
| 17:50 | devinus_ | hrm |
| 18:06 | yo | hi..I've a little problem with a binding in a loop while try resolve a problem 4clojure..I'm really noob someone can help me? http://pastebin.com/YNA5t6qi |
| 18:11 | yo | no one can help me?...I don't know why when binding my all is empty in every loop http://pastebin.com/YNA5t6qi |
| 18:22 | broquaint | That code doesn't even compile, yo. |
| 18:25 | Raynes | broquaint: That sounded so ghetto. |
| 18:26 | broquaint | Word. |
| 18:27 | nickmbailey | heh, yo, listen to bro |
| 18:29 | notostraca | jeremyheiler, any ideas? |
| 18:29 | jeremyheiler | notostraca: i've been trying to play around with it in the repl, but i am not having any luck using gen-class in a repl. |
| 18:29 | notostraca | really, if anyone here has a good workflow for making java-consumable static functions written in clojure, I would love to hear it |
| 18:30 | notostraca | jeremyheiler, I think you need to be compiling |
| 18:30 | notostraca | uh, I don't know how to get clojurebot to get the docs for a function |
| 18:30 | jeremyheiler | notostraca: yeah,that's what im doing next |
| 18:30 | jeremyheiler | (doc str) |
| 18:30 | clojurebot | "([] [x] [x & ys]); With no args, returns the empty string. With one arg x, returns x.toString(). (str nil) returns the empty string. With more than one arg, returns the concatenation of the str values of the args." |
| 18:31 | notostraca | (doc gen-class) |
| 18:31 | clojurebot | "([& options]); When compiling, generates compiled bytecode for a class with the given package-qualified :name (which, as all names in these parameters, can be a string or symbol), and writes the .class file to the *compile-path* directory. When not compiling, does nothing. The gen-class construct contains no implementation, as the implementation will be dynamically sought by the generated class in functions in an implemen |
| 18:31 | notostraca | When not compiling, does nothing. |
| 18:31 | jeremyheiler | nice, i should learn how to read someday |
| 18:32 | notostraca | seems like a useful talent to put on a resume... :-P |
| 18:33 | jeremyheiler | lol |
| 18:36 | notostraca | jeremyheiler, should I pastebin my code? |
| 18:37 | jeremyheiler | sure |
| 18:40 | notostraca | http://pastebin.com/FcUajnfB |
| 18:42 | notostraca | the Java call is just |
| 18:42 | notostraca | tableData = TSVReader.loadTSV("text" + File.separator + "TSVTable.txt"); |
| 18:43 | notostraca | oh, the type of tableData is Map<String, Map<String, String>> |
| 18:45 | notostraca | the error is still java.lang.UnsupportedOperationException by the way |
| 18:45 | notostraca | hmm, I wonder if I take away the static metadata... |
| 18:45 | jeremyheiler | Don't you want the method to be static? |
| 18:46 | notostraca | yes, but it isn't strictly necessary |
| 18:50 | notostraca | hmm, same error |
| 18:50 | notostraca | with or without static |
| 18:51 | jeremyheiler | i got an example to work with out static |
| 18:55 | notostraca | jeremyheiler, what do you think I am doing wrong? |
| 18:56 | jeremyheiler | Are you able to call your methods with java interop from clojure? or is this error just when using straight java? |
| 18:57 | gtrak | notostraca, it would be useful to see the full stacktrace, where the error is happening is more important than what it is |
| 18:57 | notostraca | gtrak, sure |
| 18:57 | notostraca | let me get that ready |
| 18:58 | gtrak | with line numbers, preferably |
| 18:59 | rickmode | notostrace: Clojure maps are immutable, so UnsupportedOperationException is thrown if one of the modification methods is used. |
| 19:00 | rickmode | so maybe your java code is trying to modify the map? |
| 19:00 | gtrak | if only we had a full stacktrace xD |
| 19:07 | rickmode | So type hints... I've been use *warn-on-reflection* to find and remove these warnings, however various authors suggest leaving them until needed. So what's the best practice? In code that'll get executed potentially thousands of time per second it seems worthwhile to use hints. |
| 19:08 | Raynes | If you want to add type hints, go for it. |
| 19:08 | Raynes | Eliminating reflection is in general a good thing. |
| 19:08 | gtrak | a bad typehint will turn a methodnotfound into a classcastexception |
| 19:08 | Raynes | Especially if it is causing problems. |
| 19:08 | Raynes | Performance problems, I mean. |
| 19:09 | rickmode | I'm not trying to use the hints as a poor-man's type system. ;) |
| 19:09 | gtrak | rickmode, just leave it on all the time |
| 19:09 | gtrak | you only really need them for interop |
| 19:09 | rickmode | gtrak: ya - I am doing interop. |
| 19:10 | gtrak | make a single layer that handles all the dirty parts :-) |
| 19:10 | gtrak | having them scattered around would make them less informative i think |
| 19:10 | rickmode | no such layer in this case... I'm putting clojure into the midst of a large java app |
| 19:10 | notostraca | gtrak, sorry was trying to recompile and ugh |
| 19:11 | gtrak | np |
| 19:11 | rickmode | but ya - I am wrapping some method calls in fn's and passing those around instead |
| 19:11 | notostraca | http://pastebin.com/FcUajnfB is the clojure, http://pastebin.com/iYTLQz8s is the java, http://pastebin.com/qg2YMzKM is the stack trace |
| 19:11 | gtrak | that's the best you can do really |
| 19:12 | rickmode | (def assets (agent {} :meta {:primary? true :key-fn (fn [^AssetBean a] (.getId a))})) |
| 19:12 | gtrak | notostraca, you have to aot compile the namespace |
| 19:12 | notostraca | gtrak, I did that |
| 19:12 | gtrak | i don't think you did |
| 19:12 | notostraca | I get eclipse to auto-complete the namespace, so... |
| 19:12 | rickmode | it's kinda slick - one set of code that handles cache maps keyed an arbitrary method of an object |
| 19:13 | gtrak | there's another way to make clojure run the ns and compile it, i forget |
| 19:13 | notostraca | I see TSVReader.class in the /classes folder... |
| 19:13 | notostraca | or rather in the namespace in the /classes folder |
| 19:13 | notostraca | but it is possible I am modifying the map somewhere |
| 19:14 | gtrak | notostraca, it's a compilation problem |
| 19:14 | notostraca | ok |
| 19:14 | notostraca | I will see what I can do... |
| 19:15 | gtrak | how are you actually running it? |
| 19:15 | gtrak | from the java? |
| 19:16 | notostraca | yeah, I pasted the java file |
| 19:16 | notostraca | http://pastebin.com/iYTLQz8s |
| 19:17 | gtrak | and what are you using to build the classes? |
| 19:17 | gtrak | eclipse? |
| 19:17 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IPersistentStack> |
| 19:17 | notostraca | yeah, with ccw |
| 19:17 | gtrak | are they separate projects? |
| 19:17 | notostraca | no |
| 19:17 | notostraca | I am using the compile in repl function of CCW |
| 19:17 | gtrak | hmm, I'm not quite sure then |
| 19:18 | gtrak | but the java compiles? |
| 19:19 | rickmode | notostraca: silly question perhaps, but why are you constructing a hashmap copying the data from the hashmap passed back by loadTSV? |
| 19:19 | notostraca | yes, the exception is at runtime |
| 19:19 | gtrak | hmmm |
| 19:19 | gtrak | what's the point of the '-' prefix? |
| 19:19 | gtrak | just asking b/c i've never done it |
| 19:19 | notostraca | loadTSV returns a Map, which should be pass-able to the constructor of a HashMap |
| 19:19 | jeremyheiler | either case, "-" is the default |
| 19:19 | notostraca | (ccw.debug.serverrepl/with-exception-serialization (clojure.core/binding [clojure.core/*compile-path* "classes"] (clojure.core/compile 'net.myexperiments.viciouscycle.util.TSVReader))) |
| 19:19 | notostraca | net.myexperiments.viciouscycle.util.TSVReader |
| 19:20 | notostraca | sorry about the paste, but that's the "compile in REPL" line and its output |
| 19:20 | gtrak | notostraca, so... maybe you never initialized the namespace |
| 19:20 | notostraca | yeah, I don't have an init function |
| 19:21 | notostraca | I don't know what I would do in it if everything is static |
| 19:21 | rickmode | perhaps just use HashMap<String, Map<String, String>> tableData = loadTSV(...); |
| 19:22 | rickmode | notostraca: what gtrak is saying is: you haven't initialized Clojure |
| 19:22 | notostraca | d'oh |
| 19:22 | gtrak | rickmode, it might not be needed, since the class is AOT compiled |
| 19:22 | gtrak | looking at this: http://stackoverflow.com/questions/2181774/calling-clojure-from-java |
| 19:22 | rickmode | check out clojure.main.java for an example |
| 19:23 | rickmode | hmmmm... |
| 19:23 | gtrak | notostraca, {:static true} [loadTSV [String] java.util.Map] and (defn load-tsv-clj |
| 19:23 | gtrak | typo? |
| 19:24 | rickmode | notostraca: try simplifying things... create a method that returns a boolean or something and make sure that call works |
| 19:24 | notostraca | ok |
| 19:25 | gtrak | notostraca, ha, does prefix not need ""? |
| 19:25 | gtrak | look at this: http://kotka.de/blog/2010/02/gen-class_how_it_works_and_how_to_use_it.html |
| 19:25 | rickmode | notostraca: it smells like there's trouble with the nested maps... maybe some sort of type mismatch clojure doesn't care about? |
| 19:25 | gtrak | rickmode, that's not it |
| 19:25 | notostraca | gtrak, I have a separate loadTSV and load-tsv-clj function so one can be dynamic and have ints and strings mixed, and one is just all strings for Java |
| 19:26 | gtrak | looks like the prefix should work fine |
| 19:27 | rickmode | notostraca :have you tried using Object as the return type and inspecting the returned value in Egglips to see if what your getting back matches your type signature? |
| 19:28 | gtrak | rickmode, it's not getting that far |
| 19:28 | notostraca | waitaminute |
| 19:29 | notostraca | :static true ? |
| 19:29 | rickmode | oic |
| 19:29 | gtrak | static true should work |
| 19:29 | gtrak | otherwise the java wouldn't compile |
| 19:30 | notostraca | #^{:static true} or ^{:static true} |
| 19:30 | notostraca | do I need the # ? |
| 19:31 | gtrak | that's not the issue |
| 19:31 | gtrak | try naming the methods the same |
| 19:31 | gtrak | -loadTSV and loadTSV |
| 19:32 | rickmode | last time i messaged with gen-class I used the macro version instead of :gen-class in ns |
| 19:33 | rickmode | But... It looks like your ns should be net.myexperiments.viciouscycle.util... your name is OK |
| 19:34 | gtrak | yea, strange, I don't get it |
| 19:35 | rickmode | actually it looks like it'll work |
| 19:35 | gtrak | notostraca, wait, why is load-impl-ns flase? |
| 19:36 | gtrak | false* |
| 19:39 | gtrak | ah, I see that only affects if it tries to compile the .clj |
| 19:39 | gtrak | it might not make a difference |
| 19:39 | gtrak | well, i'm stumped |
| 19:40 | notostraca | sorry, I was working on a previous suggestion |
| 19:41 | notostraca | I made a function called returnsTrue |
| 19:41 | notostraca | guess what it does... |
| 19:41 | gtrak | same thing? |
| 19:41 | notostraca | and it can't be called either |
| 19:41 | gtrak | try making load-impl-ns true |
| 19:42 | gtrak | notostraca, it seems like you should only set it false if you know what you're doing, eg. some special compilation stuff |
| 19:43 | gtrak | that's gotta be it |
| 19:43 | notostraca | gtrak, if I set it to true I get a different error |
| 19:43 | notostraca | http://pastebin.com/Fckvfy53 is my java code now |
| 19:43 | gtrak | show the tra e |
| 19:44 | gtrak | trace* |
| 19:45 | notostraca | http://pastebin.com/J6z7Lsgu |
| 19:45 | notostraca | err |
| 19:45 | notostraca | that's the clojure code |
| 19:45 | gtrak | set load-impl-ns to true |
| 19:45 | notostraca | http://pastebin.com/EhXvd2Fw is the trace |
| 19:45 | notostraca | doing that now |
| 19:45 | gtrak | and make it -returnsTrue |
| 19:47 | zakwilson | https://github.com/zakwilson/timeline/blob/master/src/timeline/data.clj <-- trying out Korma here and... not quite getting it. Throws NPE whenever I try to select an event. |
| 19:48 | notostraca | ok, with it true, http://pastebin.com/8ByRMqUW |
| 19:48 | notostraca | oh right, - |
| 19:48 | gtrak | and.... magic? |
| 19:50 | notostraca | and, with the -, http://pastebin.com/kWQDytCm |
| 19:50 | notostraca | same stack trace |
| 19:51 | gtrak | hmm, so this error is happening in the init of the namespace |
| 19:51 | gtrak | it's not getting to your method call yet |
| 19:51 | notostraca | aaaaah... |
| 19:52 | gtrak | it looks as if there's a classpath issue? maybe the class is compiled against a different version of clojure than supplied? |
| 19:52 | notostraca | I don't have an init function, but the class is supposed to be all static methods |
| 19:52 | notostraca | oh that could be it! |
| 19:52 | gtrak | notostraca, all namespaces have a static initializer |
| 19:54 | gtrak | notostraca, yup that's it: a quote from a newsgroup thread with the same error: "turns out that the 0.2.5-SNAPSHOT build |
| 19:54 | gtrak | erroneously included some AOT-compiled class files built against |
| 19:54 | gtrak | Clojure 1.2.0 that precluded that build of Clutch from working with |
| 19:54 | gtrak | 1.3.0. I have now pushed up a new 0.2.5-SNAPSHOT to clojars that |
| 19:54 | gtrak | should resolve your issue." |
| 19:55 | notostraca | it might be that I am compiling with 1.3.0 and using 1.2.0 |
| 19:55 | notostraca | or vice versa |
| 19:55 | gtrak | yea, exactly |
| 19:55 | gtrak | so your aot class is linked against different java classes |
| 19:55 | gtrak | fix that shit |
| 20:00 | gtrak | notostraca, you can learn a lot from this: http://clojure.org/compilation |
| 20:00 | notostraca | looks like it works now! |
| 20:02 | notostraca | gtrak, yeah I read that many times... |
| 20:02 | notostraca | the version thing was the issue |
| 20:02 | gtrak | not just that |
| 20:02 | gtrak | notostraca, so yea, you had two problems, you definitely want to let clojure initialize the namespace for you, and you disabled that, and the namespace couldnt' call a clojure.lang.RT.keyword( method because it didn't exist, because the versions were wrong |
| 20:02 | notostraca | oh ok |
| 20:03 | gtrak | clojure.lang.RT is a java class in the clojure.jar |
| 20:03 | notostraca | oh wow, thank you, all of #clojure |
| 20:04 | notostraca | it is nice to have a helpful community for a great language :-) |
| 20:04 | gtrak | https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java |
| 20:04 | gtrak | take a look |
| 20:04 | jeremyheiler | notostraca: thank you for bringing up an interesting problem, forcing me to dive into gen-class |
| 20:04 | gtrak | notostraca, yes, I've been meaning to learn gen-class as well :-) |
| 20:05 | gtrak | now I feel like I know it |
| 20:05 | notostraca | glad I could... help? |
| 20:05 | notostraca | good good |
| 20:05 | notostraca | and clojure seems to handle all the data stuff I want to use it for with flying colors |
| 20:06 | gtrak | now i just have to learn records and protocols |
| 20:06 | gtrak | and macros |
| 20:06 | notostraca | same here :-) |
| 20:09 | gtrak | it's fun to learn the innards though, I always feel like I learned some secret power when I dig through clojure :-) |
| 20:09 | gtrak | in java innards I'm thinking 'why the f*** did they do that way?' |
| 20:10 | notostraca | haha true |
| 21:15 | TimMc | alexbaranosky: What license should I stick on the seqs-and-colls thing? EPL seems traditional around here. |
| 21:17 | seancorfield | is there something like interleave that works with sequences of unequal length? |
| 21:18 | seancorfield | easy enough to write my own but i didn't want to reinvent the wheel... :) |
| 21:19 | TimMc | seancorfield: Like 1111 22222222 -> 122122122122? |
| 21:21 | seancorfield | more like 12121212 then the rest of the longer seq |
| 21:22 | seancorfield | and it needs to be lazy :) |
| 21:22 | seancorfield | so no (take (min (apply map count the-seqs)) ...) stuff :) |
| 21:23 | seancorfield | i'll just take a copy of interleave and modify it for my needs |
| 21:23 | notostraca | seancorfield, makes sense |
| 21:23 | notostraca | gotta love open source :-) |
| 21:23 | seancorfield | maybe i'll ask on -dev why interleave has to have seqs of identical lengths (or it throws away additional items) |
| 21:24 | notostraca | oh, actually... |
| 21:24 | seancorfield | i can understand map doing that (since you have a fn of a fixed number of args) |
| 21:24 | TimMc | seancorfield: Call it interleave-all, in the spirit of partition-all. |
| 21:24 | notostraca | you could interleave until you reach the end of either seq and then conjoin on the rest of the remaining seq? |
| 21:24 | seancorfield | ,(interleave [1 2 3 4 5] [:a :b :c]) |
| 21:24 | clojurebot | (1 :a 2 :b 3 ...) |
| 21:24 | TimMc | haha, clojurebot |
| 21:24 | seancorfield | not helpful clojurebot ! |
| 21:25 | TimMc | seancorfield: Also, make sure it takes an arbitrary number of arguments! |
| 21:25 | notostraca | ,(interleave [1] [:a :b :c] |
| 21:25 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 21:25 | notostraca | ,(interleave [1] [:a :b :c]) |
| 21:25 | clojurebot | (1 :a) |
| 21:25 | TimMc | &(interleave [1 2 3 4 5] [:a :b :c]) |
| 21:25 | lazybot | ⇒ (1 :a 2 :b 3 :c) |
| 21:25 | seancorfield | TimMc: if it's based on interleave, it will :) |
| 21:26 | notostraca | &(interleave '(1) [:a :b] {"Alpha" "Bet") |
| 21:26 | lazybot | java.lang.RuntimeException: Unmatched delimiter: ) |
| 21:26 | notostraca | &(interleave '(1) [:a :b] {"Alpha" "Bet"}) |
| 21:26 | lazybot | ⇒ (1 :a ["Alpha" "Bet"]) |
| 21:26 | TimMc | seancorfield: It's been done on the ML. |
| 21:27 | TimMc | seancorfield: https://groups.google.com/group/clojure/msg/cbe820823ff7f9ac |
| 21:29 | seancorfield | nice, thanx TimMc |
| 21:29 | notostraca | Huh, what is John Harrop doing on the Clojure ML? Isn't he an F#/OCaml guru? |
| 21:30 | TimMc | EPL: "Contributor" means any person or entity that distributes the Program. |
| 21:30 | TimMc | ^ that's a weird definiton |
| 21:31 | TimMc | notostraca: SCANDAL |
| 21:31 | notostraca | TimMc, heh yes |
| 21:31 | TimMc | Next we will see a Fox News exposé. :-P |
| 21:32 | notostraca | I like F# too, but the current application I am using uses the JVM, and I know Java better than C# anyway -- plus, Clojure is great |
| 21:32 | notostraca | I really have found dealing with complex data to be very simple with Clojure |
| 21:33 | notostraca | but it has been hard to translate from Clojure to Java, which is most of what I have been doing with Clojure has been... |
| 21:34 | TimMc | notostraca: You mean interop where Java consumes data from a Clojure API? |
| 21:34 | notostraca | TimMc, well... |
| 21:36 | TimMc | Hmm, the EPL doesn't feel as solid as the GPL in terms of consistency. |
| 21:44 | notostraca | TimMc, the code I was trying to write needing to extend a Java class at read-time, without being AOT-compiled first, so gen-class wouldn't help. I needed the public variables declared in the parent class to be used in my code... |
| 21:44 | notostraca | (this is using the messy Java game library GTGE) |
| 21:45 | notostraca | I'm considering just using LWJGL... |
| 21:52 | TimMc | notostraca: So proxy isn't sufficient? |
| 21:54 | notostraca | TimMc, it might, but I was trying the wrong everything, it seemed -- now I am going to use Clojure for library code to deal with tricky data stuff, and stick to Java for slow-grind code |
| 21:55 | TimMc | heh |
| 23:07 | technomancy | http://twitter.com/#!/headius/status/142457369476083712 |
| 23:28 | tmciver | what's the difference between (fn [a b & more] ...) and (fn [a b & [more]]...)? |
| 23:31 | tmciver | &((fn [a b & more] [a b more]) 1 2 3 4 5) |
| 23:31 | lazybot | ⇒ [1 2 (3 4 5)] |
| 23:32 | tmciver | &((fn [a b & more] [a b [more]]) 1 2 3 4 5) |
| 23:32 | lazybot | ⇒ [1 2 [(3 4 5)]] |
| 23:32 | tmciver | &((fn [a b & [more]] [a b more]) 1 2 3 4 5) |
| 23:32 | lazybot | ⇒ [1 2 3] |
| 23:32 | tmciver | &((fn [a b & [more]] [a b more]) 1 2 [3 4 5]) |
| 23:32 | lazybot | ⇒ [1 2 [3 4 5]] |
| 23:35 | tmciver | &((fn [a b & [more]] [a b more]) 1 2 {:a 1 :b 2}) |
| 23:35 | lazybot | ⇒ [1 2 {:a 1, :b 2}] |
| 23:35 | tmciver | &((fn [a b & [more]] [a b more]) 1 2 {:a 1 :b 2} 3 4) |
| 23:35 | lazybot | ⇒ [1 2 {:a 1, :b 2}] |
| 23:52 | georgek | hi, what are some common reasons why I would get an error of "Starting swank server... |
| 23:52 | georgek | error in process filter: Symbol's value as variable is void: Warning" on clojure-jack-in, this is Emacs 24 from a clean lein new test project |
| 23:54 | technomancy | georgek: make sure you're on the latest clojure-mode |
| 23:58 | georgek | technomancy: just reinstalled and I have 1.11.2, though your repo says 1.11.4 is the latest, would that bugfix possibly fix this issue do you think? |
| 23:58 | technomancy | georgek: yeah, that was a recent fix |