#clojure logs

2011-04-13

00:35kephale001 /j #incanter
00:35kephale001upps
00:35kephale001any incanter folks here?
02:49devn,(let [{:keys [a b c d]} {:a 1 :b 2 :c 3 :d 4}] [a b c d])
02:49clojurebot[1 2 3 4]
02:49devn,*clojure-version*
02:49clojurebot{:major 1, :minor 2, :incremental 0, :qualifier ""}
02:49devnhmm, weird
02:52devnim doing this in my repl and i keep getting nil
02:52devnthe thing im using is clearly a map
02:54devn,(let [{:keys [layer octave duration n-notes repetitions]} {:layer "0" :octave "5" :duration "q" :n-notes "16" :repetitions "2"}] [layer])
02:54clojurebot["0"]
02:54devnweird
02:57devn(def note-map-coll (first [{:layer 0 :octave 5 :duration "q" :n-notes 16 :repetitions 2}, {:layer 1 :octave 3 :duration "q" :n-notes 4 :repetitions 8}]))
02:58devn(defn play-random-note-maps [{:keys [layer octave duration n-notes repetitions]} nmc] [layer])
02:59devn;=> "Wrong number of args (1)"
02:59devnwhen calling (play-random-note-maps note-map-coll)
03:02devn(defn play-random-note-maps [nmc]
03:02devn (let [{:keys [layer octave duration n-notes repetitions]} nmc]
03:02devn [layer]))
03:03stirfoodevn: don't key arguments have to be in a rest list? [& {:keys ...}]
03:03devn^^works, is this intentional?
03:04devnstirfoo: no, but curiously...
03:04devn(defn play-random-note-maps [{:keys [layer octave duration n-notes repetitions]} & nmc] [layer])
03:04devn;=> ["0"]
03:08devncurious...bed time
03:09stirfooare defn, defmacro, let, and letfn argument destructuring handled the same?
03:10stirfoomy ver: {:major 1, :minor 2, :incremental 0, :qualifier ""}
03:16stirfoo,(print "foo")
03:16clojurebotfoo
03:18stirfoo,(defmacro awhen [x f] `(when-let [r# ~x] (~f r#)))
03:18clojurebotDENIED
03:19stirfoobah!
03:29stirfoo,(print "bar")
03:29clojurebotbar
03:29stirfooso, you just don't like macros
04:05raekstirfoo: yes they are handled the same. but note that with defn, you can't do (defn foo args ...) or (defn foo [:as args] ...)
04:05raekstirfoo: this is because destructuring are done for function parameters, but not the whole parameter list
04:20noidi_I have an unbound var, for which I need to establish a binding during my cucumber test run. I can't use binding, since in cuke4duke there's no way to surround all the test code.
04:21noidi_alter-var-root doesn't work, since the var has no root binding
04:21noidi_and I can't re-def the var since it's defined in another namespace
04:22raeknoidi_: alter var root takes the var object as an argument
04:22ejacksonhello
04:22noidi_what's the best way to set the var's binding for the rest of the programs execution? intern? push-thread-bindings (without popping)?
04:22raekit sounds like you are sending it the value of the var
04:23raekif you want to set it once during initialization, and binding is not an option, then I'd suggest alter-var-root or intern
04:23raek(alter-var-root #'the-var altering-fn)
04:23noidi_that doesn't work without a root binding
04:23raek(intern 'the-ns 'the-var value)
04:23raekoh, now I see :)
04:24raekthe intern version should work, then
04:24noidi_thanks, I'll go with intern
04:25raekif you use lein, it is probably possible to make a wrapping binding with a hook
04:26noidi_I use maven
04:27noidi_cuke4duke sucks a bit when it comes to setup/teardown code...
04:29noidi_but yay, the intern hack worked
04:36clgvnoidi_: I am curious. what is cuke4duke used for? there is only a short sentence talking about "step definitions".
04:37noidi_it's Cucumber for JVM languages http://cukes.info/
04:38clgvah "behavior driven development". I did read about bdd for c# some weeks ago
04:40noidi_I don't buy completely into the whole BDD thing, but cucumber is quite nice for writing tests that exercise the complete program
04:41clgvI had similar thoughts while reading: it enables tests whose definition is much more similar to specified use cases
04:42clgvs/much more/very/
04:42sexpbot<clgv> I had similar thoughts while reading: it enables tests whose definition is very similar to specified use cases
07:07markomanwhat are good practices to create tests on clojure?
07:08ejacksondo so :)
07:09markomani have punch of files now and want to do tests for them, maybe not the order some suggest, but anyway. i wonder if I should test every function, what about defn- ?
07:09ejacksonyou should really only test the interface functions
07:09markomando you usually test with big sets of good, bad, correct and false values?
07:10ejacksoni try to get an example of each mode of success/failure etc
07:10ejacksonthere are no coverage tools, but you would like to exercise each logical phase of your code
07:11markomancan you provide example of "each phase"?
07:13markomanis there any tool in clojure to get started with tests easily? i mean when i create new project with lein, it creates a test file fore core.clj. something similar that scans files on src and creates some files automated?
07:19ejacksonsorry, "each phase" -> "each logical branch "
07:19ejacksoni dunno of any tests
07:19ejacksoni just make a test directory and put the tests in there
07:19ejacksondunno what's to automate :)
07:21markomanyou could have a skeleton of files and public functions from files pre made
07:22markomanim lazy writer and copy paster :)
07:26markomanhttps://github.com/marick/Midje seems to be one of the many test frameworks
07:29clgvmarkoman: it is. there is also clojure.test
07:30markomanim using (is) tests at the moment, but thinking if there are more organized ways, especially for web apps
07:31clgvyeah I've been using them too
07:34clgvI was considering to test midje next when I start testing the new code
07:38ejacksonyeah I looked at it, but i'm sticking with clojure.test for now
07:39markomandecisions :)
07:40clgvyeah I am still wondering if midje provides me real advantages and if it's mature enough
07:43markomanthere is also this https://github.com/semperos/robot-remote-server-clj robotframework for automated testing
07:44clgvmarkoman: I am not doing webdevelopment, so dont need that one ;)
07:45markomanright. it would be ideal to make tests first and use functions from tests on actual app, but it requires total twist of mind, at least on my case
07:46clgvhmm don't know that test-first is always a good choice
07:46clgvs/that/if/
07:46sexpbot<clgv> hmm don't know if test-first is always a good choice
07:48TimMcI try for test-first as an ideal, but I don't hate myself if I implement first. It works out to a nice balance.
07:48markomanid like to have bug free apps, tired of problems and time they take, lol
07:48TimMcWriting unit tests after implementation catches enough bugs as it is. :-)
07:49ejacksoni agree. pure TDD presumes the lack of a repl
07:49ejacksoni like to play about in the REPL get it in line
07:49ejacksonthen write the tests to 'tie it down'
07:49ejacksoncan think more flexibly, i find
07:49TimMcI don't think that's true, though.
07:50clgvwith all the probabilistic stuff I do, it's sometimes really difficult to come up with complete tests
07:50TimMcejackson: I think the REPL is great for getting a correct implementation quickly, but that's probably orthogonal to whether you've already written the tests.
07:50markoman(probably-true test case)
07:51TimMcclgv: You pass around a random seed?
07:51markomanor just (probably? test case) :)
07:51TimMc(Or use binding, I guess.)
07:52clgvhmm for simple cases this is an option. I used mocking to select the cases I need
07:52ejacksonTimMc: writing tests often fixes my initial mode of thought on a problem, whereas playing in a repl often leads me to new thoughts and thus a different interface to test
07:53TimMcejackson: There is that.
07:54markomani still find myself uncomfortable with testing new functions on REPL. I mean it takes time to collect all pieces from repl history and put on function
07:54ejacksonmarkoman: Oh i write code in a file, and use C-x C-e to pass it to the repl to avoid that
07:55markomanplus knowing, what is active on current repl namespace, that gives gray hairs too
07:55ejacksoni *do* end up with giant (comment ...) blocks that I then purge
07:55ejacksonotherwise yes, you have spaghetti
07:55markomanlol, that I know very well already
07:55clgvIn fact you cant test everything in REPL. I often have to write new functions that are deep within my algorithm framework, so that a huge setup would be required to get the input for these functions - debug-repl is an option though
07:56ejacksonclgv: yeah, I have same problems, getting into a deep context
07:56ejacksoni keep meaning to try these debug tools, but never seem to get around to it :(
07:56clgvyou should get started with debug-repl easily
07:57clgvit's kinda nice to launch a repl inside your algorithm at a point you specified
07:57markomanemacs slime?
07:57ejacksonyeah, emacs+slime
07:58ejacksonmarkoman: the other thing I do have a foo-lab.clj file, that loads up relavent libraries, and play there
07:58ejacksonbut *always* write the tests afterwards
07:59ejacksonfor me its mostly to keep tabs on the interfaces so that if something changes between when I worked in the repl, and time t, a test will break to alert me
08:00markomanyeah, its good tip, test interfaces primarily
08:01markomanyou mean you create a foo-lab and :use or :require all your libs there?
08:02clgvmarkoman: depends - my only interface function is the main algorithm which is not easily testable, so I have to test its inner parts
08:02ejacksoni think its the accepted practice for unit testing
08:02ejacksonalthough I agree with clgv too :)
08:03markomanclgv: sure. i think different purposes makes the different
08:03markomandifference*
08:04clgve.g. it was a pretty good idea to test the creation of the commulative distribution function and it's usage to select a random element accordingly
08:05ejacksonindeed !
08:05ejacksoninversion sampling :)
08:06ejacksonthat's such a cute idea
08:09markoman(vals {:a 1 :b 2}) is different datatype than [1 2]
08:09markomanhow can you convert vals same, or are they both ordered lists?
08:10clgvlet's see which: ##(type (vals {:a 1 :b 2})) and ##(type [1 2]) ;)
08:10sexpbot(type (vals {:a 1, :b 2})) ⟹ clojure.lang.APersistentMap$ValSeq
08:10sexpbot(type [1 2]) ⟹ clojure.lang.PersistentVector
08:10ejackson_##(type (into [] (vals {:a 1 :b 2})))
08:10sexpbot⟹ clojure.lang.PersistentVector
08:10clgv&(compare (vals {:a 1 :b 2}) [1 2])
08:10sexpbotjava.lang.ClassCastException: clojure.lang.APersistentMap$ValSeq cannot be cast to java.lang.Comparable
08:11markomanvector should keep its index order by default?
08:12markomanpersistent map sounds like it keeps order too
08:18clgv&(= (seq (vals {:a 1 :b 2})) (seq [1 2]))
08:18sexpbot⟹ true
08:32markomanok, seq and type into makes them same
08:33markomanthanks again guys
08:37ejacksonmarkoman: sortof. into turns into a the vals into an actual vector. seq just presents a seq over each collection.
08:38clgv$source group-by
08:38sexpbotgroup-by is http://is.gd/JJJRzs
08:38cemerickI simply can't help it. :-(
08:39ejacksonwhere is the troll show ?
08:40cemerickIt's not much of a show. :-)
08:40edwThinking of Marilyn Manson: "We're all stars now, in the troll show..."
08:40ejacksonyou should feed it spicier trolltreats
08:41cemerickejackson: I'd feel badly for the unwilling spectators.
08:42ejacksoni guess so, it sortof makes you a troll too...
08:42ejacksona troll of the 2nd order
08:42edw$source map
08:42sexpbotmap is http://is.gd/Fd9Ag4
08:42edwThat is kinda awesome.
08:45clgvedw: it is :)
08:45clgvfindfn is even better ;)
08:48edwsexpbot is a bit cagey regarding help. Talking to it is like playing zork. Kinda hot.
08:49clgv$findfn {:bla 1 :blubb 2 :lala 3 :haha 4} [:bla :lala] {:bla 1 :lala 3}
08:49sexpbot[clojure.core/select-keys]
08:49clgvedw: that's what I meant - feels like magic ;)
08:50ejacksonwhat !
08:50ejacksonits become selfaware
08:50edwHow many minutes did it take to develop a sense of irony?
08:51edw$findfn {:a 1 :b 2 :c 4} [1 2 3]
08:51sexpbot[]
08:51edw$findfn {:a 1 :b 2 :c 4} [1 2 4]
08:51sexpbot[clojure.core/vals]
08:52edwI could spend all day talking to sexpbot.
08:54edwWhoa, it automatically posts gists when its responses get too chatty!
09:15matthias_okay... so i got swank and leiningen and emacs + slime working but... how do i now build and run a clojure program? i made a new project and put some code into core.clj and then added the program's namespace to the project.clj after :main, but it says it doenst find a main. im not even sure how that's supposed to work, do clojure programs have mains?
09:20edwmatthias_: Check out the "sample" test project in the leiningen repo on github. I'd tell you the answer, but I'd rather help you develop mad learning skillz.
09:27matthias_i've checked it out, that's where i saw the :main stuff
09:27matthias_but i havent read all of it yet
09:28ejacksonmatthias_: you'll only use a main if you precompile stuff, usually in clojure you won't need to do so
09:28edwOK, I couple of "hints": 1) in projects.clj: ":main nom.nom.nom".
09:29edw2) in src/nom/nom/nom.clj: "(defn -main [& args] ... )
09:30edw(End quote.)
09:30matthias_ugh, i think i was in the wrong folder. its like folder/folder/folder/project.clj, i was in folder/folder and folder/project.clj also exists
09:30ejacksonmatthias_: if you have lein, swank, emacs and slime all working then all you need to is:
09:30matthias_weird
09:30ejacksonissue: lein swank from the project root directory
09:30matthias_there's a start function in the program im trying to run
09:31ejacksonthen in emacs go M-x slime-connect
09:31ejacksonthat'll bring up a repl in emacs
09:31ejacksonfrom there you're off
09:31edwejackson: I didn't even want to touch the "why do you want a `main' anyway?" question... There's some REPL philosophy grokking that needs to occur her.
09:32matthias_does lein search for a project.clj in a higher directory if it doesnt find one where you are?
09:32edws/her\./here./
09:32sexpbot<edw> ejackson: I didn't even want to touch the "why do you want a `main' anyway?" question... There's some REPL philosophy grokking that needs to occur here.
09:32ejacksonmatthias_: don't think so, issue it from the root
09:32matthias_well that seems to have happened when i was in the wrong folder
09:32matthias_maybe
09:33matthias_at least it ran without complaining when i was in a folder without project.clj
09:34matthias_getting lots of artifacts missing when i run lein deps now... but i dont see it telling me what's actually missing
09:35matthias_looks like it cant find clojure contrib :|
09:35edwmatthias_: Are you starting with the simplest possible scenario that should work? You don't need a lot of dependencies to get a lein project running a swank server and Emacs connected to it.
09:35matthias_i've already had that
09:36matthias_now im trying to run an example program from the web
09:36matthias_(its tetris with penumbra)
09:37edwmatthias_: Dude, try creating a new, empty, lein project, adding swank to the dev-dependencies, firing it up, and connecting to it. Keep it simple...
09:37matthias_oh, i had to add clojure contrib to the deps
09:37matthias_i did that before
09:37edwDoes it work?
09:38matthias_yes it does
09:39matthias_i mean the simple version worked
09:39edwSo what didn't work that led you to download a random project from the internet and try to get that to work?
09:40matthias_slime still says it cant find the (start) function. thats define in my core.clj
09:40edwDude you (use 'core)?
09:40matthias_i didnt download a random project. i got swank + slime to work and then i wanted to run a real program. everything worked until there, but i couldnt get the real program to work
09:40matthias_no
09:41edwTry that.
09:41matthias_Could not locate core__init.class or core.clj on classpath:
09:41matthias_ [Thrown class java.io.FileNotFoundException]
09:41edwIs core in 'src/'?
09:42matthias_its in src/tetris/
09:42edwSo, did you do a (use 'tetris.core)?
09:43matthias_org.lwjgl.opengl.GL11
09:43matthias_ [Thrown class java.lang.ClassNotFoundException]
09:43edwIs that a depenedency?
09:44edws/dependendency/dependency/
09:45matthias_penumbra is a dependency. penumbra uses lwjgl
09:46matthias_i installed lwjgl using synaptic. dont know how to add it as a dependency
09:46edwAnd I have no idea what synaptic is.
09:47matthias_the package manger gui of ubuntu
09:48matthias_is there really no easier way to run a clojure program? i thought it must be something like "cljcompile bla.clj" "these jars are not in your classpath!" *adds to classpath* "cljcompile bla.clj" "success!" "clj bla.class" program runs :>
09:48edwWell that org.lwjgl.opengl... reference is probably to some Java glue classes (that are missing).
09:50edwYes, you can `lein run' and if you've defined a main package, its `main-' will be be called.
09:50matthias_oh, i think i had to run lein native-deps
09:50edwErr, `-main' function.
09:52matthias_aahhh now it works :)
09:52edwThere have got to be easier ways to play Tetris under Ubuntu...
09:52matthias_thanks for your help
09:52edwYou're welcome.
10:46choffsteinHey all. What is the best way to find out whether clojure core or contrib contains a function? For example, if I want to know if there is a natural log implementation, what's the best way to try to find that?
10:47TimMcchoffstein: I use clojuredocs.org
10:49jlf`choffstein: http://clojuredocs.org/clojure_core/clojure.core/find-doc
10:49choffsteinperfecto. Thanks
10:50choffsteinangerman, I can feel your pain
10:51angermanchoffstein: worst of all. It simply makes no sense. the users have to connect to an ssl site. The routing is funtional, there's just no state.
10:51angermanit makes no sense at all.
10:51choffsteinangerman: that is confusing ...
10:51choffsteinangerman: I would be happy to give you a set of fresh eyes, though no promise I can get anywhere on it
10:52angermanchoffstein: nah, it's been reviewed three times already. I'm currently thinking about the clients network topology.
10:52choffsteinangerman: well, best of luck :)
10:52angermanchoffstein: thanks, will need it :D
10:53choffsteinwhen you have to start thinking network topology level...
10:53angermanespecially because I don't think I'll be able to obtain any reliable information from the persons within...
10:53angermanthat's probably along the lines of: "Well, we click this icon and then we are on the internet"
10:55TimMcangerman: Session data is stored in cookies?
10:56angermanno. cookies are only used to identification, then the session-data is pulled out of memcache
10:57TimMcAnd users are getting each others' data?
10:57angermanapparently. but it looks more like they get another session.
10:57TimMcAh, OK.
10:57TimMcConsistently?
10:57angermanno
11:01TimMcI'm not sure what network topology has to do with this.
11:01angermanTimMc: I'm wondering if there is some weird proxy in between.
11:01TimMcAh.
11:03TimMcangerman: In a case like this, it might be interesting to send the cookie data explicitly in the response body and have JS check to see if they differ. :-P
11:03TimMcIn any case, it sounds like a slog.
11:05sritchiehey all -- once I bundle up a project with "lein uberjar", how can I use it to load up a repl?
11:06sritchiesomething like -- java -jar myproject-standalone.jar clojure.lang.Repl
11:07angermanTimMc: yes. it is _very_ strange.
11:08TimMcAnybody seeing checksum problems with maven central?
11:10clgvsritchie: you can use clojure.main/repl in your -main function explicitely
11:11sritchieclgv: ah, got it. so, I should add ":main clojure.main" to project.clj?
11:11TimMcsritchie: java -cp myproject-standalone.jar clojure.lang.Repl is a start
11:11sritchieor define a -main function in one of my namespaces, point to that, and run clojure.main/repl there?
11:12clgvsritchie: hmm would be an option as well. I thought you might have a -main function already, so you could include the repl call in there
11:12TimMcsritchie: So you're not asking how to get a REPL in an arbitrary uberjar?
11:12sritchieTimMc: that would be more helpful, I think
11:13sritchieI'm getting -- Failed to load Main-Class manifest attribute from forma-0.1.0-standalone.jar
11:13sritchieI'm not sure how to provide that at the command line
11:13TimMcThat's not what I get.
11:13TimMcIt yells at me about clojure.lang.repl being deprecated and then gets me a repl anyway.
11:14TimMcc.l.Repl, rather
11:14sritchiehere's my command -- java -jar forma-0.1.0-standalone.jar clojure.lang.repl
11:14sritchies/repl/Repl
11:14sexpbot<sritchie> here's my command -- java -jar forma-0.1.0-standalone.jar clojure.lang.Repl
11:14sritchiedo you have any :main at all defined?
11:14TimMcYou want -cp I think.
11:14TimMcInstead of running the jar, you use it as a library.
11:15sritchieException in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
11:15sritchiefollowed by
11:15sritchieCould not find the main class: clojure.lang.Repl. Program will exit.
11:15sritchiebut that gives me a lead!
11:25angermanAre bindings call local?
11:27amalloyangerman: huh?
11:29raekclgv: clojure.main defines a main function, but it hase the name "main" instead of "-main", so you can't use the :main option for that directly, unfortunately
11:29edwWhy does (java.lang.Math/PI) not throw an exception?
11:29raekiirc, this was discussed recently at the leiningen mail list
11:30clgvraek: sritchie needed it. so he might still implement his own main and call clojure.main/repl in it
11:31sritchieclgv: bundling with cake uberjar, then running java -cp myapp-standalone.jar clojure.lang.Repl actually ended up working out
11:31raekyou could also start you project with java -jar myproject-standalone.jar clojure.main
11:32raekhrm, maybe you need to have -cp instead of -jar there...
11:32Vinzenthttp://paste.lisp.org/display/121462 - any ideas? This code is in fn called from the macro
11:34amalloyVinzent: are you on clojure 1.3?
11:35Vinzentamalloy, no, stable 1.2
11:36amalloy&(let [f "f"] (fn [x] (throw (UnsupportedOperationException. (str "z" type)))))
11:36sexpbot⟹ #<sandbox15764$eval18933$fn__18934 sandbox15764$eval18933$fn__18934@144774e>
11:37amalloyVinzent: sexpbot is on 1.2.0 and it works; i tried it on 1.2.1 and it works. i'm going to say you have something messed up in your environment. maybe stale AOT compiled classes? those cause messes "like" this
11:37Vinzentit's ok from the repl for me too. Problem appears only in that function.
11:37edw&(java.lang.Math/PI)
11:37sexpbot⟹ 3.141592653589793
11:38edw^^^ ???
11:38amalloyedw: it's not printing all the infinite digits! oh no!
11:39amalloyVinzent: that is not clear. what do you mean, it's okay from the repl but only "in that function". if that function works in the repl, the problem is not in that function
11:39edwNo, what's bothering me is that both "java.lang.Math/PI" and "(java.lang.Math/PI)" eval to the same thing.
11:39edwI am confused.
11:40amalloy&(map macroexpand '((Math/PI) Math/PI))
11:40sexpbot⟹ ((. Math PI) Math/PI)
11:40amalloy&(doc .)
11:40sexpbot⟹ "Special Form: Please see http://clojure.org/special_forms#.&quot;
11:40amalloygo read about the . special-form: it says it's just fine to call a field as a function
11:41amalloyhm. that link kinda sucks, though
11:42edwAh. Thanks. Makes sense if you think of it as if it's calling an implicit getter.
11:42amalloytry http://clojure.org/java_interop
11:42edwamalloy: No prob; I know where. Ah. Thanks.
11:43Vinzentamalloy, well, fn itself works fine, but when called from the macro leads to that creepy exceptions. I can paste the whole code, but don't think somebody wants to read it all
11:43amalloyheh. i'm glad thinking of an implicit getter works for you, cause it certainly doesn't do anything for me
11:43edwI'm trying to work with Java here, trying not to be a hater.
11:47amalloyedw: what really happens is that (. Math PI) looks inside of the Math class to see whether Math has a field named PI or a no-arg method named PI
11:47amalloythat allows ##(.PI Math) to expand into something simple
11:47sexpbotjava.lang.IllegalArgumentException: No matching field found: PI for class java.lang.Class
11:47amalloyhm. guess not
11:48amalloy&(map macroexpand '((Math/PI) (.PI Math)))
11:48sexpbot⟹ ((. Math PI) (. (clojure.core/identity Math) PI))
11:48amalloyfeh
11:51edwI'll checkout out the source. This came up because I was verifying my conversion of Morrie's Law into radians, and accidentally typed (java.lang.Math/PI) and got an answer.
11:51amalloyedw: you don't have to type java.lang., you know
11:52edwAh. Thanks. But it's a nice reminder to pay respect to the gods.
11:55amalloy*smile* on the contrary, the java gods only want you typing when they demand it. else it is sacrelige
11:56edwBut srsly, I knew I didn't have to type some part of it, but I'm getting over a cold and the amber light on my caffeine guage just lit up.
11:56edws/guage/gauge/
11:56sexpbot<edw> But srsly, I knew I didn't have to type some part of it, but I'm getting over a cold and the amber light on my caffeine gauge just lit up.
12:02VinzentAh! there was a typo, not 'type' but 'foo' of course: http://paste.lisp.org/display/121462#1 And no, I have no aot-things. When any local var passed to the Exception constructor, ExceptionInInitializerError is throwed
12:03amalloyVinzent: i figured you actually meant type. but it works fine with foo too
12:03amalloy&(let [f "f"] (fn [x] (throw (UnsupportedOperationException. (str "z" f)))))
12:03sexpbot⟹ #<sandbox15764$eval19011$fn__19012 sandbox15764$eval19011$fn__19012@17994ab>
12:07Vinzentamalloy, i can't reproduce it too. There is a macro which calls one fn, then passes the result to another, then uses last result to generate some defs. I've tried to write thing with similar structure but have no luck
12:22VinzentSo I have no idea what actually leads to the exception; probably it'd be better to pass just a static string...
12:31matthias_(im completely new to slime and emacs and clojure) hmm, i tried running a function by having the point in it and pressing C-M-x. slime is running and if i start the same function by typing it in the repl, it works. i tried making a new function (println "bla"). running that with C-M-x worked. saw bla in the repl. but starting the other function doesnt work. it's the start function of penumbra's tetris example. any guesses why that might b
12:31matthias_e?
12:31clojurebotthe reason to use the immutable types is that it saves you from all that stuff; if you don't use them you don't get the benefit.
12:31matthias_uh huh
12:31matthias_wow, that got a bit long
12:31amalloymatthias_: just long enough to split into two messages :P
12:32matthias_heh
12:32amalloy"having point in it" sounds worrying. C-M-x evals the form *starting* at point
12:32amalloyi think
12:32Vinzentтщ
12:32amalloyi usually use either C-c C-c (eval top-level form containing point) or C-x C-e (eval point ending at form)
12:32Vinzent*no
12:32matthias_hmm, i thought it starts the "toplevel form". some video said so, and it seemed to be working
12:33matthias_i'll try cc
12:33amalloymatthias_: they're probably right, then. as i said, i don't use it much
12:35matthias_difference seems to be that cc also compiles? i dont really get it
12:35matthias_C- C-c didnt work either, but got a different reply in the minibuffer
12:47rak85hi, guys!
12:48rak85is there any way to remove the keys in a hash which have empty values?
12:48rak85or giving a condition?
12:48rak85or a function? =P
12:49amalloyfilter
12:50amalloy&(into {} (remove (comp nil? val) {:a 1 :b nil})))
12:50sexpbot⟹ {:a 1}
12:50rak85filter is returning a list for me
12:50amalloya little more involved than needed to remove strictly nils, but more flexible than the simple ##(into {} (filter val {:a 1 :b nil}))
12:50sexpbot⟹ {:a 1}
12:51cemerickamalloy: you need nil? to remove strictly nils
12:52cemerick&(into {} (filter val {:a false :b nil}))
12:52sexpbot⟹ {}
12:52rak85thanks, amalloy
12:52cemerickTruthiness, you hurt so bad. :-)
12:52amalloycemerick: yeah, i know
12:52cemerickI know you know; just being pedantic in a spare moment. :-)
12:53amalloy*laugh* thanks; my life might actually be fun if you didn't have spare moments
13:08Raynescemerick: http://www.reddit.com/r/Clojure/comments/gn3d1/can_has_meet_clojure_website/c1p1vdz This must be why we write books.
13:10cemerickRaynes: that's a nice comment :-)
13:10RaynesNice. Frightening, but nice.
13:10cemerickI can't say I have any groupies of my own yet, though.
13:28devnbetter way to do #(apply str (interleave " " ["A1" "A2" "A3"])) ?
13:29amalloydevn: clojure.string/join
13:29devn,(apply str (interleave " " ["A1" "A2" "A3"]))
13:29clojurebot" A1"
13:29amalloyyou also meant intperpose, not interleave
13:29devnblah thank you :\
13:29amalloy&(doc interpose)
13:29sexpbot⟹ "([sep coll]); Returns a lazy seq of the elements of coll separated by sep"
13:29devnand of course..join..*doh*
13:32stirfooWhy would slime not pretty print an expanded macro (C-c RET)? Not sure if this is the correct place to ask that question, but there it is.
13:38edwHas the state of Clojure SLIME debugging advanced in the last couple months?
13:38technomancyedw: there's this: http://georgejahad.com/clojure/swank-cdt.html
13:39edwtechnomancy: Thanks!
13:40edwRuh roh: "Installing *should* now be just a matter of..." (Em. mine.)
13:51matthias_erm, java is currently using 1gb of ram... im not doing anything, just having swank open
13:54pdk,(/ (+ .7 .9 1) 3)
13:54clojurebotjava.lang.Exception: Unable to resolve symbol: .7 in this context
13:54pdk,(/ (+ 0.7 0.9 1) 3)
13:54clojurebot0.8666666666666667
14:03fliebelpdk: Floating point is lovely, eh?
14:04amalloyi don't get the joke. ##(/ 2.6 3) is basically the same, right? i wouldn't expect rounding errors for that
14:04sexpbot⟹ 0.8666666666666667
14:11znutar_Is there some handy reference for the differences between java floating point and ieee754?
14:11fliebel&(/ (rationalize 2.6) 3)
14:11sexpbot⟹ 13/15
14:22chouser,(/ (+ 7/10 9/10 1) 3)
14:22clojurebot13/15
14:22chouser,(double (/ (+ 7/10 9/10 1) 3))
14:22clojurebot0.8666666666666667
14:27choffsteinWhat is the best way to set a default value for a function input?
14:29Chousukechoffstein: multiple arities?
14:30Chousukeeg. (defn foo ([] (foo :defval)) ([x] (do something with x)))
14:30choffsteinyeah, I guess. so if I do (defn f [a b] ...), if b is not supplied, it has a default value. I assume this can only really be done using match cases on arity or with a map input, right?
14:31Chousukeyeah.
14:31Chousukefor that case, just supply both arities [a] and [a b]
14:31choffsteinokay. thanks.
14:33cemerickchoffstein: don't forget about keyword args
14:56dnoleninteresting how fancy abstractions in Haskell, SML, and Ocaml, Scala don't play well with usability features like pattern matching...
15:12angermanyikes, why are ssl certs so damn expensive?
15:13angerman(and the system is flawed… just gives the client a warm and fuzzy feeling :( )
15:13angermananyone got a sugestion?
15:13MarkN3DSeller's market, I guess
15:13MarkN3DDid you check GoDaddy? I thought they had certs for relatively cheep
15:15angermanoh crap, what's that warrenty about?
15:15kencauseyangerman: The value of an SSL certificate is in the certainty that it represents who it claims to represent.
15:15cemerickangerman: I'm idly investigating gandi.net. They seem to have very reasonable cert prices, along with a good assortment of other stuffs.
15:15kencauseyangerman: As such, if the certifier does proper checking (aka labor) then the costs can be high.
15:17angermankencausey: yes, yes, yes… but they ssl provider seem to focus on ecommerce and offer some insurance… :/
15:17angermankencausey: doesn't ssl encrypt the data channel as well?
15:18kencauseyI should say that the last time I got one I got it from GoDaddy
15:18kencauseyBut this is for a non-public site so identification certainty is of little importance
15:18kencauseyangerman: of course, and for me that was the important part
15:19kencauseywe got along for years with a self-signed certificate but it became more and more annoying so it was worth about $30 per year to deal with it
15:19angermanyea right. that's all I neeed, the user should feel fuzzy because it has the *secure* feature feeling and I get a secured channel.
15:19semperosif I have a seq of seqs, all integers; how do I find the inner seq with the largest number in first position?
15:20semperose.g. [ [1 2 3 4] [200 5 6 7 8] [9 10 11] ]
15:20semperosin this case, I want [200 5 6 7 8] returned
15:20semperossince 200 is larger than 1 or 9 (the first element of the other two vectors)
15:21angermankencausey: yea, been going with self singed ssl for a while as well. But the more computer-challenged the people become the worse it gets.
15:22angermanhmm comodo (via namecheap) starts at 8,95/yr
15:23markskilbecksemperos: first and sort, I'd guess.
15:25semperosmarkskilbeck: actually, sort will save me work I was already doing; thanks
15:25markskilbecksemperos: ##(first (sort-by first > [[1 2 3] [200 4 5] [6 7 8]]))
15:25sexpbot⟹ [200 4 5]
15:25semperosnice
15:26choffsteinanyone use marginalia?
15:26choffsteinit looks ... awesome
15:26semperosyep
15:26angermanchoffstein: marginalia?
15:26semperosquite nice
15:27semperosfogus' code documentation tool
15:27choffsteinany gotchas I should be aware about?
15:27angermansemperos: ohh the literate code thing with markdown?
15:27semperosyep
15:27angermanyea, that looked nice
15:27semperoschoffstein: not that I'm aware of
15:27semperosit's hosted on Github, so you can just leave fogus an issue if something is up :)
15:28markomani have two problems to throw on table now
15:28choffsteinJust wondering if it was as awesome as it looks before I jump in head first :D
15:28semperosas long as you understand it's not producing documentation like on clojure.org or javadoc
15:28semperosI just add it as a dev-dep and run "lein marg" do generate the docs
15:28semperosproduces a single uberdoc.html file
15:28semperosthat's it
15:28markomanfirst one is simple i want [1 2 3] -> "1,2,3"
15:30semperos,(apply str (interpose "," [1 2 3]))
15:30clojurebot"1,2,3"
15:30amalloyaugh. clojure.string/join
15:30semperos:)
15:30semperoswhere's the fun in that?
15:31semperosmarkoman: I'd check clojure.string for any string needs by default, including join
15:31markomanalright, will do that
15:32rak85hi, everyonde
15:32rak85*everyone
15:32rak85how do i check if a given string is in a list of strings?
15:32rak85i'm trying contains?
15:32markoman$source join
15:32sexpbotSource not found.
15:32amalloyclojurebot: contains?
15:32clojurebotcontains? is for checking whether a collection has a value for a given key. If you want to find out whether a value exists in a Collection (in linear time!), use the java method .contains
15:32rak85but it's not returning properly...
15:32markoman$source clojure.string/join
15:32sexpbotclojure.string/join is http://is.gd/1eAPlt
15:33rak85(contains? [1 2 3 4 "adf"] "adf) -> false
15:33rak85sorry, (contains? [1 2 3 4 "adf"] "adf") -> false
15:33amalloyrak85: do you read what people say? i just asked clojurebot about contains, just for you
15:33rak85Yes, I read amalloy
15:34semperos,(some #{"asdf"} [ 1 2 3 "asdf" ])
15:34clojurebot"asdf"
15:34semperos,(some #{ "asdf"} [ 1 2 3 "asd" ])
15:34clojurebotnil
15:35semperosrak85: ^^
15:35semperosis that what you meant?
15:36markskilbeckrak85: amalloy told you why contains? *wouldn't* work.
15:55markomanok, join is clear now. then other q is more complicated to present but im sure answer is simple
15:58fliebelchouser, fogus`: JoC has arrived! Thank you for writing that.
15:59chouserfliebel: Thanks, hope you enjoy it!
15:59amacforgot to order that
16:00chouseramac: I don't know if you get the ebook with it when you order from amazon.
16:00fliebelchouser: What is the ebook anyway? Not the meap I assume?
16:01chouserThe PDF is available now, laid out like the printed book (to wit, rather better than the early MEAP versions)
16:01semperosand has color :)
16:01chouserother formats will be available eventually: epub, mobi, etc.
16:03markomanso the question is here http://pastebin.com/BmZbkJZF how to loop list and get expected return
16:06amacchouser: good to know regarding the ebook, I love my kindle
16:07chousermarkoman: maybe replace the 'let' line with (for [dtype (map :dtype division)]
16:07chouserhm, no that's not right
16:08chouser(defn form-generate division-coll (for [division division-coll] ...then your let, etc...))
16:09markomanyes, i was thinking i need to variables for division in there, let me test
16:09phenom_what's the easiest way to get the name of a function passed in as a parameter ?
16:09phenom_chouser: just got my copy of JoC :) thnx for all the work !
16:10chouserphenom_: quite welcome. Fogus did most of the work, but I'll take the credit anyway.
16:11choffsteinAnyone use marginalia that can tell me why my comments at the bottom of: https://github.com/newfoundresearch/construct-index/blob/master/src/construct_index/core.clj don't make it into the docs (http://github.com/newfoundresearch/construct-index/raw/master/docs/uberdoc.html)? Thanks.
16:13choffsteinFor some reason, it just seems to ... stop working half way through my comments :D
16:15markomanim starting to love this channel and language, thanks chouser :)
16:17markomanworking version http://pastebin.com/qAf3GdcQ
16:19fogus`choffstein: Can you modify the comments at lines 127-128 to remove the ## and -- ? They might be causing issues. Not sure yet though.
16:19markomanI seem to have this repeating pattern on my codes now: {:id (:id args)} its kind of transfering key from one map to other, not bad if its just id, but when it multiplies Im thinking if there is a shortcut
16:19choffsteini'll try it now fogus`
16:20fogus`Thanks
16:21choffsteinDoesn't seem to make a difference
16:21markomanis it time for macros here?
16:23fogus`Weird. I'll investigate later tonight
16:23fogus`Sorry about that
16:25markomani think its just filtering map
16:26choffsteinfogus`: No worries. It is an amazing tool :)
16:29markoman(select-keys args [:id]) -> {:id (:id args)} -> {:id 'some} I think
16:54choffsteinman, it's amazing how much my network messes up my clojure work when I try to use clojars.
16:54choffsteinThings that don't compile now because of strange errors will work fine on my home network...
17:02choffsteinlike, for example, 'resolve-uri' cannot be found in hiccup. Of course it can. But for some reason, lein deps just gets some whacky downloads on this network. It is ... strange.
17:03jkkramerchoffstein: have you tried lein clean to see if it helps?
17:07scottjanyone know where the project fetcher is hosted?
17:08choffsteinjkkramer: yep
17:17wwmorganif I have a collection of key-value pairs [[:a :b] [:a :c] [:d :e]], how can I turn it into a map grouped by key? {:a [:b :c] :d [:e]} ?
17:19raek,(group-by first [[:a :b] [:a :c] [:d :e]])
17:19clojurebot{:a [[:a :b] [:a :c]], :d [[:d :e]]}
17:20chouser,(reduce (fn [m [k v]] (assoc m k (conj (m k []) v))) {} [[:a :b] [:a :c] [:d :e]])
17:20clojurebot{:d [:e], :a [:b :c]}
17:21raek,(apply merge-with into (for [[k v] [[:a :b] [:a :c] [:d :e]]] {k [v]}))
17:21clojurebot{:d [:e], :a [:b :c]}
17:22wwmorganthanks raek, chouser
17:23chouser,(->> [[:a :b] [:a :c] [:d :e]] (group-by first) (map (fn [[k v]] [k (map second v)])) (into {}))
17:23clojurebot{:a (:b :c), :d (:e)}
17:23scottj(reduce (fn [m [k v]] (update-in m [k] conj v)) {} [[:a :b] [:a :c] [:d :e]])
17:24RaynesI thought I was in #perl for a moment there. What, with all these ways to do the same thing. :>
17:26scottjs/conj/(fnil conj [])/
17:26sexpbot<scottj> (reduce (fn [m [k v]] (update-in m [k] (fnil conj []) v)) {} [[:a :b] [:a :c] [:d :e]])
17:28drewrI have a script that bootstraps some code using eval, but eval insists on printing to stdout the result of the ns form inside
17:28drewris there any way to turn that off or otherwise do what I'm doing?
17:30polypusbest client lib for redis: clj-redis or redis-clojure or wrapping jedis or ??
17:31fliebelpolypus: Or Aleph?
17:32fliebelhttps://github.com/ztellman/aleph/blob/master/src/aleph/redis.clj
17:33polypusfliebel: ty, forgot about that one. looking better and better since i also want websockets
17:57devnclj-redis
17:57devnpolypus: that's your best bet...right now
17:58devnQ: If I have a (defn [{:keys [foo bar]}] [foo bar]), is there an option I can use to retain the original map as something I can pass along?
17:59raekdevn: {:keys [foo bar], :as m}
18:00joshua__Hmm. When I do lein deps I'm getting a slew of WARNING] POM for 'org.clojure:clojure:pom:1.2.0:compile' is invalid. It will be ignored for artifact resolution. Reason: Not a v4.0.0 POM. for project org.clojure:clojure at /root/.m2/repository/org/clojure/clojure/1.2.0/clojure-1.2.0.pom
18:00joshua__I have no idea what I'm doing wrong.
18:01devnraek: hmph, thought i tried that, guess not. thanks!
18:03MarkN3Djoshua__: I seem to recall seeing something like that when using an old version of marginalia, does that help?
18:03joshua__MarkN3D, Nope, not really. I get that errors for -every- project I have. So I can't really do anything with Clojure right now =/
18:04joshua__So I not only get it for Clojure, but for Enlive etc. When I use lein run it fails saying clojure.main not found.
18:04MarkN3Djoshua__: Hmm, corrupted lein plugin?
18:04raekjoshua__: maybe you could try to remove the files in ~/.m2/
18:04MarkN3Dreinstall leiningen?
18:06joshua__raek, looks like that is working ;)
18:06raekmaybe it was a corrupted download
18:07joshua__Might be. I'm on the school network which can cut out randomly.
18:08MarkN3DI'll have to remember that one
18:10joshua__Gah. Checksums keep failing..
18:10joshua__A lot of: [WARNING] *** CHECKSUM FAILED - Error retrieving checksum file for org/mongodb/mongo-java-driver/2.0/mongo-java-driver-2.0.pom - IGNORING
18:10joshua__Caused by: org.codehaus.plexus.util.xml.pull.XmlPullParserException: end tag name </HEAD> must be the same as start tag <META> from line 1 (position: START_TAG seen ...snapshots/enlive/enlive/1.0.0-SNAPSHOT/maven-metadata.xml"></HEAD>... @1:361)
18:10joshua__ ???
18:11raeklooks like you get HTML in your files
18:11raekmaybe a login portal or something
18:12raekor a bad http proxy
18:26joshua__raek, ahh. Thank must be it. I have to go through a proxy, because I'm on the schools internet... this sucks. This also explains why I don't get the error when I ssh to my linode box.
23:02choffsteinAny idea where I could be dredging up this error from (using hiccup): Exception in thread "main" java.lang.IllegalAccessError: resolve-uri does not exist (form_helpers.clj:1)
23:03choffsteindigging down the stack trace, it seems to be coming from me calling (:use [hiccup core page-helpers form-helpers]) in one of my name spaces
23:03choffsteinbut I don't know why it would be giving that error
23:44choffsteinWhy in the world am I getting this error?
23:46choffsteinwhy ... why ... why
23:46carllercheAre there any clojure json parsers than can take a lazy seq and return a lazy seq/
23:46amalloycarllerche: don't think so. json objects are hashes
23:47carllercheamalloy: I'm trying to parse the campfire streaming API which returns a stream of json hashes... not sure of the best way to do it (my "learn clojure" project is trying to write a campfire bot)
23:49choffsteinwell, well, well...hiccup 0.3.0 works, but not 0.3.4. Interesting. I wonder why...
23:51technomancyI really hope hiccup is named after the hero of http://en.wikipedia.org/wiki/How_to_Train_Your_Dragon_(film)
23:55technomancywhy does this echo a newline despite the output redirection? rlwrap -m -q '"' /bin/true > /dev/null 2>&1
23:57amalloytechnomancy: rlwrap uses ncurses or something doesn't it?
23:57amalloy(fyi, foo &>/dev/null is shorthand for that)
23:58justinlillyhttp://i.imgur.com/dcVGX.png -- I don't see a newline? ... or at least not an extra one.
23:59amalloygood point. neither do i; that rlwrap produces the same output as echo -n, not echo, for me