#clojure log - Oct 06 2014

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

1:47 jergason: is there a way to specify that I just want the latest version of a dependency in my project.clj file? putting * didn't work

1:50 Kneiva: "I really don't recommend this practice (nor using version ranges) for the sake of build reproducibility. A build that starts to suddenly fail for an unknown reason is way more annoying than updating manually a version number." - Pascal Thivent

1:50 that's from here: http://stackoverflow.com/questions/30571/how-do-i-tell-maven-to-use-the-latest-version-of-a-dependency

1:52 sm0ke: in clojurescript i have an atom a and would like to attach a callback to it when it becomes true, whats the sane way to do that?

1:53 Kneiva: jergason: but if you really want to do it: http://stackoverflow.com/a/5698227/1790621

1:53 jergason: oh, that might be outdated

1:53 jergason: Kneiva: ah, i didn't know it used maven under the hood. i'm pretty new to the jvm

2:54 mercwithamouth: ping

3:04 Guest80083: pong

3:46 mercwithamouth: ok all of a sudden cider-jack-in stopped working. i'm geting a lein execuable isn't on exec-path

3:46 i've never had that issue before...

3:50 daniel___: looking for a clojure way of solving this problem: https://gist.github.com/danielstockton/419abc82332703edc230

3:52 seems tricky to avoid stackoverflow errors

4:00 mercwithamouth: any cider guys here? getting an error when repl starts http://pastie.org/9624243

4:00 more than likely clojure--prettify-symbols-alist should have a single '-'???

4:00 lazybot: mercwithamouth: How could that be wrong?

4:00 snowstalker: mercwithamouth I have no idea what that could be, but can you check if cider-nrepl and cider are both the same version (e.g. 0.7.0)?

4:01 mercwithamouth: yeah..checking now

4:02 hmm cider is 8.0

4:02 not sure when the hell it updated....

4:04 ok going to remove and load the stable

4:26 daniel___: how would people solve this as a 4clojure type challenge? https://gist.github.com/danielstockton/419abc82332703edc230

4:27 mercwithamouth: light table or emacs?

4:28 daniel___: vim

4:29 mercwithamouth: =P i used vim for years

4:33 engblom: Speaking about editors and IDEs: If you were in the situation you got 12x45min to teach an elementary school class basics about Clojure and having no time to teach them an editor at the same time, what would you recommend?

4:35 daniel___: engblom: sublime or something?

4:35 engblom: I looked at nightcode but it does not have rainbow parenthesis by default making it more difficult for the kids. Otherwise it would be perfect for this situation as it has REPL and loading the code to REPL built in.

4:39 magopian: daniel___: dunno how to solve your problem, but i'd love to, so if you find the solution, please share ;)

4:40 given the number of cases to explore (factorial 26 right?), it looks like something NP

4:40 even if you can trivially drop some of the cases to explore, you still have soooo many...

4:41 daniel___: magopian: it is NP, its basically the knapsack problem

4:42 magopian: yeah

4:42 clojurebot: Gabh mo leithscéal?

4:42 daniel___: magopian, i think the idea is to build a tree from all the numbers which has all the less than numbers as children and traverse it, probably some ways to prune it

4:45 borkdude: engblom I think for just one simple workshop this can be great https://github.com/bodil/catnip

4:49 engblom: borkdude: Thanks, I will check it up!

4:49 code2learn: hi, i am start learning clojure

4:49 borkdude: engblom however, you need to install leiningen on their system etc. Intellij + cursive might be a good option too

4:50 code2learn: and want to know anyone knows how to use overtone.at-at

4:51 i am building a simple program to keep polling ebay

4:51 cfleming: engblom: I develop Cursive, if you'd like help with that or you have questions, feel free to ask, either here or on cursive@cursiveclojure.com

4:51 engblom: You should also take a look at Light Table

4:53 code2learn: and let the program notify me whenever a needed item appears on ebay and matches with my price

4:55 engblom: cfleming: When looking at the home page of Cursive, it looks like it will become just a commercial product. Is that the case?

4:55 cfleming: engblom: It will at some point, yes.

4:56 borkdude: cfleming maybe you can release a simple free version with the cool things disabled

4:56 cfleming: borkdude: I'm definitely thinking about this, or maybe even with most of the cool parts but just a license forbidding commercial work.

4:57 borkdude: That would work for both academic + OSS

4:57 borkdude: I guess some people would take advantage of it, but it might be worth it. I'd like as many people as possible to be able to use it.

4:57 borkdude: cfleming intellij uses this model also right

4:57 cfleming e.g. no highlighting for many things in free

4:58 cfleming: borkdude: Right, but you have to apply to them for a free license.

4:58 borkdude: Oh, that's different.

4:58 borkdude: cfleming yeah, when I was a lecturer I used Pycharm etc. for free

4:58 cfleming: borkdude: Community edition is free, right. That does all you want for Java unless you need the enterprise stuff.

4:58 borkdude: But you can get free versions of Ultimate, or right, PyCharm etc, but you have to apply for them.

4:59 borkdude: I don't have bandwidth to administer that so I was considering an honesty model.

5:00 borkdude: cfleming or a trial version for x days

5:00 cfleming: borkdude: Yes, I'll definitely do that either way.

5:01 engblom: Personally I want cross platform solution any kid could install at home. The school is running Debian and most kids have Windows at home.

5:01 If it is too difficult to obtain and install, they will never do it.

5:02 cfleming: engblom: Right, Cursive will work like that. I'm planning (or at least thinking seriously about) a free version for academic use, but I'm busy right now and I haven't finalised the details.

5:02 borkdude: engblom have you also looked at eclipse + counterclockwise, it's entirely open source/free

5:02 cfleming: engblom: If that uncertainty is a problem for you, I think you should check out LightTable.

5:03 borkdude: engblom I have used eclipse + ccw in education

5:03 engblom not kids though

5:05 mercwithamouth: should this be all i need to display my html file with compojure? http://pastie.org/9624332

5:06 cfleming: engblom: Take a look at Cursive and try it out - if you'd like to use it drop me a mail, I'm sure we can work something out.

5:07 engblom: cfleming: So how do I download it?

5:07 borkdude: engblom download the intellij community edition

5:07 engblom and then via the cursive site you'll find instructions how to add the plugin

5:08 cfleming: engblom: There are instructions here: https://cursiveclojure.com/userguide/

5:08 sindu: daniel___: it's a knapsack problem.. if you try to solve it with DP (dynamic programming), you'll need an array of 2x100 000 000 with running time of 26x100 000 000

5:09 cfleming: engblom: But if you're looking for the simplest thing possible, I think Light Table is for you - take a look at both of them and see what you think.

5:09 asQuirreL: amalloy, hey, I don't know if you remember me, but I was the person who asked about the map with unusual shared value properties. I have a solution for it, so I figured I'd show you it as it explains what I wanted better than I could: http://hastebin.com/exuwayutik.clj

5:09 sindu: basically you have 2 nested loops, outer loop is iterating state, inner loop iterates 1..100 000 000, and as you go you update array[i]=true if array[i-state] is true

5:11 the idea is array[i] represents whether it's possible to have a sum of i

5:14 mercwithamouth: sweet..got it =P

5:14 daniel___: sindu, i'd rather try and solve it in a functional way

5:15 my attempt is recursive and consumes all the heap space though https://gist.github.com/danielstockton/043a3d3093e90ba55657

5:51 lgrapenthin: I'm having trouble with using profiles and uberjar in leiningen: lein with-profiles +dev uberjar does not include dev dependencies in the uberjar

5:52 Cr8: tried pruning as I generated permutations, I run out of memory p quick tho

5:53 hellofunk: in Om, what is the scope of a #js :ref? It appears to be known only within the Om component that sets it, is that right?

5:54 Cr8: course if you just want the answer, the search space is actually not that large

5:55 ddellacosta: hellofunk: yeah, it's within the component to the best of my knowledge. Children certainly can't see a parent's ref, which I know because it bit me yesterday when I was splitting a component out from its parent.

5:55 hellofunk: ddellacosta and it also appears that siblings and parents cannot see children's refs

5:56 ddellacosta: hellofunk: in general, if you don't explicitly pass something down it won't be shared, as far as I know.

5:56 Cr8: found in haskell w/ brute force in ~30s

5:58 hellofunk: ddellacosta some some wild photos on cnn from tokyo today

5:59 ddellacosta: hellofunk: oh, the Typhoon? I've avoided going out, although it got sunny halfway through the day, so I did laundry...haha

5:59 hellofunk: nice

5:59 ddellacosta: :-)

5:59 * ddellacosta goes to look at what typhoon insanity others have been experiencing

5:59 hellofunk: ddellacosta are you writing an Om cookbook? or do you have a nice public place with all your collected notes and tips?

6:00 ddellacosta: hellofunk: oh, if you're referring to that repo, I'm just collecting stuff as I see questions come up on the mailing list, and as I think of stuff I don't know how to do yet or which seems like it'd be good to share

6:00 magopian: while you're talking about om and cookbooks and stuff, i'm planning on a "shared discovery" of om with a few others over the internet (google hangout I guess)

6:00 ddellacosta: magopian: neat, sounds cool

6:01 magopian: i've been through the basic tutorial and a few others, any advice on what to try/trial/play with, and what form?

6:01 ddellacosta: dunno if it'll be cool or not, i'm not going to "teach" anything, because i don't know anything, it's just me and maybe two or three others willing to give it a shot, together :)

6:01 (but remotely ;)

6:01 ddellacosta: magopian: still good stuff, learning together like that is great!

6:01 magopian: it's an experiment, we'll see if it's worth it

6:01 annapawlicka: magopian ddellacosta that would be awesome

6:02 magopian: nice if you think it's a good idea ;

6:02 );)

6:02 hellofunk: magopian i think the best way is to just build out a simple app with Om, then all the concepts fall into place. doing something original vs. following a tutorial makes you exercise your knowledge of how to apply the techniques.

6:02 ddellacosta: magopian: as far as advice, I'm biased because I use Om every day for work, and for me working on a big project was really educational, so I would suggest...working on a project.

6:02 or, what hellofunk says ^

6:02 magopian: so any advice on what to do during this session? I think it'll be rather short (maybe an hour? or two?), and I think some of the people won't have previous clojure knowledge at all (I only have a very small knowledge of it myself)

6:02 ddellacosta: and maybe annapawlicka has thoughts too...

6:03 magopian: well, be careful not to get stuck on Clojure stuff

6:03 hellofunk: magopian i also recommend core.async involved as I don't think it is possible to write a really tight Om app without it

6:03 magopian: ddellacosta: yeah, that would be annoying, I have to come up with a dead simple project, and at least have an idea of how to implement it beforehand I guess

6:04 ddellacosta: magopian: if you are working with beginners basic Clojure questions may end up taking over, and Om really uses a fair number of advanced Clojure/CLJS concepts, so may be good to start by going over some basic Clojure stuff.

6:04 magopian: hellofunk: yeah, i'd like to add some of this (i've seen the screencast by swannodette, and it was awesome)

6:04 annapawlicka: all the gotchas usually come up during big projects and i tend to make notes like "don't ever do x", "remember to do x" etc.

6:04 magopian: not just sure how to fit all this in a one (or two?) hour slot

6:04 ddellacosta: magopian: yeah, if you can get the basics of Om across without getting mired in Clojure stuff that'd be great

6:04 oh yeah, annapawlicka had a blog post about that, probably good to pass that around

6:04 hellofunk: magopian honestly i don't think Om is an appropriate topic for those quite new to clojure or clojurescript.

6:05 magopian: hellofunk: ahhh, interesting point of view

6:05 ddellacosta: do you have a link?

6:05 annapawlicka: i shoudl probably write part ii of that post

6:05 ddellacosta: hellofunk: it's a mixed bag, right? I think that it's got a lot of momentum and that may carry beginners over the hump, so to speak

6:05 magopian: ddellacosta: hellofunk: i thought about om because i'm interested in it myself, and because the two others are interested in frontend dev

6:05 hellofunk: ddellacosta: i will say this, using Om helped solidify for me how reification and protocols work, as otherwise i'd have not used them probably ever

6:06 ddellacosta: annapawlicka: yes, you should. ;-)

6:06 magopian: (ember.js and angular, iirc)

6:06 ddellacosta: hellofunk: yeah, for example--those two are big in Om

6:06 magopian: ddellacosta: but then I could use prismatic's om-tools, and don't touch reification at all ;)

6:06 and use a simple enough project to not have to deal with protocols (which i still find pretty hard to grok)

6:07 ddellacosta: magopian: yeah, I dunno, that's reasonable too I suppose

6:08 magopian: I don't think there's a perfect answer but I think regardless of what you do, come up with a specific project to work through and give it to folks beforehand, if possible

6:08 magopian: i need to find a nice and dead simple project, maybe something like a todolist

6:08 annapawlicka: i hear reagent is easier for beginners. but i wouldn't even try to explain wrappers like these to beginners. it'd be easier to just show core.async and how to wire it with events, while building a simple web app

6:08 magopian: or just a counter, or something really really really simple

6:08 ddellacosta: magopian: well then, funny that you mention that, I think there is a good todo list built in Om... ;-)

6:09 magopian: because i'll have to give a short overview of clojure for starters

6:09 ddellacosta: yeah, the todolist mvc by swannodette?

6:09 ddellacosta: magopian: have you taken a look at the examples that David packages w/Om? there is a simple selection thing in there if I recall

6:09 magopian: yeah, that's what I was thinking of

6:09 hellofunk: magopian to really understand Om I think working with it directly is most educational. using other tools to abstract it only gets further from understanding how it works. for example, I like using the #js and (apply dom/div...) techniques, and using (reify...) because it's easier to know what's really happening

6:10 magopian: hellofunk: but then it needs an understanding of the reader macros and reification

6:11 ddellacosta: magopian: here is annapawlicka's post about common Om mistakes, btw: http://annapawlicka.com/common-mistakes-to-avoid-when-creating-an-om-component-part-1/

6:11 hellofunk: magopian -- there is a risk that someone who sees all this for the first time, including Om helper tools, will not know which is Om and which is something else.

6:11 ddellacosta: hellofunk: yeah, kind of hard to avoid that

6:11 I mean, there is a learning curve to all of this

6:11 jonathanj: does anyone here use plugins in vim for editing clojure code?

6:12 hellofunk: a while back there was a comment from Nolen on google cljs group about how closures in cljs are not "free" and take a performance hit. does this mean that (let [f #(something...)] (f...)) is not wise in cljs functions?

6:12 jonathanj: i'm having trouble understanding how paredit is missing a feature that moves down or up a form

6:12 hellofunk: he suggested "breaking out the helpers" so they weren't defined inside another function

6:12 jonathanj: ie. something like f( but less stupid

6:12 hellofunk: jonathanj which ide?

6:13 jonathanj: vim?

6:13 clojurebot: Gesundheit!

6:13 ddellacosta: ah, hahaha

6:13 you snarky clojurebot you

6:13 ,(println "is hiredman still not responding to me?")

6:13 clojurebot: eval service is offline

6:13 ddellacosta: yep

6:14 xcthulhu: hellofunk: What kind of performance hit? You might have to checkout jsperf to get any real sense of anything

6:14 hellofunk: xcthulhu i'm not sure what he was referrign to

6:14 xcthulhu: Spidermonkey and V8 have very different performance profiles for this sort of thing

6:15 jonathanj: it seems insane to me that there's no motion for moving down and up forms

6:15 xcthulhu: % goes to matching paren, usually all I use

6:15 Since it has been a feature of VI since before I was born, I understnad

6:16 jonathanj: that's not usually very useful

6:16 if you're on (defn then % takes you to the end of the function, whereas usually you want to start navigating *in* to the function

6:17 mercwithamouth: not really a clojure question but....postgres or mysql?

6:17 xcthulhu: postgres

6:17 schmir: postgres

6:18 xcthulhu: You can use datomic with postgres as a backend...

6:18 mercwithamouth: i'm making a toy bookmark app...with allows you to attach notes to your bookmarks...as well as create containers with 'like' bookmarks and carry conversations on the given topic with friends

6:18 xcthulhu: heh...i've been debating on trying that...

6:19 xcthulhu: You should give it a shot, it’s awesome

6:19 mercwithamouth: i almost think 'redis' would be really cool for what i want as well...but i really want to get a handle on SQL opposed to continuing to play with all of these new databases...

6:19 xcthulhu: Plus, in memory testing is pretty sweet, but you can do that with h2 as well if you don’t write really funky SQL schemas

6:19 magopian: hellofunk: ah, that's true, about not knowing what is om and what is om-tools

6:20 mercwithamouth: sigh...so datomic...i suppose i could advance the project to some sort of bookmarking/studying tool

6:21 xcthulhu: mercwithamouth: Since it’s a toy app, what do you want to learn exactly?

6:22 Migrations?

6:22 mercwithamouth: really i'm just toying with compojure and eventually 'om'

6:22 i wouldn't mind putting it up publicly in time for my friends and I to use. the idea isn't 'solid' yet though.

6:23 magopian: hellofunk: ddellacosta: annapawlicka: anyway, thanks a lot for your feedback and encouragements, i'll let you know how it went (if I manage to pull it out ;)

6:23 ddellacosta: magopian: good luck! And have fun. :-)

6:23 magopian: 4;3~thanks ;)

6:24 xcthulhu: If you have the bandwidth, I say checkout datomic

6:25 Especially if you want to have your database behave like a graph

6:26 Which sounds vaguely like what you want to do

6:27 hellofunk: ddellacosta: annapawlicka: what are the common sources of js memory leaks you see from using Om/cljs?

6:28 ddellacosta: hellofunk: not sure I've seen Om-specific memory leaks

6:28 annapawlicka: hellofunk: what ddellacosta said

6:29 hellofunk: i wonder if the cljs closures are giving me the leaks i see. have yet to do robust profiling

6:29 ddellacosta: hellofunk: a clojure in and of itself shouldn't cause a memory leak, just depends on how you're using it

6:29 hellofunk: er... *closure

6:33 hellofunk: ddellacosta ok

6:34 amalloy: leaking dom nodes? that happens all the time in js, doesn't it?

6:34 ddellacosta: amalloy: sure, just not sure there is anything specific to Om there

6:34 not that I know of at least. May be.

6:35 amalloy: no, but hellofunk didn't say om-specific, just "when using om"

6:35 ddellacosta: amalloy: okay, fair enough. :-)

6:37 daniel___: amalloy, you like a good problem

6:37 might be one for 4clojure

6:37 https://gist.github.com/danielstockton/043a3d3093e90ba55657

6:37 i havent come up with a solution yet

6:38 amalloy: i actually was just starting on that

6:39 it looks kinda like the knapsack problem, really, but might be tractable at that size

6:44 daniel___: im not really sure how to do it without a brute force type approach, and always run out of heap space

6:47 xcthulhu: Well, so don’t brute force it

6:47 As you go along, picking populations, keep a running sum

6:48 If the running sum gets too big, don’t follow that branch

6:48 amalloy: xcthulhu: that's still pretty brute-force, and the first thing i tried

6:48 you're still in the position of trying to solve the knapsack problem with the greedy algorithm :P

6:50 xcthulhu: You have to do backtrack search, but you don’t keep every path in memory, right?

6:51 Okay, I guess this is what you are doing

6:52 amalloy: xcthulhu: even if memory weren't an issue, 2^26 is a large enough search space that you need more clever pruning

6:52 just removing the most obviously-impossible stuff isn't good enough

6:52 xcthulhu: *grumble* back to depth first forests :(

6:53 Or you could be dumber than that and try annealing?

6:54 Doesn’t seem like an annealing problem

6:54 You should use this as a cruel interview question

6:55 amalloy: daniel___: https://gist.github.com/amalloy/70c58e289de9e892468d is the obvious approach that xcthulhu and i thought of first

6:56 but i think this is basically a special case of a well-known NP-hard problem, so unless you have some reason to believe that this special case has a neat trick to it, i'd guess you can't really do anything

6:56 so, that's all from me and i'm off to bed. let me know if you figure out the trick

6:57 Johannes`: hi, when I run http://pastebin.com/t7wqhBCW in the REPL, the loop form is executed before the dotimes form. why is this?

6:59 daniel___: amalloy_: no, i have no reason to suspect there is a neat trick

7:01 Johannes`: dotimes only runs after (get-number) has returned

7:06 daniel___: i still get a java heap space error with this algo, maybe i need to configure something on the jvm to allow more memory?

7:07 anyway, nn

7:30 noncom|2: i remember recently talking to someone here about dynamically compile and load a java class from leins :java-sources.. and i was told that this is impossible due to jvm limitations, however, i have found some sources that suggest that this is possible.. so what is true of this ?

7:41 perplexa: noncom|2: sounds like real bad application architecture in first place

7:42 noncom|2: perplexa: security and stuff, exceptions and stuff, right.. but that is for a sandbox, so i think that it is acceptable..

7:44 perplexa: i don't see what speaks against having it in your source all the time. maybe have a look at leiningen profiles when you need specific resources only in certain environment

7:44 +s

7:45 noncom|2: perplexa: i want to have a persistant clojure repl running, with possibility to reload classes from their source files..

7:45 i know that sounds creepy

7:45 for many reasons

7:46 but i want to let java-only devs to write plugins to the program too, being able to change them in runtime, without restarting the program

7:46 it is supposed that the users realize all the risks and take the necessary care..

7:47 perplexa: hm i don't know how to do that, sorry

7:47 good luck, tho

7:56 dysfun: it's not trivially solveable for java. you need something like jrebel for that

7:56 or some clever ide integration

8:05 can i make a keyword function part of a protocol?

8:06 it seems like an ugly solution

8:06 no. i can imagine why

8:06 CookedGryphon: noncom|2: it's totally possible to compile and load java classes at runtime, I remember doing it for a uni project once, it just ran javac on command and then did forName with a custom classloader

8:08 dysfun: reload is a little harder

8:15 noncom|2: yeah, well, ok... i imagine i can compile and load a class, but what about recompile and reload ?

8:21 szymanowski: hello, i'm searching a way of overwriting object's method while keeping all others methods as is

8:22 overwriting an object's method

8:22 is it possible with proxy?

8:30 agarman: noncom|2: you can reload by swapping classloaders

8:30 noncom|2: if you load the class through your apps primary classloader, you'll have a hard time reloading

8:35 noncom|2: agarman: so you're saying that i just have to create a custom classloader for every reload operation ?

8:36 agarman: noncom|2: pretty much, if you need to load a class with the same FQ name as an already loaded class, you can only do that inside another classloader

8:37 noncom|2: agarman: thank you, this is a very valuable piece of info !

8:37 agarman: noncom|2: good luck

8:38 noncom|2: https://github.com/zeroturnaround/jf-hw-classloaders may be relevant to what you're wanting to do

8:41 noncom|2: yes, really, that's it

8:41 agarman: noncom|2: ^_^

9:59 grandy___: hello, just working with reagent and secretary, and wondering if there is a recommended way to handle updating window.location after calling secretary/dispatch! to navigate to a different route handler?

10:02 AeroNotix_: https://gist.github.com/AeroNotix/1c669b4af6fedf952e63

10:02 any ideas?

10:07 justin_smith: AeroNotix_: maybe run lein clean and try again?

10:07 weird that it would be trying to include something in the "stale" directory

10:07 AeroNotix_: justin_smith: it's a permissions issue

10:07 It's building in a directory it doesn't have permissions for

10:07 excellent handling of that though

10:09 clgv: AeroNotix_: file an issue for it.

10:10 AeroNotix_: clgv: need to fully understand it first

10:10 necronian: Is there a reason to wrap a function in a empty (let []) like in this start-server function in the rook documentation? http://howardlewisship.com/io.aviso/documentation/rook/dev.html

10:10 AeroNotix_: fuuuuuuuuuuuck and that host just got deleted

10:12 clgv: well I can't debug that now https://github.com/technomancy/leiningen/issues/1724 created an issue for it

10:12 clgv: necronian: usually no. in Clojure's implementation there is a scenario though where (let [] ...) is used instead of (do ...) - I dont remember the exact explanation for that one right now

10:13 AeroNotix_: you should specify that you want a better error message there ;)

10:14 AeroNotix_: clgv: I should hope that's obvious

10:15 clgv: AeroNotix_: well, the point of issues is to be as specific as possible so no implicit knowledge is require to work on it

10:16 necronian: clgv: Thanks, so it's probably just an accident. I was thinking maybe there was some sort of magic happening I didn't understand.

10:16 clgv: AeroNotix_: right now your ticket could be closed with "This exception is expected."

10:17 necronian: yeah, maybe they had some local bindings in an earlier version of those snippet

10:17 AeroNotix_: clgv: clearly the exception should be raised when it couldn't write the file that it later expects it to be there?

10:18 clgv: I'd love to be a neckbeard with you all day but there is other software that I more urgently need to pretend to care about.

10:18 clgv: we'll catch up later.

10:18 clgv: AeroNotix_: just specify what you think is wrong with the behaviour you described or be disappointed if it just sits there unresolved ;)

10:19 AeroNotix_: clgv: I don't have time right

10:36 ben_m: Hey everyone. Is there something like a map with default values for collections that ran out before the longest one? As opposed to map which stops when one collection is done.

10:37 clgv: ben_m: not in clojure.core

10:38 ben_m: Too bad, I'll have to think of another way then :)

10:38 clgv: ben_m: but you can write it yourself pretty easily, just adapt the implementation of `map`

10:39 ben_m: There's likely a better solution, I'm just approaching this weirdly.

10:40 clgv: ben_m: you just need a `some` instead of the `every?` there https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L2631

10:41 ben_m: `or` instead of `and` in the 2/3 arity cases

10:41 ben_m: I have a graph in a triangle shape where the nodes on a row connect to both nodes below it. Trying to write a function that, given two rows, returns all the paths.

10:41 clgv: then you'll get `nil` and just need to insert the default value instead

10:41 ben_m: clgv: Writing that function wouldn't be a problem, I just feel like there's a nicer way of doing what I described.

10:41 But thanks :)

10:41 borkdude: do many people use :pre and :post in clojure functions?

10:41 I haven't used them much

10:42 but maybe I should

10:42 justin_smith: ben_m: sounds like a 4clojure problem I've seen

10:42 clgv: borkdude: I always was not sure if I could turn them off in a production release ;)

10:42 ben_m: justin_smith: Project Euler, that's why I'm intentionally not just stating the full problem :D

10:42 borkdude: clgv and are you sure now?

10:43 justin_smith: ben_m: you can do that kind of combinatorial thing with recursive calls to mapcat

10:43 ben_m: mapcat because each input element can become 0 or more output elements (as opposed to 1:1 with map)

10:44 ben_m: I did it using mapcat and then regrouping using group-by, but that's kind of ugly.

10:44 But I'll spend some more time thinking about this, maybe the data structure I want out of this isn't optimal in the first place.

10:45 justin_smith: I would think there is a mapcat variation without group-by

10:46 ben_m: justin_smith: This is what I'm trying to write currently http://sprunge.us/WNCK

10:48 Better paste http://sprunge.us/XZgU

10:49 Almost there.

10:49 justin_smith: ben_m: haha, looking back at the triangle thing I solved on 4clojure, I actually used a graph algorithm, making a vertex out of each number, and edges representing valid paths (this was for a minimal path algorithm)

10:50 which works, and is reasonably efficient, but like many graph algorithms is definitely not the most concise way to solve the problem

10:50 ben_m: justin_smith: This problem has me calculate the maximum path (each node is a value) from top to bottom. I'm going through it row by row and collect the best path to each node, then recurse with the rest of the triangle/graph.

10:50 justin_smith: ben_m: same problem then :)

10:51 daniel___: who likes challenges? https://gist.github.com/danielstockton/043a3d3093e90ba55657

10:51 keep getting stackoverflow errors

10:52 justin_smith: concat will do that

10:52 what happens is the laziness causes multiple calls to concat to stack up

10:52 and by the time you force the laziness, it explodes on the stack

10:52 daniel___: mhm

10:52 lazy-cat?

10:54 justin_smith: I don't think lazy-cat will help here - in fact the stacked up laziness is a big part of the problem

10:54 daniel___: it did :D

10:54 did i just get lucky?

10:54 justin_smith: oh, I guess I was wrong

10:54 daniel___: yeah, seems to work

10:54 i think its the fact it means the recursive call is lazy?

10:54 justin_smith: I don't really get how lazy-cat avoids the concat pileup problem, but if it does, great

10:55 daniel___: its the pile up of summing-to perhaps

10:55 justin_smith: could be the way laziness linearizes recursion into thunks representing the next step

10:58 clgv: borkdude: no, not really

11:10 justin_smith: clgv: borkdude: "By default, assertions are disabled at runtime. Two command-line switches allow you to selectively enable or disable assertions. ... -ea ... -da" http://docs.oracle.com/javase/7/docs/technotes/guides/language/assert.html

11:12 clgv: justin_smith: what does that mean for clojure's :pre :post? they are usually enabled by default

11:12 justin_smith: they generate assertions, when you make a jar, java decides whether assertions are run

11:12 clojure uses jvm native assertions, they are a feature the vm controls

11:13 clgv: justin_smith: but are you sure that's the same mechanism since it says "by default disabled"

11:13 justin_smith: when you run java -jar, yes, disabled

11:13 hmm - now I see your point

11:14 http://stackoverflow.com/questions/24949418/how-to-disable-clojure-assertions-including-preconditions

11:14 ,*assert*

11:14 clojurebot: true

11:14 justin_smith: there we go

11:14 borkdude: I wish I could make assert a little more expressive, like in (let [x "foo"] (assert (number? x)))

11:14 now it prints Assert failed: (number? x)

11:14 clgv: ah right I vaguely remembered a dynamic binding

11:15 borkdude: I want to see: "foo is not a number"

11:15 clgv: ,(doc assert)

11:15 clojurebot: "([x] [x message]); Evaluates expr and throws an exception if it does not evaluate to logical true."

11:15 clgv: ,(assert (number? 'x) "foo is not a number")

11:15 clojurebot: #<AssertionError java.lang.AssertionError: Assert failed: foo is not a number\n(number? (quote x))>

11:16 justin_smith: ,(binding [*assert* false] (assert false) true)

11:16 clojurebot: #<AssertionError java.lang.AssertionError: Assert failed: false>

11:16 justin_smith: hmm

11:17 ,(set! *assert* false)

11:17 clojurebot: #<IllegalStateException java.lang.IllegalStateException: Can't change/establish root binding of: *assert* with set>

11:17 justin_smith: ahh, can't do it on clojurebot, but that is how it is done (works in my repl)

11:18 clgv: justin_smith: yeah that wont work.

11:18 justin_smith: it must be set befor your actual files are compiled

11:18 justin_smith: ahh, of course

11:18 so yeah, set it in project.clj

11:18 clgv: justin_smith: so :global-vars or java commandline are the only places where it has an effect

11:19 justin_smith: well, setting it will effect things compiled after that point

11:19 so you could turn off assertions before requiring other code... but that seems messy

11:19 clgv: yeah right, without AOT that is tricky

11:19 borkdude: clgv yeah, but those are not used by default in defn

11:20 clgv: borkdude: ah ok you meant for _pre/:post ...

11:20 borkdude: clgv yeah

11:21 clgv I guess this is what Schema is for

11:21 clgv: borkdude: maybe contracts are the better choice: https://github.com/clojure/core.contracts

11:21 ah well that schema lib probably as well...

11:24 borkdude: clgv or core.typed

11:25 clgv or Haskell

11:25 :P

11:41 Fender: ok, so I have this function (fn transform [args]) and I want to return the sexpr represenation of function call like, e.g., (let [targs (map transform args)] (cons f (cons some-param targs))). Now if f is ternary and has >=3 args, I need to call something like (reduce #(f some-param %1 %2) (first targs) (rest targs)). I tried some (list reduce (list fn '[x1 x2] (f some-param x1 x2)) (first targs) (rest targs)) but that doesnt work some r

11:42 forgot some quotes

11:42 thing is not that my code doesnt compile, it's that it returns (first args)

11:45 even (list #'reduce #'println (first targs) (rest targs)) doesnt print anything

11:45 but (cons f (cons some-param targs)) does

11:47 borkdude: I thought to myself: which idiot calls a function like (#'function ...)

11:47 but I did it myself because the function was prive

11:47 private ;)

11:48 unit tests

11:48 Fender: well, you also might need it in web handlers

11:48 but that's something else

11:49 justin_smith: Fender: why would (list #'reduce #'println (first targs) (rest targs)) print anything? is this a macro?

11:50 Fender: its just for testing

11:50 I want to substitute println by something else

11:52 justin_smith: but putting println in a list is not going to print anything, and if you thought it would you should probably back up and read some basic clojure intro

11:53 clgv: ,(reduce #(do (println %2) %1) nil (range 5))

11:53 clojurebot: 0\n1\n2\n3\n4\n

11:53 borkdude: Fender I know

11:53 justin_smith: clgv: but that's not what he was doing - he was literally putting #'println in a list

11:53 clgv: though a `doseq` would be the right tools here ;)

11:54 justin_smith: I just showed him how his goal of printing via reduce would work

11:54 justin_smith: oh, I had no idea what any of that was supposed to do

11:55 Fender: well, I was talking more like (eval (list reduce (list 'fn ...) )

11:56 justin_smith: eval is bad. Always look for a way not to use eval.

11:56 Fender: as I said, "I want to return the sexpr represenation of function call"

11:56 grandy___: anyone know the best way using secretary to make routes show up in the location when they are navigated to?

11:56 Fender: thanks justin, I know that

11:58 clgv: you want to retrieve the sexpr that defines a function?

11:58 Fender: eaxactly

11:58 and I got it

11:58 clgv: well, no idea what your problem is then..

11:58 Fender: the targs had to be made a list by (cons list ...) again

11:59 imagine you get a function description (sexpr) via eMail and you want to offer this function via a web service to the subscriber

12:00 sexpr is basically just the mathematic subset of clojure

12:00 justin_smith: Fender: so something like serializable-fn

12:00 https://github.com/technomancy/serializable-fn

12:01 Fender: actually the opposite

12:01 clgv: justin_smith: I thought he said he managed that already?

12:01 Fender: I get a function description

12:01 but thanks anway

12:02 danneu: has anyone deployed an uberjar straight to heroku, bypassing heroku's own build process?

12:03 clgv: to get a compiled function from an s-expr represented string you can just used read-string and eval

12:04 Fender: well, as said, I had to transform the arguments beforehand

12:04 and the function actually was also transformed

12:05 justin_smith: so you are hand rolling a substitute for macros

12:05 Fender: kind of

12:05 I think thats a good description

12:07 technomancy: danneu: you could do that with the new build api https://blog.heroku.com/archives/2014/5/21/introducing_programmatic_builds_on_heroku

12:07 haven't tried it myself

12:08 danneu: technomancy: thanks

12:08 technomancy: danneu: sorry, this link is better https://blog.heroku.com/archives/2013/12/20/programmatically_release_code_to_heroku_using_the_platform_api

12:16 mbac: (.. java.net.InetAddress getLocalHost getHostName)

12:16 what's ..?

12:16 ToxicFrog: Repeated .

12:17 eqv to java.net.InetAddress.getLocalHost().getHostName()

12:17 nullptr: http://clojure.org/java_interop#Java Interop-The Dot special form-(.. instance-expr member+)

12:17 mbac: whoa

12:18 clgv: ,(.. java.net.InetAddress getLocalHost getHostName)

12:18 clojurebot: "localhost"

12:18 clgv: hehe

12:19 mbac: cute

12:24 TimMc: It expands to (-> java.net.InetAddress (.getLocalHost) (.getHostName))

12:25 err... almost

12:26 I guess .. has some special logic to turn that first call into a static method call.

12:34 clgv: ,(macroexpand-1 '(.. java.net.InetAddress getLocalHost getHostName))

12:34 clojurebot: (.. (. java.net.InetAddress getLocalHost) getHostName)

12:34 danneu: i have to stop and think about it every time i see '..' and '.'

12:34 clgv: ,(. Long (parseLong "42"))

12:34 clojurebot: 42

12:35 clgv: as it seems there is no special logic needed for static calls

12:36 technomancy: . isn't meant for direct usage

12:36 and .. is pretty archaic too

12:39 borkdude: integer? returns true for all longs?

12:39 Bronsa: borkdude: the docstring never mentions any concrete java class

12:39 borkdude: k, I'm looking at the source now

12:40 Bronsa what do you mean, never?

12:40 dbasch: borkdude: yes

12:40 Bronsa: integer doesn't mean Integer

12:40 virmundi: Hello. I'm looking for naming guidance on methods and logging. My understanding is that everything that has a side-effect should have an "!" at the end. Logging is a side-effect. Therefore, should any methods that have logging end in "!"?

12:41 dbasch: virmundi: no, side effects usually mean changing state

12:41 log is similar to print

12:42 virmundi: Ok. Thanks.

12:43 borkdude: Bronsa k

12:49 TimMc: So it's really . that has the smarts.

12:50 Nova_: Thanks you, but if you make an account with that url you will have 10 usd for start... https://www.digitalocean.com/?refcode=57f20058a282

12:52 gfredericks: Any guesses why adding lein-cljsbuild repl-listen code to the om tutorial gives me a repl that hangs on eval?

12:52 * gfredericks hasn't done clojurescript in a while

13:05 mdeboard: gfredericks: It's because you don't have a browser window open to the page I bet

13:05 the right port etc

13:06 it's just waiting for a browser to eval the code in, I think.

13:13 michaelmeixner: newbie has a short question

13:14 I want to calculate the deltas between the elements of a vector

13:14 say [2 3 5 8]

13:14 I found I can do :

13:15 (partition 2 1 [2 3 5 8])

13:15 ben_m: (map - coll (rest coll))

13:15 michaelmeixner: ah ...

13:16 ben_m: Change - to a lambda if you want absolute deltas of course :)

13:16 michaelmeixner: great, thanks - I knew there had to be a simple solution

13:17 thanks again

13:17 justin_smith: michaelmeixner: there is also (map #(apply - %) (partition 2 1 coll))

13:17 ben_m: michaelmeixner: You're welcome

13:27 literary: help

13:27 ben_m: 911?

13:28 lavokad: :D

13:28 literary: Caused by: java.lang.IllegalArgumentException: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil

13:28 wth

13:28 java.lang.ExceptionInInitializerError

13:29 noonian: sounds like some sort of null pointer exception

13:29 you are passing nil to something where you think you have a non-nil value

13:29 literary: its on line 1 of a file

13:29 the (ns) line

13:36 it fails consistently, and did not fail on friday.

13:36 i have no understanding of why it fails.

13:36 justin_smith: can you share a paste of the ns declaration?

13:37 noonian: literary: if you post your ns form on refheap, pastebin, or as a gist people here will be in a better position to help you

13:42 Bronsa: literary: are you using core.typed?

13:43 literary: no

13:43 mdeboard: hm

13:43 Bronsa: literary: you need to post the source that's causing that exception anyway, we can't help you only with that exception

13:44 mdeboard: Can someone help me understand why this happens

13:44 &(apply Math/abs [-1 -2 -3])

13:44 lazybot: java.lang.RuntimeException: Unable to find static field: abs in class java.lang.Math

13:44 Bronsa: mdeboard: methods aren't first class objects like functions

13:44 justin_smith: mdeboard: methods are not first class

13:44 mdeboard: I see

13:44 ben_m: &(apply #(Math/abs %) [-1 -2 -3])

13:44 lazybot: clojure.lang.ArityException: Wrong number of args (3) passed to: sandbox5671$eval12864$fn

13:45 ben_m: Well whatever but that.

13:45 Bronsa: mdeboard: there's really no good wayt to use apply with static methods

13:45 mdeboard: well yeah but I got that too, and don't understand

13:45 Bronsa: I see, ok

13:45 you can't use map either right

13:45 or reduce

13:45 (no reduce implies no map, you're right

13:45 )

13:45 Bronsa: mdeboard: well you can, you just have to wrap the method call in an anonymous function

13:46 justin_smith: mdeboard: only first class Objects can be arguments to functions

13:47 mdeboard: Oh right

13:47 &(apply #(Math/abs %) [-1])

13:47 lazybot: ⇒ 1

13:47 literary: Bronsa, noonian, https://gist.github.com/anonymous/4f4463805ba92ca1036b

13:47 mdeboard: understood

13:48 I got nerd-sniped

13:48 Bronsa: mdeboard: what I meant by "you can't use apply for methods" is that usually you use apply when you don't know the arity of the function you're invoking -- you have to know the arity of the method you're invoking

13:49 TimMc: Don't tell me what I have to do!

13:49 mdeboard: &(let [coll [2 3 5 8]] (map (comp #(Math/abs %) -) coll (rest coll)))

13:49 lazybot: ⇒ (1 2 3)

13:50 mdeboard: ben_m nerd-sniped me

13:50 with the absolute value thing

13:50 ben_m: I knew why it didn't work but I didn't immediately know how to fix it.

13:50 noonian: literary: do you require any namespaces in that file that you wrote? if so the bug is probably in one of those files and because the ns didn't compile you can't require it in that one

13:51 literary: yes

13:52 TimMc: &"you there?"

13:52 lazybot: ⇒ "you there?"

13:52 TimMc: Bronsa: ##(apply #(clojure.lang.Reflector/invokeStaticMethodVariadic "java.lang.Math" "abs" (object-array %&)) [-1])

13:52 lazybot: java.lang.SecurityException: You tripped the alarm! class clojure.lang.Reflector is bad!

13:52 grandy___: quick question: when working with reagent and secretary, if I call (secretary/dispatch! "/some-route") it loads the handler, but the url still shows "/". If I hook into google history and watch for navigation events and call secretary/dispatch! when such an event occurs, then when I call (secretary/dispatch! ... ) the handler gets called twice... any

13:52 ideas?

13:52 TimMc: oy

13:52 noonian: literary: i would try, from the repl, requiring each of the other namespaces you wrote manually until one fails and then look closer at that one

13:53 literary: thank

13:53 TimMc: ,(apply #(clojure.lang.Reflector/invokeStaticMethodVariadic "java.lang.Math" "abs" (object-array %&)) [-1]) ;; let's try the other parent

13:53 clojurebot: 1

13:53 literary: lein repl fails for me

13:53 Exception in thread "main" java.lang.ExceptionInInitializerError

13:53 (inc TimMc)

13:53 lazybot: ⇒ 72

13:54 noonian: literary: if you have a :main key in your project.clj just comment that out for now

13:54 literary: then your repl should start up in the 'user namespace

13:54 Bronsa: TimMc: c.l.Reflector is cheating

13:54 literary: does

13:54 TimMc: literary: I wonder how many of my karma points are for awful ideas I give to people.

13:54 Bronsa: :-D

13:55 literary: TimMc: dont beat yourself up over it everyones just doin their best you know what they say be more kind than necessary to everyone you meat for they are fighting a hidden battle that you know nothing about

13:57 found it

13:57 (slurp nil)

13:57 clojure.java.io/resource stopped working in tests at some point

13:57 noonian: literary: nice!

13:57 literary: not that it ever was *executed* during tests,

13:57 but now it no longer even compiles during tests

13:57 jba-123: what's the recommended way to have multiple core-async listener ?

13:57 literary: oh wait its not in a funciton its in a def

13:57 thanks you noon ian

13:58 noonian: no problem

13:58 literary: i really think this is the worst error message

13:58 i think even perl is more readable

13:58 and nobody can read perl not even perl parsers

14:01 bbloom: seems like puredanger is going around bumping tickets to 1.8

14:02 i guess that means a 1.7 release is eminent

14:03 Bronsa: bbloom: yeah, I'm a bit disappointed that critical bugs are getting postponed once again though :/

14:04 bbloom: Bronsa: i'm only disappointed b/c i know how slow the release cycle is. i understand the desire to ship transducers though

14:04 maybe 1.8 will be a quick follow up to 1.7, we'll see

14:04 Bronsa: I hope that too, but I won't bet on it

14:05 bbloom: me neither

14:05 hiredman: it never is

14:05 Bronsa: I'm a bit tired of having to rework all my patches all the times because they break with the last master

14:06 bbloom: yeah, that's the biggest reason i don't contribute patches as often as i would (all jokes about jira aside) -- contributing patches creates *reoccurring* work for me

14:06 gfredericks: mdeboard: I *think* I had it open; doesn't it not show the repl prompt at all until a browser connects?

14:09 mdeboard: gfredericks: mmm maybe!

14:09 Bronsa: bbloom: I only keep contributing patches because I know that a ticket without patch will rot forever

14:09 bbloom: yup

14:09 hiredman: watching http://dev.clojure.org/jira/browse/CLJ-1297 comments roll through my inbox every morning always makes me shake my head

14:11 I guess today wasn't a comment, just alex bumping it

14:18 m1dnight_: So _tried_ reading the paper on Actors by Carl Hewitt but it just does not make sense to me..

14:29 danneu: if you start a go-loop in an Om component's IWillMount that spins forever, i suppose you need to poison the go-loop in IWillUnmount or it'll keep going even after it's been removed from the dom, right?

14:31 nullptr: danneu: that's my understanding -- it will be "waiting forever" in that case

14:31 you can just close the channel in IWillUnmount and abort the go-loop

14:32 i haven't confirmed that though

14:32 turbofail: m1dnight_: haven't read it myself, but from what i've heard you're in good company there

14:33 danneu: it's just (go-loop [] (<! (timeout 1000)) ... (recur)). i suppose i would (let [[ch v] (alts! [(<! (timeout 1000)) poison-ch]) when (not= ch poison-ch) recur.

14:35 nullptr: e.g. https://github.com/swannodette/om-sync/blob/master/src/om_sync/core.cljs#L121

14:38 danneu: nullptr: thanks, will copy the master

14:41 m1dnight_: turbofail: It's really messy. Imagine a paper written on a typewriter, pulled through OCR 10 times. It's something like that :p

14:41 There is a "summary" by Gul Agha and Rasjesj Karmani which is very readable and to the point.

15:09 danneu: i want to create a stateful Om component for every user in the list that follows them as they are shifted around. however, my stateful ticker-components don't work how i think they would: https://www.refheap.com/91285

15:12 nullptr: you need to add a key so react knows the canonical identity -- you probably have a warning about that in your js console

15:12 http://facebook.github.io/react/docs/multiple-components.html#dynamic-children

15:19 danneu: nullptr: thanks for the help. got it working

15:19 (got no console err, though)

15:20 borkdude: cfleming dunno what this is https://www.dropbox.com/s/obicqrmq8ujc741/Screenshot%202014-10-06%2021.18.45.png?dl=0

15:20 cfleming cursive still seems to work ;)

15:23 liflash: hi everyone

15:26 i'm using om-sync and the ring middleware for sending edn parameters from a client to the server. the sent request is correct and contains everything needed, but on ther server side the parameter never arrives. That is the edn-params in the request map is always nil. any ideas?

15:27 danneu: nullptr: my goal here was to make a jquery.timeago.js-like component. (auto-updating distance-in-words, e.g. "2 min ago" -> "3 min ago"). gist: https://gist.github.com/danneu/10280fe5e4079634917c

15:27 nullptr: liflash: you're wrapping your routes with wrap-edn-params?

15:27 liflash: exactly

15:30 danneu: (the gist works now)

15:30 liflash: do you need some more info to think of possibilities?

15:31 nullptr: danneu: cool -- you might also be interested in: https://github.com/Prismatic/om-tools#mixin-tools

15:31 liflash: what's your route definition look like?

15:31 danneu: nullptr: thanks

15:33 liflash: (defroutes some-routes (POST "/timeline/updaterank" [edn-params :as para]

15:33 (println "update-rank request parameter map: " edn-params "\npara: " para)))


15:34 nullptr: i have a working project where it's defined as:

15:34 (POST "/rsvp" {edn-params :edn-params} (rsvp edn-params))

15:35 liflash: yeah, i had look into it and on the github site compojure explains that there are different ways of destructuring. they introduced their own style for simplicity


15:35 but good to know it works for you

15:36 nullptr: if the mime types are right and the middleware is installed properly not sure where else it'd go awry

15:36 minimal: (def app (-> routes wrap-edn-params))

15:36 liflash: (wrap-edn-params routes) should work, too, right?

15:43 d0ky: hello is that implementation of RBtree http://daly.axiom-developer.org/clojure.pdf#section.2.4 suitable for program like videostore to make custom data structure to store there items ?

15:47 danneu: liflash: when in doubt, i drop in some noisy middleware and compare it to what i'm seeing in in the Network tab of my browser dev tools https://gist.github.com/danneu/ac3a99ac8eb0c0f4ca58

15:47 justin_smith: d0ky: I'd assume you want persistence, which probably means a real database of some sort

15:48 liflash: danneu: thanks, will have a look

15:49 d0ky: justin_smith: not really it is to school and i has to be in java and i want to practice functional approch ... and rich hickey is good at it so that's why i want to do that way to learn something new

15:53 liflash: danneu: any idea why pprint is unknown?....

15:54 noonian: liflash: you need (:require [clojure.pprint :refer [pprint]])

15:55 borkdude: how does one combine core.typed with prismatic/schema? when I use a s/defn core.typed gets screwed

15:55 liflash: danneu: oops, thought it was available by default, thanks

15:57 borkdude: I must say I like both approaches: core.typed for static checks, schema for run time checks

15:59 mr_rm: is this the right place to ask a question about the library "Liberator"?

16:00 don't see a dedicated irc channel

16:00 borkdude: mr_rm sure, ask

16:01 mr_rm: i have this code: http://pastebin.com/McMHm0md when i call post with curl, i get the "called post" message. unfortunate, i get the same from my browser. i don't understand why GET from the browser goes to the post! function

16:02 liflash: danneu: nullptr : just tried the debug middleware and the request seems to be empty on arrival already... but the network infos from the browser request tools tell me the request was sent with the correct data. this looks like something totally stupid

16:03 danneu: nullptr on my side, of course ;)

16:04 mr_rm: borkdude: sorry, i should have posted the defresource for user too: http://pastebin.com/2TjNLfF2

16:04 jlongster: I was looking at how core.async handles transducers that produces more values than it takes in (mapcat), and saw that a FixedBuffer will actually resize if that happens. so the size is not fixed. is that not a problem usually?

16:04 dnolen_: ^

16:04 danneu: liflash: can you substantiate that the request has header "Content-Type": "application/edn"?

16:05 ale`: Hi, I'm playing with Clojure-clr, specifically I am trying to eval clojure code from a c# console program. This is the sample code: https://gist.github.com/3e83f8f413f570b47339 . I get a NullReferenceException when I eval the import statement. What am I doing wrong?

16:05 borkdude: mr_rm aren't the :allowed-methods etc supposed to be in the liberator resource rather than in the compojure route?

16:07 mr_rm if you can just post your whole namespace it's easier to see

16:07 mr_rm because namespace definitions matter

16:07 dnolen_: jlongster: a problem how?

16:08 danneu: liflash: what does (:body request) look like? all wrap-edn-params does is, if content-type is some form of application/edn, then (edn/reader (:body req)) and (assoc req :edn-params result-of-that).

16:09 jlongster: dnolen_: you assume a certain buffer size which implies certain blocking behavior. but I get the sense you don't write go blocks that depend that specifically on the details of non-blocking/blocking

16:09 I need to write more code with buffers

16:09 mr_rm: borkdude: right, i understand. i think you're right about putting :allowed-methods in the resource. i'll try that. in the meantime: http://pastebin.com/p2hQSSgq

16:10 borkdude: mr_rm also :handle-ok etc

16:10 mr_rm you should call the resource from liberator and then the resource decides via the liberator decision tree what to return

16:10 liflash: danneu: in fact i can't. regarding the output of your debugging lines, the request before the handler has content-type nil

16:10 borkdude: mr_rm call the resource from the compojure route I mean

16:11 dnolen_: jlongster: right this is why it's preferred that an api receive a pre-allocated channel

16:12 jlongster: buffering is a property of channels not go blocks themselves

16:12 liflash: danneu: ok, i think there must be something wrong with the authorization middleware. a friend of mine wrote it using friend. maybe he got something wrong with the routing

16:13 mr_rm: borkdude: gotcha. yes i see that i skipped the resource entirely in the process. that helps

16:14 jlongster: dnolen_: yeah. right now we throw an error in `add` on a FixedBuffer if it is full, and I just noticed that that's different

16:14 it feels weird to resize the buffer automatically, but if the user shouldn't care about it, cool

16:14 liflash: danneu: thanks a lot for your help. will have a look at it on my own for now

16:21 mr_rm: borkdude: yeah, that works when i put it all inside the one resource. i was suffering a case of mild retardation: http://pastebin.com/g7b56yWS

16:21 borkdude: thanks again

16:24 borkdude: i had the (do (println...)) in there just to see something quickly but i can see it's doing the right thing now for both GET and POST. that certainly cleared up my confusion re putting those keywords in the resource, not the route

16:25 borkdude: if you don't mind another question, is Liberator still viewed as a good library in this space. it looks perfectly fine to me but i'm only just getting started with web dev in clojure and don't know the ecosystem very well yet

16:26 borkdude: s/space\./space\?/

16:27 kenrestivo: are there any gotchas i should look out for when backing a core.async channel with an inputstream?

16:29 hiredman: what does backing mean?

16:31 ppppaul: anyone here use lighttable ?

16:31 hiredman: in any case you'll want to use a ReadableByteChannel and bytebuffers, not an InputStream

16:37 borkdude: mr_rm yes, I view liberator as a good library for creating REST services

16:39 ppppaul: liberator has a little bit of a learning curve. worth it if you want to handle many types of status codes in a more declarative way

16:40 borkdude: mr_rm take a look at the decision tree of liberator, that's really the main idea of it

16:42 perplexa: hello. anybody here using cursive? i just imported a leiningen project and it says "xyz cannot be resolved" for everything. all clojure core functions included. is there anything i'm missing?

16:42 borkdude: perplexa I'm using cursive, but I didn't use "import"

16:43 perplexa I just open the project.clj

16:43 perplexa ask cfleming

16:44 dbasch: http://diegobasch.com/random-partition-of-a-sequence justin_smith gfredericks

16:45 perplexa: borkdude: how do you just open the project.clj? :P

16:45 borkdude: perplexa File -> Open or something

16:45 liflash: danneu: still there?

16:45 perplexa: borkdude: it doesn't really create a project from that, though

16:46 hiredman: perplexa: likely your repl has *ns* set to a namespace that doesn't have anything refered in to it

16:46 borkdude: perplexa no, I create projects with leiningen from the shell

16:46 hiredman: perplexa: you should be able to call core functions if you fully qualify

16:46 (clojure.core/+ 1 2)

16:46 gfredericks: dbasch: woohoo I'm internet famous!

16:46 perplexa: borkdude: me too ;P

16:46 hiredman: how or why your repl is in that state, I dunno

16:47 perplexa: mh

16:47 borkdude: perplexa ah, well, then you're good to go

16:47 gfredericks: dbasch: (random-partition (range)) is a cool idea I wouldn't have thought of

16:47 liflash: danneu: just saw that content-type isn't empty. don't know what happened the first time. the (:body req) is #<HttpInput org.eclipse.jetty.server.HttpInput@155b539>, how can i see what's in there?

16:47 dbasch: gfredericks: you should expect 0.2 new twitter followers from my post :P

16:50 gfredericks: dbasch: hey there the are right now

16:50 perplexa: borkdude: yeah, was using vim + leiningen's repl so far. but wanted to give cursive a shot

16:55 dogonthehorizon: Greetings folks. I have a nested Clojure collection that I am attempting to convert to its Java counterpart using clojure.walk/postwalk. However, I can't figure out why I'm getting an NPE when I traverse the first collection type. Would anyone be able to explain this? Thanks! Here's a conensed snippet of the problem: https://gist.github.com/dogonthehorizon/41f65925f595180f096e

16:56 amalloy: dogonthehorizon: clj-type->java-type returns nil for anything but a map or vector

16:56 borkdude: perplexa I've been working with it for a few days, and I like it so far

16:56 amalloy: but like...just don't write this function at all. clojure's lists implement j.u.List, etc

16:57 dogonthehorizon: amalloy: d'oh, missed that one. But what do you mean I shouldn't write the function? How would I go about translating the types for use in Java?

16:57 amalloy: just don't. give them the clojure types

16:58 dogonthehorizon: Wouldn't that require me to import clojure.lang and friends in my Java code?

16:58 amalloy: no

16:58 the point is that an IPersistentVector *is* a j.u.List, and it's Iterable, and all that good stuff

16:59 so you can iterate over it with like: for (Long l : coll) ...

16:59 justin_smith: dbasch: re: the blog post, very cool

16:59 hiredman: I dunno

17:00 will javac let you do that without generics?

17:00 liflash: how can i find out what's in the :body #<HttpInput org.eclipse.jetty.server.HttpInput@155b539> of a request?

17:00 amalloy: hiredman: just lie about the types: List<Map<String, Integer>> loms = f.invoke(x)

17:01 hiredman: amalloy: ah, sure

17:01 dogonthehorizon: amalloy: ...ah. Well now I feel silly for going through all this work, heh. Thanks for walking me through that! :)

17:03 borkdude: dogonthehorizon there's also an API for calling clojure functions from java: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/java/api/Clojure.java

17:04 noonian: liflash: according to the docs that is a subclass of java.io.InputStream so you can probably just use slurp to read it

17:05 dbasch: justin_smith: thanks

17:05 liflash: noonian: thanks, didn't know where to look at

17:05 dbasch: justin_smith: btw, I ended up bringing that geohash code down to the same speed as the java version https://www.refheap.com/91288

17:05 noonian: liflash: np

17:06 dbasch: thanks to Bronsa who pointed out that bit-flip and bit-test are not inlined

17:06 dogonthehorizon: borkdude: Yeah, I looked at that api a while back but calling Clojure like this feels less fluid. I've chosen the gen-class/aot route to wrap the logic in my Clojure project, but the final piece of the puzzle was getting the return statements to line up with the types I was expecting in Java.

17:06 clojurebot: No entiendo

17:06 borkdude: dogonthehorizon makes sense

17:11 liflash: is #<HttpInput org.eclipse.jetty.server.HttpInput@155b539> the expected :body when using http-kit?

17:12 noonian: liflash: are you using ring? you should get a map with a :body and :status key if so

17:12 liflash: i would expect to get the body i send from the client, like for example a map

17:13 yes, i use ring

17:14 noonian: liflash: try (println (slurp (:body request)))

17:14 liflash: this returns the expected body

17:16 justin_smith: liflash: the reason you get a HttpInput is that you may be able to close the stream after reading a few bytes - the most flexible option is to handle you an abstraction for the input from the client, and let you read as much or as little as you want

17:18 liflash: i see

17:18 brehaut: $seen technomancy

17:18 lazybot: technomancy was last seen talking on #clojure 4 hours and 41 minutes ago.

17:19 liflash: my core problem is that wrap-edn-params seems to be able to extract the edn from that inputstream

17:19 rurumate: how to define riemann zeta function in clojure?

17:20 mathematica has it built in it seems

17:20 liflash: seems not to be, sorry

17:22 hiredman: liflash: are you setting the content type?

17:23 liflash: i'm using om and the content-type is set to application/edn

17:24 hiredman: what edn params middleware are you using?

17:24 liflash: compojure

17:24 no, sorry

17:24 ring

17:25 hiredman: liflash: I don't think ring has such a thing

17:25 https://github.com/ring-clojure/ring/tree/master/ring-core/src/ring/middleware

17:25 liflash: i required [ring.middleware.edn :refer [wrap-edn-params]]

17:26 hiredman: liflash: ok, but where did ring.middleware.edn come from?

17:27 justin_smith: maybe this one ? https://github.com/tailrecursion/ring-edn/tree/master/src/ring/middleware

17:27 liflash: oh, i see what u mean. i think it comes from [fogus/ring-edn "0.2.0"]

17:28 i'm working with a friend of mine, he added it

17:28 and he says all this already worked

17:28 don't know what the problem is

17:28 the content type is correct, but the resulting map only contains :edn-params nil

17:29 hiredman: sounds like the inputstream is empty or contains nil

17:29 (or you are printing out the contents of the inputstream before the middleware can read it)

17:30 justin_smith: yeah, input streams are stateful, so be careful of emptying it prematurely

17:32 dbasch: cool - at least to me the clojure version is nicer than the java. Pity it took more work to make it perform.

17:33 dbasch: in fact with the latest feedback from amalloy it’s now faster than the java version https://www.refheap.com/91289

17:34 liflash: hiredman: hmmm... currently looks like a mess and i don't know where to start. will have deeper look first. thanks for your hints

17:40 turbofail: huh. why aren't bit-test and bit-flip inlined?

17:41 just an oversight?

17:41 dbasch: turbofail: they are not

17:41 hiredman: likely

17:41 (which is why a machine shoud be generating all this)

17:41 dbasch: oh, why, yeah most likely an oversight

17:41 amalloy: i'd guess it's because there's no single jvm bytecode for them

17:42 the others are inlined so that they can be removed entirely and replaced with a bytecode instruction, via intrinsics

17:42 whereas inlining this one doesn't buy you anything more than letting hotspot inline it

17:42 Bronsa: amalloy: them being not inlined prevents the unboxed arities to be used though

17:42 turbofail: yeah, their function definitions don't do any type hinting

17:43 amalloy: ah, yes indeed, since there are primitive versions that definitely should be inlined

17:46 hiredman: it should all be machine generated

17:50 akurilin: Has anybody here succeeded with disabling connection pooling done by Korma?

17:50 Trying to figure out if I'll have to fork the lib to do it

17:52 Hm I guess there's :make-pool? in there

17:54 gfredericks: huh. I've never noticed a lib with no dependencies before

17:54 only lists clojure under :dev

17:55 (test.check)

17:57 amalloy: gfredericks: that seems like a decent idea, really

18:02 TimMc: I only just introduced a dependency on cloure.set into org.timmc/handy, which surprised me.

18:03 *clojure, why does my typing suck so much these days

18:04 technomancy: for once we can't blame nil

18:12 vIkSiT: hello all

18:12 what's the easiest way to add a snapshot build of a library using lein?

18:12 eg, om 0.7.3 is stable, but the github master branch is on 0.7.4 snapshot

18:13 nullptr: you can just pull the code and run: lein install

18:13 vIkSiT: what can I do to add the latter to my project.clj?

18:13 nullptr, ah - and then it get's installed as a dep into .m2?

18:13 nullptr: yup

18:13 technomancy: vIkSiT: it depends on whether the snapshots are published

18:13 vIkSiT: (and project.clj will pull it once the entry is added?)

18:13 technomancy, right, the snapshots aren't published in this case

18:13 technomancy: if they are, it will just work

18:13 em-dash: I’m sure this is dead simple: what kind of strategy should I use to find a map (which contains a specific key) within a vector of maps?

18:13 technomancy: yeah, in that case manual lein install

18:13 vIkSiT: cool, ty

18:14 justin_smith: em-dash: are you looking for it once, or looking repeatedly?

18:14 em-dash: I expect it to appear once in the vector

18:14 justin_smith: how often do you look it up?

18:15 for finding it once (first (filter ...)) if repeatedly, (group-by :your-key vec-of-maps)

18:15 em-dash: oh, I want to extract it and build a map with the value I find (I’m parsing horribly formatted XML)

18:15 vIkSiT: has anyone here used clojurescripts nativestore btw?

18:15 em-dash: justin_smith: thank you! that’s exactly the nudge I needed :)

18:16 vIkSiT: and another question - when using luminus, if I connect to the lein REPL using cider, adding a new route doesn't reflect in the running program - need to manually quit the repl and re "lein repl"

18:16 justin_smith: em-dash: for example if you are finding many items by the same key, group-by is a huge win

18:17 vIkSiT: any ideas on why repl/running program state wouldn't get updated through cider, C-c C-k? or even C-x C-e?

18:17 em-dash: justin_smith: I’m dealing with ill-formatted XML. once I get the data into a sane shape, group-by will be much more applicable

18:17 justin_smith: thanks again :)

18:18 justin_smith: vIkSiT: if some service like ring was initialized by having a function passed in, just chaning the def of the function won't change what the server runs

18:18 for example

18:18 also look out for things that have defonce semantics

18:19 vIkSiT: ah

18:19 justin_smith: for example defmulti

18:19 vIkSiT: it's basically a defroute, yes - using ring

18:19 justin_smith: pass #'handler to the server process rather than handler

18:19 ring will dereference the var instead of using the value of the var

18:19 *do a dereference of the var for each request, that is

18:23 vIkSiT: justin_smith, not sure I understood that last part

18:23 how do you mean pass the deferenced handler to the server?

18:24 justin_smith: I mean the server derferences on each request

18:24 dbasch: whenever I see defonce I think of beyonce

18:24 vIkSiT: I just go to the (deroute my-app ... (GET "/route" [] (my-handler)) and C-x C-e

18:24 justin_smith: rather than getting the immutible fn value and just using that

18:24 right, and that changes a var

18:24 vIkSiT: right

18:24 justin_smith: it does not alter the fn that you passed to the server

18:24 seangrove: dbasch: But isn't it true that you're just generally thinking of beyonce?

18:24 vIkSiT: ah

18:24 justin_smith: the server is still using the old fn

18:24 vIkSiT: well.

18:24 dbasch: (beyonce put! “a ring on it”)

18:24 justin_smith: if you pass in a var, it can deref for each request

18:25 vIkSiT: C-x C-k should do the right thing though?

18:25 dbasch: seangrove: no, just this once

18:25 * seangrove can't keep up with the wit

18:25 seangrove: Damn, outclassed

18:26 justin_smith: vIkSiT: how can it if the ring process did not receive a var?

18:26 if it does not get a var, and only an fn, it has no way to see a new value

18:26 unless you kill and restart the server on every ns refresh

18:29 grandy___: can someone help me with a potentially dumb conceptual question about secretary for cljs ? Trying to figure out how to make the URL in the browser show the proper "route" after secretary/dispatch! .. tried hooking in google history but then the navigation event triggers the route a second time on the initial page load

18:29 vIkSiT: justin_smith, I think I see your point

18:29 trying to wrap my head around it..

18:29 grandy___: using secretary + reagent on the client side and compojure+yesql on the server side

18:30 justin_smith: vIkSiT: if the server process was using your handler function directly, it would see the update (as long as it had not been inlined)

18:31 vIkSiT: but when it gets a function as an argument, it only gets the fn

18:31 vIkSiT: ah

18:31 justin_smith: vIkSiT: when you change a defn, you don't mutate the fn it referred to - that is immutible and still referred to by the server process. The only way the server (which never saw the name of your function) to see an update is to get the var that gets rebound

18:31 vIkSiT: it gets the defintion of function f at time t1.

18:32 justin_smith: right

18:32 vIkSiT: and then at time t2, i add a new route

18:32 now, i cx ce the function

18:32 justin_smith: and the fn does not change - the var just points to a different fn now

18:32 vIkSiT: the function itself uptakes the value at t2, ie, if I were to use it now, it would work fine

18:32 but ring still has the pointer of fn at time t1?

18:32 cfleming: borkdude: That's a weird screenshot - can you send me your log at cursive@cursiveclojure.com? Help->Show log in Finder/Explorer/whatever it is on Linux

18:33 vIkSiT: so I need some way to update ring's pointer from fn at time t1 to t2

18:33 cfleming: perplexa: Did you get that cursive problem sorted out?

18:33 vIkSiT: justin_smith, does that make sense? ^

18:33 justin_smith: yeah

18:34 vIkSiT: in fact if you hand ring a var, ring decides "oh this is mutable, I have to make sure to check for the latest value each time I use it"

18:35 vIkSiT: justin_smith, ah

18:35 justin_smith: if ring didn't know how to handle vars, another option would be to pass in a handler function that derefs a var, or an atom, each time it is invoked

18:35 luckily we don't have to mess with that

18:35 vIkSiT: ah

18:35 from what I can see, handler.clj contains (def app (app-handler [home-routes base-routes] ... )

18:36 and (defroutes home-routes ... (..routes..))

18:36 amalloy: justin_smith: amusingly, (defn super-handler [req] (handler req)) would work as well as passing the var

18:38 also, i don't know if you're intentionally simplifying this here, but ring really doesn't know or care about vars, only functions. it just works because vars, when called as functions, deref themselves

18:38 vIkSiT: hmm

18:38 so this is actually compojure, and I see this: (defn get-handler [] (-> #'app ... ))

18:38 (def app (app-handler [home-routes] .. ))

18:39 so ultiamtely, the var here IS being passed in

18:39 but still no joy in code reload. hmm

18:40 hiredman: vIkSiT: no, it isn't

18:40 vIkSiT: hmm?

18:41 the var is for app but not home-routes?

18:49 tuft: does anyone know of a library for collecting/deferring side effects within a particular scope? nothing as hard core as the IO monad

18:50 (which i assume someone has recreated in clojure somewhere =)

18:57 justin_smith: tuft: how about building a sequence of thunks (functions of one argument) and later running them all in series?

18:59 nkozo: is possible to reference the instance created by proxy inside one of the proxy methods?

19:01 found it, you can using "this"

19:02 tuft: justin_smith: i'm wondering how many puppies i'd kill if i collected them in an atom in a dynamically bound var someplace so they didn't need to be returned and passed along from every level in the call stack =)

19:03 justin_smith: heh

19:03 clearly, you also need (defonce dead-puppy-count (atom 0))

19:04 amalloy: i'm not sure dead puppies are better in a var than on the call stack anyway

19:04 you just want them out of your program entirely

19:06 justin_smith: tuft: more seriously - depends on who uses your code, and what the chances are that it would be used by two separate parts of the same program

19:07 dbasch: justin_smith: (defonce shrodingers-cat (atom (rand-nth [:dead :alive])))

19:08 technomancy: dbasch: no, you need to make it part of a lazy seq

19:08 that way it's literally in both states until it's observed

19:09 justin_smith: dbasch: (defer (rand-nth [:dead :alive])) both :alive and :dead until you deref it

19:09 dbasch: (inc justin_smith)

19:09 lazybot: ⇒ 86

19:09 dbasch: (inc schrödinger)

19:09 lazybot: ⇒ 1

19:10 justin_smith: (defer ((rand-nth [#(System/exit 0) #(println "survived")])))

19:11 tuft: justin_smith: yeah i guess returning data instead is the way to keep puppy mortality down

19:11 dbasch: justin_smith: that reminds me of my macro to execute the body or throw an excepton 1/n of the time at random

19:12 justin_smith: dbasch: the purpose?

19:12 dbasch: an excepton: a fundamental component of exceptions

19:12 justin_smith: dbasch: large exepton collider

19:12 dbasch: justin_smith: test random failures of a process that was trying to fetch stuff from the network

19:13 justin_smith: ahh, of course - simulate unrepliable infrastructure

19:13 cbp: (doc defer)

19:13 clojurebot: No entiendo

19:13 * cbp got here late

19:14 dbasch: (doc recursion)

19:14 clojurebot: Excuse me?

19:14 dbasch: wrong answer clojurebot

19:14 justin_smith: I don't know why I was doing "defer" - it's delay (and it does deferred evaluation)

19:15 (doc delay)

19:15 clojurebot: "([& body]); Takes a body of expressions and yields a Delay object that will invoke the body only the first time it is forced (with force or deref/@), and will cache the result and return it on all subsequent force calls. See also - realized?"

19:18 amalloy: justin_smith: just (def defer delay), so that you can run into the same problems with var redefinition

19:19 justin_smith: heh

19:19 amalloy: (modulo the baloney about setting ^:macro)

19:22 justin_smith: I refuse to look up "modulo the baloney" on urbandictionary

19:23 dbasch: amalloy: for proper behavior, wrap that in without-redefs from useless

19:23 amalloy: hah

19:24 dbasch: (defn maybe-or-maybe-not [x] true) <- also for useless

19:25 justin_smith: (def calculate (constantly 42))

19:25 dbasch: (defn perhaps [x] false)

19:30 amalloy: i can't believe ∀ isn't on any Compose-key sequence. surely Compose A v is obvious enough? but instead you get five different sequences that all result in ©

19:31 how am i supposed to type stuff like ∀x i really don't recommend you look up x on urban dictionary

19:33 justin_smith: heh

19:33 http://www.urbandictionary.com/define.php?term=%E2%88%80

19:37 dbasch: ∃x such that the urban dictionary entry for x is ∅

19:38 or maybe ⊂ ∅

19:39 no, belongs dammit

19:39 ∰ whatever

19:40 justin_smith: dbasch: x is a proper subset of the null set?

19:42 dbasch: I meant ∈

19:42 but I can barely type regular ascii characters

19:43 justin_smith: dbasch: do you use emacs?

19:43 dbasch: I do

19:44 justin_smith: M-x insert-char allows globs and tab completion

19:44 you type in the name of the unicode symbol to insert it

19:44 ☃ (SNOWMAN)

19:44 catern: woah

19:44 dbasch: ∀your base, your base ∈ us

19:44 catern: that's cool

19:45 justin_smith: also M-x describe-char tells you the UNICODE NAME of the char so you can insert-char another time

19:45 nullptr: wow, never knew that λ

19:45 dbasch: I need to drop colloquy and consolidate inside emacs

19:45 nullptr: (inc emacs)

19:45 lazybot: ⇒ 4

19:45 justin_smith: ie. ∈ is ELEMENT OF

19:48 at one point I had a piece of elisp code that collected every unicode symbol that had the property Ps (Punctuation, Open) and their matching Pe (Punctuation, Close) item

19:49 for ideas on how we could generalize clojure for more collection types

19:49 turns out there are hundreds of them...

19:51 verma: I've seen in some tbaldrige screencasts the fn is replaced by the lambda symbol, what sorcery is that?

19:51 justin_smith: there is an emacs mode for that (it only effects display, not file contents)

19:52 verma: http://www.emacswiki.org/PrettyLambda

19:52 verma: nice

19:53 justin_smith: that links to the more general pretty-symbol, and I think that has a clojure specific variant

19:53 verma: thanks!

19:53 found this for vim: http://demonastery.org/2012/07/lambda-conceal-in-vim/

19:54 justin_smith: https://github.com/jimweirich/emacs-setup-esk/blob/master/pretty.el here's one for clojure lambda

19:54 verma: nice, thanks justin_smith

19:55 amalloy: justin_smith: that one refers to functions that don't exist unless you install ESK, like esk-pretty-lambdas

19:55 justin_smith: oh, yeah, don't use that

19:56 verma: oh no way! https://github.com/fwolanski/vim-clojure-conceal

19:56 :)

19:57 technomancy: racket lets you just put λ directly in your code

19:58 justin_smith: clojure would let you do that too, but any collaborators would hate you for it

19:58 technomancy: pfff, collaborators

19:58 verma: is racket .. umm .. popular?

19:58 amalloy: probably has more users than clojure? i guess i'm not sure

19:58 technomancy: verma: it's got roughly 50% as many projects as clojure on github iirc

19:58 amalloy: it's in the ballpark, anyway

19:58 technomancy: so less popular, but not by an order of magnitude

19:59 verma: nice, it looks fun

19:59 technomancy: verma: it's great

19:59 amalloy: justin_smith: collaborators will hate you regardless

19:59 verma: technomancy, you writing any fun stuff in it?

19:59 justin_smith: ,(def ☠ "touch this and die" ())

19:59 clojurebot: #'sandbox/☠

19:59 technomancy: verma: yeah. working on a hypercard clone.

20:00 nullptr: if you are using a very recent version of emacs, `prettify-symbols-mode' is a built-in

20:00 technomancy: verma: https://github.com/technomancy/cooper

20:00 nullptr: and by default you get lambdas in lisp-modes (clojure included)

20:00 technomancy: the gui and drawing libs especially are great

20:00 amalloy: like any time i give a talk about utility libraries or macros, the Q&A is like "but wait, won't people have to understand the new abstractions/shortcuts you wrote to understand your code?"

20:00 verma: technomancy, sweet! taking a look

20:00 amalloy: and it's like...do you *really* want to start every project at a base abstraction level of zero?

20:01 justin_smith: amalloy: but you define a function here - how can someone use that function without reading and understanding your code?

20:01 amalloy: justin_smith: that argument never convinces anyone, it turns out

20:01 so anyway, those people will hate you regardless of what you do

20:01 hiredman: I love my unicode joins https://github.com/hiredman/graph/blob/master/src/com/manigfeald/graph.clj#L286-L296

20:01 catern: justin_smith: I can see you're putting to use the function you mentioned in #emacs

20:01 technomancy: amalloy: well, obviously the more you diverge from clojure.core, the more you're asking people to keep in their heads

20:02 it's a matter of cost/benefit

20:02 justin_smith: catern: I'm in #emacs?

20:02 dbasch: amalloy: before I start a new project, I go to the beach and bring a bucket of sand so I can make my own nand gates

20:02 verma: hiredman, how do people type those in?

20:02 justin_smith: catern: or you mean I used insert-char SKULL AND CROSSBONES - yeah

20:02 hiredman: I read somewhere if you use non-blocking io you can scale up human understanding by 10x

20:03 verma: I use M-x ucs-insert and completion

20:03 catern: justin_smith: yeah, sorry, I just assumed that I was in #emacs when I saw that before

20:03 verma: hiredman, hmm, nice

20:04 dbasch: technomancy: I guess his point is that if you make (defmacro fetch) happen, then people don’t have to look it up every time they see it

20:04 amalloy: technomancy: not really. if some utility helps compute whatever my program does, then i have three choices: (1) don't use that utility, inlining something like it whenever necessary; (2) define the utility in my program and reuse it there; (3) use the utility from my utility project

20:04 (2) and (3) are the same except for where the code is located, and arguing for (1) is arguing that you shouldn't build abstractions

20:05 in all cases, whoever reads my code has to understand whatever the utility function would do

20:05 technomancy: amalloy: oh you're talking about separate libs specifically

20:05 justin_smith: catern: #clojure goes off topic a lot but not nearly as much as #emacs

20:06 catern: justin_smith: hey what's wrong with that

20:06 technomancy: verma: let me know what you think if you try it

20:06 verma: technomancy, sure, starting to play with racket a little bit

20:07 technomancy: verma: I'm working on a blog post about that project specifically, and then I hope to follow up with one on FP in racket more generally

20:07 verma: take a look at fstruct.rkt for more on that topic; should help you feel more at home coming from clojure

20:07 verma: nice

20:08 technomancy: structs that are callable like functions and support the dictionary interface

20:09 racket is mostly FP-friendly, but the default structs feel like they're more designed for imperative work

20:09 easy fix though =)

20:16 kenrestivo: hiredman: what is this ⨝ ?

20:19 amalloy: kenrestivo: 0x2A1D JOIN

20:21 dbasch: I just realized that the ‘decode’ part of this library doesn’t even work https://github.com/talkto/geohash

20:22 the example given in the readme encodes something and then decodes to something different

20:25 hiredman: http://en.wikipedia.org/wiki/Relational_algebra

20:25 (not that I used it as a natrual join)

20:26 http://en.wikipedia.org/wiki/Relational_algebra#.CE.B8-join_and_equijoin

20:30 kenrestivo: hiredman: thanks

20:41 Ymesio: Hi all

20:41 So I have a collection of numbers, say 1,2,3,4

20:42 I need to map over it, but what I need is not the Nth value, but aclually the list with Nth value removed

20:42 So I would get 2 3 4 then 1 3 4 then 1 2 4 then 1 2 3

20:42 What would be the best way to do that?

20:43 justin_smith: is the order important?

20:44 Ymesio: Not really

20:45 justin_smith: ,(let [input [1 2 3 4]] (map #(disj (set input) %) input))

20:45 clojurebot: (#{4 3 2} #{1 4 3} #{1 4 2} #{1 3 2})

20:45 justin_smith: you could do something less elegant with remove and an equality predicate if ordering was important

20:49 Ymesio: justin_smith: Looks like that could work thanks a lot

20:49 justin_smith: ,(let [input [1 2 3 4]] (map #(remove #{%} input) input))

20:49 clojurebot: ((2 3 4) (1 3 4) (1 2 4) (1 2 3))

20:49 justin_smith: an alternative

20:49 I like the former better though (as long as unordered sets are OK of course)

20:52 Ymesio: I’d assume disjunction is be constant

20:52 * should be

20:54 justin_smith: Thanks, will use the first one

20:54 justin_smith: yeah, there is the overhead of creating the set once, but disj is constant time

20:55 exactly

20:55 amalloy: justin_smith: that's not much good if you have duplicate elements

20:56 justin_smith: yes, that's also an important point

20:56 amalloy: you knida need a frequency map instead of a set, if you want to handle that possibility

20:56 Ymesio: I don’t have any duplicates

20:58 wei: did filter-key get removed?

20:58 Ymesio: justin_smith: thanks again

20:58 justin_smith: Ymesio: np

20:59 wei: looks like it is private? http://www.clodoc.org/doc/clojure.core/filter-key

21:00 (doc clojure.core/filter-key)

21:00 clojurebot: "([keyfn pred amap]); "

21:00 justin_smith: $source clojure.core/filter-key

21:00 lazybot: clojure.core/filter-key is http://is.gd/VSfdpE

21:00 justin_smith: well, lazybot gives us the 1.4 version...

21:01 dbasch: Ymesio: you can do (concat (take n x) (drop (inc n) x))

21:01 justin_smith: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L3923 but yeah, still private

21:01 wei: is there a public function to return key-value pairs where the key fits a predicate? i guess it’s not too hard to write it, but i always trust core functions’ performance :)

21:01 dbasch: or something to that effect

21:01 Ymesio: ,(concat (take n x) (drop (inc n) x))

21:01 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: n in this context, compiling:(NO_SOURCE_PATH:0:0)>

21:02 justin_smith: Ymesio: definitely not constant time, but that is definitely another approach

21:03 dbasch: ,(let [n 2 x (range 5)] (concat (take n x) (drop (inc n) x)))

21:03 clojurebot: (0 1 3 4)

21:04 justin_smith: ,(let [input {1 :a 2 :b 3 :c 4 :d}] (select-keys input (filter even? (keys input)))) ; wei

21:04 clojurebot: {2 :b, 4 :d}

21:04 wei: justin_smith: fair enough, thanks

21:04 (inc justin_smith)

21:04 lazybot: ⇒ 87

21:16 gfredericks: reiddraper: I'm watching this shrink that has taken the 2nd child for about the 400th time straight and realized I could do a kind of binary search down the shrink tree to jump to wherever that pattern quits

21:17 * gfredericks assumes that doesn't really make any sense

21:21 justin_smith: gfredericks: out of context you sound like a weird parent talking about his kid's psychologist

21:21 catern: yes

21:21 i just flipped to this channel in IRC and that's how I interpreted

21:21 it

21:25 danneu: i upgraded cider and now my *cider-error* buffer briefly flashes an error before going blank. i have to C-c C-z to see the error on the repl

21:25 https://dl.dropboxusercontent.com/spa/quq37nq1583x0lf/oth82eom.png

21:27 justin_smith: ~cider

21:27 clojurebot: cider is Cider is unstable and broken right now, most things don't work. Use the last stable version of nrepl.el for now.

21:27 justin_smith: heh, I wondered what clojurebot had to say about that

21:27 amalloy: probably not far off

21:28 justin_smith: ~nrepl

21:28 clojurebot: nrepl is a network REPL implementation: http://github.com/clojure/tools.nrepl

21:28 justin_smith: ~slime

21:28 clojurebot: Titim gan éirí ort.

21:28 arrdem: dbasch: any solutions to that recovery prolblem?

21:28 dbasch: not yet

21:29 in casee someone is interested here, I shuffled a paragraph from a fairly popular book: http://pastebin.com/raw.php?i=GGhh3WA2

21:29 the idea is to recover it

21:30 justin_smith: translation of that factoid above: "May you fall without risinge"

21:30 (sic)

21:32 grandy___: anyone here used secretary?

21:32 ~secretary

21:32 clojurebot: Huh?

21:32 dbasch: I believe seangrove did

21:32 grandy___: seangrove: true?

21:33 trying to figure out the best way to navigate between "pages" and update the url shown in the browser

21:33 dbasch: grandy___: at least it’s in this app https://github.com/sgrove/omchaya/blob/fe5861e7f483e0f6ac2b1685dfaca2c680e36c32/src/omchaya/routes.cljs

21:34 grandy___: dbasch: hmm looking

21:34 dbasch: he's not handling the use case i'm curious about

23:02 cfleming: arrdem: BTW looks like there's an old, non-functioning Grimoire at http://www.arrdem.com/grimoire/ - you might want to redirect to the new one

23:12 arrdem: cfleming: yeah that is an old version.. I thought it was redirecting

23:12 cfleming: I'll check it out, thanks

23:12 cfleming: arrdem: NP

23:13 arrdem: BTW something I like a lot about the new ClojureDocs is that I can navigate it without much mousage. I like the Grimoire narrow-down search, but if I type, say, cond-> into the search box, enter doesn't take me to it - that would be really nice.

23:13 arrdem: The crossclj integration is awesome BTW.

23:35 celwell: How could I make map that returns a certain value when a requested key does not exist?

23:36 justin_smith: celwell: it takes an extra arg for that

23:36 ,({} :a :not-found)

23:36 clojurebot: :not-found

23:36 justin_smith: if you need to hard code a default, maybe you need a function and not a map?

23:38 celwell: justin_smith: maybe, i was hoping to not use a function though. I'd like to have something like:

23:38 (def form-id-aliases

23:38 {1 {:patient-questionnaire [2 4 5 6 7 8 9 11]}

23:38 2 {:patient-questionnaire [2 4 5 6 7 8 9 11 13 14]}

23:38 :not-found {:patient-questionnaire [2 4 5 6]}})

23:38 I guess there's no simple way to do that?

23:39 justin_smith: you could use a custom lookup function and pass both the map and key, and let the lookup function specify or find the default

23:39 finally, it is actually possible to extend the interfaces and protocols that a map does, with custom defaulting behavior, but that may be more work than is worth it

23:39 celwell: is it possible to make a 'lazy-map

23:40 ' ... that fills in all the missing vals

23:40 justin_smith: not with the standard map type, no

23:40 celwell: hmm.. ok I'll probably have to just use the :not-found thing in a ll my lookups

23:41 justin_smith: (defn get-with-default [m k] (m k (:not-found m)))

23:41 you can probably give it a less messy name

23:42 celwell: yeah, thanks

23:43 ToxicFrog: ,(let [my-map {:a 1 :b 2 :not-found "kittens"} my-map-with-default #(my-map % (my-map :not-found))] [(my-map-with-default :a) (my-map-with-default :z)])

23:43 clojurebot: [1 "kittens"]

Logging service provided by n01se.net