#clojure log - Apr 04 2013

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

0:34 davidchambers: Why does (keys "") return nil, whereas (keys "abc") is an error?

0:34 http://stackoverflow.com/questions/15802559/why-does-keys-return-nil-in-clojure-whereas-keys-abc-is-an-error

0:38 amalloy: davidchambers: because (seq "") is nil

0:38 and (keys m) is (map key (seq m)), more or less

0:39 davidchambers: amalloy: thanks, that makes sense

0:40 tupi: hello. i am using clojure to write [learning to] imagej [no GUI] scripts. to strat with, i am trying to translate a small java code which comes from a marco recorded session... i see this line: "Prefs.blackBackground = true;" and the doc tells me ij has a Prefs class, the doc says: public static boolean blackBackground. how would I write the correspondig clojure expression?

0:43 xeqi: tupi: (set! Prefs/blackBackground true) I think

0:44 tupi: xeqi: tx

0:52 tyler_: whats a function to see if something is in a collection

0:53 i tried contains? but that wasn't what i was looking for

0:53 xeqi: ~contains

0:53 clojurebot: contains is gotcha

0:53 xeqi: hmm, did that text change?

0:53 n_b: ,(doc contains)

0:53 clojurebot: Gabh mo leithscéal?

0:54 xeqi: tyler_: ##(some #{:x} [:a :b :c :x])

0:54 lazybot: ⇒ :x

0:54 xeqi: &(some #{:x} [:a :b :c])

0:54 lazybot: ⇒ nil

0:54 bbloom: lynaghk: ok i can finally look at mysteries now, if you haven't solved it yet. heh.

0:54 tyler_: thats clever heh

0:54 xeqi: thnx

1:15 tupi: in java they do: RoiManager rm = RoiManager.getInstance(); if (rm==null) rm = new RoiManager(); which i translated to:

1:15 (import '(ij.plugin.frame RoiManager)) (let [rm (RoiManager/getInstance)] (when-not rm (set! rm (new RoiManager))))

1:15 but rm is immutable, what would be the right thibg to do ?

1:16 xeqi: (let [rm (or (RoiManager/getInstance) (RoiManager.))] ...)

1:16 Raynes: I like to think RoiManager is a way to keep track of your illegal steroid injection plan.

1:17 tupi: of course! tx. sorry to ask basic Q, i am a beginner

1:17 Raynes: xeqi lives to serve.

1:19 tupi: in scheme, anythink that is not #f is #t, can i say in clojure anything that is not nil is true ?

1:20 amalloy: tupi: anything that is not nil or false

1:20 tupi: ok

1:22 alex_baranosky: is anyone using reducers regularly?

1:25 bbloom: alex_baranosky: if you have an underlying question, ask that directly

1:26 Raynes: Uh oh.

1:26 A veteran just got "ask your real question"'d.

1:26 ~anyone

1:26 clojurebot: Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."

1:27 alex_baranosky: fortunately, I was asking the question I care about

1:27 Raynes: I suspected as much.

1:28 SegFaultAX: Bro, do you even Lisp?

1:28 bbloom: Raynes: i wasn't sure if there WAS an underlying question

1:28 alex_baranosky: wondering if anyone uses them regularly. They seem like something with a lot of potential but I don't hear people talking about them a ton.

1:28 bbloom: alex_baranosky: i said that because i'm using reducers in fipp, but not for their parallel nature

1:28 alex_baranosky: so i didn't know if you were looking for popularity figures or help

1:29 alex_baranosky: bbloom: what do you use them for if not their parallel nature?

1:31 bbloom: alex_baranosky: they save the significant overhead of creating intermediate structures, so if you don't need laziness, they are a big perf win

1:31 alex_baranosky: bbloom: nice, there's a perfect example of something I should know more about

1:32 bbloom: alex_baranosky: https://github.com/brandonbloom/fipp/blob/master/src/bbloom/fipp/transduce.clj#L41-L44

1:32 alex_baranosky: bbloom: I was reading the implementation a while back, is it true that only vectors parallelize?

1:32 bbloom: that's the reducer equiv of doseq

1:32 that each function is eager

1:33 i use reducers to pipeline side effects at the end of the pipeline

1:33 alex_baranosky: like i said: i don't use the parallel features :-P

1:33 alex_baranosky: i stick a lazy seq in the top of the pipeline, so i'm guarented to be linear

1:34 alex_baranosky: but each reduce function calls the next reducer function directly, which means that space complexity for intermediate data structures is constant.... and that constant is zero

1:34 no chunking or anything like that

1:35 alex_baranosky: fascinating

1:37 bbloom: space complexity is not something I've spent a ton of time thinking about

1:37 I'm curious what your motivation for writing a better pprint are?

1:38 bbloom: alex_baranosky: ah, now i remember why your name is familiar! you had emailed me a while back when i mentioned i was between jobs :-)

1:39 alex_baranosky: bbloom: yep, that was me

1:39 bbloom: alex_baranosky: heh, so i wrote a better pretty printer sort of by accident. i never actually got around to the thing that had me researching it in the first place

1:39 amalloy: alex_baranosky: saving the allocations is probably a bigger win than parallelizing, since you can do the former all the time, and something concurrently foldable is not that common

1:39 bbloom: alex_baranosky: i wanted to experiment with some ideas regarding stylesheets & aspect-oriented rewriting of propertied trees

1:40 amalloy: certainly it's not true that only vectors can fold in parallel; anything can implement coll-fold. at the moment, i don't know of anything else that *does*, unless you count patches that haven't been applied to master

1:40 bbloom: alex_baranosky: my thought was that pretty printing could have colors or line breaking preferences that would be something i could apply stylesheets to play with

1:40 alex_baranosky: what i discovered was that pretty printing is kinda complicated, heh

1:40 alex_baranosky: so i got side tracked implementing an interesting algorithm, and never got around to the propertied tree beyond the basic pretty print document primitives

1:41 amalloy: eg, i submitted an impl of (reducers/range min max step) that can fold itself in parallel

1:41 bbloom: alex_baranosky: i thought pretty printing would be easier than a full on application/browser DOM, but apparently everything is always harder than it appears & my attention span is shorter than anticipated always

1:41 devn: How do people generally choose to refer to set and string in the arglist of your function definitions?

1:41 alex_baranosky: amalloy: yeah, so anything *Can* but by default only vectors do, cool

1:41 devn: specifically "set" -- what do people use when a function specifically expects a set

1:42 alex_baranosky: bbloom: doing anything well could take a year or two :(

1:42 amalloy: alex_baranosky: that's not a very good summary. not every data structure can fold, and "by default" is misleading

1:42 anything that can access bits of itself at random and knows its final size can implement fold, but not every data structure can do that

1:42 bbloom: amalloy: can proper linked lists fold? not really, unless you count the degenerate case of linear traversal

1:43 alex_baranosky: devn: I have adopted this approach (defn f [foo-set] (set/difference foo-set #{:a})

1:43 wliao: Hi, is there a way to get macroexpanded source code during clojure compilation process.

1:44 amalloy: bbloom: not really. you could implement it to walk over the list once to start, and then chop it up and reduce the chunks in parallel. if your reducef is much more expensive than walking the list, that'd be a win

1:44 bbloom: amalloy: ok, but that's assuming a finite sequence. probably the right API design choice to disallow that & force a `vec call

1:45 amalloy: you certainly can't do it lazily

1:48 tupi: hum, in the methods class summary i see getInstance, so i can use it in clojure like RoiManager/getInstance, but in the same summary i see runCommand, but (RoiManager/runCommand rm "reset") fails - translating java: rm.runCommand("reset");

1:49 bbloom: alex_baranosky: space complexity is something i've recently been thinking about a lot

1:50 alex_baranosky: more generally, i keep finding that a surprising number of things can be thought of in terms of space vs time. not just algorithmic complexity

1:50 alex_baranosky: what project brought it to the forefront for you?

1:50 there's probably something for me to learn around these concepts

1:51 bbloom: nothing really in particular. clojure has just fundamentally changed how i approach problems & a big part of that is rich's views on identity and value

1:51 i feel like clojure has a damn near perfect model for working with finite data and instantaneous time

1:51 amalloy: (.runCommand rm "reset")

1:51 bbloom: it also provides a quite reasonable and far from broken model for working with time, timelines, and infinite data

1:52 but there is so much more to explore there, i think

1:52 and then when i started playing with factor & concatenative programming, i realized that you can even think of stack machines vs register machines as time vs space

1:53 or consider variable bindings: lexical scope assigns a value to a name for an extend of space, but dynamic scope assigns a value to a name for an extend of time

1:53 it's quite amazing how often computer science dualities can be reframed in terms of space vs time

1:54 so now i just think about those two words/ideas anytime i encounter anything :-P

1:55 alex_baranosky: bbloom: don't dynamic bindings assign a variable for time as well as space?

1:57 bbloom: alex_baranosky: it's from push-thread-bindings to pop-thread-bindings. the binding macro has some notion of space, but that's just one composition of push & pop bindings

1:57 alex_baranosky: bbloom: I think there's some food for thought there. I recently worked on a project with work where I had to care about memory usage and calculation time more than in the past and I learned a lot in the process. I'd like to explore more of how reducers can also teach me something

1:58 bbloom: alex_baranosky: so not sure if reducers per say offer this idea uniquely. i assume you can get this same effect w/ regular lazy sequences, but fipp relies on "state transducers"

1:58 alex_baranosky: and specifically, to accomplish the bounded space requirement, they are "finite state transducers"

1:59 essentially little state machines that take messages in, do some processing against local state, and send some messages out

1:59 each step in the pipeline can be thought of like a little agent

1:59 not quite a clojure agent, which is not quite an erlang agent

1:59 simpler than both

2:00 here's map-state: https://github.com/brandonbloom/fipp/blob/master/src/bbloom/fipp/transduce.clj#L13-L24

2:00 essentially, each mapper function returns [new-state mapped-value]

2:00 instead of just mapped-value

2:00 https://github.com/brandonbloom/fipp/blob/master/src/bbloom/fipp/printer.clj#L79-L90

2:01 that's a trivial state transducer which has as it's only state an integer called "position"

2:01 the same file has more complex state below

2:01 the pretty printer itself is a pipeline of transformations, each with it's own finite state

2:01 surely your distributed systems at runa do this kinda stuff all the time :-)

2:02 but it's cool to see it in such raw form: none of the boilerplate around it to blue a complex topology of processes together

2:02 s/blue/glue

2:07 meta comment: everybody forgive me for the philosophical ramblings. i had a very long day and then drank a bottle of wine

2:08 alex_baranosky: bbloom: sorry got pulled away. Cool stuff, I just need to go read the code again, and make something useful with reducers. That's the only way these ideas really sink in for me

2:09 bbloom: alex_baranosky: totally understand. i'm the same way. i guess the big thing for my use case was that reducers are eager, not lazy

2:09 alex_baranosky: so keep that in mind if you're looking for a project idea

2:09 alex_baranosky: most of the time I don't need lazy evaluation

2:11 bbloom: most of the time either is just as good as the other

2:11 it's when you need side effects, that laziness stinks

2:11 and it's when you have infinite structures that eagerness stinks

3:42 worrelsik: Is there some way to find out in the REPL which forms have been read and evaluated by using a (load-file my-file)?

3:56 ejackson: worrelsik, I don't think so.

4:11 worrelsik: ejackson: so opening the file in an editor is my best bet to find out ?

4:12 ejackson: yeah

4:12 worrelsik: Or is there some sort of debugger-like way to step through the forms of the file?

4:18 clgv: worrelsik: the Clojure plugin "Counterclockwise" for Eclipse allows you to step through the code in debug mode.

4:19 foo12: worrelsik: are you trying to see where in a file the evaluation breaks?

4:22 talios: I believe La Clojure for IntelliJ also has stepping support

4:22 dan_b: is there a reasonably elegant way to use lemningen to build java and/or c files? I think i need to add some jni stuff to my clojure project

4:23 leiningen, even

4:24 (to be slightly more precise "to build artefacts *from* java or c files")

4:25 foo12: dan_b: i'm pretty sure it has an option where you can just give a vector of java source folders and it'll compile those before it does the clojure

4:26 ebaxt: dan_b: http://nakkaya.com/2010/04/05/managing-native-dependencies-with-leiningen/ or http://antoniogarrote.wordpress.com/2010/09/08/zeromq-and-clojure-a-brief-introduction/ should get you started

4:26 clgv: dan_b: java is built-in - dont know about jni and c...

4:27 foo12: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L241

4:27 dan_b: foo12: ah, that second link looks v. useful, thanks

4:45 worrelsik: foo12: No, I'm doing an exercise from Brian Maricks' book, and some functions I need to use are defined in a file. So I'd like to have an overview of which functions were defined

4:46 clgv, talios: thanks

4:50 foo12: can't you just do something like (ns-vars 'that.files.namespace)

4:52 ... and probably filter out anything that file's namespace uses

4:52 okay nevermind

4:52 clgv: foo12: you mean `ns-publics`, I think ;)

4:52 foo12: oh is that a thing?

4:53 that's good to know, thanks

4:53 ejackson: oooh, something new :)

4:54 clgv: ,(keys (ns-publics 'clojure.core))

4:54 clojurebot: (sorted-map read-line re-pattern cond->> keyword? ...)

5:14 mpfundstein: when running LaClojure in IntelliJ, does someone now how i have to structure my src path so that .clj files get added to the classpath? When i require src/whatever/whatever.clj in src/whatever/test.clj i get FileNotFoundException Could not locate whatever/test__init.class or whatever/test.clj on classpath: clojure.lang.RT.load (RT.java:432)

5:20 DerGuteMoritz: hey guys, I get a StackOverflowError with lein deps :tree which seems to originate from leiningen.deps/check-for-range; any clues?

5:20 i.e. leiningen.deps/check-for-range calls itself to deeply

6:04 otfrom: morning

6:12 hyPiRion: gfredericks: with their factorizations?

6:12 That'd be fancy.

6:16 Ember-: is anyone making a replacement for clojuredocs.org?

6:16 it bugs me that it hasn't been updated since 1.3

6:18 babilen: Ember-: The last time I asked this the answer was more or less: The code is on github, feel free to implement it. I've just checked and Zachary Kim never replied, so I have no idea if there is any interest in updating it ever.

6:21 Ember-: babilen: yeah, I've come to the same conclusion

6:22 that's why I asked if anyone is actually recreating the site

6:22 as far as I understand clojuredocs is written in ruby

6:22 babilen: It is, yes.

6:22 Ember-: would make more sense for it to be written with clojure

6:23 would make generating apidocs automatically a breeze

6:23 then only thing needed in addition would be to add examples funtionality (which is the reason I actually like clojuredocs)

6:24 babilen: Which would, essentially, mean that the entire website has to be reimplemented. It is probably possible to use the design though.

6:24 Ember-: yeah I know it would mean rewrite

6:24 but that site is not *that* complicated

6:24 few days from an experienced clojurist

6:25 babilen: yeah, which would be a wonderful service to the Clojure community

6:25 Ember-: yup

6:25 once again a project which would be fun to make but so little time...

6:25 which is most likely the reason this hasn't been done yet :)

6:26 but, people on this channel could start the rewrite project as an opensource community project in github for example

6:26 someone would have to take lead responsibility though

6:26 preferably someone with more experience in clojure than me

6:26 :P

6:28 the need is there, someone would just have to start the project

6:29 jballanc: Ember-: there is http://clojure-doc.org/

6:29 but it's less of a replacement and more of a compliment

6:30 but the community surrounding CDS seems much more engaged

6:30 Ember-: jballanc: yeah, not an ideal API reference

6:30 jballanc: their Emacs and Vim tutorials are pretty great, though

6:31 Ember-: I don't disagree but what I'm talking here about is *good* api reference page

6:32 clojuredocs is hands down the best out there (at least of what I'm aware of) but the problems mentioned above stand

6:34 vijaykiran: I agree that clojuredocs.org usecase is different than clojure-doc.org - I did start looking into existing code of clojure-docs.org and pondering about a rewrite

6:35 looks like the indexer and site are different projects - site is in Ruby, but the "indexer" is still Clojure AFAIU

6:38 Anderkent: can i reference a type name via require/refer, or do I have to use import?

6:39 vijaykiran: Anderkent: java type ?

6:39 Anderkent: record, for example

6:40 it seems weird that i'd have to do (import my_other_ns.ARecord), manually replacing - with _, instead of (refer 'my-other-ns.MyRecord)

6:40 hyPiRion: gfredericks: Actually, I did something like that for some time ago. Not the natural numbers, but a sorted subset of them

6:40 I can't remember what they were named, I'll have to look it up.

6:45 vijaykiran: Anderkent: because defrecord generates a class and it is different than clojure vars (?)

6:47 murtaza52: c When I start my lein repl, I keep getting this error - "NullPointerException java.util.concurrent.ConcurrentHashMap.hash (ConcurrentHashMap.java:332)" How do I look for the source of the error ?

6:48 Bronsa: murtaza52: (pst *e)

6:51 murtaza52: Bronsa: thanks for the tip

6:52 Bronsa: :)

7:01 fractastical: hmm, the old "db-spec null is missing a required parameter" error greets me again

7:02 pisketti: Is there any documentation available for java.jdbc?

7:02 Other than http://clojure.github.com/java.jdbc which basically just lists the function.

7:03 http://en.wikibooks.org/wiki/Clojure_Programming/Examples/JDBC_Examples something like this but more systematic

7:03 Or perhaps like in clojuredocs, with a few examples

7:04 That would be immensely helpful

7:09 murtaza52: I get the following stacktrace when typing "lein repl" https://www.refheap.com/paste/13253. Any ideas what could be causing it ?

7:12 foo12: just a guess but maybe a wrong namespace reference in project.clj?

7:14 or maybe the wrong leiningen

7:14 i had lein 1 hiding in my path somewhere and it did stuff like that on lein 2 projects

7:50 murtaza52: foo12 : Thanks. Yes there was a lein1, which I deleted and things started working :) Just for my info, how did u debug this, bcoz I couldnt make any connection between lein and the stacktrace.

7:59 foo12: murtaza52: i didn't really debug it, i just figured if lein breaks so badly it actually stacktraces before running anything either the project.clj is incredibly screwed up or it's the wrong version of lein

8:04 murtaza52: foo12: that is valuable advice, thanks :)

8:37 Sonderblade: how do you get a value out of a map which has strings as keys?

8:38 mpenet: ,(doc get)

8:38 clojurebot: "([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."

8:40 papachan: question: if you want to compile an web app in clojure, do you compile a war for tomcat?

8:42 hyPiRion: papachan: either a war or an uberjar

8:42 ring is able to do both

8:43 papachan: thanks hyPiRion

8:45 wink: one ring to serve them all

8:48 jweiss: wow, referring to protocol functions by value is dangerous

8:49 at least, during development of said proto and the impls :)

8:52 asaleh: clojure.core.logic question: can you use it to generate strings?

8:53 hyPiRion: asaleh: hmm...

8:53 You could probably generate sequences of integers representing strings

8:54 asaleh: hyPiRion, will show gist so you know what I mean :)

8:54 ebaxt: ,(let [fun (fn [] "foo")

8:54 isfun (fn [x] (and (not (map? x)) (ifn? x)))]

8:54 (prn (isfun fun))

8:54 (prn (isfun {})))

8:54 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

8:55 hyPiRion: okay

8:56 ebaxt: ,(let [fun (fn [] "foo") isfun (fn [x] (and (not (map? x)) (ifn? x)))] (prn (isfun fun)) (prn (isfun {})))

8:56 clojurebot: true\nfalse\n

8:57 asaleh: generating strings with clojure logic problem : https://gist.github.com/AdamSaleh/5310152

8:57 hyPiRion, ^

8:59 hyPiRion: asaleh: str is impure, using e.g. (fresh [x y] (== y (str x))) won't work

8:59 It'll bind y to the .toString variant of the fresh variable x

9:00 Not entirely sure whether logic has some way of doing that yet, perhaps dnolen could answer that if he were here

9:04 asaleh: hyPiRion, ok, will try mailing list :)

9:05 hyPiRion: asaleh: yeah, I guess that's your best bet :)

9:45 gmanika: I have a deftype A that uses deftype B and vice-versa and the Clojure compiler doesn't like that. How do I work around this? Can I toward-declare types or something?

9:45 s/toward/forward/

9:56 kxra: can someone help me do some stuff to a list of words and get lein working?

9:58 i just need 15 minutes of help. 20 tops

10:08 matthavener: kxra: sure, i can try

10:10 nDuff: kxra: In general, btw, it's preferable to ask your questions to the channel, rather than try to get a single volunteer (though you appear to have been successful in the latter endeavor in this case).

10:12 kxra: nDuff: ah, thanks. i see. i asked for a volunteer because i thought i might need a lot of simple and didn't want to bog down the channel

10:13 my core.clj is on etherpad https://pad.riseup.net/p/5FI1GoysZUst

10:13 i'm currently just trying to get it to run before anything else

10:14 nDuff: kxra: That works for me.

10:14 kxra: ...of course, you have to actually _do_ something with the wordlist inside the body to see it

10:14 kxra: lein is giving me lots of errors

10:15 nDuff: kxra: Can you provide those somewhere, and your project.clj?

10:15 gtrak: is this bad form? ##(str (.sym :hello/asdf))

10:15 lazybot: ⇒ "hello/asdf"

10:17 kxra: nDuff: http://pastebin.ca/2349578

10:17 getting my project.clj now

10:17 http://pastebin.ca/2349580

10:17 nDuff: Ahh.

10:18 the :main shouldn't be a filename

10:18 kxra: ...but rather just the namespace name, :main words.core

10:18 kxra: ah, i see

10:18 ah! thanks

10:19 i wonder why lein didn't do that when i created the project

10:20 TimMc: kxra: I think the default lein template is for libraries, not applications (which have a :main).

10:20 nDuff: kxra: ...well, not all programs _have_ a main

10:20 kxra: TimMc nDuff: ah! that makes sense

10:20 TimMc: lein new app words

10:22 You can even do fancy things like `lein new app org.timmc/words`, which creates a project in a new directory called "words" with the appropriate group and artifact names, and src/org/timmc/words.clj.

10:22 No need for core.clj.

10:47 kxra: nDuff: i've updated the etherpad to the most recent code, but now i'm getting even more errors

10:48 http://pastebin.ca/2349605

10:49 nDuff: kxra: your pastebin says lowercase, whereas your etherpad says lower-case

10:49 gfredericks: TimMc: now I know

10:50 kxra: nDuff: ah, good catch. thanks

10:50 hard to keep them in perfect sync

10:50 nDuff: kxra: By the way, if you haven't played with it yet, the kind of experimentation you're doing right now is part of what Light Table is really, really good for.

10:51 kxra: nDuff: ah, turns out there was a dash in both, but the one in emacs was some weird special character for some reason

10:51 nDuff: i'll look at light table

10:52 nDuff: Heh. Don't let me dissuade you from emacs, though; Light Table is great for experimentation, but it's what I use for doing real work.

10:52 s/it's/emacs is/

10:54 kxra: is lighttable libre software?

10:54 piranha: somebody had a library for javascript which had a lot of clojure standard functions implemented (a-la partition-by, split-at, etc). I've seen it just few days ago and now I can't remember the name. Does anyone know what I'm talking about?

10:55 kxra: after i fixed the special dash character, i still get these errors: http://pastebin.ca/2349610

10:55 fewer, at least!

10:56 nDuff: kxra: It's been promised that the core of the final product will be OSS; it may be supported by commercial add-ons or components.

10:56 kxra: ...so, remember, your code has a :main in it

10:56 kxra: that means you need to actually use gen-class with a -main function

10:56 kxra: if you don't want to have that requirement, take the :main out of your project.clj

10:57 (and then you won't compile to externally-runnable jars, but at this stage, do you really _need_ to?)

10:57 ("externally runnable" in the ''java -jar foo.jar'' sense, that is)

10:57 piranha: ah, found it: http://fogus.github.com/lemonad/

10:57 kxra: nope

10:57 nDuff: kxra: It'd be easier if you had this in a git repository, by the way.

10:57 kxra: having things split across multiple paste sources is a pain.

10:58 kxra: true

10:58 i've actually been using darcs

10:58 nDuff: Heh.

10:58 * nDuff <- bzr partisan from back in the day

10:58 nDuff: ...and GNU Arch before that.

10:58 Anyhow, when the bzr people think your SCM has performance problems, well... :P

10:59 kxra: that said -- is your repo public?

10:59 kxra: nDuff: yeah, i just need to update it. it's a total mess

11:04 nDuff: http://hub.darcs.net/kxra/CS-0286

11:04 nDuff: kxra: (that said, I sorely miss back when DSCMs were competing in part on coming up with better merge algorithms)

11:05 kxra: ...showing a bunch of Ruby there.

11:06 ...oh, under words/

11:06 kxra: nDuff: yeah, the clojure is in words

11:06 sorry

11:07 nDuff: kxra: ''lein compile'' works fine. What are you actually doing to trigger the bug, ''lein run''? As I said before, you need to define a main- and use gen-class for that.

11:08 err, -main, not main-

11:09 * nDuff signs up on DarcsHub to create a fork

11:15 kxra: nDuff: if i don't specify a main, lein run only tells me that i need to specify one

11:15 nDuff: kxra: Because you're using ''lein run'', yes.

11:15 kxra: I'm not sure why you're using ''lein run'' at all.

11:15 kxra: ...you can invoke your code directly from emacs, after all.

11:16 kxra: anyhow -- I have an example that adds an appropriate -main, and am trying to figure out how to push it up to DarcsHub.

11:17 kxra: nDuff: ah, i thought you said that it would only prevent me from compiling to jars

11:17 nDuff: kxra: Doesn't stop you from compiling to jars, either; stops those jars from being runnable.

11:17 (as opposed to usable from libraries).

11:17 kxra: ah, i see

11:18 nDuff: kxra: What does your emacs setup look like? Do you have nrepl, clojure-mode, and friends?

11:19 kxra: See http://hub.darcs.net/charles-dyfis-net/CS-0286/browse/words/src/words/core.clj

11:19 ppppaul: people using drip with lein 2.1.2 ???

11:19 lazybot: ppppaul: How could that be wrong?

11:19 ppppaul: i love wrong

11:20 anyway, i seem to have lost my dripyness with my upgrade to lein 2.1.2 (i'm not sure what version i was using before)

11:20 kxra: nDuff: i don't have much added on to emacs, but let me check those out

11:20 nDuff: kxra: if you don't have addons yet, I'd suggest using Emacs Live

11:21 kxra: ...that gives you a full set tested and supported together

11:21 kxra: see https://github.com/overtone/emacs-live

11:21 kxra: ...also, the video at http://vimeo.com/22798433

11:24 kxra: nDuff: emacs live is amazing.

11:25 nDuff: kxra: Yes. Yes, it is.

11:26 kxra: nDuff: can i see all the languages it plays nice with? i'll need ruby, scala, prolog, and haskell

11:30 murtaza52: kxra: there are packages for most other languages in emacs. if they are not included with emacs-live u can install them separately. What emacs live gives you is a very easy way to get started with clojure and emacs.

11:30 ppppaul: i use emacs dead

11:31 kxra: murtaza52: ah, i see. that's what i was wondering-- whether emacs-live was specific to clojure or just a general package

11:32 murtaza52: kxra: its an assembled to package to provide u all the settings to play with clojure. You can then add any other ones, or change remove existing ones for other languages. You will have to google for packages for other's and will usually find very good ones.

11:34 kxra: nDuff: no if my goal is to count the number of times words start with each letter of the alphabet, would the simplest way to do that be to define a map then do something with doseq to sequentially tally the first letter of each word in the list?

11:34 s/no if/so if

11:35 deg: I'm about to try out ClojureScript. I come from a background in client/desktop programming and am comfortable in Clojure. I'm near-ignorant on the details of web technologies. What's the best path (sample code, tutorials, etc.) to ramp up on this learning curve. I want my first focus to be small, mildly-interactive, apps running in chrome on mobile devices.

11:37 corecode: how do you get emacs to glow?

11:37 or is that just a video processing feature

11:37 murtaza52: deg: look at webfui, also I just pushed a sample project I am working on that uses clojurescript + clojure - https://github.com/murtaza52/mashup

11:38 ToBeReplaced: kxra: didn't read whole thread so i might be missing context, but it sounds like you're looking for `frequencies`

11:38 kxra: corecode: good question. i assumed it was video processing

11:39 murtaza52: deg: also it may be nice if you gain an understanding of web technoligies in general before jumping to client side with clojurescript. So look at webnoir (which is no deprecated) and luminus

11:39 gilbertw1: deg: I learned it pretty easily using it to play around in nodejs....It's pretty quick and easy to setup and play with......I mainly used this: http://mmcgrana.github.com/2011/09/clojurescript-nodejs.html

11:40 deg: and the js comparison: http://himera.herokuapp.com/synonym.html

11:43 kral: who is doing tests with #clojure hashtag on twitter?

11:44 corecode: kxra: ok.

11:44 deg: (oops, looks like I was disconnect just after my last request. If anyone has answered me, please repeat. Sorry.)

11:47 andyfingerhut: kxra: Not sure if your question was answered, but if words is a collection of strings, you could do (frequencies (first words))

11:48 or if you want not only the count but a list of words starting with each letter: (group-by first words)

11:48 kxra: andyfingerhut: ah yeah, that's what i was looking for

11:48 the count

11:48 i'm going to keep poking at it

11:48 this is helping me understand clojure much better

11:49 asteve: so I have input called dir and I need to do something conditionally on the value of dir

11:49 andyfingerhut: There's no harm in re-implementing frequencies or group-by yourself the first time, for the learning experience. But once you know they exist and how to use them, may as well.

11:49 murtaza52: deg: (as req psting again)look at webfui, also I just pushed a sample project I am working on that uses clojurescript + clojure - https://github.com/murtaza52/mashup

11:49 asteve: if it's 1 then I need to add to pos, if it's -1 then I need to add to neg

11:49 murtaza52: deg: also it may be nice if you gain an understanding of web technoligies in general before jumping to client side with clojurescript. So look at webnoir (which is no deprecated) and luminus

11:49 asteve: this seems simple but I'm confused on how to do it in clojure

11:50 andyfingerhut: asteve: Are you doing this in a loop or something, and the final result includes pos and neg?

11:50 gilbertw1: deg: I learned it pretty easily using it to play around in nodejs....It's pretty quick and easy to setup and play with......I mainly used this: http://mmcgrana.github.com/2011/09/clojurescript-nodejs.html

11:50 deg: and the js comparison: http://himera.herokuapp.com/synonym.html

11:51 asteve: something similar, I need to keep track of all pos and neg for all time for an element in a table, and also have the true standing; i.e. is the value currently pos or neg

11:53 andyfingerhut: The condition is simple enough, e.g. (if (pos? dir) (something-positive) (if (neg?dir) (something-negative))). The main reason for my question is in case you wanted some kind of side effects in the actions.

11:54 asteve: I do need side effects but for easy of time and typing I may make it ugly like that

11:55 I think the real problem is that I need to get the current values for some of these table entries

11:55 and I'm all hopped up on percocet and can't think

11:55 hah, anyway, thanks for the simple help

11:56 andyfingerhut: That is for all positive and negative values, not just 1 and -1. You can also use (= dir 1) if you need to check for that specific value. Also (case dir 1 (something-1) -1 (something-minus-1) nil), where the nil is a "do nothing" case if it is neither 1 nor -1.

11:59 nDuff: kxra: Howdy -- just back from a meeting, and it looks like andyfingerhut came up with the same answer I would have.

12:00 kxra: ...re: doseq, that should only be used when you're aiming for side effects (like printing); using it for calculations is generally a "code smell".

12:01 asteve: ,(def dir 2) (if (pos? dir) (dir) (neg? dir) (+ dir 1)))

12:01 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

12:02 andyfingerhut: asteve: (dir) will try to call dir as a function. Leave off the parens there.

12:03 asteve: whoops

12:04 andyfingerhut: Unlike Java/C/etc. you can't just throw in extra parentheses without changing the meaning.

12:04 asteve: ya, so I just need to clarify

12:05 (if (pos? dir) (+ 1 num) (neg? dir) (- num 1)) is the right syntax for an if elseif?

12:07 nDuff: asteve: no; if you wanted else conditions, you'd use cond

12:07 andyfingerhut: asteve: No, if only has a "then" and "else" branch, no else if capability. You could use cone if you want something like else if

12:08 You can nest ifs to achieve else if, too, but it gets nested deeply pretty quickly.

12:08 bbloom: asteve: also, there are inc and dec functions for +1 and -1

12:08 nDuff: asteve: ie. (cond (pos? dir) (inc num) (neg? dir) (dec num) :else num)

12:09 asteve: ok

12:18 jcromartie: I'm not entirely convince that it's worth the trouble to have factory functions for Compojure handlers, vs. just defining handlers themselves as top-level fns with dynamic vars for the data model

12:36 nz: http://www.techempower.com/blog/2013/03/28/framework-benchmarks/ compojure performs rather nicely in this benchmark

12:52 olenhad: Hey guys, what's the idiomatic way of doing a lookahead peek in a coll whilst traversing it (saying during a reduce like operation)

12:54 bbloom: olenhad: i'd imagine that depends on the type of lookahead. is it a single element look ahead?

12:55 olenhad: single element

12:55 bbloom: preferebaly single element

12:55 S11001001: (map vector s (rest s)) ;a lazy seq of element + next element, stops at 2nd-last

12:56 bbloom: olenhad: then it's cheap to just ask for the next element with first or second or fnext or whatever

12:57 olenhad: S11001001: That seems right, Thanks!

13:15 ejackson: olenhad: another trick would be (map vector (partition 2 1 s))

13:16 you could do n-ahead lookup nicely by changing 2 to n.

13:18 Glenjamin: nz: i saw someone ranking it by (performance)/(performance of fastest on same runtime), to get an estimate of "potential of platform uztilised" - compojure is poor if you measure it that way :(

13:21 asteve: how can I test a compojure program locally?

13:22 nevermind

13:24 thalassios_xelon: hello room :) i get this exception java.lang.ClassFormatError: Invalid method Code length 105540

13:24 what this means?

13:24 CompilerException java.lang.ClassFormatError: Invalid method Code length 105540 in class file GrBDDSo/random_formula$eval1613, compiling:(NO_SOURCE_PATH:1:1)

13:25 jcromartie: what's your code?

13:25 thalassios_xelon: code?

13:25 jcromartie: thalassios_xelon: can you share the code that causes the exception?

13:25 clojurebot: all ur code r belong to us

13:26 nDuff: thalassios_xelon: see http://docs.oracle.com/javase/specs/jvms/se5.0/html/ClassFile.doc.html#9279

13:26 jcromartie: it basically means that a .class file is invalid

13:26 nDuff: thalassios_xelon: ...in particular, search for the restriction on code_length

13:26 thalassios_xelon: i dont know what code_length means

13:26 nDuff: from 4.8.1: The value of the code_length item must be less than 65536.

13:27 thalassios_xelon: Your class is too big.

13:27 jcromartie: nDuff: no, that code_length is for methods

13:27 code on the JVM only lives inside methods

13:27 I don't think thalassios_xelon neds to become familiar with the internals of JVM class loading

13:27 thalassios_xelon: i am tottally newbie

13:27 :)

13:28 nDuff: jcromartie: If an error is being triggered to the effect that the generated methods outstrip a JVM limit, sure, the details of that are unimportant, but the gist of it is useful.

13:28 jcromartie: nDuff: yes, sure, it's always helpful to know more

13:28 thalassios_xelon: let's just step back. can you paste (at https://www.refheap.com/paste) the code that throws the exception?

13:29 asteve: now I'm getting somewhere!

13:29 so why doesn't lein uberjar build the same as lein ring server?

13:29 jcromartie: asteve: uberjar is general purpose

13:30 asteve: jcromartie: how do I ensure that my app is built and packaged?

13:30 thalassios_xelon: https://www.refheap.com/paste/13264

13:31 jcromartie: asteve: you specify a main namespace with the :main option in your project.clj, then you implement (defn -main [& args] ) in your namespace

13:31 asteve: hmm

13:31 jcromartie: asteve: then you can run your project from the uberjar like: java -jar myuberjar.jar options to main

13:31 and the arguments to -main are all strings

13:32 nDuff: thalassios_xelon: Would the full package (w/ dependencies and such) be available somewhere?

13:32 thalassios_xelon: ...by the way, I don't see random-formula in there.

13:33 jcromartie: yeah, I suspect some kind of macroexpansion gone wild?

13:33 * nDuff notes that there's eval in there

13:33 nDuff: is this happening at compile time or runtime?

13:34 thalassios_xelon: CompilerException java.lang.ClassFormatError: Invalid method Code length 105540 in class file GrBDDSo/random_formula$eval1613, compiling:(NO_SOURCE_PATH:1:1)

13:34 nDuff: thalassios_xelon: yes, but is it during a ''lein compile'', or while your code is actually being invoked (ie. triggered by an eval)?

13:35 jcromartie: asteve: but how you package your system depends on the destination

13:35 nDuff: thalassios_xelon: if it's the latter, it'd be interesting to look at just _what_ is being eval'd.

13:35 asteve: right, this is going to elasticbeanstalk and I don't think I have the option to specify the main; I thought the ring plugin was supposed to take care of that?

13:36 thalassios_xelon: the error occurs on fuction call

13:36 nDuff: thalassios_xelon: then we need to see the code that's actually being put through eval by the function.

13:36 thalassios_xelon: fortunately, it shouldn't be hard to print it to a log.

13:36 thalassios_xelon: i hava a (list 'let pairs ...) and pairs might be too large

13:37 can this be the problem?

13:38 anyway thx guys,i keep in mind that somethin in the class is too big

13:38 and i will search for the bug

13:39 ispolin: to refactor multiple nested "when-let"s, is the maybe-m monad from algo.monads the way to go, or is there something in the core already?

13:39 bbloom: ispolin: cond->

13:40 as-> etc

13:44 ispolin: bbloom: "as->"?

13:44 bbloom: (doc as->)

13:45 clojurebot: "([expr name & forms]); Binds name to expr, evaluates the first form in the lexical context of that binding, then binds name to that result, repeating for each successive form, returning the result of the last form."

13:45 ispolin: ah, cool. I was trying to find it in the cheatsheet

13:45 jcromartie: asteve: are you using lein beanstalk?

13:45 ispolin: thanks

13:46 asteve: jcromartie: no

13:46 jcromartie: asteve: that might be helpful...

13:47 lein-beanstalk uses lein-ring to run the app

13:47 asteve: I thought about it

13:47 jcromartie: lein ring war/lein ring uberjar are similar to lein jar and lein uberjar, but oriented around making a deployable J2EE war file

13:50 asteve: ah

13:59 thalassios_xelon: i asked before i have an exception CompilerException java.lang.ClassFormatError: Invalid method Code length 78921 in class file GrBDDSo/random_formula$eval2355, compiling:(NO_SOURCE_PATH:1:1)

14:00 i have a (eval (list 'let pairs ....)) in my code and the pairs get toooo big ,can be this the problem?

14:01 jcromartie: what's random-formula look like?

14:01 can you just share that?

14:02 thalassios_xelon: the problem isnt in the random formula ns,

14:02 wait a sec

14:04 jcromartie: "Invalid method Code length 78921 in class file GrBDDSo/random_formula"

14:04 would seem to indicate that it is

14:09 frozenlock: If there a way to round numbers to a given precision? Kinda like (format "%.2f" 0.11111), but to return a number, instead of a string.

14:10 * frozenlock is tempted to do `(read (format "%.2f" 0.11111))'

14:12 amalloy: uh. Math/round?

14:13 frozenlock: Doesn't that just round to a whole number?

14:13 ,(Math/round 111.111)

14:13 clojurebot: 111

14:14 amalloy: $javadoc java.lang.Math round

14:14 lazybot: http://docs.oracle.com/javase/6/docs/api/java/lang/Math.html#round(float)

14:15 amalloy: huh. was sure there was a roundTo parameter of some kind

14:16 pjstadig: multiply by 100, Math/round, then divide by 100

14:17 or maybe convert to a BigDecimal and round using a MathContext or something

14:17 frozenlock: any stupid move in this? https://www.refheap.com/paste/13269

14:18 thalassios_xelon: https://github.com/tkaryadis/GrBDDS this is my code in read me the bug

14:20 the bug is in the pformula ns

14:22 pjstadig: frozenlock: if that works for you, then it's fine.

14:23 frozenlock: Well it works, but I'm always interested in any more efficient ways :)

14:24 pjstadig: if you need something like half even rounding or something, then you'd want to go for BigDecimal rounding

14:25 you probably want BigDecimal instead of binary floating points anyway

14:25 unless you really, really know for sure that you want binary floating point numbers

14:25 and even then you probably want BigDecimals

14:26 Glenjamin: frozenlock: why do you need to round to a number of decimal points but still have a floating point / numeric value?

14:27 frozenlock: Glenjamin: trying to make an invoice. $0.123122312 just seemed silly :/

14:28 technomancy: ...!

14:28 pjstadig: frozenlock: yeah you definitely should be using BigDecimals if you're doing currency calculations

14:29 nDuff: thalassios_xelon: doesn't run exactly as in the gist -- GrBDDSo.change-letters is referenced in some of that code, whereas the actual namespace has been renamed.

14:29 frozenlock: technomancy: Dad, did I do something wrong?

14:29 pjstadig: Understood

14:29 technomancy: frozenlock: floats for currency

14:29 pjstadig: http://speleotrove.com/decimal/

14:29 Glenjamin: frozenlock: perhaps also DecimalFormat/Currency classes ?

14:30 technomancy: http://themosthorriblething.com/horribleimgs/d6SAIi.gif

14:30 rcg: frozenlock, i'd keep as much precision as possible and only round on string output?

14:31 nDuff: thalassios_xelon: anyhow, fixing that, it generates a pretty huge function.

14:31 rcg: i.e., when you eventually print the resulting value

14:31 asteve: when you get the really small shit to work, that's when you know you've made progress :)

14:31 Glenjamin: i agree with rcg, you're only throwing away data otherwise

14:32 unless you're dealing with the UK tax system, in which case the tax calculation formula does in fact throw away information at some points

14:32 rcg: (format "%.2f" 1.23456789)

14:33 frozenlock: Glenjamin: French-canadian tax system :P At least we don't tax the taxes anymore...

14:33 Glenjamin: when you do PAYE tax here, you have to round the monthly value to the nearest 10 at some point iirc

14:34 nDuff: thalassios_xelon: ...have a look at https://gist.github.com/charles-dyfis-net/773cfbf2c9d8e3d966cb

14:36 thalassios_xelon: I'd suggest refactoring to not need such large functions as part of your evaluation model.

14:40 frozenlock: pjstadig: Interesting read!

14:40 :tps 0.49950000000000006 ... Ahhhh the trailing 6... must... keep... data

14:45 thalassios_xelon: nDuff, thx :))

14:45 you think the biggg let is the problem right?

14:46 nDuff: thalassios_xelon: Easy to test. Eval that string with and without the huge let.

14:46 thalassios_xelon: how to fix it?

14:48 nDuff: Shoot -- that wasn't even the whole thing

14:48 ...printer was set to elide.

14:50 * nDuff switches from print to prn

14:53 thalassios_xelon: thx nDuff for the time you help me i also learned to find the code that caused the exception bye room:))

14:54 nDuff: thalassios_xelon: FWIW, I'm still working on it.

14:57 thalassios_xelon: ok :)

14:58 nDuff: thalassios_xelon: The easy answer is not to include the huge thing in your eval.

14:58 thalassios_xelon: if you generate a function that takes the huge thing on its argument list, for instance, you're set.

15:00 ppppaul: anyone here benchmark their clojure servers?

15:00 siege or weighttp?

15:01 i'm wondering what types of speed i should expect out of a barebone ring server

15:04 nDuff: ppppaul: ...well, there was the big shootout the other week, which basically put Compojure at 1/3 the speed of the fastest thing benchmarked in any language

15:04 n_b: ppppaul: https://github.com/ptaoussanis/clojure-web-server-benchmarks have you seen this?

15:04 and the shootout http-kit did the other week

15:04 ppppaul: http://http-kit.org/

15:06 * nDuff scowls at the use of seq in the bash driving that benchmark

15:07 thalassios_xelon: internet failed nduff what you said? if you generate a function that takes the huge thing on its argument list, for instance, you're set.

15:07 nDuff: thalassios_xelon: that's what I said, yes.

15:08 txdv: huge thing ... hehe

15:08 thalassios_xelon: :) ok thx very much

15:08 nDuff: thalassios_xelon: there's no reason to eval with that as a literal

15:08 ...when you can pass it around as data.

15:08 * nDuff is actually a little curious as to whether using partial with it would work.

15:08 nDuff: ...I'm expecting that it would.

15:08 ...but do report back.

15:09 thalassios_xelon: i think its easy to fix

15:09 nDuff: (not partial inside the eval, but partially applying the function you get out of the eval)

15:11 naxui: hello

15:11 i have a question

15:12 nDuff: naxui: no need to introduce yourself or wait for volunteers -- it's normal form in IRC to just ask your question straight out.

15:13 hyPiRion: naxui: hi there, just ask whatever you wonder about

15:13 thalassios_xelon: bye room :) thx for help

15:15 jcromartie: is add-watch really *still* alpha?

15:15 it's been there since 1.0

15:17 pjstadig: jcromartie: yes

15:19 hyPiRion: alpha essentially means that its semantics may still be changed in 1.x really

15:19 * gfredericks tries to imagine clojure 4.0

15:21 hyPiRion: gfredericks: I'm assuming that somewhere around 2.5 it will be like Erlang: Only performance improvements

15:22 Or perhaps multiple different versions, one for debugging, a slim version for deploying apps, and a performant one for server stuff

15:26 TimMc: nDuff: Apparently that was too scary an idea.

15:26 gfredericks: hyPiRion: I expect by 4.0 we will have added refinements

15:27 hyPiRion: heh

15:27 gfredericks: and operator overloading

15:27 hiredman: we'll have a sweet pandas like library

15:28 gfredericks: korma will finally get merged into clojure.core

15:28 hiredman: http://vimeo.com/59324550

15:29 gfredericks: clojure 3.0: because it's not clojure-in-clojure until we've built a JVM

15:29 TimMc: In the year 2525^W^W^Wclojure 4.0, protocols will be implemented using monad transformers... and vice versa.

15:29 gideonite: gfredericks: holy macaroni

15:30 gfredericks: (require '[clojure.jvm :as jvm])

15:31 nDuff: gfredericks: ${deity}, I hope not.

15:31 TimMc: Clojure 4.0: Rich Hickey overwrites the universe's operating system with Clojure, says the language is finally complete.

15:31 nDuff: gfredericks: ...unless, by that time, korma has been rewritten to no longer be so macro-centric.

15:32 gfredericks: clojure 5.0: method_missing

15:32 hiredman: https://github.com/lihaoyi/Metascala

15:32 Glenjamin: xeqi: i'll have a look

15:33 xeqi: Glenjamin: thanks, its my plan to get both patches in this evening for a new release

15:33 Glenjamin: xeqi: ah, i think it's to do with timezones when trying to use the asctime format

15:33 which doesn't specify a timezone

15:33 xeqi: ugh, *shiver*

15:33 Glenjamin: i could increase the generated time from 1 hour to 1 day, which would pass the test suite - or just revoke support for the asctime format

15:34 *-1 hour -> -1 day

15:35 xeqi: how were you able to tell its a timezone issue?

15:35 Glenjamin: 1) asctime doesn't specify a timezone, 2) it's to do with times, it's always timezones, 3) i just reproduced - set my tz to EST and it fails, but works on UK time

15:36 software dev in the UK means when stuff defaults to GMT/UTC, it often appears to work - until it suddenly doesn't

15:38 asteve: is gmt ever different from utc?

15:38 Glenjamin: no, but UK is currently on BST, which is GMT+1

15:38 often software written here in winter breaks in spring :)

15:39 xeqi: Glenjamin: I think I'd vote for removing asctime for now and it can get added in another release

15:39 Glenjamin: sounds good, gimme 5 mins

15:39 xeqi: after some more thought

15:39 thanks

15:42 Glenjamin: hrm, going to improve the "can't parse date" message as well - just realised the loop + try..catch approach leaves you with a null pointer if it fails

15:52 ppppaul: thanks nDuff and n_b ... following how http_kit did their benchmarks, i am having trouble replicating his results.... my req/sec max out at 160.... a far cry from the 600 000 (8 core machine, java maxing out all cores during benchmark)

15:59 akhudek: ppppaul: did you do hte linux modifications?

16:02 Glenjamin: xeqi: would you prefer a second commit that removes the asctime support, or squashed into a single commit that never had it?

16:02 xeqi: Glenjamin: feel free to rebase it

16:02 * squash

16:02 ppppaul: akhudek, ulimit is set the same, the ports are set the same

16:03 am i missing a mod other than those two?

16:03 btw, ulimit was tricky to set

16:03 Glenjamin: xeqi: ok, pushed the fix to glenjamin/master

16:04 presumably that means travis is running their boxes in UTC

16:05 xeqi: Glenjamin: I'm kinda surprised I'm not, but I did reinstall recently

16:07 Rich_Morin: dakrone: yt?

16:07 akhudek: ppppaul: I haven't done that test myself, but I would guess that it's an OS limit. There may be something additional you need to do for your machine. Not sure.

16:17 antares_: ppppaul: it may be a good idea to ask the author. Default OS settings definitely are not optimal for 600K connections.

16:18 nDuff: ppppaul: I can reproduce http_kit's results.

16:19 ppppaul: ...for that matter, I actually get much _faster_ HTTP connection times during the ab test

16:20 ToBeReplaced: is this still the preferred way to unroll a map into a funciton that has optional keyword keys?: (apply (fn [& {:keys [foo]}] (inc foo)) (apply concat {:foo 1}))

16:22 xeqi: Glenjamin: thanks again for fixing all that stuff

16:24 number35: hi all

16:24 nDuff: ppppaul: ...well, strike that. I get much better results during the ab test; with his custom client, I'm peaking at 65,000 concurrent connections; looks like I missed an OS limit during setup/configuration.

16:25 number35: i am solving a little bit of 4clojure

16:25 is there anyone who was solving it ?

16:26 antares_: number35: certainly. What is your question?

16:26 aphyr: Hey cemerick, you ever come up with a (case+) which can use enums in AOT code?

16:26 Or is my best bet still (condp =)?

16:27 number35: antares : i am not very experienced but i would like to make first step in (in a lame way) partially solve 73. and learn a little bit

16:27 i am using this

16:27 http://pastebin.com/P8Q2uTGy

16:27 tu

16:27 to

16:27 http://www.4clojure.com/problem/73#prob-title

16:27 get green light for first variant of problem 73

16:27 but i get this

16:28 clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox1145$eval5660$fn

16:28 so obviously i am getting something wrong it takes the whole tic tac toe three vectors

16:28 as one argument and i dont know why

16:28 nDuff: number35: would you consider using a pastebin without the animated advertisements?

16:29 number35: refheap.com is somewhat preferred herebouts, being written in Clojure itself (source available on github).

16:29 number35: of course

16:29 why not

16:30 https://www.refheap.com/paste/e0ef736098821248f3ec45318

16:31 here you have it on refheap

16:33 gilbertw1: number35: I think you need to wrap you arguments in an outer array: [[[a,b,c] [d,e,f] [g,h,i]]]

16:33 nDuff: *nod*.

16:34 asteve: has anyone here worked with the clojure library for dynamodb?

16:34 gilbertw1: number35: It looks like your waiting for 3 arrays instead of a single destructured arrray

16:36 number35: interesting

16:38 gilbertw1: but check this i cannot change that part of the code

16:38 http://www.4clojure.com/problem/73

16:38 nDuff: number35: you can add the extra wrapping [] in your fn call

16:38 number35: that way you're expecting a single list as an argument and destructuring it, instead of expecting three lists.

16:39 gilbertw1: you need to change the argument list in your fn

16:39 your defining and fn that takes three different arrays versus a single array containing three arrays

16:41 nDuff: number35: ...that is: (fn [[[a b c][d e f][g h i]]] ...)

16:42 number35: nice !

16:43 thank you guys

16:51 rwilcox: I've got a newbie question. I'm playing with the clj-time package and trying this code and getting an odd error. I'm dealing with a LocalDate type with both variables so I'm not sure what's up. Anyone have any thoughts? (in-days (interval (today) (local-date (year (today)) 1 1)))

16:51 the error I get: ClassCastException org.joda.time.LocalDate cannot be cast to org.joda.time.ReadableInstant clj-time.core/interval (core.clj:388)

16:51 (I'm trying to get the number of days it's been since the start of the year)

17:00 nm: I switch everything to local-now, instead of local-date and it's now working :)

17:02 Glenjamin: rwilcox: it looks like LocalDateTime isn't a readable instant - probably something to do with lack of timezone information

17:03 LocalDate even, not LocalDateTime

17:03 the joda time API docs probably make it easier to see the relationships

17:03 rwilcox: Glenjamin: hmm, yeah was wondering if it really wanted TZ or time info

17:03 Glenjamin: thank you :)

17:04 Glenjamin: since you're doing the interval, you should just be able to use (now)

17:05 (in-secs (interval (date-time (year (now)) 1 1) (now)) )

17:06 hyPiRion: oh dear, that looks messy

17:06 (-> (now) year (date-time 1 1) (interval (now)) in-secs) is perhaps a bit better

17:07 hiredman: cemerick: https://github.com/clojure/tools.nrepl/blob/master/src/main/clojure/clojure/tools/nrepl/middleware/pr_values.clj#L6 importing the interface under Transport like this is kind of gross, consider using/requiring the protocol instead

17:08 rwilcox: hyPiRion: Interesting. I need to read up on -> … this is kind of the first time I've sat down to write any kind of non-trivial Clojure

17:11 cemerick: hiredman: huh; at some (probably primordial) point in time, reify really needed the interface, not the protocol

17:11 hyPiRion: rwilcox: Ah. Sometimes it eases the readability quite a bit

17:11 choixer: hello everyone, writing my first code in clojure. Could you suggest solutions to parse html? (for example i need to find div with class .author and all links)

17:11 hyPiRion: ,(use '[clojure.walk :only (macroexpand-all)])

17:11 clojurebot: #<SecurityException java.lang.SecurityException: denied>

17:11 hyPiRion: :o

17:11 oh well

17:11 ,(clojure.walk/macroexpand-all '(-> (now) year (date-time 1 1) (interval (now)) in-secs))

17:11 clojurebot: #<ClassNotFoundException java.lang.ClassNotFoundException: clojure.walk>

17:11 hyPiRion: oh hurr

17:12 &(clojure.walk/macroexpand-all '(-> (now) year (date-time 1 1) (interval (now)) in-secs))

17:12 lazybot: ⇒ (in-secs (interval (date-time (year (now)) 1 1) (now)))

17:12 cemerick: hiredman: BTW: http://dev.clojure.org/jira/browse/NREPL-29 I have a fix for that floating around somewhere, will try to push that in over the weekend

17:13 rwilcox: hyPiRion: … the frack… ?

17:13 hyPiRion: I've got a lot of food for thought now

17:13 hyPiRion: rwilcox: Let me check if I can find a good link which explains it

17:14 hiredman: cemerick: ah, this is the thing I was asking about with pr-value?

17:14 hyPiRion: rwilcox: http://blog.fogus.me/2009/09/04/understanding-the-clojure-macro/

17:14 cemerick: hiredman: yup

17:14 hiredman: cool

17:15 rwilcox: hyPiRion: oh cool. OHHH and that macroexpand thing was you telling the bot to unwrap that

17:16 hyPiRion: rwilcox: yeah

17:17 clojure.walk/macroexpand-all is great to check if you understand a macro correctly

17:17 (or if you've made one which expands right)

17:17 hiredman: cemerick: I have actually realized I don't actually need to override pr-value, but I would like to get between pr-value and eval in the stack, which I don't seem to be able to do either

17:17 eval being interruptable eval

17:18 cemerick: hiredman: look at the add-stdin middleware; it slips itself in between something supporting "eval" and the session middleware

17:19 hiredman: yeah, maybe I jsut did this wrong

17:20 cemerick: I'd have no difficulty believing that there's bugs in the middleware dependency jumble. I need to revisit that impl significantly. The 'no deps' policy is a bummer.

17:24 technoma`: cemerick: since when do you live by the rules? =)

17:26 asteve: my ring functions are returning nil and my browser is showing the last route, I'm not sure why

17:28 hiredman: https://gist.github.com/531453 gives you a linearized run list from a graph like {:a #{:b :c} :b #{:c} :c #{}}, where each value is a set of dependencies

17:29 weavejester: asteve: What are you running it with?

17:30 asteve: weavejester: I've built an uberwar by lein ring uberwar and uploaded it to elastic beanstalk

17:31 weavejester: asteve: And it worked locally?

17:31 asteve: no

17:31 deg: gilbertwl: Sorry, I got called away by family right after I posted cljs question. Thanks for your answer.

17:31 asteve: I should also say that I'm testing it locally with lein ring server

17:31 deg: murtaz52: ditto

17:31 gfredericks: Yo-Yo Ma + techno music => technoma

17:32 weavejester: asteve: What functions are returning nil?

17:32 asteve: weavejester: I have a route that's matched and the request is sent to the proper function, the function returns nil

17:32 and the browser is displaying my last route which is not-found

17:33 it makes it difficult to debujg

17:33 weavejester: asteve: So the issue isn't with Ring, it's with the function that returns nil?

17:33 asteve: weavejester: the issue is certainly with the function but I don't understand why ring chooses to show the last route?

17:33 unless my function is really returning a 404 and ring is showing the 404

17:33 weavejester: asteve: Presumably you're using Compojure?

17:34 asteve: weavejester: yes

17:34 weavejester: asteve: Compojure tries routes in order until it finds one that does not return nil.

17:34 asteve: So a route returning nil is the same as one that isn't matched.

17:34 asteve: ah!

17:38 weavejester: actually I think you're the person to ask about rotary; what happens when I request an item with get-item that doesn't exist?

17:38 weavejester: asteve: I can't recall off the top of my head. Probably throws an exception, because that's what the AWS libs tend to do when they can't find something.

17:39 asteve: Best thing to do is to try it and see,

17:39 asteve: my "try it and see" is resulting in unexpected results

17:41 weavejester: asteve: What's the unexpected result?

17:41 asteve: the method returning nil when it should return a result

17:42 I'm checking to see if the item exists and I'm getting nil all the way up the chain

17:45 weavejester: asteve: Let me just check and see what actually happens

17:46 asteve: thanks

17:49 aaelony: Just starting to work with XML, and I am counting first level tags with this: (count (:content (clojure.xml/parse (java.io.File. "myfilename" )))) This tells me that I have 113 child tags below the parent tag. I know that there are 4 types of child tags though. How can I get the counts for each of the 4 types of child tags?

17:49 weavejester: asteve: Looks like it returns nil

17:50 asteve: thanks

17:50 weavejester: Which is surprising, because the AWS libs don't usually do that

17:50 But good, because returning nil for a key that isn't found is idiomatic Clojure.

17:52 cemerick: technoma`: ha. I do, until I have good reason otherwise.

17:52 nREPL has actually had a no-deps rule from the start, long before it was a contrib.

17:54 asteve: bah!

17:54 wrong primary key the entire time

17:54 weavejester: thanks very much

17:54 weavejester: No problem

17:57 Sometimes taking an ugly Java API and turning into a Clojure API can be very theraputic

17:58 dakrone: weavejester++

17:59 hiredman: you should try taking a java project and slow replacing the inside with clojure, it is great

18:00 slowly

18:01 weavejester: I'm currently toying around with jmonkeyengine, which is a 3D game engine for Java

18:02 I had to abuse the :resources-path in Clojure, because the project, despite being quite recent, doesn't use Maven

18:03 And I also had to force Java 1.6 with .leinrc because OpenGL with Java 7 on OSX is missing some bits.

18:03 But aside from that, it's working okay.

18:13 hiredman: /win 12

18:13 rboyd: I just did that 5 minutes ago in another chan

18:31 corecode: so what's the deal with hygienic macros? seems that clojure's macros are hygienic because of the reader?

18:32 lynaghk: bbloom: cemerick solved the mystery yesterday---it turned out to be a compiler bug related to closures. Thanks anyway, though =)

18:32 bbloom: lynaghk: hurray, compiler bugs. fun!

18:32 technoma`: corecode: clojure's macros aren't hygenic, but they don't suffer from the problems that hygenic macros are meant to solve.

18:32 lynaghk: bbloom: yeah, it was subtle as hell (for me, anyway)

18:32 bbloom: deets here: https://gist.github.com/lynaghk/0a8a3dd71cc3c830f507

18:33 jackdanger1: weavejester: could you share a link to the jmonkeyengine project? I'd love to play around with that.

18:33 bbloom: lynaghk: wacky.

18:33 corecode: technoma`: then i don't know what hygienic means

18:33 lynaghk: bbloom: I'm not doing anything to dig deeper though---if you're itching to get into the Clojure compiler internals feel free to investigate and make the world better for the rest of us =)

18:34 bbloom: lynaghk: nah. i got a contract i want to get done so i can get back to interesting stuff :-P

18:35 technoma`: corecode: CL's macro system makes accidental symbol capture bugs really easy to make; hygenic macros and auto-gensym (which clojure does) both make that problem go away

18:35 corecode: technoma`: so hygienic doesn't mean "no accidental symbolic capture"?

18:35 lynaghk: bbloom: yeah, I hear you on that.

18:41 technoma`: corecode: that's an oversimplification

18:41 corecode: yea, i got that much :

18:41 :)

18:44 technoma`: http://www.reddit.com/r/programming/comments/7epv2/rich_hickeys_clojure_talk_at_the_jvm_language/c06gvar

18:51 corecode: oh i wish i could reduce clj to a compact VM+memory allocator

18:51 then i wouldn't have to bother with scheme

18:51 powr-toc: what's the difference between setting :durable false on queue start and :persistent false on publish?

18:52 it seems my queue started with durable false; is 2x quicker when I publish with :persistent false

18:54 oops wrong channel :-)

18:58 asteve: I would like to modify {:up 1 :down 1} to be {:up 2 :down 1}; what function is the best choice?

18:59 I only want to change the key :up

19:05 arrdem: corecode: why not?

19:05 if you throw out JVM compat it should be doable.

19:07 weavejester: jackdanger1: http://jmonkeyengine.com/

19:07 corecode: arrdem: okay

19:08 arrdem: what do you think do i have to do?

19:08 arrdem: i'm looking at picobit, which is a VM in 8KB machine code

19:08 arrdem: but it's scheme, and i'd rather do clojure than scheme

19:09 ivan: &(update-in {:up 1 :down 1} [:up] inc) ; asteve

19:09 lazybot: ⇒ {:down 1, :up 2}

19:09 corecode: JIT is no option tho :/

19:09 ivan: &(assoc {:up 1 :down 1} :up 2)

19:09 lazybot: ⇒ {:down 1, :up 2}

19:09 asteve: why would you use assoc vs. update-in?

19:11 arrdem: the only issue I forsee with doing scheme rather than R5RS

19:11 is the size of the standard library

19:11 asteve: update-in takes a function not a constant as its argument(s)

19:11 sshack: Okay, I have a simple problem. I've got a vector of vectors with keyword/values [[name: "George Smiley" age: 68], [name: "karla" age:56]]. If I have a name, how can I return the entire row?

19:12 corecode: arrdem: what do you mean by that?

19:12 arrdem: corecode: clojure has more standard library symbols than common lisp

19:12 the R5RS standard fits in the index of the common lisp standard

19:13 asteve: ah

19:13 arrdem: while clojure is nice, you can build it atop another lisp once you add synchronization primitives.

19:13 corecode: arrdem: you're saying r5rs < cl < clj, regarding size of stdlib

19:13 locks: hi, I want to use show, but my repl is saying clojure.contrib.repl-utils can not be located

19:13 arrdem: corecode: in absolute terms yes.

19:14 locks: I'm using 1.5.1, did it get moved somewhere else?

19:14 corecode: arrdem: i guess that makes it so appealing.

19:15 arrdem: corecode: yeah when I finally do my lisp vm I intend to do R5RS or R7RS when it comes out just due to library size.

19:16 asteve: arrdem: ivan NullPointerException clojure.lang.Numbers.ops (Numbers.java:942) when doing (update-in data ["up"] inc)

19:16 where data is {"down" "0", "standing" "1", "url" "google.com", "up" "2"}

19:16 arrdem: asteve: read the docs on update-in

19:16 asteve: update-in applies a function to the current value

19:16 and generates a new value therefrom

19:17 which replaces the current value at that key

19:17 assoc straight "sets" the key

19:17 ivan: &(inc "2")

19:17 lazybot: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number

19:18 corecode: arrdem: how is lisp VM and library size connected?

19:19 arrdem: corecode: if you want to be able to invoke a symbol, function or macro it has to come from somewhere

19:19 locks: answered myself, it's clojure.java.javadoc now

19:19 corecode: arrdem: but most of the library is written in scheme/lisp

19:19 arrdem: no?

19:20 arrdem: only a few specials require implementation

19:20 arrdem: corecode: depends. yes as you note what I would call the "elegant" lisps are defined in terms of some very small kernel

19:20 corecode: however Clojure's stdlib uses a looot of java calls

19:21 corecode: so you could absolutely define some primitives and then use a pre-written bootstrap to get r5rs working

19:21 corecode: but that ain't gonna happen with clojure.

19:21 corecode: arrdem: ah.

19:21 hm.

19:22 arrdem: is it mostly sequence/string handling, etc?

19:22 arrdem: corecode: TBH I'm not familiar enough with clojure.core to comment.

19:23 corecode: ok

19:23 arrdem: corecode: you're probably right but I won't confirm or deny.

19:27 * corecode grumbles and moves back hacking something in scheme

19:27 arrdem: corecode: TBH I suggest that you layer clojure over top of scheme

19:28 corecode: add futures and atoms so that you have some synchronization primitives, then with some well placed reader macros you should be able to build clojure in scheme.

19:29 corecode: 'cause the core features you need are namespaced symbols, threads and synchronized access variables

19:29 corecode: yes

19:29 my problem is that picobit has its own compiler written in racket

19:29 arrdem: corecode: then keywords, the vector syntax and the map syntax is just reader sugar

19:29 corecode: and i don't think it implements everything

19:29 i.e. no macros

19:30 technoma`: corecode: what about scheme bugs you in particular?

19:30 corecode: now i have to learn racket to extend this

19:30 technoma`: lack of persistent data structures?

19:30 arrdem: corecode: so this is the one I'm reading atm...

19:30 technoma`: most of the things that drive me nuts about elisp are not flaws that scheme shares

19:30 corecode: technoma`: the bareboneness is confusing

19:30 technoma`: except for the lack of associative data structure literals; ugh

19:30 arrdem: corecode: http://www.stripedgazelle.org/joey/dreamos.html

19:31 technoma`: corecode: so are you coding to the standard instead of against chicken, racket, etc?

19:31 that sounds exhausting =\

19:31 corecode: technoma`: i'm trying to be practical

19:31 technoma`: in the end i want something to run on a microcontroller

19:31 technoma`: seems like fully embracing a specific implementation is the only way to actually get anything done

19:31 arrdem: corecode: check out the implementation of that scheme runtime. it's really cute 'cause it bootstraps r4rs using a small runtime and macros

19:32 corecode: the picobit compiler is also fairly small, i guess. 3k lines of racket

19:33 but my true goal is to investigate state machine-based programming

19:35 muhoo: alex_baranosky: technomancy: is anyone actively working on slamhound these days?

19:37 technoma`: muhoo: alex occasionally pokes at it. it's been working decently enough for my uses that I haven't needed to recently.

19:37 asteve: I would like to bind a function to a variable if the function is not nil; is that not if-let?

19:38 arrdem: asteve: depends on the invocation but potentially.

19:39 muhoo: technoma`: it's kind of driving me crazy that there's no way to have two different ns'es that have the same var in them.

19:40 arrdem: muhoo: it's evil, but you can def a var with the fully qualified name of the other

19:40 muhoo: no i mean the same NAME, but different vars

19:41 technoma`: muhoo: you should only have to fix that once though; IIRC if you've put it in the ns already it should prefer it over another var

19:41 asteve: ,((defn moop [] nil) (if-let [poom (moop)] poom)

19:41 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

19:41 arrdem: muhoo: urgh that's a mess.

19:42 muhoo: example: foo/settings, and bar/settings . both named settings, but different ns'es. if i go into (ns baz), and run slamound, even if i want bar/settings it'll do (:require (foo :as bar))

19:42 even if i *explicitly write* "bar/settings", it'll ignore that, and go require foo as bar

19:43 i'd just blow off slamhound, but it's essential for doing java interop :-(

19:43 Apage43: it is?

19:44 muhoo: yeah, if you have (:import ... ) forms that are like a page long

19:44 Apage43: ah

19:44 I have never really had to import more than a few things in one file

19:44 technoma`: muhoo: oh, if you refer to both of them in the same ns; that case probably isn't handled yet =\

19:44 tieTYT: why isn't there a def- ?

19:45 technoma`: it can handle the existence of two same-named vars but only if they're not refered in the same place; that does suck

19:45 muhoo: technoma`: right. hmm.

19:45 the problem is, to be completely clear, is not that foo/settings is referenced in baz, but that foo/somethingelse is reference in baz

19:46 technoma`: oh; huh... weird

19:46 I definitely haven't put it through heavy usage yet

19:46 muhoo: which seems to cause it to want to pull in that ns. once it does, it seems to go, oh lookee here you have settings in this ns, perhaps this is what you meant

19:47 it's a great codebase. which means i don't understand it well enough to hack on it

19:47 ToBeReplaced: is there a filter-with like (filter-with [1 nil 2] [:a :b :c]) which would return '(:a :c) ?

19:47 muhoo: technoma`: tis ok. i'll just have to be careful just to watch what it does and work around stuff like this.

19:50 technoma`: muhoo: getting a failing test case as a pull request might be a nice start

19:51 muhoo: technoma`: cool, ok will do

20:01 patchwork: Why would > lein clean hang?

20:02 technomancy_: patchwork: windows?

20:02 patchwork: No, osx

20:02 tieTYT: i heard that steve yegge wrote this article about clojure but I can't find it by googling. Anyone have a link?

20:02 technomancy_: patchwork: hm; not sure. it's just rm -rf target

20:03 patchwork: Could it be the checking for plugins in profiles.clj?

20:03 (just thought of that)

20:03 does that get run before every command?

20:03 technomancy_: patchwork: plugins get loaded, yeat

20:03 patchwork: So that is a remote request that could be hanging

20:03 technomancy_: you could try lein -o clean

20:04 patchwork: Yeah that completed immediately!

20:04 thanks!

20:05 quile: I have a commit in develop for your errors

20:06 It should handle localization mismatches correctly now

20:06 let me know

20:06 (even for the case where the join model is not localized but the from and to models are)

20:06 technomancy_: patchwork: wrong channel =\

20:07 patchwork: Ha! Thanks : ) I type in this window so much I didn't even check

20:09 We just had an issue where our client won't allow new clojure projects because its security static analyzer doesn't support clojure : (

20:09 Serious bummer for us

20:10 trying to find a way around using java

20:11 arrdem: clojurebot: ping

20:11 clojurebot: PONG!

20:11 arrdem: good.

20:18 jack_rabbit: How do I pull deps for my leiningen project into the repl?

20:19 technomancy_: jack_rabbit: you mean you changed project.clj and don't want to restart?

20:19 jack_rabbit: No. I'm using nrepl, and they don't seem to be available. At least I can't (require) them.

20:20 technomancy_: you're probably not connected to the repl server you think you are

20:20 jack_rabbit: Oh wait.

20:20 It was.

20:20 Syntax syntax syntax. Forgot to quote the package, since you don't quote it when calling ns.

20:39 combataircraft_: Is there anybody interested in doing functional programming in JavaScript ecosystem?

20:39 gfredericks: If we could do that bit over (ns vs require) how would we do it different?

20:42 technomancy_: gfredericks: making require a macro that took symbols for backwards-compat would unify things without requiring a time machine

20:44 if we could go back in time I'd say having (ns myns (require 'some.thingy)) wrap all its regular require function calls in a transactional load would have my vote for sure =)

20:45 hiredman: :(

20:45 require as a function is nice

20:45 making it a macro would not be

20:46 technomancy_: right; you wouldn't be able to map it, etc

20:46 yeah, I can't think of a good way to do it that would be backwards-compatible

20:46 which could be why no one's proposed anything?

20:47 making ns treat all non-keyword clauses as a body might be interesting

20:49 haven't really thought that through

20:52 cemerick: gfredericks: "copy racket" is a decent start, perhaps

20:52 technomancy_: cemerick: what

20:53 my only take-away from the racket keynote was "wow, I'm so glad we don't have to deal with any of that madness"

20:53 though that was more about compilation phases than the syntax I guess

20:54 cemerick: right, you can put whatever sugar you want on top

20:55 many of the pain points around ns and require is that there's stuff underneath that you wish you could affect, but can't

20:55 technomancy_: the fact that it's not extensible for stuff like ns+?

20:57 gfredericks: does racket have eval?

20:57 cemerick: technomancy_: one manifestation, yeah

20:58 gfredericks: stop trolling ;-)

20:58 gfredericks: cemerick: the seeming strict separation between compile-time and runtime makes me wonder

20:58 do they pile the whole racket compiler into every excutable just in case you want to eval something?

20:59 maybe a lightweight interpreted version?

20:59 cemerick: gfredericks: yes

21:00 racket doesn't compile to C or anything

21:00 technomancy_: I think you can tree-shake eval out

21:00 chessguy: ya'all know anything about a startup called runa? does a lot of clojure work

21:02 gfredericks: they sponsored clojure/west last year

21:02 arrdem: technomancy_: really? I suppose that any code generation you could do and then eval could be expressed as a lambda tempate...

21:02 chessguy: gfredericks: i heard they were the first company to put clojure code in production

21:02 technomancy_: arrdem: well, I don't know if racket has it specifically, but I know several schemes do

21:03 gfredericks: chessguy: that would be difficult to verify

21:03 technomancy_: chessguy: not quite

21:03 luc prefontaine was the first to post about it

21:03 chessguy: technomancy_: that name doesn't ring a bell. not a relevancer?

21:04 technomancy_: chessguy: no. he works for a hospital IIRC.

21:04 predated runa by quite a bit; at least six months?

21:04 I think his was January of 09

21:04 chessguy: technomancy_: i see

21:05 technomancy_: maybe i misunderstood

21:05 technomancy_: do you know anything about the runa guys? i'm curious about what kind of reputation they have in the community

21:06 seems like they're doing some pretty serious statistical modeling work

21:07 cemerick: who went to production first vs. who talked first, etc.

21:07 technomancy_: chessguy: we evaluated their clustering library in late 09 and found it to be kinda shaky

21:08 chessguy: gotcha

21:09 technomancy_: you could read Clojure in Action; it was written by their founder

21:09 chessguy: indeed

21:10 i saw his talk from strange loop on zolodeck. it was interesting

21:38 tomoj: in clojurescript, (re-matches #"foo" nil) is []

21:39 I wonder if it should throw an exception or return nil?

21:42 asteve: clojure is a beautiful thing when it works

21:56 mthvedt: ,(re-matches #"foo" nil)

21:56 clojurebot: #<NullPointerException java.lang.NullPointerException>

21:59 gfredericks: (throw (new javascript.lang.NullPointerException))

22:01 kwertii: What's the easiest way to programmatically generate arguments for a function with destructuring {:as opts} that expects to be called like (foo "bar" :baz 1)?

22:02 The best I've got is (apply (partial foo "asdf") [:bar 1]), which isn't very clean looking.

22:03 ivan: clojurebot: mapply?

22:03 clojurebot: You could (defn mapply [f & args] (apply f (apply concat (butlast args) (last args))))

22:04 kwertii: ivan: Nice. Thanks!

22:09 murtaza52: clojureboot: what is mapply doing?

22:09 clojurebot: what is mapply doing?

22:09 clojurebot: It's greek to me.

22:12 murtaza52: A question about ns compilation and loading in jvm - I have a top level function call that I make in one of my ns. If I require than ns in my projects ex.core, then the call gets executed (This is what I want). So is the ex.core file of any project compiled and loaded into the jvm first ? (as I understand all other ns are compiled as needed)

22:18 mmitchell: for learning purposes, i'm trying to wrap with-redefs with my own calling semantics using a macro. I have a function called "add" that I want to redefine, but I'd like to redefine it like this: (my-redef {:f1 add :f2 (constantly 10)}) -- any pointers for making this work?

22:19 I'm having problems with the un-quote splicing into (with-redefs [k1 v1...

22:22 gfredericks: mmitchell: can you paste the code that doesn't work?

22:23 (refheap.com)

22:26 mmitchell: gfredericks: ok, my real code is a little more complicated, but i think you'll get the idea

22:26 gfredericks: ok here you go: https://www.refheap.com/paste/13281

22:27 gfredericks: mmitchell: so lines 13+14 are the intended usage?

22:28 mmitchell: gfredericks: exactly yes

22:28 i tried to use a for, to pull the :fn1 and :fn2 values out for each "mock", but nothing I tried worked

22:30 juxt would work work as well for each map, but expanding into the binding vector that "with-redefs" expects... I just can't figure it out

22:30 gfredericks: mmitchell: so on line 11

22:30 you've got yourself a list of maps

22:30 each with a :fn1 and :fn2 key

22:30 mmitchell: gfredericks: yes

22:30 gfredericks: and you want to turn that list of maps into a flat sequence of alternating fn1s and fn2s

22:31 mmitchell: exactly

22:31 gfredericks: it sounds like you're aware of how to make a sequence of pairs

22:31 which is half the way there

22:31 (you can do this outside the backtick by the way)

22:31 mmitchell: oh really?

22:32 gfredericks: sure

22:32 the arguments are just data, you can play with them like data

22:32 mmitchell: oh right

22:33 gfredericks: backtick just gives you templating and a couple safety mechanisms. it isn't even strictly necessary (as you must know since you didn't even use it in the mock macro)

22:33 mmitchell: ahh right yes

22:34 gfredericks: so a list of pairs can be flattened with (apply concat pairs)

22:34 you could unquote-splice those into the vector, or put them in a vector and unquote the whole vector in without splicing

22:35 at that point backtick is doing very little for you

22:35 and you might find it simpler to say (list* `with-redefs things body)

22:36 mmitchell: ok thinking...

22:41 gfredericks: so i am trying this one out, but my function values are all nil: https://www.refheap.com/paste/13282

22:41 gfredericks: welp that's exactly what I had in mind

22:42 (apply concat (map ...)) is (mapcat ...) btw

22:42 mmitchell: oh cool, good to know

22:42 gfredericks: but why it doesn't work...

22:44 * gfredericks mucks with the repl

22:45 gfredericks: oh golly

22:45 of course

22:47 the argument to with-mocks is not the maps

22:47 it's the call to mock

22:47 mmitchell: oh yes

22:47 gfredericks: with-mocks does not see {:fn1 add :fn2 (constantly 10)} it sees (mock add (constantly 10))

22:48 you could (comp (juxt :fn1 :fn2) macroexpand-1) instead of (juxt :fn1 :fn2)

22:48 but this is getting ugly fast

22:49 so where you actually want to go depends on the nature of your "learning purposes" I suppose

22:50 mmitchell: gfredericks: interesting, well i'm learning already so this is good

22:52 gfredericks: with-redefs-fn is a thing

22:54 mmitchell: gfredericks: actually, maybe "mock" should just be a function?

22:57 gfredericks: it could but if that's the only change you'd have the same problem

22:57 mmitchell: yeah

22:59 gfredericks: so one question is why you need `mock` to exist

23:00 but with-redefs-fn can solve the problem because you don't need the redefinitions map to exist until runtime

23:00 then the macroexpansion order isn't important anymore

23:01 mmitchell: gfredericks: well, my idea is that i would have a map for each "mock". Each map would also contain a :called key, which would be an integer that's incremented each time its called. I could then know whether or not a mock was actually called, and raise an error if it wasn't. Does that make sense?

23:02 oh yeah, i'll checkout with-redefs-fn

23:05 gfredericks: well for that use case you want the map to exist at runtime, sort of. I've done call counts before by adding an atom as metadata on the function

23:07 anyhow I'm heading out; have fun

23:07 mmitchell: gfredericks: cool thanks for your help!

23:08 gfredericks: np

23:51 asteve: I have a map that looks like {"first "this", "second" "that"} I would like to recreate the map such that {"first" "this", "second" "that plus new"}

23:51 update-in?

23:58 arrdem: asteve: if you want your update to be some function of the existing value yes

23:58 asteve: I'd really like to append the new string to the end

23:59 arrdem: ,(update-in {"this" "that"} ["that"] str " and other")

23:59 clojurebot: {"that" " and other", "this" "that"}

23:59 arrdem: ,(update-in {"this" "that"} ["this"] str " and other")

23:59 clojurebot: {"this" "that and other"}

23:59 arrdem: ,(doc update-in)

23:59 clojurebot: "([m [k & ks] f & args]); 'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, and returns a new nested structure. If any levels do not exist, hash-maps will be created."

Logging service provided by n01se.net