#clojure log - Dec 02 2011

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:00 devn: technomancy: i'm not sure what you mean by referencing 12factor

0:01 technomancy: i was referring to heroku allowing for the end-user to decide how their app should be built via lein, etc.

0:03 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

0:11 technomancy: oh, yeah. you can alter the buildpack now; it's all open source

0:11 (kind of a soft launch thing)

0:11 https://github.com/heroku/heroku-buildpack-clojure

0:33 devn: technomancy: awesome! thanks.

0:34 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?

0:34 I'm sick of dancing around it. It's better in so many ways than previous languages I've used.

1: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?

1:16 tensorpudding: well, slime can connect to swank on other hosts can't it

1:20 technomancy: notsonerdysunny: you have to tunnel it over SSH

1:23 notsonerdysunny: technomancy: can you may be tell me how to do that..?

1:24 technomancy: same as you'd tunnel any protocol really; using the -L argument

1:24 http://www.revsys.com/writings/quicktips/ssh-tunnel.html

1:52 hiredman: technomancy: so I've started on a roundtripping reader and some code to edit and re-align code using zippers

1:53 (you end up with these whitespace nodes all over the place you want to skip over)

1:54 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

2:18 zerokarmaleft: that's cool, i'd love to have bindings reformatted like that at the press of a button

2:23 spoon16: technomancy

2:23 you around?

3:04 wiseen: are :pre and :post conditions always executed or only in debug mode ?

3:10 spoon16: in leiningen is it possible to change the :library-path for dev dependencies?

3:45 bartj: while using send-off, is there a default first parameter ?

4:40 Borkdude: morning.

4:41 kzar: G'mornin'

4:42 ejackson: wotcha

4: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?

4:45 So how go about it then?

4:45 sorry symbol evaluates to its value I mean

4:45 the value it is currently bound to

4:47 this clearly isn't possible: (my-doc +), because + would evaluate to the value, a function

4:48 Chousuke: Borkdude: you need a macro

4:48 Borkdude: but how would you make (my-doc '+) work?

4:48 raek: Borkdude: your description is accurate - for a function

4:48 Borkdude: 'doc' is a macro, so the usual rules of evaluation do not have to apply

4:49 Borkdude: raek: I see that, but doc expects a "name", is that a symbol?

4:49 Chousuke: yes.

4:49 but since it's a macro it treats its arguments literally, ie. without evaluating them

4:49 raek: Borkdude: it requires that the code literal at that place is a symbol

4:50 Borkdude: Can we make a function that expects a symbol and just passes it to doc?

4:50 Chousuke: not without trickery.

4: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

4:50 Chousuke: you need eval for that

4:51 eg (defn my-fn-doc [s] (eval (list 'doc s)))

4:51 but that's bad. don't do that :P

4:52 Borkdude: hehe, it was the accepted answer on SO

4:52 raek: but since there is no function version of 'doc', does Borkdude have any other alternative?

4:52 Wild_Cat: why is doc a macro, btw?

4:53 Chousuke: for nicer syntax I guess

4:53 raek: Wild_Cat: probably for user convenience. you don't have to use it like (doc #'some-fn)

4:54 the implementors should have made a function version too

4: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 '+ ?

4:54 Chousuke: Borkdude: because then doc looks up the documentation for s

4:54 as in, the literal s

4:54 Wild_Cat: raek: hmm... Why would I need to #' a function whose doc I want?

4:54 raek: Borkdude: (doc s) will always get the same argument: the symbol s

4:54 Wild_Cat: (note: I'm an extreme noob to both Clojure and Lisps in general, my questions may seem dumb)

4:54 raek: Wild_Cat: because the doc string is not stored in the value of the var, but in the var itself

4:55 Wild_Cat: raek: ah!

4:55 raek: ,(:doc (meta #'conj))

4: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."

4:55 Borkdude: Chousuke: this makes sense

4:55 raek: ,(:doc (meta conj))

4:55 clojurebot: nil

4:55 Wild_Cat: raek: so you mean that given a documented function f and (def g f), (doc g) wouldn't give me anything?

4:55 raek: Wild_Cat: yes.

4:56 Wild_Cat: I see.

4:56 that's an important difference from Python, I guess (where docstrings are stored in the __doc__ attribute of whatever it is you're documenting)

4:56 raek: this is one reason it is hard to do a namespace that "forwards" to another

4:59 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*".

5:01 Borkdude: raek: can you give a real example of this?

5:02 raek: bound-fn and bound-fn*

5:02 Fossi: let let*

5:02 raek: future and future-call

5:02 Borkdude: ,(doc bound-fn)

5: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."

5:02 Borkdude: ,(doc bound-fn*)

5: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."

5:03 Borkdude: same docs? no info on macro of fn?

5: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))

5:04 Borkdude: ah, i see

5:04 ,(doc let*)

5:04 clojurebot: excusez-moi

5:05 raek: fn* and let* are not examples of this

5:05 they are "the real" special forms

5:05 fn and let are actually macros

5:05 Fossi: oh, k

5:05 Borkdude: ok

5:05 raek: I think it has to do with where destructuring happends

5:06 also: (future (x)) == (future-call (fn [] (x)))

5:06 (which also explains how 'recur' behaves in the body of 'future')

5:15 tscheibl: ,(->> ["Hello" "world"] (#(if (< 0.5 (rand)) (replace {"world" "underworld"} %1) %1)) (clojure.string/join " "))

5:15 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.string>

5:15 tscheibl: :p

5:15 outsmarting the threading operators

5: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?

5:43 (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?)

5:44 raek: biallym: this is usually solved by passing #'foo instead of foo

5:45 vars implement IFn by delegating to their current value

5:45 biallym: Awesome!

5:45 that is a very acceptable solution!

5:46 Did I mention that I love's clojure's design more and more every day

5:46 (And java's less and less)

5:46 (Not that I have ever used java, but java interop is always a pain for me)

5:46 tscheibl: same goes for me :)

5:47 i'm beginning to forget about the java syntax...

5: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?

5:48 One thing that I noticed was: [INFO] artifact org.clojure:clojure: checking for updates from sonatype-snapshots

5:48 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.

5: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

5:50 tscheibl: @raek: vars implement IFn?

5:50 ,(#(%) #'a)

5:50 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)>

5:51 tscheibl: ,(let [a 42] (#(%) #'a))

5:51 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)>

5:51 tscheibl: ,(def a 42) (#(%) #'a)

5:51 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

5:51 tscheibl: arghh

5:52 , (let [a 42] (#(%) #'a))

5:52 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)>

5:53 tscheibl: throws this in my 1.3 repl: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>

5: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

5:54 it does implement IFn

5:54 but a long doesn't

5:54 so probably you're getting the value of a var and not the var itself?

5:54 biallym_: ,(let [a (var #(identity %)] (#'a :foo))

5:54 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: ]>

5:54 tscheibl: but i'm passing the var...

5:54 biallym_: ,(let [a (var #(identity %))] (#'a :foo))

5:54 clojurebot: #<CompilerException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol, compiling:(NO_SOURCE_PATH:0)>

5:55 biallym_: ,(let [a (var #(identity %))] (a :foo))

5:55 clojurebot: #<CompilerException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol, compiling:(NO_SOURCE_PATH:0)>

5:55 biallym_: I give up >.>

5:55 Borkdude: biallym you are getting the var of an anonymous function, does that make sense ?

5:55 tscheibl: why?

5:55 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IPersistentStack>

5:55 biallym_: I was trying to make a var

5:55 >.>

5:55 obviously not working

5:55 Borkdude: ,(doc var)

5:55 clojurebot: No entiendo

5:56 tscheibl: ,(let [a 42] (fn [a*] (a*)) (var a))

5:56 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)>

5:56 tscheibl: outputs the var in my 1.3 rwpl

5:56 #'at.hauptversammlung.backoffice.server.api.core/a

5:56 like thios

5:56 Borkdude: biallym_: var takes a symbol

5:57 tscheibl: ok wrong... hehe

5:57 biallym_: Yea I know that now... I thought it was like ref :p

5:57 obviously I failed miserably

5:57 tscheibl: ,(let [a 42] ((fn [a*] (a*)) (var a)))

5:57 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)>

5:58 tscheibl: outputs: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>

5:58 .. in my repl

5:58 biallym_: ,*1

5:58 clojurebot: #<Unbound Unbound: #'clojure.core/*1>

5:58 tscheibl: ,(let [a 42] ((fn [b] (b)) (var a)))

5:58 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)>

5:58 biallym_: ,(binding [*1 (fn [x] (identity x))] (*1 :foo))

5:58 clojurebot: :foo

5:59 biallym_: thats what I was trying to do

5:59 &*1

5:59 lazybot: ⇒ #<Unbound Unbound: #'clojure.core/*1>

5:59 tscheibl: yep... but obviously I cannot execute a var as a function...

5:59 Borkdude: tscheibl: let doesn't use vars

6:00 biallym_: look at how I did

6:00 it

6:00 tscheilb, you are doing it wrong >.>

6:00 binding manipulates vars

6:00 vars are not an object you can create

6:00 tscheibl: that's obvious, too

6:00 biallym_: they are a pseudo construct of the symbol table

6:00 tscheibl: hmm

6:01 biallym_: let me use a better example

6:01 tscheibl: (let [a 42] ((fn [a*] (var-get a*)) (var a)))

6:01 this works.... but I have to use var-get

6:02 biallym_: Thats because var implements IFn by returning the value, 42 doesn't implement IFn

6:03 A better example:

6:04 &(binding [*1 (fn [x] (identity x))] ((var *1) :foo))

6:04 lazybot: java.lang.SecurityException: You tripped the alarm! pop-thread-bindings is bad!

6:05 biallym_: &(binding [*1 (fn [x] (identity x))] (#'*1 :foo))

6:05 lazybot: java.lang.SecurityException: You tripped the alarm! pop-thread-bindings is bad!

6:05 tscheibl: damn bots ;)

6:05 biallym_: &(binding [*1 (fn [x] (identity x))] (*1 :foo))

6:05 lazybot: java.lang.SecurityException: You tripped the alarm! pop-thread-bindings is bad!

6:05 biallym_: ,(binding [*1 (fn [x] (identity x))] (*1 :foo))

6:05 clojurebot: :foo

6:05 biallym_: ,(binding [*1 (fn [x] (identity x))] ((var *1) :foo))

6:05 clojurebot: :foo

6:05 biallym_: btw identity is broken

6:06 actually . is broken

6:06 but w/e

6:06 which just makes java interop so much more painful

6:07 tscheibl: ,(binding [*1 (fn [x] x)] ((var *1) :foo))

6:07 clojurebot: :foo

6:07 tscheibl: why do u use identity at all?

6:07 biallym_: Oh because I was using the #(fn %)

6:07 form, which requires a fn on the front

6:07 tscheibl: ahh

6:08 .. ok now I'm beginning to grasp...

6:09 the vars IFn implementation calls the underlying value as a function

6:09 biallym_: Yes

6:10 Oh I did not fully grasp this the first time around.. so much mroe awesome, so many problems fixed

6:10 tscheibl: ... before i thought it would return the vars value .. like var-get

6:10 biallym_: so many fewer macros to write

6:10 it's 3am, I can have horrible english >.>

6:11 tscheibl: .. no prob :)

6:11 ... i wouldn't recognize

6:12 ..i'm austrian.. we speak mountain english

6:12 tsdh: Is there something to tell the clojure reader/compiler "ignore the following if (foo) evaluates to false"?

6:12 tscheibl: macro

6:12 tsdh: tscheibl: Or, right. :-)

6:34 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...

6: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

6:49 tscheibl: kzar: maybe this way https://github.com/mmcgrana/clj-http

6: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

6:50 tscheibl: exactly

6:50 kzar: tscheibl: But it seems like a PITA and a hack when HTTP has support for proxies?

6:51 tscheibl: how would http support proxies?

6:51 without a proxy server?

6:52 ..someone will have to do the proxying

6: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

7: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

7:03 this is a jetty proxy handler

7:03 .. but you would have to do some java interop

7:07 kzar: tscheibl: cheers

7: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

7:15 i.e. the lower the value, the more chance it has of being selected

7:15 in the above case "ydwD0" and "o_E-." would be the most likely to be returned

7:17 currently it's extremely inefficient: https://gist.github.com/1423043

7:17 popfitness would be the above map

7:19 Fossi: how do you want to map "fitness" to your randomization? linear like in the above?

7:19 ejackson: daniel: you should assign a value to each entry, normalize by the total and then use inversion sampling

7:19 http://en.wikipedia.org/wiki/Inverse_transform_sampling

7:20 if you sample without replacement you will need to renorm after the first sample

7:21 daniel: Fossi, I would like to test different possibilities ideally

7:22 kephale: ejackson: for evolutionary computation this is standard practice

7:22 daniel: thanks ejackson

7:22 kephale: daniel: look up roulette wheel selection, there are algorithms for it online

7:22 daniel: kephale: cheers

7:22 ejackson: kephale: yeah, its bread and butter across the board :)

7: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)

7:24 of course tournament selection is better than fitness proportional anyway

7:27 ejackson: kephale: I'm not sure I understand your jargon (not used perjoratively), what do you mean by tournament selection and fitness proportional ?

7: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

7:28 so i generate a random number between 0 and 1

7:29 ejackson: then choose that value form the vector of cumulative probabilities that is the lowest value greater than your random number

7:29 bobs your uncle

7:30 daniel: how do i make the probabilities cumulative?

7:30 kephale: daniel: like ejackson said. you can't use a map because you need to keep the individuals sorted by their cumulative fitness

7:31 ejackson: ,(reductions + 0 [1 2 3])

7:31 clojurebot: (0 1 3 6)

7:31 ejackson: take (rest ...) of that

7: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

7:33 daniel: ,(reductions + 0 [1 2 4])

7:33 clojurebot: (0 1 3 7)

7: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

7:33 daniel: kephale: isn't that a poor model for reality?

7:33 ejackson: kephale: is it reduced variance or something ?

7: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.

7:34 ejackson: kephale: aaaah, its domain optimisation thing.

7:35 makes sense

7:35 kephale: mmm, its fun stuff

7: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 :>

7:35 daniel: kephale: that being tournament selection

7:35 kephale: Fossi: lol

7:36 raek: tscheibl: did you get your question answered?

7: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

7: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

7:41 kephale: daniel: that is fine, but doing it over a tournament instead of the entire population is the key idea there.

7: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

7:42 ah no

7:42 ok, i got it :)

7:44 kephale: daniel: out of curiosity, is this for a class?

7:44 daniel: nope

7:44 just me playing about with stuff

7:44 kephale: ah cool, all the better

7:46 daniel: trying to learn me some clojure and it seemed like a fun little program to write

7:47 also trying to fill my github page with as many little projects as possible in the hope of finding better employment

7:48 kephale: CS research FTW

7:48 biallym_: Any leiningen gurus know how native deps work?

7:49 Because I am having trouble getting them to work and I think it is conceptual problem

7:50 daniel: kephale: wouldnt be any point where im living

7:50 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]]

7: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

7: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

7:54 daniel: kephale: so instead of 9616, i'd have 9616 + 4289 ?

7:54 and so on

7:54 first i need to sort them right?

7: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)

7:55 and yes, first sort by the values returned by reductions

7:55 daniel: sorry, assuming they are normalised

7:56 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)

7:57 i need to normalize (total - value) i think

7:57 so they are all inverted

7: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

7:58 daniel: dont i have to sort before taking the reductions?

7:59 kephale: no, you just need the order to be based on the cumulative sum

8:00 in theory you miiight get a slight performance bump by sorting before calling reductions

8:01 daniel: my understanding is: sort from lowest to highest value, normalize, reductions

8:02 so once they are normalized they should be sorted from highest to lowest probability

8:02 and then picking a random number between 0-1 will tell me where in the order to select from

8: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

8:03 then you spin the wheel, and probabilistically you will land on the individuals of appropriate fitness regardless of the initial sort

8: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?? :/

8:06 you're saying i can do without sort altogether?

8:06 kephale: yeah

8:06 ,(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)

8:06 clojurebot: (["{x:I{" 0.11090138] [".^t#c" 0.3595439] ["072!^" 0.77806795] ["P`VQx" 0.844495] ["t3x.g" 1.0])

8: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.

8:07 daniel: in the above, "P`VQx" 0.844495 should be most likely

8:08 however i dont see how selecting a random number between 0 and 1 would yield that with most likelihood

8: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

8:08 in the above the most likely would be 072...

8:08 daniel: i dont have negative fitness (0 is perfectly matching target)

8:08 kephale: any value of rand between 0.359 and 0.778 matches 072!^

8:09 daniel: i see, so yeah i need it the other way

8:09 kephale: yeah i know, but i got lazy

8:09 daniel: i need to normalize (total - val) so that higher = better

8:09 kephale: and didnt want to take your fun : P

8:11 daniel: anyway, i've grilled you enough :) i have more than enough to be getting on with

8:11 thanks a lot

8:11 kephale: cheers and enjoy

8:56 tscheibl: raek: yep, thx

9:36 ilyak: hi *

9:36 I have a long 3585395648

9:36 how do I make int -709571648 from it in clojure?

9:37 in java ((int) Long.parseLong("3585395648") & 0xffffffff) does the trick

9:37 ,(int (bit-and 0xffffffff (Long/parseLong "3585395648")))

9:37 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Value out of range for int: 3585395648>

9:37 raek: ilyak: 3585395648 does not fit in an int

9:38 ilyak: raek: Therefore I want -709571648

9:38 Which does :)

9:38 clgv: ,(int (bit-and (long 0xffffffff) (Long/parseLong "3585395648")))

9:38 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Value out of range for int: 3585395648>

9:38 raek: ,(bit-and 0xffffffff 3585395648)

9:38 clojurebot: 3585395648

9:39 raek: ,(bit-and 0x0ffffffff 3585395648)

9:39 clojurebot: 3585395648

9:40 ilyak: , (- 0xffffffff 3585395648)

9:40 clojurebot: 709571647

9:40 ilyak: I guess I can use this but still

9:40 ,(- 3585395648 0xffffffff)

9:40 clojurebot: -709571647

9:40 ilyak: ,(- 3585395648 0x100000000)

9:40 clojurebot: -709571648

9: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...

9:43 ilyak: exactly

9:51 raek: ,(.intValue 3585395648)

9:51 clojurebot: -709571648

9:52 raek: ilyak: that does not use the dedicated JVM instruction, but is short at least

9:59 ilyak: :)

9:59 cool

10:01 raek: ,(unchecked-int 3585395648)

10:01 clojurebot: -709571648

10:01 raek: there it is!

10:01 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 ,(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 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 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 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 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 ejackson: yeah, it's pretty rough

10:25 ejackson: have you tried a model dependent filter ?

10:25 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 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 data from this kind of study

10:30 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 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 ejackson: e.g., LPF everything greater than the supposed signal?

10:36 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 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 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 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 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 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 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 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 (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 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 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 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 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 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 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 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 *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 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 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 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 ..arhhh gen-class

12:28 TeXnomancy: hiredman: so you've started a reader! interesting.

12:28 is it based on your old reader?

12:28 tscheibl: deftype would have been more elegant

12:28 hiredman: TeXnomancy: no

12:30 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 read* at the bottom is the function I have been using for testing

12:33 pass it an inputstream, you can back a seq of Nodes, that may change

12:33 err, you get back a single node actually

12:33 anyway, you have Nodes that represent whitespace so you can round trip, needs comment support, etc

12:34 TeXnomancy: slick!

12:34 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 TeXnomancy: no

12:35 needs metadata support and lots of other stuff

12:35 (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 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 with nesting

12:38 hiredman: technomancy: yeah, I had other plans, but they ended up falling through

12:38 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 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 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 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 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 pauldoo: it requires a change to Clojure.

15:57 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 ,((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 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 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 (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 &`#(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 tsally: I don't know if recur in #() ever happens in the real world.

16:13 recur usually indicates a sufficiently complicated operation is being written that it deserves to be named.

16:14 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:35 duck1123: gtrak: looks like it's just calling out to growlnotify

16:35 so no

16:35 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 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 (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 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:05 * jweiss surprised this isn't possible with reflection

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 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 technomancy: dont have clojure or lein or anything

17:11 emacs and a java vm

17:11 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 The exact exception is

17:27 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 In my clojure ns, I have: :methods [^{:static true} [loadTSV [String] java.util.Map]

17:31 and it is possible the typing is screwed up

17:32 oh sorry, that :methods is part of a :gen-class with: :name "net.myexperiments.viciouscycle.util.TSVReader" :load-impl-ns false

17:33 and I don't really know what load-impl-ns does either

17:40 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 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 the clojure doc shows there being an outer vector

17:45 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 you can use getenv and setenv to figure it out

17:50 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 which makes sense why it wouldnt source

17:50 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 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 jeremyheiler, I think you need to be compiling

18:30 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 (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 the Java call is just

18:42 tableData = TSVReader.loadTSV("text" + File.separator + "TSVTable.txt");

18:43 oh, the type of tableData is Map<String, Map<String, String>>

18:45 the error is still java.lang.UnsupportedOperationException by the way

18:45 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 hmm, same error

18:50 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 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 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 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 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 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 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 or rather in the namespace in the /classes folder

19:13 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 I will see what I can do...

19:15 gtrak: how are you actually running it?

19:15 from the java?

19:16 notostraca: yeah, I pasted the java file

19:16 http://pastebin.com/iYTLQz8s

19:17 gtrak: and what are you using to build the classes?

19:17 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 I am using the compile in repl function of CCW

19:17 gtrak: hmm, I'm not quite sure then

19:18 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 what's the point of the '-' prefix?

19:19 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 net.myexperiments.viciouscycle.util.TSVReader

19:20 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 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 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 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 hmmmm...

19:23 gtrak: notostraca, {:static true} [loadTSV [String] java.util.Map] and (defn load-tsv-clj

19:23 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 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 :static true ?

19:29 rickmode: oic

19:29 gtrak: static true should work

19:29 otherwise the java wouldn't compile

19:30 notostraca: #^{:static true} or ^{:static true}

19:30 do I need the # ?

19:31 gtrak: that's not the issue

19:31 try naming the methods the same

19:31 -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 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 slaps notostraca

19:36 gtrak: false*

19:39 ah, I see that only affects if it tries to compile the .clj

19:39 it might not make a difference

19:39 well, i'm stumped

19:40 notostraca: sorry, I was working on a previous suggestion

19:41 I made a function called returnsTrue

19:41 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 notostraca, it seems like you should only set it false if you know what you're doing, eg. some special compilation stuff

19:43 that's gotta be it

19:43 notostraca: gtrak, if I set it to true I get a different error

19:43 http://pastebin.com/Fckvfy53 is my java code now

19:43 gtrak: show the tra e

19:44 trace*

19:45 notostraca: http://pastebin.com/J6z7Lsgu

19:45 err

19:45 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 doing that now

19:45 gtrak: and make it -returnsTrue

19:46 * gtrak slaps him again

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 oh right, -

19:48 gtrak: and.... magic?

19:50 notostraca: and, with the -, http://pastebin.com/kWQDytCm

19:50 same stack trace

19:51 gtrak: hmm, so this error is happening in the init of the namespace

19:51 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 oh that could be it!

19:52 gtrak: notostraca, all namespaces have a static initializer

19:54 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 erroneously included some AOT-compiled class files built against

19:54 Clojure 1.2.0 that precluded that build of Clutch from working with

19:54 1.3.0. I have now pushed up a new 0.2.5-SNAPSHOT to clojars that

19:54 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 or vice versa

19:55 gtrak: yea, exactly

19:55 so your aot class is linked against different java classes

19:55 fix that shit

20:00 notostraca, you can learn a lot from this: http://clojure.org/compilation

20:00 notostraca: looks like it works now!

20:02 gtrak, yeah I read that many times...

20:02 the version thing was the issue

20:02 gtrak: not just that

20:02 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 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 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 now I feel like I know it

20:05 notostraca: glad I could... help?

20:05 good good

20:05 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 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 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 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 and it needs to be lazy :)

21:22 so no (take (min (apply map count the-seqs)) ...) stuff :)

21:23 i'll just take a copy of interleave and modify it for my needs

21:23 notostraca: seancorfield, makes sense

21:23 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 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 ^ that's a weird definiton

21:31 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 I really have found dealing with complex data to be very simple with Clojure

21:33 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 (this is using the messy Java game library GTGE)

21:45 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 &((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 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

Logging service provided by n01se.net