#clojure logs

2011-12-02

00:00devntechnomancy: i'm not sure what you mean by referencing 12factor
00:01devntechnomancy: i was referring to heroku allowing for the end-user to decide how their app should be built via lein, etc.
00:03devntechnomancy: 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:11technomancyoh, yeah. you can alter the buildpack now; it's all open source
00:11technomancy(kind of a soft launch thing)
00:11technomancyhttps://github.com/heroku/heroku-buildpack-clojure
00:33devntechnomancy: awesome! thanks.
00:34devnman, 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:34devnI'm sick of dancing around it. It's better in so many ways than previous languages I've used.
01:15notsonerdysunnywhen 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:16tensorpuddingwell, slime can connect to swank on other hosts can't it
01:20technomancynotsonerdysunny: you have to tunnel it over SSH
01:23notsonerdysunnytechnomancy: can you may be tell me how to do that..?
01:24technomancysame as you'd tunnel any protocol really; using the -L argument
01:24technomancyhttp://www.revsys.com/writings/quicktips/ssh-tunnel.html
01:52hiredmantechnomancy: so I've started on a roundtripping reader and some code to edit and re-align code using zippers
01:53hiredman(you end up with these whitespace nodes all over the place you want to skip over)
01:54hiredmanI 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:18zerokarmaleftthat's cool, i'd love to have bindings reformatted like that at the press of a button
02:23spoon16technomancy
02:23spoon16you around?
03:04wiseenare :pre and :post conditions always executed or only in debug mode ?
03:10spoon16in leiningen is it possible to change the :library-path for dev dependencies?
03:45bartjwhile using send-off, is there a default first parameter ?
04:40Borkdudemorning.
04:41kzarG'mornin'
04:42ejacksonwotcha
04:44BorkdudeI 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:45BorkdudeSo how go about it then?
04:45Borkdudesorry symbol evaluates to its value I mean
04:45Borkdudethe value it is currently bound to
04:47Borkdudethis clearly isn't possible: (my-doc +), because + would evaluate to the value, a function
04:48ChousukeBorkdude: you need a macro
04:48Borkdudebut how would you make (my-doc '+) work?
04:48raekBorkdude: your description is accurate - for a function
04:48raekBorkdude: 'doc' is a macro, so the usual rules of evaluation do not have to apply
04:49Borkduderaek: I see that, but doc expects a "name", is that a symbol?
04:49Chousukeyes.
04:49Chousukebut since it's a macro it treats its arguments literally, ie. without evaluating them
04:49raekBorkdude: it requires that the code literal at that place is a symbol
04:50BorkdudeCan we make a function that expects a symbol and just passes it to doc?
04:50Chousukenot without trickery.
04:50raekBorkdude: now you see why macros are contagious. to reuse a macro, you might need to make the calling code a macro too
04:50Chousukeyou need eval for that
04:51Chousukeeg (defn my-fn-doc [s] (eval (list 'doc s)))
04:51Chousukebut that's bad. don't do that :P
04:52Borkdudehehe, it was the accepted answer on SO
04:52raekbut since there is no function version of 'doc', does Borkdude have any other alternative?
04:52Wild_Catwhy is doc a macro, btw?
04:53Chousukefor nicer syntax I guess
04:53raekWild_Cat: probably for user convenience. you don't have to use it like (doc #'some-fn)
04:54raekthe implementors should have made a function version too
04:54BorkdudeChousuke: 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:54ChousukeBorkdude: because then doc looks up the documentation for s
04:54Chousukeas in, the literal s
04:54Wild_Catraek: hmm... Why would I need to #' a function whose doc I want?
04:54raekBorkdude: (doc s) will always get the same argument: the symbol s
04:54Wild_Cat(note: I'm an extreme noob to both Clojure and Lisps in general, my questions may seem dumb)
04:54raekWild_Cat: because the doc string is not stored in the value of the var, but in the var itself
04:55Wild_Catraek: ah!
04:55raek,(:doc (meta #'conj))
04:55clojurebot"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:55BorkdudeChousuke: this makes sense
04:55raek,(:doc (meta conj))
04:55clojurebotnil
04:55Wild_Catraek: so you mean that given a documented function f and (def g f), (doc g) wouldn't give me anything?
04:55raekWild_Cat: yes.
04:56Wild_CatI see.
04:56Wild_Catthat's an important difference from Python, I guess (where docstrings are stored in the __doc__ attribute of whatever it is you're documenting)
04:56raekthis is one reason it is hard to do a namespace that "forwards" to another
04:59raekwhen 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:01Borkduderaek: can you give a real example of this?
05:02raekbound-fn and bound-fn*
05:02Fossilet let*
05:02raekfuture and future-call
05:02Borkdude,(doc bound-fn)
05:02clojurebot"([& 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:02Borkdude,(doc bound-fn*)
05:02clojurebot"([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:03Borkdudesame docs? no info on macro of fn?
05:04raekyou use bound-fn* like this (bound-fn* (fn [x y] (+ x y))) and bound-fn like this (bound-fn [x y] (+ x y))
05:04Borkdudeah, i see
05:04Borkdude,(doc let*)
05:04clojurebotexcusez-moi
05:05raekfn* and let* are not examples of this
05:05raekthey are "the real" special forms
05:05raekfn and let are actually macros
05:05Fossioh, k
05:05Borkdudeok
05:05raekI think it has to do with where destructuring happends
05:06raekalso: (future (x)) == (future-call (fn [] (x)))
05:06raek(which also explains how 'recur' behaves in the body of 'future')
05:15tscheibl,(->> ["Hello" "world"] (#(if (< 0.5 (rand)) (replace {"world" "underworld"} %1) %1)) (clojure.string/join " "))
05:15clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.string>
05:15tscheibl:p
05:15tscheibloutsmarting the threading operators
05:41biallymSo 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:43biallym(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:44raekbiallym: this is usually solved by passing #'foo instead of foo
05:45raekvars implement IFn by delegating to their current value
05:45biallymAwesome!
05:45biallymthat is a very acceptable solution!
05:46biallymDid I mention that I love's clojure's design more and more every day
05:46biallym(And java's less and less)
05:46biallym(Not that I have ever used java, but java interop is always a pain for me)
05:46tscheiblsame goes for me :)
05:47tscheibli'm beginning to forget about the java syntax...
05:47AWizzArd|workFast 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:48AWizzArd|workOne thing that I noticed was: [INFO] artifact org.clojure:clojure: checking for updates from sonatype-snapshots
05:48AWizzArd|workBut 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:49biallymI 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:50tscheibl@raek: vars implement IFn?
05:50tscheibl,(#(%) #'a)
05:50clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)>
05:51tscheibl,(let [a 42] (#(%) #'a))
05:51clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)>
05:51tscheibl,(def a 42) (#(%) #'a)
05:51clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
05:51tscheiblarghh
05:52tscheibl, (let [a 42] (#(%) #'a))
05:52clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)>
05:53tscheiblthrows this in my 1.3 repl: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
05:53Borkdudetscheibl: 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:54Borkdudeit does implement IFn
05:54Borkdudebut a long doesn't
05:54Borkdudeso probably you're getting the value of a var and not the var itself?
05:54biallym_,(let [a (var #(identity %)] (#'a :foo))
05:54clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: ]>
05:54tscheiblbut i'm passing the var...
05:54biallym_,(let [a (var #(identity %))] (#'a :foo))
05:54clojurebot#<CompilerException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol, compiling:(NO_SOURCE_PATH:0)>
05:55biallym_,(let [a (var #(identity %))] (a :foo))
05:55clojurebot#<CompilerException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol, compiling:(NO_SOURCE_PATH:0)>
05:55biallym_I give up >.>
05:55Borkdudebiallym you are getting the var of an anonymous function, does that make sense ?
05:55tscheiblwhy?
05:55clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IPersistentStack>
05:55biallym_I was trying to make a var
05:55biallym_>.>
05:55biallym_obviously not working
05:55Borkdude,(doc var)
05:55clojurebotNo entiendo
05:56tscheibl,(let [a 42] (fn [a*] (a*)) (var a))
05:56clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)>
05:56tscheibloutputs the var in my 1.3 rwpl
05:56tscheibl#'at.hauptversammlung.backoffice.server.api.core/a
05:56tscheibllike thios
05:56Borkdudebiallym_: var takes a symbol
05:57tscheiblok wrong... hehe
05:57biallym_Yea I know that now... I thought it was like ref :p
05:57biallym_obviously I failed miserably
05:57tscheibl,(let [a 42] ((fn [a*] (a*)) (var a)))
05:57clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)>
05:58tscheibloutputs: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
05:58tscheibl.. in my repl
05:58biallym_,*1
05:58clojurebot#<Unbound Unbound: #'clojure.core/*1>
05:58tscheibl,(let [a 42] ((fn [b] (b)) (var a)))
05:58clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)>
05:58biallym_,(binding [*1 (fn [x] (identity x))] (*1 :foo))
05:58clojurebot:foo
05:59biallym_thats what I was trying to do
05:59biallym_&*1
05:59lazybot⇒ #<Unbound Unbound: #'clojure.core/*1>
05:59tscheiblyep... but obviously I cannot execute a var as a function...
05:59Borkdudetscheibl: let doesn't use vars
06:00biallym_look at how I did
06:00biallym_it
06:00biallym_tscheilb, you are doing it wrong >.>
06:00biallym_binding manipulates vars
06:00biallym_vars are not an object you can create
06:00tscheiblthat's obvious, too
06:00biallym_they are a pseudo construct of the symbol table
06:00tscheiblhmm
06:01biallym_let me use a better example
06:01tscheibl(let [a 42] ((fn [a*] (var-get a*)) (var a)))
06:01tscheiblthis works.... but I have to use var-get
06:02biallym_Thats because var implements IFn by returning the value, 42 doesn't implement IFn
06:03biallym_A better example:
06:04biallym_&(binding [*1 (fn [x] (identity x))] ((var *1) :foo))
06:04lazybotjava.lang.SecurityException: You tripped the alarm! pop-thread-bindings is bad!
06:05biallym_&(binding [*1 (fn [x] (identity x))] (#'*1 :foo))
06:05lazybotjava.lang.SecurityException: You tripped the alarm! pop-thread-bindings is bad!
06:05tscheibldamn bots ;)
06:05biallym_&(binding [*1 (fn [x] (identity x))] (*1 :foo))
06:05lazybotjava.lang.SecurityException: You tripped the alarm! pop-thread-bindings is bad!
06:05biallym_,(binding [*1 (fn [x] (identity x))] (*1 :foo))
06:05clojurebot:foo
06:05biallym_,(binding [*1 (fn [x] (identity x))] ((var *1) :foo))
06:05clojurebot:foo
06:05biallym_btw identity is broken
06:06biallym_actually . is broken
06:06biallym_but w/e
06:06biallym_which just makes java interop so much more painful
06:07tscheibl,(binding [*1 (fn [x] x)] ((var *1) :foo))
06:07clojurebot:foo
06:07tscheiblwhy do u use identity at all?
06:07biallym_Oh because I was using the #(fn %)
06:07biallym_form, which requires a fn on the front
06:07tscheiblahh
06:08tscheibl.. ok now I'm beginning to grasp...
06:09tscheiblthe vars IFn implementation calls the underlying value as a function
06:09biallym_Yes
06:10biallym_Oh I did not fully grasp this the first time around.. so much mroe awesome, so many problems fixed
06:10tscheibl... before i thought it would return the vars value .. like var-get
06:10biallym_so many fewer macros to write
06:10biallym_it's 3am, I can have horrible english >.>
06:11tscheibl.. no prob :)
06:11tscheibl... i wouldn't recognize
06:12tscheibl..i'm austrian.. we speak mountain english
06:12tsdhIs there something to tell the clojure reader/compiler "ignore the following if (foo) evaluates to false"?
06:12tscheiblmacro
06:12tsdhtscheibl: Or, right. :-)
06:34tsdhWhy 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:35kzarIs 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:49tscheiblkzar: maybe this way https://github.com/mmcgrana/clj-http
06:50kzartscheibl: 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:50tscheiblexactly
06:50kzartscheibl: But it seems like a PITA and a hack when HTTP has support for proxies?
06:51tscheiblhow would http support proxies?
06:51tscheiblwithout a proxy server?
06:52tscheibl..someone will have to do the proxying
06:57kzartscheibl: 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:03tscheiblkzar: 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:03tscheiblthis is a jetty proxy handler
07:03tscheibl.. but you would have to do some java interop
07:07kzartscheibl: cheers
07:15danielI 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:15danieli.e. the lower the value, the more chance it has of being selected
07:15danielin the above case "ydwD0" and "o_E-." would be the most likely to be returned
07:17danielcurrently it's extremely inefficient: https://gist.github.com/1423043
07:17danielpopfitness would be the above map
07:19Fossihow do you want to map "fitness" to your randomization? linear like in the above?
07:19ejacksondaniel: you should assign a value to each entry, normalize by the total and then use inversion sampling
07:19ejacksonhttp://en.wikipedia.org/wiki/Inverse_transform_sampling
07:20ejacksonif you sample without replacement you will need to renorm after the first sample
07:21danielFossi, I would like to test different possibilities ideally
07:22kephaleejackson: for evolutionary computation this is standard practice
07:22danielthanks ejackson
07:22kephaledaniel: look up roulette wheel selection, there are algorithms for it online
07:22danielkephale: cheers
07:22ejacksonkephale: yeah, its bread and butter across the board :)
07:23kephaledaniel: basically you make a vector of pairs of *cumulative* normalized fitness and individuals, then in O(n) you search for the (rand)
07:24kephaleof course tournament selection is better than fitness proportional anyway
07:27ejacksonkephale: I'm not sure I understand your jargon (not used perjoratively), what do you mean by tournament selection and fitness proportional ?
07:28danielkephale: 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:28danielso i generate a random number between 0 and 1
07:29ejacksonthen choose that value form the vector of cumulative probabilities that is the lowest value greater than your random number
07:29ejacksonbobs your uncle
07:30danielhow do i make the probabilities cumulative?
07:30kephaledaniel: like ejackson said. you can't use a map because you need to keep the individuals sorted by their cumulative fitness
07:31ejackson,(reductions + 0 [1 2 3])
07:31clojurebot(0 1 3 6)
07:31ejacksontake (rest ...) of that
07:32kephaleejackson: 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:33daniel,(reductions + 0 [1 2 4])
07:33clojurebot(0 1 3 7)
07:33kephalebasically 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:33danielkephale: isn't that a poor model for reality?
07:33ejacksonkephale: is it reduced variance or something ?
07:34kephaledaniel: 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:34ejacksonkephale: aaaah, its domain optimisation thing.
07:35ejacksonmakes sense
07:35kephalemmm, its fun stuff
07:35Fossi"a mating tournament doesn't take place across all individuals on Earth" ah, that's what went wrong when somebody invented the internet :>
07:35danielkephale: that being tournament selection
07:35kephaleFossi: lol
07:36raektscheibl: did you get your question answered?
07:37kephaledaniel: 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:40danielkephale: 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:41kephaledaniel: that is fine, but doing it over a tournament instead of the entire population is the key idea there.
07:41danielim 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:42danielah no
07:42danielok, i got it :)
07:44kephaledaniel: out of curiosity, is this for a class?
07:44danielnope
07:44danieljust me playing about with stuff
07:44kephaleah cool, all the better
07:46danieltrying to learn me some clojure and it seemed like a fun little program to write
07:47danielalso trying to fill my github page with as many little projects as possible in the hope of finding better employment
07:48kephaleCS research FTW
07:48biallym_Any leiningen gurus know how native deps work?
07:49biallym_Because I am having trouble getting them to work and I think it is conceptual problem
07:50danielkephale: wouldnt be any point where im living
07:50danielso 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:50AWizzArd|workDo 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:51kephaleyeah, 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:54danielkephale: so instead of 9616, i'd have 9616 + 4289 ?
07:54danieland so on
07:54danielfirst i need to sort them right?
07:55kephaledaniel: 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:55kephaleand yes, first sort by the values returned by reductions
07:55danielsorry, assuming they are normalised
07:56danieli 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:57danieli need to normalize (total - value) i think
07:57danielso they are all inverted
07:57kephalereductions is to get the cumulative fitness. i also generally have fitness correspond to error, in which case you sort the other way
07:58danieldont i have to sort before taking the reductions?
07:59kephaleno, you just need the order to be based on the cumulative sum
08:00kephalein theory you miiight get a slight performance bump by sorting before calling reductions
08:01danielmy understanding is: sort from lowest to highest value, normalize, reductions
08:02danielso once they are normalized they should be sorted from highest to lowest probability
08:02danieland then picking a random number between 0-1 will tell me where in the order to select from
08:02kephalefeel 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:03kephalethen you spin the wheel, and probabilistically you will land on the individuals of appropriate fitness regardless of the initial sort
08:05danielkephale: 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:06danielyou're saying i can do without sort altogether?
08:06kephaleyeah
08:06kephale,(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:06clojurebot(["{x:I{" 0.11090138] [".^t#c" 0.3595439] ["072!^" 0.77806795] ["P`VQx" 0.844495] ["t3x.g" 1.0])
08:07kephalesorry i said sort initially, but you don't actually need it. technically you don't have to normalize, but that is standard practice.
08:07danielin the above, "P`VQx" 0.844495 should be most likely
08:08danielhowever i dont see how selecting a random number between 0 and 1 would yield that with most likelihood
08:08kephaleand if you have negative fitness values it can get hairy, so normalizing is best (also note that this wont work with negative fitness
08:08kephalein the above the most likely would be 072...
08:08danieli dont have negative fitness (0 is perfectly matching target)
08:08kephaleany value of rand between 0.359 and 0.778 matches 072!^
08:09danieli see, so yeah i need it the other way
08:09kephaleyeah i know, but i got lazy
08:09danieli need to normalize (total - val) so that higher = better
08:09kephaleand didnt want to take your fun : P
08:11danielanyway, i've grilled you enough :) i have more than enough to be getting on with
08:11danielthanks a lot
08:11kephalecheers and enjoy
08:56tscheiblraek: yep, thx
09:36ilyakhi *
09:36ilyakI have a long 3585395648
09:36ilyakhow do I make int -709571648 from it in clojure?
09:37ilyakin java ((int) Long.parseLong("3585395648") & 0xffffffff) does the trick
09:37ilyak,(int (bit-and 0xffffffff (Long/parseLong "3585395648")))
09:37clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Value out of range for int: 3585395648>
09:37raekilyak: 3585395648 does not fit in an int
09:38ilyakraek: Therefore I want -709571648
09:38ilyakWhich does :)
09:38clgv,(int (bit-and (long 0xffffffff) (Long/parseLong "3585395648")))
09:38clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Value out of range for int: 3585395648>
09:38raek,(bit-and 0xffffffff 3585395648)
09:38clojurebot3585395648
09:39raek,(bit-and 0x0ffffffff 3585395648)
09:39clojurebot3585395648
09:40ilyak, (- 0xffffffff 3585395648)
09:40clojurebot709571647
09:40ilyakI guess I can use this but still
09:40ilyak,(- 3585395648 0xffffffff)
09:40clojurebot-709571647
09:40ilyak,(- 3585395648 0x100000000)
09:40clojurebot-709571648
09:41raekah, you want to sign extend the 32-bit part into 64 bits (yielding a negative number) and then put that in an int...
09:43ilyakexactly
09:51raek,(.intValue 3585395648)
09:51clojurebot-709571648
09:52raekilyak: that does not use the dedicated JVM instruction, but is short at least
09:59ilyak:)
09:59ilyakcool
10:01raek,(unchecked-int 3585395648)
10:01clojurebot-709571648
10:01raekthere it is!
10:01raekilyak: ^ :-)
10:01fdaoudraek, you rock
10:01raekI knew it had to be there
10:02clgv$findfn 3585395648 -709571648
10:02lazybot[clojure.core/unchecked-int clojure.core/hash]
10:09daniel,(repeat 2 (rand))
10:09clojurebot(0.8713460673000076 0.8713460673000076)
10:09danielhow can i get that to calculate rand twice instead of repeating the outcome?
10:09daniel,(repeatedly 2 (rand))
10:09clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.ClassCastException: java.lang.Double cannot be cast to clojure.lang.IFn>
10:10clgv,(repeatedly 2 rand)
10:10clojurebot(0.9786849028024637 0.03287114030092053)
10:10danielhmm
10:10clgvrepeatedly expects a function with zero arguments
10:10danieland if it's more complicated than rand
10:12clgvif it's still simple use an anonymous function e.g. #(f ... ) e.g. ##(repeatedly 2 (rand (rand)))
10:12lazybotjava.lang.ClassCastException: java.lang.Double cannot be cast to clojure.lang.IFn
10:12clgv&(repeatedly 2 #(rand (rand)))
10:12lazybot⇒ (0.044365083534149696 0.1420443694132764)
10:12clgvif it's complex define a function via defn for it
10:13danielah i need to wrap it in #()
10:13danielcheers
10:14ihodesdoes anyone on here have any experience with using clojure to process time series? i want to extract periodic anomonlies from a time series
10:15ihodesnot extract, but mark
10:16clgvihodes: sounds more like an algorithmic problem than a language specific one. ;)
10:16ihodesit is :)
10:16ejacksonihodes: how are these anomalies defined ?
10:17clgvso what is the clojure related portion of the question?
10:18ihodesejackson: 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:19ihodesclgv: 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:20clgvihodes: 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:20licenserI'd have a question to clojureql
10:20TimMcihodes: 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:20ihodesclgv: 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:20licenseractually I don't thank non the less :P
10:20TimMcThat's a cheap way of getting a window.
10:21ihodesTimMc: what do you mean, matching points? compared (nth x 1) to (nth x 2) and keep sliding?
10:21ihodesor some kind of autoconvolution?
10:23ejacksondo you have an estimation of the noise ?
10:23TimMc&(let [x (range), x+1 (drop 1 x), x+2 (drop 2 x)] (map #(nth % 5) [x x+1 x+2]))
10:23lazybot⇒ (5 6 7)
10:24ejacksonit seems that you want an adaptive filter with the cutoff dependent on a noise estimate ?
10:24ihodesejackson: 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:25ejacksonoh dear lord
10:25ihodes*reading of each FREQUENCY not ready -- typo, my bad
10:25ihodesejackson: yeah, it's pretty rough
10:25ejacksonhave you tried a model dependent filter ?
10:25ejacksonsomething kalman like ?
10:25ihodesand the signal i'm trying to mark in the time series is a digital signal, so we can't do a bandpass filter
10:25ihodesbecause it pulses, it doesn't oscillate
10:26ejacksonseems that you have a filtering problem, where you have a source and measurement model, so is a natural attack
10:26ihodesit'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:27TimMcihodes: What are you studying?
10:29ihodesTimMc: 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:29ihodesdata from this kind of study
10:30ihodesfrom electrodes on different muscle groups, and inside the back
10:30TimMcihodes: "Anomalies" being neuronal signals traveling along the cord, above and beyond the normal chatter?
10:31ihodeshere 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:32ihodesTimMc: 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:32TimMcSo... a sliding FFT would be nice. :-)
10:32ihodesmarking the muscles' response is another issue entirely... looking like signal analysis is working a little more more there
10:33ejacksonihodes: 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:33ihodesTimMc: 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:33ejacksonLPF either with a moving average, or a wavelet, should work,
10:34ihodes*but not the pulse itself
10:34ejacksonactually just point where signal - LPF(signal) > thresh should work no ?
10:34TimMcihodes: Oh, I see! FFT isn't great with non-repeating stuff, right.
10:35ihodesTimMc: 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:36ihodesejackson: e.g., LPF everything greater than the supposed signal?
10:36ihodesejackson: er, HPF i suppose
10:36ejacksonyou're looking for the position of the giant spikes ?
10:36ihodesejackson: yes
10:37ejacksonso you need a normalised signal
10:37ejacksonin order that the threshold makes sense across signals
10:37ihodesyes
10:37ejacksonthe big problem you have here is the offset from zero
10:37TimMcTwo separate problems.
10:37ejacksonand the changes in noise
10:37ihodesthat's the most common usual one, though noise can be another
10:38TimMcihodes: Noise can swamp the pulses?
10:38ihodesah, 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:38ihodesTimMc: sometimes. maybe not a case worth worrying about...
10:38TimMcOK.
10:39ihodesTimMc: but it often does approac the amplitude, which is worth worrying about
10:39ejacksonin that case signal - LPF(signal) > thresh(noise) will sort you
10:39ejacksonif the spikes are beneath the noise floor you have a harder problem
10:39TimMcihodes: So you can't necesarily use the expectation of regular-ish pulses to dynamically adjust the threshold.
10:40ihodesTimMc: right, amplitude changes periodically *and* randomly
10:41ihodesejackson: 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:41ejacksonnaaaah, do the LPF implicitly with something like an n-period moving average
10:42ihodesejackson: hmmm, how is that functionally different from doing it in the freq domain?
10:42ejacksonits easier to think about
10:42ejacksonbut is the same thing
10:43ihodesah, 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:44ihodesbut it could be preserved....it's definitely worth a shot.
10:44ejacksonno the LPF is specifically trying to remove these pulses
10:45ihodesthe pulses *are* those big spikes you see on the screenshots
10:45ejacksonso you compare your original signal to the LPF'd signal, and the pulses will comprise most of the differente
10:45ihodesinteresting--let me run that
10:46ihodesthanks all for helping me think this out, too :)
10:54TimMcihodes: Sounds like awesome research -- I wish that was my job. :-)
10:55TimMc(sort of... signal processing scares me a bit)
10:56ihodesTimMc: 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:09ihodesejackson: 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:10ejacksonthat's great news
11:10ihodesthe 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:11ejacksonclojure excels at this
11:11ejacksonI'd be happy to help you offline, if you like
11:11ihodesejackson: thanks so much. any other tips? what's your background in sig processing?
11:11ihodesejackson: you live in the area?
11:12ejacksonI just meant not in IRC, this is a bit off-topic really :)
11:12TimMcor in privmsg
11:12ejacksondon't want to incur the wrath of the Clojure mob.
11:12ejacksonTimMc: zakly.
11:12prs`are videos from the second conj available somewhere?
11:12TimMcalthough I wouldn't mind hearing more about how you solve it. :-)
11:12ihodesejackson: 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:13TimMcThe "making it fast" part would be on topic, of course.
11:13ihodesTimMc: 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:14ejacksonprs`: not yet, but they will be.
11:14ejacksoni guess, given that its quiet...
11:14ihodesTimMc: 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:15prs`ejackson: thanks, i was kinda expecting that answer, theyll probably be on blip when ready
11:15TimMcprs`: It took a while for the first Conj's videos to go up.
11:15ihodesby the way, as a side-note, R is really nice to work in.
11:16prs`TimMc: March of this year in fact, so im not holding my breath
11:16TimMcYeah, my fiancée used it for her PHd work and said it was good stuff.
11:16ihodesTimMc: you haven't convinced her to use Clojure instead? :P
11:17ejacksonhere is a fast-ish SMA for clojure: https://gist.github.com/1423801
11:17TimMcShe did it in Python, and started before I was into Clojure. :-)
11:18ejacksoni dug it out of an old codebase... hope its not horrendous
11:19ejacksonso 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:20ihodesejackson: haha, looks similar to mine from an old codebase ;)
11:20ejacksonyeah, only so many ways to skin that cat
11:23ejacksonanyway, 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:49kzarHow can I convert a ByteArrayOutputStream to an InputStream?
11:49gtrakkzar, you can either stream it or copy it
11:50raekkzar: if you have the underlying byte array, you can create a ByteArrayInputStream
11:51gtrakkzar, this is how i know to do it: http://webcache.googleusercontent.com/search?q=cache:HRHsyLVxWf8J:ostermiller.org/convert_java_outputstream_inputstream.html&amp;hl=en&amp;gl=us&amp;strip=1
11:53raekkzar: what objects to you have access to, and what are their types?
11:54raek*do you
11:56kzarWell 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:56kzarbyte 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:57kzarIf 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:58kzarSo 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:59tscheiblis it somehow possible to have a no arguments constructor on a deftype which initializes it's fields ... according to my research: NO
12:28tscheibl..arhhh gen-class
12:28TeXnomancyhiredman: so you've started a reader! interesting.
12:28TeXnomancyis it based on your old reader?
12:28tscheibldeftype would have been more elegant
12:28hiredmanTeXnomancy: no
12:30hiredmanhttps://github.com/hiredman/swank-clojure/commit/1d30e467b10ffb9846e352e1a8edd24e17d7995e
12:31TeXnomancysweet. what's implemented so far?
12:32hiredmanit can read a big chunk of its own file
12:32hiredmanread* at the bottom is the function I have been using for testing
12:33hiredmanpass it an inputstream, you can back a seq of Nodes, that may change
12:33hiredmanerr, you get back a single node actually
12:33hiredmananyway, you have Nodes that represent whitespace so you can round trip, needs comment support, etc
12:34TeXnomancyslick!
12:34TeXnomancydoes it piggyback on the main reader at all?
12:34Chousukehiredman: you probably shouldn't call end-of-list EOL :P I got confused at first
12:34hiredmanChousuke: yeah :)
12:34hiredmanTeXnomancy: no
12:35hiredmanneeds metadata support and lots of other stuff
12:35hiredman(oh god, does this mean I need to implement syntax quote again?)
12:35clojurebothttp://en.wikipedia.org/wiki/Lisp_%28programming_language%29#Self-evaluating_forms_and_quoting
12:37technomancyhiredman: were you at seajure last night?
12:37ChousukeI did a syntax-quote implementation
12:37Chousukeit was pretty awful
12:37hiredmantechnomancy: no
12:37ChousukeI probably still have that stuff on github :P
12:37technomancythat's how you were able to get so much done I guess? =)
12:38hiredmanChousuke: I did one in my first reader, and more recently I have a project to replace it with a macro
12:38Chousukehiredman: I tried a macro approach too but it got very hairy
12:38Chousukewith nesting
12:38hiredmantechnomancy: yeah, I had other plans, but they ended up falling through
12:38hiredmanhttps://github.com/hiredman/syntax-quote
12:41Chousukehttps://github.com/Chousuke/clojure/blob/clojure-reader/src/clj/clojure/lang/reader/internal.clj#L63 brr, scary code.
12:42hiredmanChousuke: did you come up with tests for it?
12:42Chousukeno
12:42hiredman:/ getting tests has been my issue
12:43Chousukethough I think it passes clojure's tests
12:45notostracaOK, 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:45notostracaor can the Clojure sorted-map be used directly from Java?
12:45hiredmanyeah, 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:45Chousukeyes
12:47notostracaChousuke, what is the type (in Java) of a sorted-map from Strings to hash-maps of Strings?
12:47ChousukeMap
12:48notostracano type parameters?
12:49Chousukethat's compile-time only, it's optional
13:29zakwilsonhttps://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:24TimMcnotostraca: 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:25notostracathanks TimMc
15:25TimMcYou probably want to expose it as a Map.
15:26TimMcChousuke: Hmm, how does compiled Java code represent its use of generics in an API?
15:26Chousukeit doesn't AFAIK.
15:26TimMcHum...
15:27Chousukeor well, not as a requirement. probably there's some sort of metadata though
15:27TimMcThere has to be, yeah?
15:27ChousukeI suppose
15:27TimMcAt least on method signatures, not on locals.
15:28Chousukeat the bytecode level it's all Objects though
15:29hiredmanjavac inserts casts
15:30hiredmanclojurebot: java generics |are| http://en.wikipedia.org/wiki/Generics_in_Java
15:30clojurebotIn Ordnung
15:36TimMchiredman: A JVM object doesn't know its parameterization, but the original .class file surely advertises the generics, yes?
15:42devnbah...jira has forsaken me -- how do you get to design docs from the dashboard?
15:43devnnevermind, found it
15:45BahmanHi all!
15:45devnanyone know where the ^:static and ^:dynamic docs are hiding?
15:46dnolendevn: ^:static doesn't do anything
15:46pauldoowhen I write (.foo bar) in closurescript, it compiles down to "bar.foo;"
15:46devndnolen: either way, looking for notes on ^:dynamic
15:46pauldoohow do I get "bar.foo();" ?
15:46dnolenpauldoo: known issue, (. bar (foo))
15:47pauldoodnolen: ahh ok - so it's a bug?
15:47TimMcpauldoo: It's a translation dilemma.
15:48pauldoodnolen: 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:48TimMcpauldoo: With Java, . is not ambiguous, since you can't ask for a method as an object.
15:48pauldoowould ((.foo bar)) also work then?
15:50TimMcpauldoo: Try it and let me know, I don't have cljs set up.
15:51pauldooTimMc: I can't get either syntax to work currently. I certainly have other errors to fix. Ill get back to you..
15:56dnolenpauldoo: we're waiting to see if (.-prop foo) gets adopted, then (.method foo) becomes unambiguous
15:56dnolenpauldoo: it requires a change to Clojure.
15:57dnolenpauldoo: 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:59devnIf I juxt keys on a map am I guaranteed the order?
15:59devn,((juxt :foo :bar) {:foo 1 :bar 2})
15:59clojurebot[1 2]
15:59devnyes, right?
16:00dnolenpalentine: (. foo (bar)) should definitely work
16:00dnolenpauldoo: oops that was for you
16:01pauldoodnolen: 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:01pauldoodnolen: so (. instance (method)) works perfectly - thanks
16:01jeremyheiler,((juxt :foo :bar) {:bar 2 :foo 1})
16:01clojurebot[1 2]
16:02jeremyheilerdevn: juxt applies the functions in the order given
16:02jeremyheiler(doc juxt)
16:02clojurebot"([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:03jeremyheilerdevn: in particular "applying each fn to the args (left-to-right)"
16:04tsallycan a function created via #() be a recur target from within the body ?
16:05TimMcyup, try it
16:06tsallythat's awesome
16:06TimMctsally: #() is just reader sugar for a fn
16:06TimMc&`#(recur)
16:06lazybot⇒ (fn* [] (recur))
16:07TimMc&(#(recur))
16:07lazybotExecution Timed Out!
16:08tsallynice
16:10TimMc&(#(if (= % 1) %2 (if (even? %) (recur (/ % 2) (inc %2)) (recur (inc (* 3 %)) (inc %2)))) 27 0)
16:10lazybot⇒ 111
16:11TimMc^ Collatz with counter.
16:12TimMctsally: I don't know if recur in #() ever happens in the real world.
16:13TimMcrecur usually indicates a sufficiently complicated operation is being written that it deserves to be named.
16:14TimMcMaybe you might see it in a function that returns a closure.
16:30gtrakdoes clj-growl work on windows?
16:34hiredman /win 15
16:34TimMcSANBOX DENIED
16:35duck1123gtrak: looks like it's just calling out to growlnotify
16:35duck1123so no
16:35duck1123unless there's a growl for windows now?
16:35gtrakthere is
16:36RaynesThere is.
16:36gtrakI want to get rid of some browser windows
16:36gtraklike tweetdeck
16:40pauldooso on previous discussion about (.foo bar) in clojurescript, what is the recommended way to access a property in cljs?
16:40pauldoo(recommended as in unlikely to break when the above is "fixed" for methods)
16:43stuartsierrathere's a wiki page about that somewhere
16:52jweisshow 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:52jweissi figured it should be accessible via the class
16:52clojurebotYou 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:57jeremyheilerjweiss: you could use reflection and call setAccessible(true), but hopefully there's a better way.
16:59jweissjeremyheiler: wow really? i was hoping it'd be simpler than that. the object in question has access to this field, shouldn't i?
16:59dnolenpauldoo: it will be an unavoidable breaking change. I'm hoping Clojure/core moves on it sooner not later.
17:03stuartsierrajweiss: with gen-class you can expose it
17:04jweissmeh, 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:05stuartsierrayou can always subclass it
17:06jeremyheilerjweiss: what i suggested was using reflection. did it not work for you?
17:07jweissjeremyheiler: oh, your suggestion was to make it permanently accessible, i just want to get the value once
17:09devinus_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:09devinus_anybody got a guide for this somewhere?
17:09technomancydevinus_: http://emacsformacosx.com plus the swank readme should get you 90% of the way there
17:10jweissi 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:10devinus_technomancy: keep in mind all i have is emacs right now
17:10devinus_technomancy: dont have clojure or lein or anything
17:11devinus_emacs and a java vm
17:11devinus_bout all i have
17:11technomancydevinus_: installing leiningen takes like five seconds; you don't need much documentation for that
17:11devinus_ok sweet
17:11technomancybut once you've got it maybe reading "lein help tutorial" would be good
17:12jeremyheilerjweiss: 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:25notostracaHmm, 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:27notostracaThe exact exception is
17:27notostracaException in thread "main" java.lang.UnsupportedOperationException: loadTSV (net.myexperiments.viciouscycle.util.TSVReader/-loadTSV not defined?)
17:30jeremyheilerhow are you calling it from java?
17:30notostracajeremyheiler, as a static function of the class TSVReader (declared with a gen-class)
17:30notostracaIn my clojure ns, I have: :methods [^{:static true} [loadTSV [String] java.util.Map]
17:31notostracaand it is possible the typing is screwed up
17:32notostracaoh sorry, that :methods is part of a :gen-class with: :name "net.myexperiments.viciouscycle.util.TSVReader" :load-impl-ns false
17:33notostracaand I don't really know what load-impl-ns does either
17:40notostracaOK, when I get rid of :load-impl-ns I get a different error -- it can't find an init function I think
17:40notostracabut the class should be just static functions...
17:41jeremyheilerAre you trying to make it a java-friendly?
17:41notostracajeremyheiler, yes
17:44jeremyheilermaybe you need to wrap all your methods (in this case 1) in a vector: :methods [^{:static true} [[loadTSV [String] java.util.Map]]
17:44jeremyheilerthe clojure doc shows there being an outer vector
17:45jeremyheilernevermind, sorry
17:48devinus_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:49hiredman the environment where your emacs is launched doesn't have your PATH set
17:49hiredmanyou can use getenv and setenv to figure it out
17:50hiredmanyou launched your emacs from a gui or something, and it didn't source you .zshrc
17:50devinus_hiredman: you're right i start emacs from a gui
17:50devinus_which makes sense why it wouldnt source
17:50devinus_hrm
18:06yohi..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:11yono one can help me?...I don't know why when binding my all is empty in every loop http://pastebin.com/YNA5t6qi
18:22broquaintThat code doesn't even compile, yo.
18:25Raynesbroquaint: That sounded so ghetto.
18:26broquaintWord.
18:27nickmbaileyheh, yo, listen to bro
18:29notostracajeremyheiler, any ideas?
18:29jeremyheilernotostraca: 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:29notostracareally, if anyone here has a good workflow for making java-consumable static functions written in clojure, I would love to hear it
18:30notostracajeremyheiler, I think you need to be compiling
18:30notostracauh, I don't know how to get clojurebot to get the docs for a function
18:30jeremyheilernotostraca: yeah,that's what im doing next
18:30jeremyheiler(doc str)
18:30clojurebot"([] [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:31notostraca(doc gen-class)
18:31clojurebot"([& 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:31notostraca When not compiling, does nothing.
18:31jeremyheilernice, i should learn how to read someday
18:32notostracaseems like a useful talent to put on a resume... :-P
18:33jeremyheilerlol
18:36notostracajeremyheiler, should I pastebin my code?
18:37jeremyheilersure
18:40notostracahttp://pastebin.com/FcUajnfB
18:42notostracathe Java call is just
18:42notostraca tableData = TSVReader.loadTSV("text" + File.separator + "TSVTable.txt");
18:43notostracaoh, the type of tableData is Map<String, Map<String, String>>
18:45notostracathe error is still java.lang.UnsupportedOperationException by the way
18:45notostracahmm, I wonder if I take away the static metadata...
18:45jeremyheilerDon't you want the method to be static?
18:46notostracayes, but it isn't strictly necessary
18:50notostracahmm, same error
18:50notostracawith or without static
18:51jeremyheileri got an example to work with out static
18:55notostracajeremyheiler, what do you think I am doing wrong?
18:56jeremyheilerAre you able to call your methods with java interop from clojure? or is this error just when using straight java?
18:57gtraknotostraca, it would be useful to see the full stacktrace, where the error is happening is more important than what it is
18:57notostracagtrak, sure
18:57notostracalet me get that ready
18:58gtrakwith line numbers, preferably
18:59rickmodenotostrace: Clojure maps are immutable, so UnsupportedOperationException is thrown if one of the modification methods is used.
19:00rickmodeso maybe your java code is trying to modify the map?
19:00gtrakif only we had a full stacktrace xD
19:07rickmodeSo 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:08RaynesIf you want to add type hints, go for it.
19:08RaynesEliminating reflection is in general a good thing.
19:08gtraka bad typehint will turn a methodnotfound into a classcastexception
19:08RaynesEspecially if it is causing problems.
19:08RaynesPerformance problems, I mean.
19:09rickmodeI'm not trying to use the hints as a poor-man's type system. ;)
19:09gtrakrickmode, just leave it on all the time
19:09gtrakyou only really need them for interop
19:09rickmodegtrak: ya - I am doing interop.
19:10gtrakmake a single layer that handles all the dirty parts :-)
19:10gtrakhaving them scattered around would make them less informative i think
19:10rickmodeno such layer in this case... I'm putting clojure into the midst of a large java app
19:10notostracagtrak, sorry was trying to recompile and ugh
19:11gtraknp
19:11rickmodebut ya - I am wrapping some method calls in fn's and passing those around instead
19:11notostracahttp://pastebin.com/FcUajnfB is the clojure, http://pastebin.com/iYTLQz8s is the java, http://pastebin.com/qg2YMzKM is the stack trace
19:11gtrakthat's the best you can do really
19:12rickmode(def assets (agent {} :meta {:primary? true :key-fn (fn [^AssetBean a] (.getId a))}))
19:12gtraknotostraca, you have to aot compile the namespace
19:12notostracagtrak, I did that
19:12gtraki don't think you did
19:12notostracaI get eclipse to auto-complete the namespace, so...
19:12rickmodeit's kinda slick - one set of code that handles cache maps keyed an arbitrary method of an object
19:13gtrakthere's another way to make clojure run the ns and compile it, i forget
19:13notostracaI see TSVReader.class in the /classes folder...
19:13notostracaor rather in the namespace in the /classes folder
19:13notostracabut it is possible I am modifying the map somewhere
19:14gtraknotostraca, it's a compilation problem
19:14notostracaok
19:14notostracaI will see what I can do...
19:15gtrakhow are you actually running it?
19:15gtrakfrom the java?
19:16notostracayeah, I pasted the java file
19:16notostracahttp://pastebin.com/iYTLQz8s
19:17gtrakand what are you using to build the classes?
19:17gtrakeclipse?
19:17clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IPersistentStack>
19:17notostracayeah, with ccw
19:17gtrakare they separate projects?
19:17notostracano
19:17notostracaI am using the compile in repl function of CCW
19:17gtrakhmm, I'm not quite sure then
19:18gtrakbut the java compiles?
19:19rickmodenotostraca: silly question perhaps, but why are you constructing a hashmap copying the data from the hashmap passed back by loadTSV?
19:19notostracayes, the exception is at runtime
19:19gtrakhmmm
19:19gtrakwhat's the point of the '-' prefix?
19:19gtrakjust asking b/c i've never done it
19:19notostracaloadTSV returns a Map, which should be pass-able to the constructor of a HashMap
19:19jeremyheilereither case, "-" is the default
19:19notostraca(ccw.debug.serverrepl/with-exception-serialization (clojure.core/binding [clojure.core/*compile-path* "classes"] (clojure.core/compile 'net.myexperiments.viciouscycle.util.TSVReader)))
19:19notostracanet.myexperiments.viciouscycle.util.TSVReader
19:20notostracasorry about the paste, but that's the "compile in REPL" line and its output
19:20gtraknotostraca, so... maybe you never initialized the namespace
19:20notostracayeah, I don't have an init function
19:21notostracaI don't know what I would do in it if everything is static
19:21rickmodeperhaps just use HashMap<String, Map<String, String>> tableData = loadTSV(...);
19:22rickmodenotostraca: what gtrak is saying is: you haven't initialized Clojure
19:22notostracad'oh
19:22gtrakrickmode, it might not be needed, since the class is AOT compiled
19:22gtraklooking at this: http://stackoverflow.com/questions/2181774/calling-clojure-from-java
19:22rickmodecheck out clojure.main.java for an example
19:23rickmodehmmmm...
19:23gtraknotostraca, {:static true} [loadTSV [String] java.util.Map] and (defn load-tsv-clj
19:23gtraktypo?
19:24rickmodenotostraca: try simplifying things... create a method that returns a boolean or something and make sure that call works
19:24notostracaok
19:25gtraknotostraca, ha, does prefix not need ""?
19:25gtraklook at this: http://kotka.de/blog/2010/02/gen-class_how_it_works_and_how_to_use_it.html
19:25rickmodenotostraca: it smells like there's trouble with the nested maps... maybe some sort of type mismatch clojure doesn't care about?
19:25gtrakrickmode, that's not it
19:25notostracagtrak, 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:26gtraklooks like the prefix should work fine
19:27rickmodenotostraca :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:28gtrakrickmode, it's not getting that far
19:28notostracawaitaminute
19:29notostraca:static true ?
19:29rickmodeoic
19:29gtrakstatic true should work
19:29gtrakotherwise the java wouldn't compile
19:30notostraca#^{:static true} or ^{:static true}
19:30notostracado I need the # ?
19:31gtrakthat's not the issue
19:31gtraktry naming the methods the same
19:31gtrak-loadTSV and loadTSV
19:32rickmodelast time i messaged with gen-class I used the macro version instead of :gen-class in ns
19:33rickmodeBut... It looks like your ns should be net.myexperiments.viciouscycle.util... your name is OK
19:34gtrakyea, strange, I don't get it
19:35rickmodeactually it looks like it'll work
19:35gtraknotostraca, wait, why is load-impl-ns flase?
19:36gtrakfalse*
19:39gtrakah, I see that only affects if it tries to compile the .clj
19:39gtrakit might not make a difference
19:39gtrakwell, i'm stumped
19:40notostracasorry, I was working on a previous suggestion
19:41notostracaI made a function called returnsTrue
19:41notostracaguess what it does...
19:41gtraksame thing?
19:41notostracaand it can't be called either
19:41gtraktry making load-impl-ns true
19:42gtraknotostraca, it seems like you should only set it false if you know what you're doing, eg. some special compilation stuff
19:43gtrakthat's gotta be it
19:43notostracagtrak, if I set it to true I get a different error
19:43notostracahttp://pastebin.com/Fckvfy53 is my java code now
19:43gtrakshow the tra e
19:44gtraktrace*
19:45notostracahttp://pastebin.com/J6z7Lsgu
19:45notostracaerr
19:45notostracathat's the clojure code
19:45gtrakset load-impl-ns to true
19:45notostracahttp://pastebin.com/EhXvd2Fw is the trace
19:45notostracadoing that now
19:45gtrakand make it -returnsTrue
19:47zakwilsonhttps://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:48notostracaok, with it true, http://pastebin.com/8ByRMqUW
19:48notostracaoh right, -
19:48gtrakand.... magic?
19:50notostracaand, with the -, http://pastebin.com/kWQDytCm
19:50notostracasame stack trace
19:51gtrakhmm, so this error is happening in the init of the namespace
19:51gtrakit's not getting to your method call yet
19:51notostracaaaaaah...
19:52gtrakit looks as if there's a classpath issue? maybe the class is compiled against a different version of clojure than supplied?
19:52notostracaI don't have an init function, but the class is supposed to be all static methods
19:52notostracaoh that could be it!
19:52gtraknotostraca, all namespaces have a static initializer
19:54gtraknotostraca, yup that's it: a quote from a newsgroup thread with the same error: "turns out that the 0.2.5-SNAPSHOT build
19:54gtrakerroneously included some AOT-compiled class files built against
19:54gtrakClojure 1.2.0 that precluded that build of Clutch from working with
19:54gtrak1.3.0. I have now pushed up a new 0.2.5-SNAPSHOT to clojars that
19:54gtrakshould resolve your issue."
19:55notostracait might be that I am compiling with 1.3.0 and using 1.2.0
19:55notostracaor vice versa
19:55gtrakyea, exactly
19:55gtrakso your aot class is linked against different java classes
19:55gtrakfix that shit
20:00gtraknotostraca, you can learn a lot from this: http://clojure.org/compilation
20:00notostracalooks like it works now!
20:02notostracagtrak, yeah I read that many times...
20:02notostracathe version thing was the issue
20:02gtraknot just that
20:02gtraknotostraca, 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:02notostracaoh ok
20:03gtrakclojure.lang.RT is a java class in the clojure.jar
20:03notostracaoh wow, thank you, all of #clojure
20:04notostracait is nice to have a helpful community for a great language :-)
20:04gtrakhttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java
20:04gtraktake a look
20:04jeremyheilernotostraca: thank you for bringing up an interesting problem, forcing me to dive into gen-class
20:04gtraknotostraca, yes, I've been meaning to learn gen-class as well :-)
20:05gtraknow I feel like I know it
20:05notostracaglad I could... help?
20:05notostracagood good
20:05notostracaand clojure seems to handle all the data stuff I want to use it for with flying colors
20:06gtraknow i just have to learn records and protocols
20:06gtrakand macros
20:06notostracasame here :-)
20:09gtrakit's fun to learn the innards though, I always feel like I learned some secret power when I dig through clojure :-)
20:09gtrakin java innards I'm thinking 'why the f*** did they do that way?'
20:10notostracahaha true
21:15TimMcalexbaranosky: What license should I stick on the seqs-and-colls thing? EPL seems traditional around here.
21:17seancorfieldis there something like interleave that works with sequences of unequal length?
21:18seancorfieldeasy enough to write my own but i didn't want to reinvent the wheel... :)
21:19TimMcseancorfield: Like 1111 22222222 -> 122122122122?
21:21seancorfieldmore like 12121212 then the rest of the longer seq
21:22seancorfieldand it needs to be lazy :)
21:22seancorfieldso no (take (min (apply map count the-seqs)) ...) stuff :)
21:23seancorfieldi'll just take a copy of interleave and modify it for my needs
21:23notostracaseancorfield, makes sense
21:23notostracagotta love open source :-)
21:23seancorfieldmaybe i'll ask on -dev why interleave has to have seqs of identical lengths (or it throws away additional items)
21:24notostracaoh, actually...
21:24seancorfieldi can understand map doing that (since you have a fn of a fixed number of args)
21:24TimMcseancorfield: Call it interleave-all, in the spirit of partition-all.
21:24notostracayou could interleave until you reach the end of either seq and then conjoin on the rest of the remaining seq?
21:24seancorfield,(interleave [1 2 3 4 5] [:a :b :c])
21:24clojurebot(1 :a 2 :b 3 ...)
21:24TimMchaha, clojurebot
21:24seancorfieldnot helpful clojurebot !
21:25TimMcseancorfield: Also, make sure it takes an arbitrary number of arguments!
21:25notostraca,(interleave [1] [:a :b :c]
21:25clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
21:25notostraca,(interleave [1] [:a :b :c])
21:25clojurebot(1 :a)
21:25TimMc&(interleave [1 2 3 4 5] [:a :b :c])
21:25lazybot⇒ (1 :a 2 :b 3 :c)
21:25seancorfieldTimMc: if it's based on interleave, it will :)
21:26notostraca&(interleave '(1) [:a :b] {"Alpha" "Bet")
21:26lazybotjava.lang.RuntimeException: Unmatched delimiter: )
21:26notostraca&(interleave '(1) [:a :b] {"Alpha" "Bet"})
21:26lazybot⇒ (1 :a ["Alpha" "Bet"])
21:26TimMcseancorfield: It's been done on the ML.
21:27TimMcseancorfield: https://groups.google.com/group/clojure/msg/cbe820823ff7f9ac
21:29seancorfieldnice, thanx TimMc
21:29notostracaHuh, what is John Harrop doing on the Clojure ML? Isn't he an F#/OCaml guru?
21:30TimMcEPL: "Contributor" means any person or entity that distributes the Program.
21:30TimMc^ that's a weird definiton
21:31TimMcnotostraca: SCANDAL
21:31notostracaTimMc, heh yes
21:31TimMcNext we will see a Fox News exposé. :-P
21:32notostracaI 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:32notostracaI really have found dealing with complex data to be very simple with Clojure
21:33notostracabut it has been hard to translate from Clojure to Java, which is most of what I have been doing with Clojure has been...
21:34TimMcnotostraca: You mean interop where Java consumes data from a Clojure API?
21:34notostracaTimMc, well...
21:36TimMcHmm, the EPL doesn't feel as solid as the GPL in terms of consistency.
21:44notostracaTimMc, 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:44notostraca(this is using the messy Java game library GTGE)
21:45notostracaI'm considering just using LWJGL...
21:52TimMcnotostraca: So proxy isn't sufficient?
21:54notostracaTimMc, 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:55TimMcheh
23:07technomancyhttp://twitter.com/#!/headius/status/142457369476083712
23:28tmciverwhat's the difference between (fn [a b & more] ...) and (fn [a b & [more]]...)?
23:31tmciver&((fn [a b & more] [a b more]) 1 2 3 4 5)
23:31lazybot⇒ [1 2 (3 4 5)]
23:32tmciver&((fn [a b & more] [a b [more]]) 1 2 3 4 5)
23:32lazybot⇒ [1 2 [(3 4 5)]]
23:32tmciver&((fn [a b & [more]] [a b more]) 1 2 3 4 5)
23:32lazybot⇒ [1 2 3]
23:32tmciver&((fn [a b & [more]] [a b more]) 1 2 [3 4 5])
23:32lazybot⇒ [1 2 [3 4 5]]
23:35tmciver&((fn [a b & [more]] [a b more]) 1 2 {:a 1 :b 2})
23:35lazybot⇒ [1 2 {:a 1, :b 2}]
23:35tmciver&((fn [a b & [more]] [a b more]) 1 2 {:a 1 :b 2} 3 4)
23:35lazybot⇒ [1 2 {:a 1, :b 2}]
23:52georgekhi, what are some common reasons why I would get an error of "Starting swank server...
23:52georgekerror 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:54technomancygeorgek: make sure you're on the latest clojure-mode
23:58georgektechnomancy: 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:58technomancygeorgek: yeah, that was a recent fix