#clojure log - Nov 15 2012

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

0:00 yedi: how do you print the current directory? (i swear i googled)

0:00 tryna debug FileNotFound error

0:02 mpan: yedi: the jvm knows and you could query it through interop

0:02 not sure if there's a more idiomatic way, though

0:03 #(System/getProperty "user.dir")

0:03 ,(System/getProperty "user.dir")

0:03 clojurebot: #<SecurityException java.lang.SecurityException: denied>

0:03 mpan: well ok the bot doesn't want me doing it here, but you could do it locally

0:04 in general, a lot of "low-level" stuff can be done directly through interop, and if you use it often, maybe you might want to make yourself a wrapper

0:06 I suppose there are probably other properties of the system they wouldn't want folks querying the bot for

0:08 yedi: sweet, thanks mpan

0:32 when using nrepl on emacs, how can you get the output from eval to print to the repl instead of the 1 line echo area?

0:35 ivan: yedi: when you nrepl-eval-expression-at-point? good question

0:39 yedi: you can get it to output to your source file by hitting C-u first and then undo :/

0:39 might have to write some elisp to do what you want

0:50 Lajjla: ivan, I am the second best programmer in the world, bested only by the microsoft chief software architect.

0:50 And I do worship His Shadow.

1:38 mpan: is it considered good/bad practice to use _ with let to interleave something side-effectful in a series of bindings?

1:39 given a case where something does require the side-effectful call to be done, and the question is just how

1:40 vs nesting lets and dos

1:43 echo-area: mpan: AFACT it is recommended as idiomatic in some Clojure text books

1:43 mpan: ... to use _ with let

1:43 AFICT

1:43 Oh sigh, As far as I can tell

1:47 mpan: echo-area: Thanks!

2:36 can someone help me with a runtime cast error please? note that the cast it's trying to do should be valid according to instance? yet it fails. https://www.refheap.com/paste/6723

2:42 mattmoss: mpan: The "to" class is an array, not a single object.

2:42 mpan: See the [ in front of the long name for TerminationCondition? Array.

2:42 mpan: mattmoss: oh! thank you!

2:43 mattmoss: np

2:43 mpan: actually, bit of further confusion

2:43 the javadoc has the signature defined as a single object w/ an ellipsis

2:44 did java add varargs generally? not just for printf now?

2:44 mattmoss: Yeah, the ellipses is varargs, which is basically an array, I believe.

2:44 I'm not up on my Java standards. :)

2:44 mpan: me neither

2:45 I write to java 5 because that's what college taught me

3:12 BuckTooth: Can you recommend any free books on Clojure for beginners?

3:15 Can anyone recommend any good clojure books for beginners? (I am looking for a free one...)

3:17 Tichodroma: BuckTooth, Programming Clojure

3:17 http://www.clojurebook.com/

3:18 BuckTooth: Tichodroma: My finacial condition dosen't allow me to buy books :(

3:19 Tichodroma: Perhaps http://clojure-doc.org/articles/content.html#tutorials has something

3:21 BuckTooth: There is no Clojure book in the library too....

3:21 SegFaultAX: BuckTooth: That's a pretty shitty financial condition if you can't even buy a book.

3:22 BuckTooth: SefFaultAX: What can I do.... I have to eat or I have to read.. I have to decide :(

3:24 Ill try to buy that anyway....

3:31 Bergle_1: I enjoying the book Programming Clojure by Stuart Halloway and Aaron Bedra - im a nooby :)

4:19 wingy_: Bergle_1: good books are valuable

4:36 alex_baranosky: what's a good way to find the memory size of some Clojure maps?

4:36 clgv: alex_baranosky: on the repl?

4:36 alex_baranosky: that'd be best, but whatever works

4:37 I'm trying to figure ou how much memory my 450,000 maps are taking up

4:37 clgv: alex_baranosky: I think your best chance is using a profiler.

4:38 I'd suggest jvisualvm (free) or yourkit (commercial with trial period)

4:38 alex_baranosky: maybe this: http://stackoverflow.com/questions/52353/in-java-what-is-the-best-way-to-determine-the-size-of-an-object

4:39 clgv: alex_baranosky: you can try that. though they say the size estimate may change on repeated invocations. but maybe it has sufficient quality for your estimation

4:40 alex_baranosky: you could also use java serialization - but that one will replace repeated occurences of the same object with a reference

4:40 Raynes: You can get a license for yourkit if your project is open source.

4:41 clgv: Raynes: yes thats true. although I dont know how much momentum your project needs to get that license

4:41 Raynes: I expect that having enough momentum to need yourkit is probably enough.

4:41 clgv: Raynes: I just bought an academic license which wasnt that expensive

4:43 alex_baranosky: no dice, this is for work

4:43 Raynes: This hotel room thermostat is either lying or I am currently incapable of producing body heat.

4:43 hyPiRion: I hope it is the former, for your sake.

4:44 Raynes: Would it be weird if I wrote some Haskell while here at the conj?

4:44 Feels weird.

4:44 clgv: Raynes: the right tool for the job ;)

4:45 Raynes: Well, it is replacing a Ruby thing I wrote ages ago.

4:45 So it has to be for a good cause.

4:45 It isn't in Clojure because of startup time.

4:45 alex_baranosky: man, this Instrumentation interface is awkward

4:46 hyPiRion: Raynes: I don't think it should be an issue, unless you're oozing betrayal afterwards.

4:46 Raynes: :p

4:47 hyPiRion: I don't think the Clojure community has done any "witch hunt" yet though. Maybe mr. Yegge qualifies for that position.

4:47 (The witch position)

4:47 alex_baranosky: Raynes: yeah I heard they can smell the betrayal on you

4:48 Raynes: That's a group of people armed with parentheses have been standing outside my door for hours now!

4:48 alex_baranosky: the thing is, I think Haskell is sufficiently nerdy to prevent any lynching

4:48 Raynes: That's why*

4:48 clgv: alex_baranosky: yeah that instrumentation is used weiredly.

5:25 maleghast: Morning All :-)

5:26 zephyr: Will the JVM remain the primary clojure platform in the future even after Clojure-in-Clojure is implemented?

5:27 maleghast: zephyr: Someone is trying to make Clojure-in-Clojure, without the JVM?

5:27 Raynes: Clojure in Clojure will still be on the JVM.

5:28 maleghast: Raynes: Yeah, I figured...

5:28 I just wanted to meet the magician that was able to take it out of the equation...

5:28 zephyr: So Clojure is basically a JVM language and will remain so. Good.

5:30 A local guild in Delhi is switching to clojure on a 10 year long mutual contract with the owner of the guild...

5:31 Raynes: I heard the Orcs are using it too.

5:32 zephyr: Orcs?

5:32 maleghast: zephyr: I think that Raynes is having fun with your use of the word "guild"

5:32 zephyr: Oh Eru did not created the orcs.... They are bad :)

5:33 otfrom: hey! Bad things/people use clojure too.

5:33 * otfrom looks shifty

5:33 zephyr: Guild is a local bank of the shopkeeprs of a perticular market....

5:33 Anderkent|away: no discrimination based on alignment please

5:33 zephyr: Elves use Clojure too...

5:33 otfrom: Chaotic Neutral for life

5:34 Anderkent|away: CN is just CE, but afraid of DM

5:34 maleghast: otfrom: O-RLY?

5:34 Anderkent|away: *applause*

5:34 otfrom: Anderkent|away: lol

5:34 maleghast: Clearly, Clojure is the language of Tinker Gnomes (and yes I'm proud of that)?

5:34 otfrom: I think I'm more Whimsical Apathetic

5:35 alignments are too much effort

5:35 * otfrom goes for more coffee

5:35 maleghast: otfrom: "Whimsical Apathetic" - Ah, Harnmaster alignments, no?

5:37 zephyr: Which DE and WM are clojure people mostly using???

5:37 lazybot: zephyr: Oh, absolutely.

5:37 maleghast: zephyr: DE? WM?

5:37 mpan: is there a way to forcefully unload everything in a repl?

5:37 maleghast: mpan: Yeah Ctrl-D

5:38 (sorry)

5:38 mpan: maleghast: I was afraid of that

5:38 Raynes: maleghast: Desktop Environment, Window Manager

5:38 antares_: Raynes: how come you are not sleeping man

5:38 maleghast: Raynes: Ah...

5:38 zephyr: maleghast: Desktop Environment. Window Manager. Add Text Editor too.

5:38 Raynes: antares_: What do you mean?

5:39 antares_: Raynes: I thought you were travelling after a sleepless night

5:39 Raynes: I was.

5:39 antares_: and you are still up?

5:39 maleghast: zephyr: To answer your question, I see a lot of people using OS X, Aqua and emacs - I use a bit of emacs a bit of vim and bit of Textmate at the moment...

5:39 Raynes: I went to sleep at 8PM and woke up at about 3:30AM.

5:39 antares_: ah, ok

5:39 Raynes: Naw, I got some sleep.

5:40 mpan: zephyr: I'm not sure about the relative popularity, but Eclipse+Counterclockwise was recommended to me when I started using Clojure, and there were a bunch of people using that

5:40 maleghast: zephyr: Some of the other regulars at the London Clojure Dojo are Ubuntu aficionados, so certainly emacs / vim for editing, but I suppose that would make them Unity users for Window Management?

5:40 mpan: that's less of a text editor and more of an IDE

5:40 zephyr: mpan: I could not afford a Mac.. I'm OK with Ubuntu, using Xmonad, Emacs.

5:41 mpan: Eclipse is pretty much as heavy as you can get into IDE territory

5:41 I think you meant that for someone else... I don't use a mac either

5:41 zephyr: How's LightTable?

5:41 mpan: they're nice but I'm happy with my pc and have no desire to change for the time being

5:42 maleghast: I have to be honest I rather detest IDEs in general, but I would also want to say that if they work for you (like any tool) then fill your boots! There are a bunch of people that are very pro Netbeans with a plugin whose name I can't remember as well

5:42 mpan: light table is pretty experimental at the moment... I'd be surprised if anyone was using it in production

5:42 maleghast: zephyr: LightTable is not ready yet, but very exciting as a posisbilty

5:42 Raynes: I don't know why not.

5:42 mpan: it's a very interesting and unique concept but the releases so far are previews

5:42 maleghast: s/posisbilty/possibility

5:42 Raynes: The latest iteration of light table is pretty useful.

5:42 It has an editor, can open and save files, an excellent evaluation mechanism, a repl.

5:43 mpan: Raynes: seems it would be such a huge mental adjustment from whatever they were using before, though

5:43 maleghast: Raynes: Yeah, I guess that's true, but I had it freeze-up a couple of times and it didn't feel, well "ready"

5:43 Raynes: Isn't that the point?

5:43 mpan: sure

5:46 mpenet: DE/WM you choose doesn't really matter no matter what language you are using

5:46 Raynes: Yeah, that was a pretty spectacularly weird question.

5:47 * maleghast thinks about it for a moment...

5:47 otfrom: I use emacs on any *nix like environment

5:47 maleghast: Yeah, you're right it's an odd question. I mean even on Windows there are strong toolsets for Clojure, so basically OS / Desktop environment is almost completely irrelevant.

5:48 otfrom: GNU emacs 24.x and as close to vanilla as possible (no aquamacs etc)

5:48 maleghast: otfrom: Bringin' Da Oldskool

5:48 otfrom: but, I've been using emacs for about 15years so I was pre-broken. ;-)

5:48 mpenet: imo emacs is the way to go, if you like IDE'ish envs then go for CCW

5:48 otfrom: eclipse+ccw is very good now

5:48 our intern used it for a bit and got on with it really well

5:48 maleghast: All joking aside I am trying to learn emacs - there's a lot to like, particularly Slime-ing, but after a professional lifetime of Vi/Vim it's a tough learning curve...

5:48 otfrom: light table looks really cool

5:49 Raynes: Ditch SLIME. Use nrepl.el.

5:49 otfrom: the vim support for clojure is getting better all the time

5:49 and Meikel (kotarak) is a *really* nice guy

5:49 maleghast: …I suppose I could just follow Chris's lead (from the Ldn Clj Dojo can't remember his surname) and use vim / nailgun etc...

5:49 otfrom: if you like vim try this: http://clojure-doc.org/articles/tutorials/vim.html

5:50 Raynes: maleghast: I use evil-mode. It is exceptional. I didn't even come to Emacs from Vim. I just used Vim for a while and realized how awesome modal editing in Emacs would be.

5:50 mpenet: maleghast: there is evil-mode

5:50 otfrom: Chris Ford @ctford ?

5:50 mpenet: Raynes beat me to it

5:50 maleghast: That's the chap...

5:50 What is this "evil-mode" that Raynes and mpenet are speaking of..?

5:50 Raynes: $google evil-mode

5:50 lazybot: [EmacsWiki: Evil] http://emacswiki.org/emacs/Evil

5:51 Raynes: maleghast: It's Vim emulation. It adds modal editing to Vim as you'd expect.

5:51 Uh

5:51 To Emacs.

5:51 maleghast: Oh wow - that would be so awesome

5:51 Raynes: Go get you some.

5:52 maleghast: does it add all the keyboard stuff that I know, like "d t ^" and "24 dd" and regular expression search / replace - you know the reasons that I love vi / vim?

5:52 Raynes: Yes.

5:52 As well as colon commands.

5:52 maleghast: OMG - so happy

5:53 I have to go to a meeting now, but this is awesomeness incarnate… I love the internet :-)

5:53 Raynes: In places where functionality overlaps with simple Emacs-native commands it may not implement the Vim way (one example is :! which evil does not implement in favor of Emacs's M-!), but it's pretty thorough.

5:54 maleghast: so cool

5:54 even with that caveat ^^

5:54 Thanks :-)

5:54 Raynes: <3

5:54 edlothiol: Raynes: how does evil interact with things like paredit?

5:55 Raynes: edlothiol: It is modal editing.

5:55 Just like in Vim you have the command mode and the insert mode.

5:55 Insert mode works as you'd expect, as normally as you'd expect.

5:55 edlothiol: so will paredit still work in insert mode, and not interfere in command mode?

5:55 Raynes: It certainly hasn't for me.

5:56 edlothiol: ok, thanks. I should try it out sometime too

5:56 Raynes: Either way, you can escape evil-mode completely by going into straight up completely normal Emacs mode.

5:56 But I've never had to do that.

5:56 It does scream "Wow, there is no way this can work this well." but it really does.

5:56 maleghast: Raynes: Sorry, I can't follow this properly… Does paredit work under evil-mode?

5:56 Raynes: maleghast: Yes.

5:57 maleghast: even more awesome

5:57 I was expecting to have to make a sacrifice there

5:57 Raynes: I was answering his question "not interfere in command mode?"

5:57 maleghast: *nods*

5:57 zephyr: *poof*

5:57 Raynes: o.o

5:59 Anderkent: About evil, do people use it because it's an improvement over vim or because it's an improvement over raw emacs?

6:00 (for clojure specific stuff, don't want to start a religious argument here)

6:00 _ulises_: heh

6:00 mpenet: it's a matter of personal taste

6:00 _ulises_: Anderkent: difficult not to go into a religious war there :)

6:01 Anderkent: what I was really asking is whether, given I'm already comfortable with vim, evil is worth researching for me

6:02 Raynes: I don't carry the opinion that Emacs is better than Vim, but I do think Emacs with evil-mode is an improvement over both Vim and Emacs. But that's for me. Please don't hurt me.

6:02 Anderkent: I was hoping for an example :)

6:03 mpenet: is there an emacs "mode" for vim?

6:03 closing the circle

6:04 Raynes: http://farm4.static.flickr.com/3389/3440941212_5327dc101e.jpg emacs

6:04 Anderkent: I guess just getting rid of vimscript would be an improvement

6:04 Raynes: http://thumbs.dreamstime.com/thumblarge_557/129010382582FY9H.jpg vim

6:04 http://www.yourvibration.com/images/BlueGlowingHand.jpg emacs with evil-mode

6:04 Anderkent: ^ Examples.

6:04 otfrom: Raynes: we won't hurt you just because your wrong and an infidel. ;-)

6:05 * otfrom thinks he might be an emacs bigot

6:05 * otfrom thinks that really people should use whatever they are comfortable with

6:06 Raynes: I just realized I linked to a website called 'yourvibration.com'. I assure you, the picture is completely SFW.

6:10 mpan: I'm probably googling wrong, but what takes a seq of [k v] vectors and creates a map?

6:11 edlothiol: ,(into {} [[1 2] [3 4]])

6:12 mpan: thank you!

6:12 Mr_Bond: what's the bot upto?

6:13 edlothiol: maybe I did it wrong? I don't really know how to use the bots here

6:13 Anderkent: no that should have worked

6:13 &(into {} [[1 2] [3 4]])

6:13 lazybot: ⇒ {1 2, 3 4}

6:13 Anderkent: well, lazybot works :P

6:17 Raynes: $findfn {1 2 3 4} [[1 2] [3 4]]

6:17 lazybot: [clojure.core/list* clojure.core/lazy-cat clojure.core/sequence clojure.core/vec clojure.core/concat clojure.core/seque clojure.core/seq clojure.core/lazy-seq clojure.core/sort]

6:17 Raynes: Did that backwards

6:18 $findfn [[1 2] [3 4]] {1 2 3 4}

6:18 Anderkent: also missed a comma in your map

6:18 Raynes: Commas are whitespace.

6:18 lazybot: []

6:18 Anderkent: right, confused languages.. What was the clojure syntax for a set, anyway?

6:18 Raynes: Oh, I see.

6:18 $findfn [1 2] [3 4] {1 2 3 4}

6:18 There is no function that does that, since into takes an argument in order to do it.

6:18 lazybot: []

6:19 Raynes: Anyways.

6:19 #{1 2 3}

6:19 Anderkent: right, ta

6:40 scottj: Raynes: how are you going to handle the conj with your sleep schedule?

6:40 Raynes: What do you mean?

6:41 My sleep schedule is, as of last night, relatively normal.

6:41 I stayed up for 30 hours and nearly killed myself to solve that problem in one day.

6:41 ;)

6:47 scottj: the conj appears to have a lot of new presenters this year, with a lot of regulars not presenting. and lots of logic talks.

6:47 Raynes: Indeed.

6:47 otfrom: always good to give new people a chance

6:48 scottj: yeah I think it's good

6:49 and I suspect they've been open to outsiders presenting since the beginning but didn't have as many submitters as this year

6:50 Raynes: Yeah, the gap left by me not submitting a talk must have left a huge hole.

6:51 * Raynes files his nails.

6:52 Raynes: It's fortunate that I didn't. I just wouldn't feel right sleeping through my own talk.

6:53 scottj: Raynes: it appears that Rich's talk is going to be at the worst time on your sleep adjustment schedule no?

6:53 Raynes: That's the least of my worries. There is a party tonight.

7:00 lpetit: Raynes: "sleeping through one's own talk" : that was *my* joke ;-)

7:01 Raynes: ambrosebs: Is it okay if I sleep through your talk? scottj is convinced I'll sleep through Rich's talk because of how late it is relevant to how early I woke up and his little I slept over the past two days, so I figure if I nap through someone's talk I should be able to prove him wrong and you smell like a martyr for the greater good.

7:02 ambrosebs: Raynes: will you be front row?

7:02 :D

7:03 Raynes: I'll probably lay behind you during your talk, so as to not bother anyone with my snoring.

7:03 ambrosebs: This sounds helpful.

7:03 Raynes: just read my dissertation and you'll be up to speed, k?

7:04 Raynes: What if I fall asleep while reading it?

7:04 ambrosebs: true

7:04 Raynes: In all seriousness, I slept straight through Chas's talk last year. I felt so horrible.

7:05 But PDF analysis and late nights = zzzzzzzrrrrr

7:05 ambrosebs: I don't want to know which timezone my body clock is in.

7:06 Raynes: I think you and I probably have similar body clocks, despite the distance.

7:06 At home I'd be going to bed right now.

7:07 * Raynes gets a shower.

7:24 pingtimeout: Hi guys

7:25 gfredericks: ,(println "pingtimeout: yo")

7:25 pingtimeout: :)

7:25 gfredericks: lazy bot.

7:26 terom: clojurebot is not here...

7:26 pingtimeout: Oh so it exists ?

7:26 gfredericks: &(println "yeah he can eval code like this")

7:26 lazybot: ⇒ yeah he can eval code like this nil

7:27 pingtimeout: Nice

7:28 Hey, I have a question about defrecords

7:28 milanj: wtf, when I do "load current buffer" (emcas + nrepl) I lost my definitions

7:28 pingtimeout: I'm trying to fool some people by creating a java library written in Clojure

7:28 milanj: I'm in right ns in *repl* and I'm getting "CompilerException java.lang.RuntimeException: Unable to resolve symbol"

7:28 wtf

7:30 pingtimeout: I know how to create a record and aot compile it, but type hints does not seem to be used in the generated constructor

7:30 => Isn't there any mean to create a strongly typed constructor using defrecord ?

7:30 xeqi: milanj: if you kill the file buffer and reopen it does the problem continue?

7:32 milanj: no

7:32 it's ok when I reopen it

7:32 xeqi: did you restart nrepl at some point?

7:32 milanj: sure

7:33 gfredericks: pingtimeout: I am ashamed for not knowing :(

7:33 milanj: first I open core.clj

7:33 C-c C-k that one

7:33 then I have all the stuff in *nrepl* buffer since I'm using it from core.clj

7:33 but after editing something it screw up

7:35 Anderkent: pingtimeout: quoting http://clojure.org/datatypes , 'note that currently a type hint of a non-primitive type will not be used to constrain the field type nor the constructor arg, but will be used to optimize its use in the class methods

7:36 'constraining the field type and constructor arg is planned'

7:37 pingtimeout: Anderkent: Aw, so I guess this would be the same for factory methods ?

7:37 gfredericks: np ;)

7:38 To be more precise, I would like to make a presentation of a super duper java library, and at the end, tell people "Oh btw, there is no single line of Java in this library"

7:38 And immediately take a picture of the audience like "wtf ?"

7:40 But this would be difficult if they see methods taking only Object as parameters

7:45 gfredericks: that would be difficult :(

7:45 you could generate java code and tell them there isn't any hand-written java?

7:46 generate dumb wrappers I mean

7:49 pingtimeout: Hmm

7:49 gfredericks: also there is no non-trivial java at all

7:50 Anderkent: yeah doing gen-(class|interface) for your public API seems like the way to do it, at least until deftype/defrecord can do it for you

7:51 pingtimeout: Anderkent: You mean that with gen-class you can strongly type methods parameters ?

7:51 I mean for non primitive arguments

7:53 gfredericks: pingtimeout: oh I bit you can yeah

7:53 s/bit/bet/

7:53 I knew I was forgetting something

7:54 pingtimeout: So I could create some static (strongly-typed) factory methods using gen-class that would call record constructors

7:54 Have to try that

7:55 Anderkent: you can, though sometimes it gets ugly - for example a method taking a array of strings would be (:gen-class :methods [[doStuffToArray ["[Ljava.lang.String;"] void]])

7:56 gfredericks: easy to make a macro for the special case you're going for

7:59 pingtimeout: Ok so I can do that, but it would be a good idea to say that it was only to show complete compatibility

7:59 gfredericks: sure

7:59 pingtimeout: Like : "Clojure is dynamic, I had to do some dirty stuff to create statically and strongly type entry points, don't do that at home"

7:59 :)

8:00 gfredericks: I had a library once that would take a namespace and gen-class a class with a bunch of static-method entry points to each function in the namespace

8:00 I don't remember if it supported types or not, but presumably it could be modified

8:00 $google lib-2367

8:00 lazybot: [fredericksgary/lib-2367 · GitHub] https://github.com/fredericksgary/lib-2367

8:00 gfredericks: pingtimeout: ^ that there

8:02 lpetit: pingtimeout: https://groups.google.com/forum/?fromgroups=#!topic/clojure/G5syTJHhG1I

8:03 pingtimeout: http://docs.datomic.com/clojure-api.html as well

8:18 mpenet: I am probably wrong but isn't this possible using definterface as well?

8:20 ,(doc definterface)

8:20 &(doc definterface)

8:20 lazybot: ⇒ ------------------------- clojure.core/definterface ([name & sigs]) Macro nil nil

8:20 gfredericks: still have to generate actual methods at some point

8:20 Anderkent: mpenet: he wanted strongly typed constructor signatures

8:21 mpenet: oh constructor, nevermind

8:35 pingtimeout: back

8:35 (sorry, had to attend a meeting)

8:35 lpetit & gfredericks thanks for the links, I'm going to have a look at it

8:46 Anderkent: Anyone figured out a nice way of running both java and clojure tests in maven?

8:52 Guest12230: hello, could anyone show me how to create a partial function in clojure using true? for example (partial true?)

8:52 i can not get it to work

8:52 clgv: lpetit: did you read my question in the repl history search issue?

8:53 bordatoue`: hello

8:53 lpetit: clgv: I may have missed it

8:53 bordatoue`: i am getting confused with partial and curry

8:54 clgv: lpetit: ah good, then you are now reminded to check it when you got time ;)

8:54 alexnixon: bordatoue`: 'partial' is clojure's implementation of currying

8:55 bordatoue`: alexnixon: could you please answer my question <Guest12230> hello, could anyone show me how to create a partial function in

8:55 clojure using true? for example (partial true?)


8:55 lpetit: clgv: In fact, i'll do it right now

8:55 clgv: :)

8:56 xeqi: ,(partial true? false)

8:56 bordatoue`: all i need to do is include a true? within a partial function

8:56 joegallo: ,(let [plus-two (partial + 2)] (plus-two 6))

8:56 xeqi: &(partial true? false)

8:56 lazybot: ⇒ #<core$partial$fn__4070 clojure.core$partial$fn__4070@1721c27>

8:56 joegallo: &(let [plus-two (partial + 2)] (plus-two 6))

8:56 lazybot: ⇒ 8

8:56 bordatoue`: joegallo: how would you add true? to partial

8:57 alexnixon: bordatoue`: I'm not sure what you mean by using true?, what are you trying to achieve?

8:57 bordatoue`: ,(def some-partial (partial true? nil)) (some-partial (= 0 0))

8:57 lpetit: clgv: help, where is it?

8:57 bordatoue`: that isn't working can someone tell me why

8:58 alexnixon: bordatoue`: because true? takes one argument. (partial true? nil) returns a function of 0 arguments that always returns false.

8:58 xeqi: bordatoue`: you don't need to partial true? there. partial is useful for functions that take multiple arguments

8:58 clgv: lpetit: http://code.google.com/p/counterclockwise/issues/detail?id=332

8:59 bordatoue`: is there any way in clojure to examing the no of arguments a fn can take

8:59 xeqi: &(doc true)

8:59 lazybot: java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.Symbol

8:59 xeqi: &(doc true?)

8:59 lazybot: ⇒ ------------------------- clojure.core/true? ([x]) Returns true if x is the value true, false otherwise. nil

8:59 alexnixon: bordatoue`: not in general, but you can try (doc f) or (source f)

9:00 bordatoue`: alexnixon: i thought partial would return a function that can take arguments

9:00 so (partial true? nil) isn't it like saying (partial true?)

9:00 alexnixon: bordatoue`: if your original function takes n arguments, and you pass m arguments to partial, you'll get a function that takes (n - m) arguments

9:01 bordatoue`: in your case, true? takes 1 argument, you passed it 1 additional argument (nil), and so you've ended up with a function that takes 1 - 1 = 0 arguments

9:02 bordatoue`: alexnixon: thanks for the detailed explanation, is nil counted as a valid arg to a fn

9:02 alexnixon: bordatoue`: yes

9:02 nil is a value, like any other

9:03 bordatoue`: so if i use something like this (partial partial true?) will this work then

9:04 lpetit: clgv: I need clarifications

9:04 clgv: lpetit: ok

9:04 alexnixon: I don't understand why you're using partial with true? _at all_, given true? takes 1 argument

9:05 lpetit: clgv: maybe we can continue this on #ccw ?

9:05 bordatoue`: alexnixon: so are you saying that one should not use partial with any fn less than one arg

9:05 alexnixon: ,(doc partial)

9:06 &(doc partial)

9:06 lazybot: ⇒ ------------------------- clojure.core/partial ([f arg1] [f arg1 arg2] [f arg1 arg2 arg3] [f arg1 arg2 arg3 & more]) Takes a function f and fewer than the normal arguments to f, and returns a fn that takes a variable number of additional args. When called,... https://www.refheap.com/paste/6724

9:06 clgv: lpetit: sure

9:08 bordatoue`: thanks alexnixon

9:09 ((curry true?) (= 0 0)) what is the equivalent of this in clojure

9:10 alexnixon: ,(true? (= 0 0))

9:10 &(true? (= 0 0))

9:10 lazybot: ⇒ true

9:10 bordatoue`: (nice )

9:12 what is the difference between a keyword and symbol

9:12 can they be interchanged

9:18 kofno: bordatoue`, here's a stackoverflow that answers that better then I could --> http://stackoverflow.com/questions/1527548/why-does-clojure-have-keywords-in-addition-to-symbols

9:19 bordatoue`: just would that link

9:19 thanks

9:23 nicl: I come from a PHP background and to inspect variables I will usually print them out using var_dump() or some equivalent. What is the suggested way for inspecting variables in Clojure?

9:23 jcromartie: nicl: println

9:24 nicl: jcromartie: thanks

9:24 c-romney: @nicl that depends on the context in which you're building your app. println works, also the repl......

9:24 foodoo: jcromartie: that doesn't work for nested data structures

9:24 jcromartie: but if you want something more like var_dump

9:24 foodoo: what?

9:24 foodoo: how so?

9:24 pingtimeout: pprint is very useful if you are in the repl

9:24 nicl: to be specific, I'd like to inspect the request object in compojure

9:24 jcromartie: yeah, pprint is good

9:24 nicl: request map

9:24 jcromartie: prn is useful too

9:25 pingtimeout: &(pprint {:foo [:bar :baz]})

9:25 lazybot: java.lang.RuntimeException: Unable to resolve symbol: pprint in this context

9:25 pingtimeout: fail

9:25 Anderkent: &(clojure.pprint/pprint {:foo [:bar :baz]})

9:25 lazybot: ⇒ {:foo [:bar :baz]} nil

9:25 jcromartie: foodoo: how does println or prn not work for nested structures? do you mean cycles?

9:25 foodoo: jcromartie: hm. Maybe I just mixed things up. Seems you are right

9:25 jcromartie: you can't appreciate pprint here with clojurebot

9:26 gotta see it in the repl

9:26 pingtimeout: nicl : pprint is like print_r in PHP

9:27 jcromartie: nicl: but let's get back to something like var_dump

9:28 nicl: ok thanks - will try them out/read the docs

9:31 jcromartie: nicl: if you want something that prints out the expression, its value, and the type of the value, then you can use a macro like this

9:32 (defmacro dump [expr] `(let [val# ~expr] (println '~expr (type val#) "->" val#)))

9:32 nicl: jcromartie: nice, thanks!

9:32 jcromartie: user> (let [x 1] (dump x))

9:32 x (class java.lang.Long) -> 1

9:44 Anderkent: eh, so clojure.test.junit is remarkably useless. Anyone know of a nicer wrapper?

9:45 noidi: Anderkent, use midje or expectations

9:45 https://github.com/marick/Midje

9:45 https://github.com/jaycfields/expectations

9:46 Anderkent: well, there's a bug in midje for junit compatible output, but it's been there for 7 months

9:46 noidi: ok

9:46 well, expectations seems to support junit

9:49 Anderkent: it says it does, but it doesn't - the wrapper provided referencens functions that were removed from core expectations... And the 'run this from a junit testcase' approach is really awkward

9:50 I don't want to run stuff in junit, I just want to have junit-like output that I can pipe into mvn surefire-report or jacoco

9:51 noidi: if clojure.test provides the output you need, you can write your tests in Midje, just wrap the facts with (deftest ...)

9:53 at least you could. I don't know if that's still supported.

9:54 Anderkent: yes, which is what I wanted to do, but clojure.test.junit fails to provide useful information (it takes the filename/line number from wrong place on the stack, and doesn't produce output conforming to the schema)

9:54 thus my question whether anyone knows of a better wrapper

9:55 noidi: dammit, I read your first message as "eh, so clojure.test is remarkably useless. Anyone know of a nicer wrapper?"

9:55 sorry :)

9:55 Anderkent: no problem :P

10:26 jcromartie: nicl: BTW if you haven't already improved it, I made a tweak to that "dump" macro

10:26 (defmacro dump [expr] `(let [val# ~expr] (println (pr-str '~expr) (type val#) "->" (pr-str val#))))

10:27 works better with strings

10:27 nicl: jcromartie: ha thanks.I'm a newbie to Clojure, haven't written a macro yet :(

10:27 jcromartie: nicl: they are occasionally useful for things like this, when you want to do something with the actual expressions passed in

10:28 nicl: btw, do you know any good Compojure tutorials/examples. Struggling to find in-depth examples beyond the very basic docs on their githubs

10:37 ivenkys: gents - basic question - i am attempting to understand a basic HOF present here(1 liner) - http://sprunge.us/VAWE - question is , how does Clojure know "f" is the other anon. function ?

10:38 its taken from the Koans

10:39 Wild_Cat: ivenkys: decompose what the line does. First, it creates an anonymous function, (fn [f] (f 5)).

10:40 then, it *calls* that function (see the extra outer paren).

10:40 with an argument that's another anonymous function: (fn [n] (* n n))

10:41 ivenkys: Wild_Cat: yup - i get the result in the repl as 25 - (i added the extra outer paren to call it)

10:42 Anderkent: so the answer is it knows f is the other function because 1. f is the name of the argument to your first function and 2. the argument to this call is the other function

10:42 Wild_Cat: exactly.

10:44 ivenkys: Wild_Cat: Anderkent: 2 is where i have a problem this "(fn[f] (f 5))" is valid on its own - so how does it know to look for the next argument ?

10:45 Wild_Cat: ivenkys: it is valid, as a function definition. Add extra parens and it becomes a call.

10:45 same difference as between foo and (foo arg1)

10:45 Anderkent: ivenkys: it does not look for an extra argument until you call it

10:46 ivenkys: Wild_Cat: Anderkent : Ah - ...

10:47 Wild_Cat: Anderkent : so it says "give me f" and f can be anything really

10:47 Anderkent: yes

10:49 ivenkys: thats beautiful -

10:49 Wild_Cat: Anderkent : gents , thanks a lot - much appreciated

11:00 Wild_Cat: so, I'm trying to figure out two things with Light Table:

11:01 1. how do I disconnect from a project?

11:01 2. how do I set it up so that I have an instarepl that auto-reloads my project's modules whenever I save a file?

11:02 rbxbx: conjconjconj :)

11:02 Wild_Cat: (actually, if I could achieve 2. with a regular lein repl, I'd be happy enough already)

11:14 dgrnbrg: hello clojurians! does anyone know how to get a value that tells you a scroll pane's position using seesaw (or interop)? I am trying to make a live-scrolling display that stops updating when the user moves the scrollbar, and the resumes when they scroll back to the bottom

11:17 maleghast: dgrnbrg: I warn you in advance I am about to be no help at all, but just wanted to say "wow, you're doing something non-web with Clojure *applause* - sincerely meant too.

11:18 ucb: heh

11:21 dgrnbrg: maleghast: I work on tons of clojure CLI and swing applications

11:23 maleghast: dgrnbrg: I don't doubt you, I am just genuinely impressed as the vast majority of stuff I hear about is web or web-api based work. Is there somewhere that I could go to see your work?

11:23 dgrnbrg: it's mostly proprietary internal research tools

11:23 i do have some stuff on github that i've done for fun (also not webapps)

11:23 @dgrnbrg on github

11:24 maleghast: dgrnbrg: Thx I will go look...

11:24 dgrnbrg: spyscope is a tracing tool, guzheng is a code coverage tool, and piplin is a hardware description language

11:24 antares_: maleghast: the majority of Clojure usage I see is in data processing, nothing to do with Web apps

11:25 maleghast: antares_: Fair enough - was not saying "this is so", but pointing out that anecdotally, most of what I see / hear about is web focused if not outright web usage.

11:25 I'd love to learn / hear more about the rest of the Clojure Ecosystem

11:38 I just tend to move in webby circles, as I am a web-focused software engineer - my real area of work / interest is middleware / APIs and infrastructure - but I am interested in other uses for Clojure (and other languages that I use / hack) and that's all I was saying… :-)

12:23 alexnixon: is it just me that finds the syntax of let-> a bit odd? Why doesn't it take a binding form (or at least have the first two arguments swapped around)?

12:26 Anderkent: where's let-> from?

12:26 alexnixon: clojure 1.5 beta

12:27 gfredericks: oh sweet I didn't know that was already around

12:29 alexnixon: yeah it's incredibly useful but feels strange to use

12:31 Anderkent: indeed the order seems wrong for a let, though right for the arrow... (let-> (my-calculation) name (do-to-name))

12:32 gfredericks: it's hard to mash two syntactic concepts together and make it feel like both

12:32 alexnixon: I'd find this more intuitive: (let-> [name (my-calculation)] (do-to- name))

12:32 and also more powerful in that you could add support for destructuring

12:32 Anderkent: perhaps, but a binding form makes it look like (let-> [name 1 othername 2] (do-to-name)) should be ok

12:33 which it is not

12:33 alexnixon: I disagree, see if-let and when-let

12:34 Anderkent: that's one of the things about if-let and when-let that bug you, I'd expect it to either be (if-let x y expr) or take any number of forms and `and` them together

12:34 *bug me

12:35 alexnixon: that may be, but that's that status quo. I'd rather have keep syntax consistent rather than have to remember a bunch of special cases.

12:37 and destructuring in let-> would be really nice

12:37 Anderkent: how do you mean?

12:40 something like (let-> [2 3] [x y] [(inc x) (inc y)])? I think that should work?

12:40 alexnixon: not quite

12:41 Anderkent: i imagine it just expands into (let [name expr name form1 name form2 name form3 ...] name)

12:44 alexnixon: (let-> [[f & r] (list 1 2 3 4)] (do-something r (foo f)))

12:44 (and imagine more forms there)

12:44 Anderkent: assuming (do-something r (foo f)) returns something that can be destructured into [f & r], that should work

12:45 alexnixon: yeah

12:45 Anderkent: (let-> (list 1 2 3 4) [f & r] (do-something r (foo f)) ...)

12:47 alexnixon: that doesn't work

12:47 if it did, then great - we have destructuring. But still, the syntax is weird

12:48 I imagine the macro will be of most use when dealing with state maps, in which case being able to pull out bits of the state in each form would be quite useful

12:50 * gfredericks agrees

12:51 Anderkent: ah, it does'nt work because it expands into (let [[f & r] expr [f & r] f1 [f & r] f2] [f & r])

12:51 alexyk: so, when starting nrepl in emacs with nrepl-jack-in, how do I make sure it uses a given project.clj?

12:51 alexnixon: Anderkent: yep

12:51 Anderkent: so to fix that they'd have to special case the last form

13:00 i.e. `(defmacro let-> [expr name & forms] (let [~name ~expr ~@(interleave (repeat name) (butlast forms)) name# ~(last forms)] name#))

13:00 ` should be before (let, not (defmacro, of course.

13:06 alexyk: hmm: nrepl-jack-in only seems to start in the right directory when you give it a prefix. By default it just starts somewhere… not in the current file's directory, apparently

13:24 yedi: is there a requests (python) equivalent for clojure?

13:25 Anderkent: clj-http

13:39 yedi: cool, thanks Anderkent

13:39 alexnixon: Anderkent: I've sent a message about let-> to the wider audience on the clojure mailing list, if you're interested in following the discussion

13:41 zodiak: stupid question, in the repl, how do I find out which version of the jar is require'd ? I mean, I have 4 versions of a jar, and unless they export a 'version' .. how do I know which one ?

13:42 clojure-newb: hey guys… just trying out : https://github.com/vaughnd/clojure-example-logback-integration, but getting 'No such namespace: logimpl', any ideas ?

13:42 seems logging is complicated at least for me

13:46 TimMc: (let [& 0] (let-> [1 2 3] [f & r] [r & f])) ;; => [(2 3) 0 (0 1)]

13:46 whee macros

13:46 zodiak: clojure-newb, never used it, but it appears you have to setup project.clj etc

13:47 personally, I would start off with tools.logging but.. that's using log4j so.. maybe 'eeww' ?

13:47 TimMc: timbre is a nice logger

13:47 zodiak: TimMc, is that the new one I read about a few days back on clojure.in ?

13:47 clojure-newb: is timbre good with clojure 1.4 ?

13:47 TimMc: No faffing around with log4j.properties files.

13:47 zodiak: ah yes.. yes it is :)

13:48 wink: whoever invented log4j.properties should be stripped off his keyboard and net access

13:48 TimMc: wink: I'm sure it seemed like a good idea at the time.

13:48 clojure-newb: I'll give it a go thx guys

13:48 wink: I've gotten programs in a new language faster running than logged my first line with log4j

13:48 that is *not* an exaggeration

13:48 clojure-newb: haha

13:49 I usually find I'd rather go outside and lick the road than set log4j up

13:49 TimMc: wink: People overestimate the difficulty of learning languages and underestimate the difficulty of learning libraries.

13:49 This is probably because they only know one language.

13:50 wink: TimMc: to use a library in a sane manner, to use it to its full potential, but a simple "I was told to use this, and I relaly just want it to log anywhere, I don't care where, give me a (sane) default"

13:50 zodiak: to paraphrase an old unix saying; log4j is user friendly, it's jst picky about who it's friends are

13:50 TimMc: heh

13:50 wink: I don't think that's unreasonable to have it work with defaults

13:51 TimMc: wink: Not unreasonable, no. But the reality is that a number of libs impose weird, hidden constraints.

13:51 s/hidden/non-obvious/

13:52 wink: yes, but I'd even prefer prepending "WARNING: CONFIGURE ME" and still have it work out of the box

13:52 TimMc: clojure-newb: Here's how I set up a different output for timbre in one of my projects: https://github.com/timmc/kpawebgen/blob/910701afb533c852630d3954c16a5c6c837168ad/clj/src/kpawebgen/core.clj

13:52 wink: I can't see how logging can be a destructive behavior

13:53 zodiak: heisenburg problems ;)

13:53 the act of logging/looking causes the problem to disappear. remove the logging/print statements and it works

13:53 welcome to C debugging ;)

13:54 clojure-newb: TimMc: thanks, I'll take a look once I get the out the box sample working

13:55 yuck… all logging being swallowed somehow

13:55 wondering if its because my other deps include logging libraries

13:55 TimMc: (timbre/set-config! [:appenders :standard-out :min-level] :debug)

13:55 zodiak: clojure-newb, yeah.. you only ~really~ want 1 logging lib ;)

13:55 TimMc: ^ the only config you really need

13:56 brainproxy: i've implemented a custom deref for one of my deftypes, but this is causing problems with the tostring/printing methods that come stock w/ deftype; anyone got an example of how I can properly implement those things so I can get something nice in the REPL for instances of my type?

13:59 zodiak: so, without a def version, is there anyway to check a library version that's been req'd ?

14:00 TimMc: zodiak: I suppose you could check the classpath.

14:01 zodiak: TimMc, yeah.. I mean.. I could hack around and do some funky introspection nonsense.. or jst fork the lib and stick in the def

14:01 I am leaning towards #2 ;)

14:01 ta though.. kinda what I was figuring/fearing

14:02 clojure-newb: ok, liking timbre, thx guys

14:02 no config and I have logging, result

14:02 TimMc: ,(.getResource (class reduce) "/clojure/core$reduce.class")

14:03 ;; => #<URL jar:file:/home/timmc/tmp/clj/lib/clojure-1.3.0.jar!/clojure/core$reduce.class>

14:03 Oh, purely programmatically? Yeah, don't peek at the classpath. :-P

14:40 zodiak: TimMc, yeah.. I jst forked the solr libs, fixed it up a bit, and put in the def for version

14:44 scottj: for anyone not at the Conj you can enjoy this just uploaded StrangeLoop talk on ClojureScript by David Nolen http://www.infoq.com/presentations/ClojureScript-Optimizations

14:45 rbxbx: Has anyone flirted with having this channel follow the #clojure hashtag on twitter? Pros/Cons?

14:45 It seems like a lot of people reach out on twitter for help more often than popping by here.

14:46 * znDuff is aghast at the thought

14:46 devth: i understand why this doesn't work but is there a way to make it work with quote/unquote? (doc (defn foo "some stuff" [] 1))

14:47 seems not since the doc macro controls when the arg gets eval'd

14:47 and to work it needs to be eval'd before going to doc. i think.

14:48 TimMc: rbxbx: I would be rather unhappy with that.

14:48 If I wanted twits, I'd grab the twatfeed.

14:48 rbxbx: TimMc fair enough.

14:49 TimMc: If the room were lower traffic, I might not mind. As it is, the bots already talk an awful lot.

14:49 rbxbx: It's fairly low volume/low noise, in my experience. But I suppose irc and twitter _are_ different things ;)

14:50 TimMc: Well, maybe I should look at the feed before saying that...

14:50 OK, Twitter apparently doesn't want me to find anything on their site without having an account. Can someone link me the feed for that hashtag?

14:51 scottj: TimMc: https://twitter.com/search/%23clojure

14:51 rbxbx: TimMc https://twitter.com/search?q=%23clojure&src=typd

14:51 TimMc: much obliged

14:51 rbxbx: TimMc bear in mind it will likely be higher volume today due to the conj.

14:51 scottj: or https://twitter.com/search/realtime?q=%23clojure

14:52 TimMc: Looks really noisy.

14:54 rbxbx: TimMc I guess we all have different capacities for noise ;) That said, I imagine you're not the only one here who'd feel the same.

14:57 Frozenlock: Are the EPL and GPL compatible? For example could I use a EPL library for a GPL application?

14:58 TimMc: rbxbx: The main problem is that it's not interactive. It's some random statement of happiness/distress or boost for a blog post or un/successful build notice that drops into the channel, but the originator isn't here to discuss it. Twitter is a broadcast medium; IRC is for conversation.

14:59 ToxicFrog: ^ That. If there were a twitter<->IRC bridge it might be useful, but not when it's one-way.

14:59 rbxbx: TimMc you've convinced me :)

15:00 TimMc and as stated earlier, those that want to tail twitter search are able to do so on an opt-in basis.

15:00 amalloy: Frozenlock: technomancy likes to point out that there's some clause in the EPL intended to provide more openness, but from the GPL's point of view it counts as a restriction, and therefore the two are incompatible

15:00 rbxbx: We've found it useful for my company's channel which had gotten me thinking about it, but the situation is different here.

15:00 ToxicFrog: Frozenlock: the EPL is not compatible: http://www.gnu.org/philosophy/license-list.html#EPL

15:02 Frozenlock: Understood, thank you very much. I suppose I could write the library under the EPL -and- the GPL, then the application under GPL.

15:02 amalloy: if it's your library, you can do whatever you want. write it under GPL and "i give myself a license to do whatever i want"

15:03 TimMc: But is EPL compatible with the WTFPL???

15:03 lazybot: TimMc: How could that be wrong?

15:05 TimMc: amalloy: But a GPL project can link against an EPL project, right?

15:07 amalloy: i'm not a lawyer, mate

15:07 danlarkin: I'm not your mate, guy

15:08 andrewmcveigh: guy, buddy....

15:08 danlarkin: joke ruiner! get him

15:09 andrewmcveigh: It's my favourite joke, friend.

15:10 ToxicFrog: TimMc: don't know. What does the EPL say about linking against it? Does it consider the rest of the program a derivative work?

15:10 TimMc: amalloy: I wasn't going to *trust* you, I just wanted your opinion. :-P

15:10 znDuff: Are you the sole copyright holder of the GPLed work?

15:11 xeqi: http://www.eclipse.org/legal/eplfaq.php#GPLCOMPATIBLE and http://www.gnu.org/licenses/license-list.html

15:13 raek: TimMc: I don't think so.

15:13 you combine two works and the GPL considers the combined work to be a derivative work of the GPL'ed code

15:13 (but the EPL does not)

15:14 TimMc: I'd expect that to result in an asymmetrical situation.

15:14 where GPL could link against EPL but not vice versa

15:23 ...so xeqi's first link confuses me.

15:36 egghead: hey guys, I've got a question about enlive... I was previously using hiccup to swap out a variable in a piece of js via a template tag, is there any way to do this sort of thing in enlive?

15:37 basically `var data = {&var}` then rendering with {:var JSON}

15:48 Kowboy: Hello, from the conj!

15:52 AndR: So light table does not like being ran from a different directory, huh.

15:52 thorwil: egghead: a long time ago i used this: https://gist.github.com/4081164

15:53 egghead: thanks thorwil, I was thinking of just doing something like that

15:53 Netfeed: anyone having problems with tower? i'm getting "Assert failed: (>= (count path) 3)" erros

15:54 thorwil: egghead: np. it was one of the factors that made me drop enlive and use hiccup ;)

15:57 TimMc: egghead: Dropping JSON into HTML is a nasty business no matter how you do it. There's a weird issue with "<".

15:57 amalloy: TimMc: that's what CDATA is for, right?

15:58 TimMc: Maybe?

15:58 egghead: been working well just using hiccup

15:58 Had to bring in enlive for scraping and figured I might as well replace hiccup

15:58 amalloy: <script> <![CDATA[ javascript & stuff with < characters ]]></script>

15:59 TimMc: What happens when you have "]]>" in your data?

15:59 amalloy: well, then you're in trouble :P

15:59 TimMc: >_<

15:59 I wish the damn browser just allowed me to use &lt;.

16:00 Ah well. If wishes were horses, web developers would be trampled.

16:00 thorwil: i think the only good reason for using enlive in templating is if you have someone else writing the templates. if you do it all yourself, hiccup is just much much cheaper

16:01 TimMc: The basic approachof enlive makes me happy.

16:01 AndR: well, enlive also allows you to see the templates without running the app

16:01 thorwil: ok, so 2 good reasons, then :)

16:02 egghead: ya TimMc

16:02 I like having html be just html

16:03 brehaut: TimMc: “Every time you write an HTML templating toolkit that doesn't escape by default, an Estonian bot herder eats a kitten.” ← high five for that quote

16:06 bobbrahms: newb question: code in http://chopapp.com/#7u7ksh29

16:07 In a let make a hashmap, put something in there, define a macro that takes a single parameter, then uses it as a method name to call on the hashmap.

16:07 that works fine.

16:07 next I make a macro that takes a method name and an argument

16:08 that one doesn't seem to work and I'm not sure why.

16:08 TimMc: brehaut: 'strue

16:08 xeqi: bobbrahms: the keys are different

16:08 "asdf" vs "somekey"

16:08 bobbrahms: oh whoops

16:09 getting the same thing though

16:09 still doesn't work for me with "somekey"

16:10 fixed version: http://chopapp.com/#qulzwhsz

16:11 AndR: that pasting tool is really inconvenient, cant copy the core without line numbers

16:11 bobbrahms: which one should I use?

16:11 znDuff: bobbrahms: gist.github.com and refheap are both well-regarded here.

16:12 bobbrahms: https://www.refheap.com/paste/6747

16:12 Frozenlock: It seems clojurescript (javascript) can't use UDP. Could someone confirm this?

16:12 znDuff: Frozenlock: What's your runtime? node.js can do it.

16:15 Frozenlock: Hmm interesting... I would have preferred to use the browser but this might be worth looking into.

16:16 bobbrahms: any macro fiends out there that can tell me what brain dead thing I did wrong in https://www.refheap.com/paste/6747?

16:16 schmir: how do I depend on a private clojure library with leiningen?

16:17 rodnaph: schmir: you mean from your own repository?

16:17 xeqi: schmir: do you have it in a private repository?

16:17 schmir: rodnaph: no, I've just got the .jar file lying around

16:18 rodnaph: oh. umm... you can either just put it in the classpath, or there's a localrepo thing u can google. i'm no pro though... heh

16:19 AndR: bobbrahms: when I try to run your code I get a compiler exception.

16:19 bobbrahms: If I set up x with a def instead of doing it in a let, then define the macro, it seems to work.

16:20 can you see where it's complaining?

16:22 it's weird that when the hashmap is defined in a let, the one macro can see it, but the other one doesn't want to play with it. but the second macro works against the hashmap when def'd

16:23 AndR: for me it fails at the (callmethod size), because it doesnt know what size is. How are you running it?

16:25 bobbrahms: I run lein repl. let me fire up a new one and make sure

16:25 AndR: yeah i think you must have def'ed x somewhere before

16:25 bobbrahms: I'm getting the same as you now. OK.

16:25 so is there a way of referring to the "let"ted one?

16:26 Thanks by the way

16:26 AndR: you have to pass it to your macro

16:26 or just define a function instead :)

16:27 bobbrahms: it's a lot easier to do what I'm doing now if I can just pass in method names like this from a map

16:27 AndR: doing (def x) then (binding [x (new HashMap)] (...))might also work

16:29 bobbrahms: hmm ok.. I'd like to know what the preferred method is.. I thought let seemed right for this. I wonder why in the scope of that let, x is not visible in the macro, but a def-ed one is.

16:30 Urthwhyte: (fn c [a & r] (if r #(a (apply (apply c r) %&)) a)) <- the %& here is the whole argument list, right?

16:32 bobbrahms: AndR: Anyhow, I think I'm un-stuck now. Thanks! anyone else who wants to chime in with a pointer to why the thing doesn't work in a let, I'm all ears

16:32 AndR: %& is the 'rest' arg (i.e #(foo %&) (fn [& rest] (foo rest))

16:32 Urthwhyte: ah, ok

16:35 AndR: bobbrahms: I think (defmacro callmethod [name] `(. x ~'name)) could work instead, as it will prevent your name argument to be expanded into `your.namespace/name`

16:36 but in general I don't think what you're doing is the right approach, and don't understand macros enough to tell you how to do it right

16:38 why not do something like this instead: https://www.refheap.com/paste/6749

16:39 bobbrahms: Ooo I like that

16:39 but there's like 15 methods on the object I really want to use (not a map)

16:40 Youve given me some good ideas to use though. thanks

16:48 alexyk: anyone using nrepl in emacs?

16:48 znDuff: ~anyone

16:48 Eh.

16:48 alexyk: I can't seem to be able to start it with a given project.clj

16:48 znDuff: alexyk: Do you have an actual question, or is this just a poll?

16:49 ...ahh.

16:49 alexyk: the problem is that C-u M-x nrepl-jack-in prompts with a directory and then enter just goers to another reline; it neber finishes

16:50 * znDuff doesn't use nrepl-jack-in at all, but starts "lein nrepl" by hand, and then uses M-x nrepl... but then, that's him.

16:50 znDuff: (actually, I don't use "lein nrepl", because I don't use lein, but that's a separate discussion)

16:50 xeqi: alexyk: what version of lein do you have?

16:50 alexyk: 2.0.0-pre10

16:51 xeqi: are you running it from a buffer in a project?

16:52 alexyk: xeqi: when I want to use a file in a project, I thought it will use project.clj in that project -- but the code seems not to show that!

16:52 brehaut: znDuff: dont use lein‽

16:52 alexyk: project is just a top-level dir supposed to contain project.clj right?

16:52 brehaut: ~guards

16:53 znDuff: clearly it is your lucky day

16:53 alexyk: znDuff: starting lein manually appeals to control freaks

16:53 which I like

16:53 xeqi: alexyk: if you have a file from a project open, then nrepl-jack-in will look for the project.clj

16:53 higher in the directory treee

16:53 alexyk: xeqi -- I thought so, but I wonder where is that in the source

16:53 of nrepl-jack-in

16:54 znDuff: brehaut: I'm in an ant+Ivy shop.

16:54 brehaut: and much of my code is plugins for tools with large, ant-and-Maven build chains.

16:54 alexyk: znDuff: condolences

16:54 brehaut: interesting

16:55 znDuff: is this just historical reasons, or continued choice?

16:55 znDuff: brehaut: Some of each.

16:56 AndR: same, I've been using maven for anything that's not toy-sized

16:56 znDuff: We wouldn't be an Ivy shop if I had a choice

16:56 ...but we wouldn't be a Leiningen shop either; Clojure is only a tiny part of what we do.

16:57 TimMc: lazybot, did you win some kind of Highlander bot fight???

16:57 lazybot: TimMc: How could that be wrong?

16:58 xeqi: alexyk: hmm, I thought it would have been around https://github.com/kingtim/nrepl.el/blob/master/nrepl.el#L1188

17:00 brehaut: maybe clojurebot just had a rough night on the town at the conj last night

17:13 Frozenlo`: Wait what... "Sorry, names based on non-ironic *jure puns are not allowed. If you intend to use this name ironically, please set the LEIN_IRONIC_JURE environment variable and try again." technomancy, that's your doing? -_-


17:14 erewhon: lol

17:14 pjstadig: technomancy has been on record for a long time on that issue

17:14 all the way back to the first Conj

17:15 Chiron_: guys, would you please help me with morphing this code to idiomatic Clojure ? http://pastie.org/5384674

17:16 Frozenlo`: "Project names containing uppercase letters are not recommended and will be rejected by repositories like Clojars and Central. If you're truly unable to use a lowercase name, please set the LEIN_BREAK_CONVENTION environment variable and try again." Wth is happening today??

17:16 lazybot: Frozenlo`: What are you, crazy? Of course not!

17:16 Frozenlo`:

17:17 brehaut: xeqi: just saw lein-pedantic; looks like a great tool

17:17 xeqi: brehaut: thanks! hope it proves useful

17:17 for you

17:19 brehaut: xeqi: it would have caught a bug in my one clj library in the wild that was reported a couple of months back :)

17:25 xeqi: brehaut: out of curiousity, did you find out about it from conj tweets, or stumble on it from somewhere else?

17:26 tufflax: Say I have this code http://pastebin.com/CRXxuxma It is kind of slow. It takes like 2 s to get the 100 000 first primes. Apparently, no reflection is going on. Can one make it faster with type hints or something?

17:26 brehaut: xeqi: prismatic via conj tweets

17:28 _repsac: I'm having a bit of trouble with the clojurescript repl. I have it up and running but how do I reload a namespace?

17:28 pjstadig: tufflax: it would be dangerous to suggest anything without doing some profiling first

17:29 _repsac: I can't seem to get the normal (use ... :reload-all) to work :(

17:33 tufflax: pjstadig, yeah maybe, but this is just toy code, not even mine. I just wanted to know more about optimizing clojure, because I found that especially arithmetic can be surprisingly slow sometimes. I was hoping someone would have some idea of why and how to fix it. I mean, I'm sure someone has done something similar before. :p

17:35 pjstadig: you could add some primitive hints to save some boxing/unboxing

17:35 but i'd guess the sequence processing is killing you

17:36 you might be better off using a loop with primitive hints where clojure (and the JVM) can avoid boxing and inline things

17:36 tufflax: What do you mean exactly by the sequence processing

17:36 pjstadig: but you'll be doing yourself a disservice by jumping in without doing some profiling

17:36 tufflax: Yeah you are probably right

17:37 pjstadig: you can use the built in profiler pretty easily to get a rough idea of the bottlenecks

17:37 every?, take-while, drop, lazy-seq

17:37 are all sequence processing functions that might be too heavy weight for you

17:38 tufflax: Can I get rid of boxing the numbers and still use the sequence functions?

17:38 pjstadig: probably not

17:39 primitives only work for locals and function parameters

17:39 tufflax: ok

17:39 pjstadig: if you put a number into a data structure, it will get boxes

17:39 SegFaultAX: Is there a hash stack implementation laying around that someone can point me to?

17:39 pjstadig: boxed

17:39 tufflax: I see

17:41 pjstadig, the built-in profiler, what is that? You mean the one you can get with the java comman line options?

17:42 pjstadig: yeah

17:42 tufflax: ok

17:42 pjstadig: http://hg.openjdk.java.net/jdk6/jdk6/jdk/raw-file/tip/src/share/demo/jvmti/hprof/manual.html

17:42 tufflax: thank you, gonna see if I can make this faster then :p

17:42 pjstadig: it's crude, but it can work

17:46 tufflax: Does anyone know if one can see videos from clojure conj online somewhere?

17:47 TimMc: tufflax: Wait until maybe July.

17:47 tufflax: :p

17:47 TimMc: unless you mean the last Conj

17:48 tufflax: no, im talking about this conj

17:48 TimMc: I'm serious, it's going to be a long wait.

17:48 tufflax: :(

17:51 alexyk: anybody using clojurescript to test sites?

17:51 doing integration tests

17:52 clicking on elements in a headless browser

18:03 gfredericks: alexyk: I did a small bit of that

18:03 I think I used some jquery simulate library

18:03 well maybe I only ran them in a real browser

18:03 alexyk: gfredericks: phantom.js?

18:03 gfredericks: I'm not real good at getting the headless things to work :/

18:03 alexyk: folks pointed me at htmlunit too

18:03 SegFaultAX: gfredericks: Phantom is pretty cool.

18:04 alexyk: JVM is the ultimate headless thing!

18:07 gfredericks: what are you talking about the JVM is used by web browsers that's what I read on the internet

18:07 it was even in the context of clojure

18:08 TimMc: gfredericks: Did you see my latest abomination with '&?

18:08 gfredericks: TimMc: no

18:08 &(let [&? 2] (+ 3 &?))

18:08 lazybot: ⇒ 5

18:09 gfredericks: "[Clojure] good for writing really complicated web apps that support lots of concurrent users.

18:09 "

18:11 TimMc: &(let [& 0 ampers (memfn assoc & _)] (ampers [1 2 3] 'first 'plac

18:11 lazybot: java.lang.RuntimeException: EOF while reading, starting at line 1

18:11 TimMc: e))crud

18:11 &(let [& 0 ampers (memfn assoc & _)] (ampers [1 2 3] 'first 'place))

18:11 lazybot: ⇒ [(first place) 2 3]

18:11 TimMc: I'm hoping you can improve it.

18:12 gfredericks: &(.assoc [1 2 3] 0 'first 'place)

18:12 lazybot: java.lang.IllegalArgumentException: No matching method found: assoc for class clojure.lang.PersistentVector

18:12 gfredericks: wat is going on here

18:12 &(doc memfn)

18:12 lazybot: ⇒ ------------------------- clojure.core/memfn ([name & args]) Macro Expands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a Java method as a first-class fn. nil

18:13 TimMc: I want it to be more elegantly horrifying.

18:15 gfredericks: I still can't tell what it's doing

18:15 I assume the _ works because let is confused about &

18:15 but what the heck object is .assoc being called on?

18:15 oh wait

18:16 &(.assoc [1 2 3] 'first 'place)

18:16 lazybot: java.lang.IllegalArgumentException: Key must be integer

18:16 gfredericks: &(.assoc [1 2 3] 0 ['first 'place])

18:16 lazybot: ⇒ [[first place] 2 3]

18:16 gfredericks: okay so it's something like that?

18:16 TimMc: Yeah.

18:16 &(macroexpand-1 '(memfn assoc & _))

18:16 lazybot: ⇒ (clojure.core/fn [target__4321__auto__ & _] (. target__4321__auto__ (assoc & _)))

18:17 gfredericks: omg and the & is somehow causing 'first and 'place to be wraped up

18:17 I'm appauled

18:17 Bronsa: woah.

18:17 that's scary

18:18 TimMc: I've been exploring the (not very scary) implications of destructuring's special treatment of the '& symbol.

18:18 gfredericks: okay so this works because fn ignores the fact that & has a local binding

18:18 TimMc: yessir

18:19 AndR: TimMc: that's hilarious :)

18:20 gfredericks: TimMc: I'm sorry I can't fiddle with it tonight; prepping for defending my master's thesis tomorrow morning

18:21 TimMc: Oh! Best of luck and coffee.

18:22 gfredericks: thanks :)

18:24 Apage43: memfn always seemed awkward to me, what with the specifying arg names

18:24 I guess its so you can typehint them

18:26 amalloy: Apage43: also so it knows how many args to use

18:26 Apage43: ah.. right

18:27 amalloy: if rich *really* cared about typehinting in memfn, you could typehint the target object like (memfn ^String indexOf ^String other)

19:00 arohner: is there a version of 'slurp out there that takes a max of N bytes?

19:03 zxtx: hey anyone around know why I might be getting NoClassFound exceptions for some but not all classes in a package

19:04 AndR: TimMc: I don't know why i find (defn suround [& rest] (let [& rest] [rest & rest])) and its 1.5 sibling (defn double-suround[& rest] (let [& rest] (let-> [rest & rest] [rest & rest])))

19:04 bbloom: zxtx: are the classes public? do you have the right CLASSPATH (ie. is it the right version of the package you think it is)?

19:04 AndR: so amusing, but i do

19:04 that first message got sent earlier than I wanted ;P

19:06 zxtx: bbloom, the classes are public

19:06 bbloom: zxtx: when do you get the error?

19:06 zxtx: when I try to import the class

19:07 (import 'com.amazonaws.mturk.service.axis.RequesterService)

19:07 I get NoClassDefFoundError Could not initialize class

19:07 but I can import other classes in mturk just fine

19:07 bbloom: zxtx: does it say which class it couldn't find? are you sure RequesterService can't be found, or maybe some dependency of RequesterService?

19:07 AndR: ah that's different than no class found

19:08 zxtx: bbloom, how can I check?

19:08 AndR: do you have a full stack trace?

19:08 bbloom: zxtx: (.printStackTrace *e)

19:08 (at the repl)

19:09 zxtx: http://cljbin.com/paste/50a58399e4b03f3a580b1dff

19:10 ivan: can I load clojuredocs examples from inside Emacs?

19:11 bbloom: zxtx: hm, not sure

19:12 zxtx: I checked the jar files and the classes are all there

19:12 AndR: zxtx: eh, probably a classpath issue after all

19:13 bbloom: zxtx: my guess isn't classpath, since it's NoClassDefFoundError, not ClassNotFoundException

19:13 zxtx: AndR, but why would some classes work and some not

19:13 bbloom: zxtx: probably a static initializer failing

19:13 zxtx: like (import 'com.amazonaws.mturk.service.axis.RequesterServiceRaw) works

19:13 AndR: try verifying the jar is in the classpath: (clojure.pprint/pprint (seq (.getURLS (java.lang.ClassLoader/getSystemClassLoader))))

19:14 bbloom: zxtx: do you have the source to RequesterService? Does it have any static field initializers, or anything like that?

19:14 zxtx: it does

19:15 bbloom: zxtx: could they be failing?

19:15 AndR: zxtx: http://mturksdk-java.svn.sourceforge.net/viewvc/mturksdk-java/trunk/src/com/amazonaws/mturk/service/axis/RequesterService.java?revision=91&view=markup

19:15 zxtx: AndR, its in there

19:15 bbloom: zxtx: http://stackoverflow.com/questions/1401111/noclassdeffound-exception-could-not-initialize-class-error-help

19:15 AndR: sorry that was ment to go to bbloom

19:16 antoineB: hello, in clojurescript should is use (set! (.-funcName obj) (fn [] ...)) or (aset obj funcName (fn [] ...))

19:16 AndR: zxtx: do you have log4j on classpath?

19:17 bbloom: zxtx: any of those static final arrays might have missign classes, there may be a transitive dependency that you need. or maybe an exception is getting thrown during initialization

19:17 antoineB: depends on your usecase

19:17 antoineB: bbloom: change a function of an object

19:17 AndR: bbloom: I'd rather look at imports - RequesterService uses log4j and sax, any of them might be missing

19:18 antoineB: bbloom: aset seems to not work

19:18 bbloom: AndR: true

19:18 zxtx: I have commons-logging but I don't see log4j

19:18 bbloom: antoineB: aset is an interop form for working with arrays. although javascript objects and arrays both have array-like get/set-prop operations, i generally avoid it for non integral keys

19:19 antoineB: makes your intention clearer

19:19 zxtx: ah, yeah, so some static initializer is probably trying to log something :-)

19:19 AndR: zxtx: just do (import 'org.apache.log4j.Logger), if that fails you need log4j jars

19:20 how did you get the lib? with lein/maven or you just dropped the jar?

19:20 bbloom: antoineB: but your aset didn't work b/c aset is a function, not a macro

19:20 zxtx: that was the issue

19:20 bbloom: antoineB: you need to do (aset obj "funcName" (fn [] …)))

19:20 zxtx: thanks! bbloom AndR

19:20 bbloom: antoineB: note the quoting

19:20 AndR: np

19:20 zxtx: im going to patch the clojar for mturk

19:20 stupid subtle bugs

19:20 antoineB: bbloom: i remmenber, i use aset/aget when the key are string

19:21 bbloom: antoineB: yup, set! is a special form, aset is a function

19:21 antoineB: you need to use aset if you need to perform some kind of higher order operation on a js object

19:22 antoineB: if you need to parameratize a set!, you need to do it with a macro

19:22 zxtx: heh, line 226

19:25 antoineB: bbloom: if i want to use a runtime generated String or Symbol for accessing a property i need aget/aset, or could i use (.- and (set! ??

19:25 lazybot: antoineB: Definitely not.

19:25 AndR: zxtx: so com.amazon:java-aws-mturk didn't have the log4j libs? Or did you use something else?

19:26 that was pretty funny from lazybot

19:26 bbloom: antoineB: you'd need an aget or aset, but you need to be careful b/c there is no guarentee that runtime names will match compile names

19:26 antoineB: especially with advanced compilation

19:26 zxtx: the pom file for the clojars was not properly defined

19:26 bbloom: antoineB: the Google Closure compiler is used, so you need to protect symbols from being munged. generally, you want to avoid doing that sort of metaprogramming at runtime

19:27 antoineB: https://developers.google.com/closure/compiler/docs/api-tutorial3

19:28 antoineB: https://developers.google.com/closure/compiler/docs/api-tutorial3#propnames

19:28 ok

19:29 bbloom: antoineB: so i guess the short answer is: decide if you want a macro or a function, then use set! in macros and aset in functions :-)

19:31 antoineB: bbloom: you suggest i can do some sort of metaprogramming with macros?

19:31 AndR: zxtx: ah I see and the original author did not push it to any public repo, so you had to push it to clojars yourself

19:32 zxtx: yep

19:32 bbloom: antoineB: in javascript land, it's common to do things like foreach(['foo', 'bar'], (function(x) { obj.prototype[x] = …

19:33 antoineB: you aget/aset for this

19:33 bbloom: antoineB: but that doesn't work if the compiler is going to rewrite symbols to save space, so tricks like that are not allowed in Google Closure Advanced Compilation mode

19:33 antoineB: i understand this

19:33 bbloom: antoineB: so instead, you can do that at compile time

19:33 antoineB: how?

19:33 bbloom: antoineB: you write a macro that expands to multiple set! forms

19:34 those set forms will expand to stuff like obj.prototype.foo = instead of the ['foo']

19:34 so that the compiler will know they are safe to rewrite

19:34 and any calls to foo would be rewritten too

19:35 lazybot: ~mail

19:35 ~mail

19:35 $mail fogus himera seems down

19:35 lazybot: Message saved.

19:35 bbloom: heh, ok, good guess :-)

19:36 antoineB: so assuming you macro take a list of symbols and an object and "return" a list of obj[symbol], how do you do that?

19:36 bbloom: antoineB: are you new to clojure too? or just clojurescript? macros take a while to get your head around

19:36 antoineB: and how do you do (for [x (range 1 10)] (aget obj (str "flower" x)) ??

19:36 lazybot: antoineB: What are you, crazy? Of course not!

19:37 antoineB: bbloom: i how not new, the only "static" way to get a value in cljs is by (.- form

19:38 bbloom: antoineB: your macro could expand to `(for [x (range 1 10)] (~(symbol (str ".-flower" x)) ~obj))`

19:39 er sorry

19:39 not that

19:39 `(do ~@(for [x (range 1 10)] `(~(symbol (str ".-flower" x)) ~obj)))`

19:39 more like that

19:40 but that makes no sense with gets heh

19:41 antoineB: bbloom: the thing i want to point out is .- form is problematic for macros

19:41 you need aget/aset

19:41 bbloom: antoineB: but aget/aset will expand to a quoted string

19:41 you can compose symbols:

19:41 antoineB: i know

19:42 bbloom: ,(symbol (str ".-" "foo"))

19:42 &(symbol (str ".-" "foo"))

19:42 lazybot: ⇒ .-foo

19:42 antoineB: ((def obj (js-obj ))

19:42 (.-test obj)

19:42 give nil as expect

19:42 Alkersh: is composing functions primarily for readability?

19:42 antoineB: ((symbol ".-test") obj)

19:43 but this wont work

19:43 bbloom: but what about: `(~(symbol ".-test") ~obj)

19:43 antoineB: same

19:43 jbryant: Using gen-class to generate nested classes. Is this possible?

19:44 bbloom: antoineB: i could swear i've done that successfully....

19:44 antoineB: what is the meaning of ` ?

19:44 bbloom: maybe the macro are run in clojure this may works

19:44 bbloom: antoineB: syntax-quote http://clojure.org/macros

19:44 Alkersh: to tell the machine to not evaluate whatever is after the backquote

19:45 bbloom: Alkersh: no, that's '

19:45 Alkersh: ` does more stuff

19:45 Alkersh: oh

19:45 Apage43: &['(a b vector) '(a b vector)]

19:45 lazybot: ⇒ [(a b vector) (a b vector)]

19:45 Alkersh: am new to it

19:45 Apage43: oh

19:45 Alkersh: and hoping to learn something here

19:45 Apage43: &['(a b vector) `(a b vector)]

19:45 lazybot: ⇒ [(a b vector) (clojure.core/a clojure.core/b clojure.core/vector)]

19:45 Apage43: there

19:46 Alkersh: bbloom

19:46 Urthwhyte: Is there a way to partition a list with a variable size window

19:46 Alkersh: is there a point to composing functions other than for readability?

19:46 because technically you could chain them and they would work the same, wouldn't they?

19:46 Urthwhyte: i.e something like (partition-all (inc (rand-int 2)) col) to get something that would be size 1,2, or 3

19:46 bbloom: Alkersh: composing functions yields a new function

19:47 Apage43: so you can, for example, (map (comp f1 f2) …)

19:47 Alkersh: that i understand

19:47 antoineB: -> macro chain functions

19:47 Alkersh: but it's merely a representation of the functions yo're composing right?

19:47 just trying to clarify if it's for readability

19:47 or has some other purpose

19:48 bbloom: Alkersh: no. composition yields an object. chaining doesn't

19:48 Alkersh: Apage43 shows one usecase

19:48 Alkersh: but couldn't you pass both into another function if necessary?

19:48 bbloom: Alkersh: there are infinite :-)

19:49 Alkersh: you mean with another fn form?

19:50 Alkersh: yes

19:50 bbloom: Alkersh: *shrug* comp lets you omit the argument list

19:50 amalloy: Urthwhyte: i think your best bet is to write it yourself with lazy-seq. shouldn't take more than a couple lines

19:50 Apage43: (comp [f g]) => (fn [& args] (f (apply g args)) ; pretty much

19:51 amalloy: *cough* (comp f g)

19:51 Apage43: agh, right

19:51 Alkersh: in other words, (f1 (comp f2 f3 ..) ...) is the same as calling (f1 (f2 (f3 ..)) ...)?

19:51 bbloom: Alkersh: no

19:51 ,(class (comp inc dec))

19:52 Alkersh: sorry if i'm being a little slow here

19:52 trying to wrap my mind round fp

19:52 bbloom: clojurebot is the one being slow

19:52 Apage43: ((comp f1 f2 f3) x) == (f1 (f2 (f3 x)))

19:52 bbloom: &(class (comp inc dec))

19:52 lazybot: ⇒ clojure.core$comp$fn__4034

19:52 Alkersh: ok

19:52 bbloom: thanks for not being lazy, lazybot

19:52 Urthwhyte: amalloy: I figured as much; just wanted to see if there was a stdlib way before I got my hands dirty. Cheers

19:53 bbloom: Alkersh: play around with comp in the repl

19:53 Alkersh: it will make much more sense if you play with it

19:53 Apage43: &((comp keyword str inc) 3)

19:53 lazybot: ⇒ :4

19:53 Alkersh: &(keyword (str (inc 3)))

19:53 lazybot: ⇒ :4

19:54 Alkersh: =S

19:54 Apage43: however, using it at the front of a form like that is atypical

19:55 Alkersh: readability?

19:55 Apage43: things that return fns are useful for things that you pass functions to, like map, reduce and such

19:56 cgag_: if i want to find the largest string in a collection, is there a better way to do it than (reduce (fn [s1 s2] (if (> (count s1) (count s2)) s1 s2)) coll)?

19:56 bbloom: ,(doc max-key)

19:56 &(doc max-key)

19:56 lazybot: ⇒ ------------------------- clojure.core/max-key ([k x] [k x y] [k x y & more]) Returns the x for which (k x), a number, is greatest. nil

19:57 bbloom: &(max-key count "a" "bc" "foo" "xy" "z")

19:57 lazybot: ⇒ "foo"

19:58 cgag_: exactly what i was looking for, thanks

20:11 Urthwhyte: amalloy: I forgot about 'partition-by

20:12 that was easy ><

20:12 amalloy: but...that doesn't work

20:21 jbryant: Anybody on nested/inner classes with gen-class?

20:23 * gfredericks would not be surprised if it wasn't possible

20:24 * bbloom is confused why you'd ever want to :-)

20:24 jbryant: Hrm… It would be the most natural way to do what I need to do, but I can hack around it.

20:25 I'm generating classes based of Avro schemas, if a record has a nested record, it would be natural to have that type as a nested/inner class since it is not used elsewhere.

20:25 bbloom: jbryant: if you need to do heavy duty java interop & it requires an inner class, maybe it's just easiest to write that bit in java?

20:25 jbryant: Generating classes off of data structures written in clojure.

20:25 Can't write it in Java.

20:28 Apage43: at the end of the day, inner classes are really just sugar aren't they? You just need to shove the $ in the name in the right place I think

20:28 jbryant: Tried it. Doesn't seem to compile. I think it's because gen-and-load-class isn't there.

20:28 just gen-class

20:28 bbloom: Apage43: as far as i know, yeah. there are some oddities around statics, finals, etc

20:30 Apage43: bbloom: yeah, if you have a non-static inner class, instances of it are associated with an instance of the outer class

20:31 sugar around the constructor

20:32 jbryant: then is there any way to create static classes with gen-class or de-sugar the constructor?

20:33 (without a deep dive of hooking into the compiler or anything crazy like that, of course)

21:03 Urthwhyte: amalloy: heh, you're totally right. Misunderstood how partition-by works (again). lazy-seq was the way to go

21:04 This is what I came up with, wondering if it's idiomatic - the doall seemed wrong to me: https://gist.github.com/67ee6569d19030cb2cc4

21:20 Hodapp: what idiomatic ways are there for building up maps in kind of the same way I might build up a list with 'map'?

21:22 right now I have something like (apply assoc {} (mapcat (fn [a] (list key... value...)) (keys othermap))) and I doubt that's optimal

21:22 bbloom: &(into {} (map (range 5) (repeat "value")))

21:22 lazybot: java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn

21:22 bbloom: er i mean:

21:22 &(into {} (map vec (range 5) (repeat "value")))

21:22 lazybot: clojure.lang.ArityException: Wrong number of args (2) passed to: core$vec

21:22 bbloom: &(into {} (map vector (range 5) (repeat "value")))

21:22 lazybot: ⇒ {0 "value", 1 "value", 2 "value", 3 "value", 4 "value"}

21:22 bbloom: *sigh*

21:22 there we go

21:22 heh

21:22 Hodapp: lol

21:23 bbloom: anyway, use into {} and a sequence of two-element vectors

21:23 &(into {} [["key" "value"] ["k" "v"])

21:23 lazybot: java.lang.RuntimeException: Unmatched delimiter: )

21:23 bbloom: &(into {} [["key" "value"] ["k" "v"]])

21:23 lazybot: ⇒ {"key" "value", "k" "v"}

21:24 bbloom: wow i suck at irc repls apparently

21:24 into uses conj to be sorta like the opposite of seq

21:24 &(seq {:x 1 :y 2})

21:24 lazybot: ⇒ ([:y 2] [:x 1])

21:27 bbloom: Hodapp: got it?

21:27 Hodapp: yes! thanks, that's working

21:28 bbloom: It's also pretty common to use a mapping function with destructuring: (fn [[k v]] …)

21:28 to transform keys or maps

21:28 keys or values* rather

21:29 ok, my error rate is apparently 1/3 or so, which means it is time to step away from the keyboard. cya

21:29 Hodapp: what I'm doing is that I have map1 and map2, and map3 gives the functions for composing map1 and map2 (i.e. every key in map3 gives a function which combines the values of map1 and map2 at that same key)

21:29 it's just stuff like scale, rotation, color shifts, where it's little more than * or + as the function

21:30 bbloom: Hodapp: hmm… merge-with maybe?

21:30 Hodapp: e.g. map1 = {:scale 2}, map2 = {:scale 10}, map3 = {:scale *}

21:30 (compose-transform map1 map2) should be {:scale 20}

21:32 this is what the (into {} (map blahblahblah)) is doing now

22:06 ekoontz: hi

22:46 wingy_: is there a way to reload the required files in a ns form

22:47 (ns repl (:require [app.server :as server]))

22:47 where do i use :reload-all

22:49 gfredericks: at the end of it

22:49 (:require [...] :reload-all)

22:56 wingy_: doesn't seem to work on Light Table

22:56 but thx

23:08 timewarrior: hi everyone.. I am new to clojure and from java world.. I am trying to implement write batching, where I collect data for 1 second and then make a request to submit the data

23:08 does anyone know whats the best practice for doing something like this

23:17 rattboi: I'm a little stuck. I'm trying to do something similar to http://blog.darevay.com/2011/06/painting-widgets-with-seesaw/ for drawing things with seesaw.

23:18 it has a draw function, which takes an odd # of arguments, like (draw g obj1 style1 obj2 style2 obj3 style3)

23:18 I have something that is looking at an array and trying to draw a grid, and based on a sequence, it is determining objN and styleN

23:19 http://pastebin.com/7kFipJSJ

23:20 I'm trying to iterate over the array, and based on the value, it determines the color

23:21 I don't know how to use "cond" to return the pair of objN and styleN

23:22 tmciver: rattboi: one issue is that for returns a (lazy) collection; you'd have to 'apply' those args to the draw function.

23:22 rattboi: can you give a small example? I'm really pretty new to clojure

23:22 (apply draw g (for stuff)) ?

23:23 tmciver: rattboi: yes, that's right.

23:25 rattboi: do you see the flatten in my code? Does that make sense to do?

23:26 TimMc: flatten rarely makes sense

23:26 tmciver: ~flatten

23:27 TimMc: clojurebot is dead today, no factoids

23:27 tmciver: :/

23:27 rattboi: I have some ideas to clean it up a bit, just a sec

23:28 TimMc: "flatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with."

23:33 rattboi: http://pastebin.com/hTnrWAQi

23:33 I put more of the work into the let statement

23:34 either with apply or not, I'm getting the error "wrong number of args (2) passed to graphics$draw

23:36 tmciver: rattboi: it looks like the for will return whatever the style function returns. And it looks like [rgb]-style local don't depend on any of the calculations you've done.

23:36 rattboi: the 'grid' inside the let does nothing.

23:37 rattboi: the let returns that value of its last statement.

23:37 rattboi: it looks like you're not using line, value or grid.

23:40 rattboi: I want to return the pair of the rect and style

23:41 area is a list of lists that is height * width

23:41 tmciver: rattboi: ah, you could put 'grid' and the cond inside []

23:42 rattboi: alternatively, you could have the cond return [grid r-style], for example.

23:42 rattboi: when that work is done, won't it look like (draw g [grid r-style] [grid g-style]) etc?

23:42 with the grid/style pair in a vec?

23:42 or am I misunderstanding this?

23:43 I'm going for (draw g grid r-style grid g-style ...)

23:43 tmciver: rattboi: hmm, possibly. I find 'for' to be confusing and don't use it often ;)

23:43 bbloom: rattboi: you want an apply on that draw :-)

23:43 (apply draw g (for ...))

23:43 tmciver: rattboi: I get by with a lot 'map's

23:46 Sgeo: tmciver, even when you have multiple sequences you wish to use?

23:46 bbloom: rattboi: https://www.refheap.com/paste/6764

23:46 rattboi: here's the changes i made

23:47 1) i hoisted the common styles out to an outer let, so that they don't get recreated on every loop

23:47 tmciver: Sgeo: just haven't needed it. I really need to try to use it more, though.

23:47 bbloom: 2) i assigned the for form to the styles value, for clarity, i left out the grid from the styles stuff

23:47 3) i map over each style and convert it into pairs of [grid style]

23:47 rattboi: brb

23:47 sorry

23:48 bbloom: 4) use apply on draw, that will expand the list of arguments

23:53 TimMc: 'for' is awesome

23:54 zodiak: TimMc, it is indeed.. reminds me of python's list comprehensions

23:54 (whether that's good or bad, I leave upto you ;)

23:54 Sgeo: It pretty much is a list comprehension

23:54 zodiak: yup

Logging service provided by n01se.net