#clojure logs

2014-10-06

01:47jergasonis there a way to specify that I just want the latest version of a dependency in my project.clj file? putting * didn't work
01:50Kneiva"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
01:50Kneivathat's from here: http://stackoverflow.com/questions/30571/how-do-i-tell-maven-to-use-the-latest-version-of-a-dependency
01:52sm0kein 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?
01:53Kneivajergason: but if you really want to do it: http://stackoverflow.com/a/5698227/1790621
01:53Kneivajergason: oh, that might be outdated
01:53jergasonKneiva: ah, i didn't know it used maven under the hood. i'm pretty new to the jvm
02:54mercwithamouthping
03:04Guest80083pong
03:46mercwithamouthok all of a sudden cider-jack-in stopped working. i'm geting a lein execuable isn't on exec-path
03:46mercwithamouthi've never had that issue before...
03:50daniel___looking for a clojure way of solving this problem: https://gist.github.com/danielstockton/419abc82332703edc230
03:52daniel___seems tricky to avoid stackoverflow errors
04:00mercwithamouthany cider guys here? getting an error when repl starts http://pastie.org/9624243
04:00mercwithamouthmore than likely clojure--prettify-symbols-alist should have a single '-'???
04:00lazybotmercwithamouth: How could that be wrong?
04:00snowstalkermercwithamouth 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)?
04:01mercwithamouthyeah..checking now
04:02mercwithamouthhmm cider is 8.0
04:02mercwithamouthnot sure when the hell it updated....
04:04mercwithamouthok going to remove and load the stable
04:26daniel___how would people solve this as a 4clojure type challenge? https://gist.github.com/danielstockton/419abc82332703edc230
04:27mercwithamouthlight table or emacs?
04:28daniel___vim
04:29mercwithamouth=P i used vim for years
04:33engblomSpeaking 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?
04:35daniel___engblom: sublime or something?
04:35engblomI 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.
04:39magopiandaniel___: dunno how to solve your problem, but i'd love to, so if you find the solution, please share ;)
04:40magopiangiven the number of cases to explore (factorial 26 right?), it looks like something NP
04:40magopianeven if you can trivially drop some of the cases to explore, you still have soooo many...
04:41daniel___magopian: it is NP, its basically the knapsack problem
04:42magopianyeah
04:42clojurebotGabh mo leithscéal?
04:42daniel___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
04:45borkdudeengblom I think for just one simple workshop this can be great https://github.com/bodil/catnip
04:49engblomborkdude: Thanks, I will check it up!
04:49code2learnhi, i am start learning clojure
04:49borkdudeengblom however, you need to install leiningen on their system etc. Intellij + cursive might be a good option too
04:50code2learnand want to know anyone knows how to use overtone.at-at
04:51code2learni am building a simple program to keep polling ebay
04:51cflemingengblom: 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
04:51cflemingengblom: You should also take a look at Light Table
04:53code2learnand let the program notify me whenever a needed item appears on ebay and matches with my price
04:55engblomcfleming: When looking at the home page of Cursive, it looks like it will become just a commercial product. Is that the case?
04:55cflemingengblom: It will at some point, yes.
04:56borkdudecfleming maybe you can release a simple free version with the cool things disabled
04:56cflemingborkdude: I'm definitely thinking about this, or maybe even with most of the cool parts but just a license forbidding commercial work.
04:57cflemingborkdude: That would work for both academic + OSS
04:57cflemingborkdude: 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.
04:57borkdudecfleming intellij uses this model also right
04:57borkdudecfleming e.g. no highlighting for many things in free
04:58cflemingborkdude: Right, but you have to apply to them for a free license.
04:58cflemingborkdude: Oh, that's different.
04:58borkdudecfleming yeah, when I was a lecturer I used Pycharm etc. for free
04:58cflemingborkdude: Community edition is free, right. That does all you want for Java unless you need the enterprise stuff.
04:58cflemingborkdude: But you can get free versions of Ultimate, or right, PyCharm etc, but you have to apply for them.
04:59cflemingborkdude: I don't have bandwidth to administer that so I was considering an honesty model.
05:00borkdudecfleming or a trial version for x days
05:00cflemingborkdude: Yes, I'll definitely do that either way.
05:01engblomPersonally I want cross platform solution any kid could install at home. The school is running Debian and most kids have Windows at home.
05:01engblomIf it is too difficult to obtain and install, they will never do it.
05:02cflemingengblom: 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.
05:02borkdudeengblom have you also looked at eclipse + counterclockwise, it's entirely open source/free
05:02cflemingengblom: If that uncertainty is a problem for you, I think you should check out LightTable.
05:03borkdudeengblom I have used eclipse + ccw in education
05:03borkdudeengblom not kids though
05:05mercwithamouthshould this be all i need to display my html file with compojure? http://pastie.org/9624332
05:06cflemingengblom: 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.
05:07engblomcfleming: So how do I download it?
05:07borkdudeengblom download the intellij community edition
05:07borkdudeengblom and then via the cursive site you'll find instructions how to add the plugin
05:08cflemingengblom: There are instructions here: https://cursiveclojure.com/userguide/
05:08sindudaniel___: 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
05:09cflemingengblom: 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.
05:09asQuirreLamalloy, 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
05:09sindubasically 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
05:11sinduthe idea is array[i] represents whether it's possible to have a sum of i
05:14mercwithamouthsweet..got it =P
05:14daniel___sindu, i'd rather try and solve it in a functional way
05:15daniel___my attempt is recursive and consumes all the heap space though https://gist.github.com/danielstockton/043a3d3093e90ba55657
05:51lgrapenthinI'm having trouble with using profiles and uberjar in leiningen: lein with-profiles +dev uberjar does not include dev dependencies in the uberjar
05:52Cr8tried pruning as I generated permutations, I run out of memory p quick tho
05:53hellofunkin 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?
05:54Cr8course if you just want the answer, the search space is actually not that large
05:55ddellacostahellofunk: 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.
05:55hellofunkddellacosta and it also appears that siblings and parents cannot see children's refs
05:56ddellacostahellofunk: in general, if you don't explicitly pass something down it won't be shared, as far as I know.
05:56Cr8found in haskell w/ brute force in ~30s
05:58hellofunkddellacosta some some wild photos on cnn from tokyo today
05:59ddellacostahellofunk: oh, the Typhoon? I've avoided going out, although it got sunny halfway through the day, so I did laundry...haha
05:59hellofunknice
05:59ddellacosta:-)
05:59hellofunkddellacosta are you writing an Om cookbook? or do you have a nice public place with all your collected notes and tips?
06:00ddellacostahellofunk: 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
06:00magopianwhile 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)
06:00ddellacostamagopian: neat, sounds cool
06:01magopiani've been through the basic tutorial and a few others, any advice on what to try/trial/play with, and what form?
06:01magopianddellacosta: 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 :)
06:01magopian(but remotely ;)
06:01ddellacostamagopian: still good stuff, learning together like that is great!
06:01magopianit's an experiment, we'll see if it's worth it
06:01annapawlickamagopian ddellacosta that would be awesome
06:02magopiannice if you think it's a good idea ;
06:02magopian);)
06:02hellofunkmagopian 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.
06:02ddellacostamagopian: 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.
06:02ddellacostaor, what hellofunk says ^
06:02magopianso 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)
06:02ddellacostaand maybe annapawlicka has thoughts too...
06:03ddellacostamagopian: well, be careful not to get stuck on Clojure stuff
06:03hellofunkmagopian i also recommend core.async involved as I don't think it is possible to write a really tight Om app without it
06:03magopianddellacosta: 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
06:04ddellacostamagopian: 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.
06:04magopianhellofunk: yeah, i'd like to add some of this (i've seen the screencast by swannodette, and it was awesome)
06:04annapawlickaall 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.
06:04magopiannot just sure how to fit all this in a one (or two?) hour slot
06:04ddellacostamagopian: yeah, if you can get the basics of Om across without getting mired in Clojure stuff that'd be great
06:04ddellacostaoh yeah, annapawlicka had a blog post about that, probably good to pass that around
06:04hellofunkmagopian honestly i don't think Om is an appropriate topic for those quite new to clojure or clojurescript.
06:05magopianhellofunk: ahhh, interesting point of view
06:05magopianddellacosta: do you have a link?
06:05annapawlickai shoudl probably write part ii of that post
06:05ddellacostahellofunk: 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
06:05magopianddellacosta: hellofunk: i thought about om because i'm interested in it myself, and because the two others are interested in frontend dev
06:05hellofunkddellacosta: 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
06:06ddellacostaannapawlicka: yes, you should. ;-)
06:06magopian(ember.js and angular, iirc)
06:06ddellacostahellofunk: yeah, for example--those two are big in Om
06:06magopianddellacosta: but then I could use prismatic's om-tools, and don't touch reification at all ;)
06:06magopianand use a simple enough project to not have to deal with protocols (which i still find pretty hard to grok)
06:07ddellacostamagopian: yeah, I dunno, that's reasonable too I suppose
06:08ddellacostamagopian: 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
06:08magopiani need to find a nice and dead simple project, maybe something like a todolist
06:08annapawlickai 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
06:08magopianor just a counter, or something really really really simple
06:08ddellacostamagopian: well then, funny that you mention that, I think there is a good todo list built in Om... ;-)
06:09magopianbecause i'll have to give a short overview of clojure for starters
06:09magopianddellacosta: yeah, the todolist mvc by swannodette?
06:09ddellacostamagopian: have you taken a look at the examples that David packages w/Om? there is a simple selection thing in there if I recall
06:09ddellacostamagopian: yeah, that's what I was thinking of
06:09hellofunkmagopian 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
06:10magopianhellofunk: but then it needs an understanding of the reader macros and reification
06:11ddellacostamagopian: here is annapawlicka's post about common Om mistakes, btw: http://annapawlicka.com/common-mistakes-to-avoid-when-creating-an-om-component-part-1/
06:11hellofunkmagopian -- 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.
06:11ddellacostahellofunk: yeah, kind of hard to avoid that
06:11ddellacostaI mean, there is a learning curve to all of this
06:11jonathanjdoes anyone here use plugins in vim for editing clojure code?
06:12hellofunka 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?
06:12jonathanji'm having trouble understanding how paredit is missing a feature that moves down or up a form
06:12hellofunkhe suggested "breaking out the helpers" so they weren't defined inside another function
06:12jonathanjie. something like f( but less stupid
06:12hellofunkjonathanj which ide?
06:13jonathanjvim?
06:13clojurebotGesundheit!
06:13ddellacostaah, hahaha
06:13ddellacostayou snarky clojurebot you
06:13ddellacosta,(println "is hiredman still not responding to me?")
06:13clojureboteval service is offline
06:13ddellacostayep
06:14xcthulhuhellofunk: What kind of performance hit? You might have to checkout jsperf to get any real sense of anything
06:14hellofunkxcthulhu i'm not sure what he was referrign to
06:14xcthulhuSpidermonkey and V8 have very different performance profiles for this sort of thing
06:15jonathanjit seems insane to me that there's no motion for moving down and up forms
06:15xcthulhu% goes to matching paren, usually all I use
06:15xcthulhuSince it has been a feature of VI since before I was born, I understnad
06:16jonathanjthat's not usually very useful
06:16jonathanjif you're on (defn then % takes you to the end of the function, whereas usually you want to start navigating *in* to the function
06:17mercwithamouthnot really a clojure question but....postgres or mysql?
06:17xcthulhupostgres
06:17schmirpostgres
06:18xcthulhuYou can use datomic with postgres as a backend...
06:18mercwithamouthi'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
06:18mercwithamouthxcthulhu: heh...i've been debating on trying that...
06:19xcthulhuYou should give it a shot, it’s awesome
06:19mercwithamouthi 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...
06:19xcthulhuPlus, in memory testing is pretty sweet, but you can do that with h2 as well if you don’t write really funky SQL schemas
06:19magopianhellofunk: ah, that's true, about not knowing what is om and what is om-tools
06:20mercwithamouthsigh...so datomic...i suppose i could advance the project to some sort of bookmarking/studying tool
06:21xcthulhumercwithamouth: Since it’s a toy app, what do you want to learn exactly?
06:22xcthulhuMigrations?
06:22mercwithamouthreally i'm just toying with compojure and eventually 'om'
06:22mercwithamouthi wouldn't mind putting it up publicly in time for my friends and I to use. the idea isn't 'solid' yet though.
06:23magopianhellofunk: 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 ;)
06:23ddellacostamagopian: good luck! And have fun. :-)
06:23magopian4;3~thanks ;)
06:24xcthulhuIf you have the bandwidth, I say checkout datomic
06:25xcthulhuEspecially if you want to have your database behave like a graph
06:26xcthulhuWhich sounds vaguely like what you want to do
06:27hellofunkddellacosta: annapawlicka: what are the common sources of js memory leaks you see from using Om/cljs?
06:28ddellacostahellofunk: not sure I've seen Om-specific memory leaks
06:28annapawlickahellofunk: what ddellacosta said
06:29hellofunki wonder if the cljs closures are giving me the leaks i see. have yet to do robust profiling
06:29ddellacostahellofunk: a clojure in and of itself shouldn't cause a memory leak, just depends on how you're using it
06:29ddellacostahellofunk: er... *closure
06:33hellofunkddellacosta ok
06:34amalloyleaking dom nodes? that happens all the time in js, doesn't it?
06:34ddellacostaamalloy: sure, just not sure there is anything specific to Om there
06:34ddellacostanot that I know of at least. May be.
06:35amalloyno, but hellofunk didn't say om-specific, just "when using om"
06:35ddellacostaamalloy: okay, fair enough. :-)
06:37daniel___amalloy, you like a good problem
06:37daniel___might be one for 4clojure
06:37daniel___https://gist.github.com/danielstockton/043a3d3093e90ba55657
06:37daniel___i havent come up with a solution yet
06:38amalloyi actually was just starting on that
06:39amalloyit looks kinda like the knapsack problem, really, but might be tractable at that size
06:44daniel___im not really sure how to do it without a brute force type approach, and always run out of heap space
06:47xcthulhuWell, so don’t brute force it
06:47xcthulhuAs you go along, picking populations, keep a running sum
06:48xcthulhuIf the running sum gets too big, don’t follow that branch
06:48amalloyxcthulhu: that's still pretty brute-force, and the first thing i tried
06:48amalloyyou're still in the position of trying to solve the knapsack problem with the greedy algorithm :P
06:50xcthulhuYou have to do backtrack search, but you don’t keep every path in memory, right?
06:51xcthulhuOkay, I guess this is what you are doing
06:52amalloyxcthulhu: even if memory weren't an issue, 2^26 is a large enough search space that you need more clever pruning
06:52amalloyjust removing the most obviously-impossible stuff isn't good enough
06:52xcthulhu*grumble* back to depth first forests :(
06:53xcthulhuOr you could be dumber than that and try annealing?
06:54xcthulhuDoesn’t seem like an annealing problem
06:54xcthulhuYou should use this as a cruel interview question
06:55amalloydaniel___: https://gist.github.com/amalloy/70c58e289de9e892468d is the obvious approach that xcthulhu and i thought of first
06:56amalloybut 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
06:56amalloyso, that's all from me and i'm off to bed. let me know if you figure out the trick
06:57Johannes`hi, when I run http://pastebin.com/t7wqhBCW in the REPL, the loop form is executed before the dotimes form. why is this?
06:59daniel___amalloy_: no, i have no reason to suspect there is a neat trick
07:01Johannes`dotimes only runs after (get-number) has returned
07:06daniel___i still get a java heap space error with this algo, maybe i need to configure something on the jvm to allow more memory?
07:07daniel___anyway, nn
07:30noncom|2i 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 ?
07:41perplexanoncom|2: sounds like real bad application architecture in first place
07:42noncom|2perplexa: security and stuff, exceptions and stuff, right.. but that is for a sandbox, so i think that it is acceptable..
07:44perplexai 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
07:44perplexa+s
07:45noncom|2perplexa: i want to have a persistant clojure repl running, with possibility to reload classes from their source files..
07:45noncom|2i know that sounds creepy
07:45noncom|2for many reasons
07:46noncom|2but 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
07:46noncom|2it is supposed that the users realize all the risks and take the necessary care..
07:47perplexahm i don't know how to do that, sorry
07:47perplexagood luck, tho
07:56dysfunit's not trivially solveable for java. you need something like jrebel for that
07:56dysfunor some clever ide integration
08:05dysfuncan i make a keyword function part of a protocol?
08:06dysfunit seems like an ugly solution
08:06dysfunno. i can imagine why
08:06CookedGryphonnoncom|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
08:08dysfunreload is a little harder
08:15noncom|2yeah, well, ok... i imagine i can compile and load a class, but what about recompile and reload ?
08:21szymanowskihello, i'm searching a way of overwriting object's method while keeping all others methods as is
08:22szymanowskioverwriting an object's method
08:22szymanowskiis it possible with proxy?
08:30agarmannoncom|2: you can reload by swapping classloaders
08:30agarmannoncom|2: if you load the class through your apps primary classloader, you'll have a hard time reloading
08:35noncom|2agarman: so you're saying that i just have to create a custom classloader for every reload operation ?
08:36agarmannoncom|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
08:37noncom|2agarman: thank you, this is a very valuable piece of info !
08:37agarmannoncom|2: good luck
08:38agarmannoncom|2: https://github.com/zeroturnaround/jf-hw-classloaders may be relevant to what you're wanting to do
08:41noncom|2yes, really, that's it
08:41agarmannoncom|2: ^_^
09:59grandy___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:02AeroNotix_https://gist.github.com/AeroNotix/1c669b4af6fedf952e63
10:02AeroNotix_any ideas?
10:07justin_smithAeroNotix_: maybe run lein clean and try again?
10:07justin_smithweird that it would be trying to include something in the "stale" directory
10:07AeroNotix_justin_smith: it's a permissions issue
10:07AeroNotix_It's building in a directory it doesn't have permissions for
10:07AeroNotix_excellent handling of that though
10:09clgvAeroNotix_: file an issue for it.
10:10AeroNotix_clgv: need to fully understand it first
10:10necronianIs 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:10AeroNotix_fuuuuuuuuuuuck and that host just got deleted
10:12AeroNotix_clgv: well I can't debug that now https://github.com/technomancy/leiningen/issues/1724 created an issue for it
10:12clgvnecronian: 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:13clgvAeroNotix_: you should specify that you want a better error message there ;)
10:14AeroNotix_clgv: I should hope that's obvious
10:15clgvAeroNotix_: well, the point of issues is to be as specific as possible so no implicit knowledge is require to work on it
10:16necronianclgv: Thanks, so it's probably just an accident. I was thinking maybe there was some sort of magic happening I didn't understand.
10:16clgvAeroNotix_: right now your ticket could be closed with "This exception is expected."
10:17clgvnecronian: yeah, maybe they had some local bindings in an earlier version of those snippet
10:17AeroNotix_clgv: clearly the exception should be raised when it couldn't write the file that it later expects it to be there?
10:18AeroNotix_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:18AeroNotix_clgv: we'll catch up later.
10:18clgvAeroNotix_: just specify what you think is wrong with the behaviour you described or be disappointed if it just sits there unresolved ;)
10:19AeroNotix_clgv: I don't have time right
10:36ben_mHey 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:37clgvben_m: not in clojure.core
10:38ben_mToo bad, I'll have to think of another way then :)
10:38clgvben_m: but you can write it yourself pretty easily, just adapt the implementation of `map`
10:39ben_mThere's likely a better solution, I'm just approaching this weirdly.
10:40clgvben_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:41clgvben_m: `or` instead of `and` in the 2/3 arity cases
10:41ben_mI 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:41clgvthen you'll get `nil` and just need to insert the default value instead
10:41ben_mclgv: Writing that function wouldn't be a problem, I just feel like there's a nicer way of doing what I described.
10:41ben_mBut thanks :)
10:41borkdudedo many people use :pre and :post in clojure functions?
10:41borkdudeI haven't used them much
10:42borkdudebut maybe I should
10:42justin_smithben_m: sounds like a 4clojure problem I've seen
10:42clgvborkdude: I always was not sure if I could turn them off in a production release ;)
10:42ben_mjustin_smith: Project Euler, that's why I'm intentionally not just stating the full problem :D
10:42borkdudeclgv and are you sure now?
10:43justin_smithben_m: you can do that kind of combinatorial thing with recursive calls to mapcat
10:43justin_smithben_m: mapcat because each input element can become 0 or more output elements (as opposed to 1:1 with map)
10:44ben_mI did it using mapcat and then regrouping using group-by, but that's kind of ugly.
10:44ben_mBut 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:45justin_smithI would think there is a mapcat variation without group-by
10:46ben_mjustin_smith: This is what I'm trying to write currently http://sprunge.us/WNCK
10:48ben_mBetter paste http://sprunge.us/XZgU
10:49ben_mAlmost there.
10:49justin_smithben_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:50justin_smithwhich works, and is reasonably efficient, but like many graph algorithms is definitely not the most concise way to solve the problem
10:50ben_mjustin_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:50justin_smithben_m: same problem then :)
10:51daniel___who likes challenges? https://gist.github.com/danielstockton/043a3d3093e90ba55657
10:51daniel___keep getting stackoverflow errors
10:52justin_smithconcat will do that
10:52justin_smithwhat happens is the laziness causes multiple calls to concat to stack up
10:52justin_smithand by the time you force the laziness, it explodes on the stack
10:52daniel___mhm
10:52daniel___lazy-cat?
10:54justin_smithI don't think lazy-cat will help here - in fact the stacked up laziness is a big part of the problem
10:54daniel___it did :D
10:54daniel___did i just get lucky?
10:54justin_smithoh, I guess I was wrong
10:54daniel___yeah, seems to work
10:54daniel___i think its the fact it means the recursive call is lazy?
10:54justin_smithI don't really get how lazy-cat avoids the concat pileup problem, but if it does, great
10:55daniel___its the pile up of summing-to perhaps
10:55justin_smithcould be the way laziness linearizes recursion into thunks representing the next step
10:58clgvborkdude: no, not really
11:10justin_smithclgv: 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:12clgvjustin_smith: what does that mean for clojure's :pre :post? they are usually enabled by default
11:12justin_smiththey generate assertions, when you make a jar, java decides whether assertions are run
11:12justin_smithclojure uses jvm native assertions, they are a feature the vm controls
11:13clgvjustin_smith: but are you sure that's the same mechanism since it says "by default disabled"
11:13justin_smithwhen you run java -jar, yes, disabled
11:13justin_smithhmm - now I see your point
11:14justin_smithhttp://stackoverflow.com/questions/24949418/how-to-disable-clojure-assertions-including-preconditions
11:14justin_smith,*assert*
11:14clojurebottrue
11:14justin_smiththere we go
11:14borkdudeI wish I could make assert a little more expressive, like in (let [x "foo"] (assert (number? x)))
11:14borkdudenow it prints Assert failed: (number? x)
11:14clgvah right I vaguely remembered a dynamic binding
11:15borkdudeI want to see: "foo is not a number"
11:15clgv,(doc assert)
11:15clojurebot"([x] [x message]); Evaluates expr and throws an exception if it does not evaluate to logical true."
11:15clgv,(assert (number? 'x) "foo is not a number")
11:15clojurebot#<AssertionError java.lang.AssertionError: Assert failed: foo is not a number\n(number? (quote x))>
11:16justin_smith,(binding [*assert* false] (assert false) true)
11:16clojurebot#<AssertionError java.lang.AssertionError: Assert failed: false>
11:16justin_smithhmm
11:17justin_smith,(set! *assert* false)
11:17clojurebot#<IllegalStateException java.lang.IllegalStateException: Can't change/establish root binding of: *assert* with set>
11:17justin_smithahh, can't do it on clojurebot, but that is how it is done (works in my repl)
11:18clgvjustin_smith: yeah that wont work.
11:18clgvjustin_smith: it must be set befor your actual files are compiled
11:18justin_smithahh, of course
11:18justin_smithso yeah, set it in project.clj
11:18clgvjustin_smith: so :global-vars or java commandline are the only places where it has an effect
11:19justin_smithwell, setting it will effect things compiled after that point
11:19justin_smithso you could turn off assertions before requiring other code... but that seems messy
11:19clgvyeah right, without AOT that is tricky
11:19borkdudeclgv yeah, but those are not used by default in defn
11:20clgvborkdude: ah ok you meant for _pre/:post ...
11:20borkdudeclgv yeah
11:21borkdudeclgv I guess this is what Schema is for
11:21clgvborkdude: maybe contracts are the better choice: https://github.com/clojure/core.contracts
11:21clgvah well that schema lib probably as well...
11:24borkdudeclgv or core.typed
11:25borkdudeclgv or Haskell
11:25borkdude:P
11:41Fenderok, 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:42Fenderforgot some quotes
11:42Fenderthing is not that my code doesnt compile, it's that it returns (first args)
11:45Fendereven (list #'reduce #'println (first targs) (rest targs)) doesnt print anything
11:45Fenderbut (cons f (cons some-param targs)) does
11:47borkdudeI thought to myself: which idiot calls a function like (#'function ...)
11:47borkdudebut I did it myself because the function was prive
11:47borkdudeprivate ;)
11:48borkdudeunit tests
11:48Fenderwell, you also might need it in web handlers
11:48Fenderbut that's something else
11:49justin_smithFender: why would (list #'reduce #'println (first targs) (rest targs)) print anything? is this a macro?
11:50Fenderits just for testing
11:50FenderI want to substitute println by something else
11:52justin_smithbut 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:53clgv,(reduce #(do (println %2) %1) nil (range 5))
11:53clojurebot0\n1\n2\n3\n4\n
11:53borkdudeFender I know
11:53justin_smithclgv: but that's not what he was doing - he was literally putting #'println in a list
11:53clgvthough a `doseq` would be the right tools here ;)
11:54clgvjustin_smith: I just showed him how his goal of printing via reduce would work
11:54justin_smithoh, I had no idea what any of that was supposed to do
11:55Fenderwell, I was talking more like (eval (list reduce (list 'fn ...) )
11:56justin_smitheval is bad. Always look for a way not to use eval.
11:56Fenderas I said, "I want to return the sexpr represenation of function call"
11:56grandy___anyone know the best way using secretary to make routes show up in the location when they are navigated to?
11:56Fenderthanks justin, I know that
11:58clgvyou want to retrieve the sexpr that defines a function?
11:58Fendereaxactly
11:58Fenderand I got it
11:58clgvwell, no idea what your problem is then..
11:58Fenderthe targs had to be made a list by (cons list ...) again
11:59Fenderimagine you get a function description (sexpr) via eMail and you want to offer this function via a web service to the subscriber
12:00Fendersexpr is basically just the mathematic subset of clojure
12:00justin_smithFender: so something like serializable-fn
12:00justin_smithhttps://github.com/technomancy/serializable-fn
12:01Fenderactually the opposite
12:01clgvjustin_smith: I thought he said he managed that already?
12:01FenderI get a function description
12:01Fenderbut thanks anway
12:02danneuhas anyone deployed an uberjar straight to heroku, bypassing heroku's own build process?
12:03clgvto get a compiled function from an s-expr represented string you can just used read-string and eval
12:04Fenderwell, as said, I had to transform the arguments beforehand
12:04Fenderand the function actually was also transformed
12:05justin_smithso you are hand rolling a substitute for macros
12:05Fenderkind of
12:05FenderI think thats a good description
12:07technomancydanneu: you could do that with the new build api https://blog.heroku.com/archives/2014/5/21/introducing_programmatic_builds_on_heroku
12:07technomancyhaven't tried it myself
12:08danneutechnomancy: thanks
12:08technomancydanneu: sorry, this link is better https://blog.heroku.com/archives/2013/12/20/programmatically_release_code_to_heroku_using_the_platform_api
12:16mbac(.. java.net.InetAddress getLocalHost getHostName)
12:16mbacwhat's ..?
12:16ToxicFrogRepeated .
12:17ToxicFrogeqv to java.net.InetAddress.getLocalHost().getHostName()
12:17nullptrhttp://clojure.org/java_interop#Java Interop-The Dot special form-(.. instance-expr member+)
12:17mbacwhoa
12:18clgv,(.. java.net.InetAddress getLocalHost getHostName)
12:18clojurebot"localhost"
12:18clgvhehe
12:19mbaccute
12:24TimMcIt expands to (-> java.net.InetAddress (.getLocalHost) (.getHostName))
12:25TimMcerr... almost
12:26TimMcI guess .. has some special logic to turn that first call into a static method call.
12:34clgv,(macroexpand-1 '(.. java.net.InetAddress getLocalHost getHostName))
12:34clojurebot(.. (. java.net.InetAddress getLocalHost) getHostName)
12:34danneui have to stop and think about it every time i see '..' and '.'
12:34clgv,(. Long (parseLong "42"))
12:34clojurebot42
12:35clgvas it seems there is no special logic needed for static calls
12:36technomancy. isn't meant for direct usage
12:36technomancyand .. is pretty archaic too
12:39borkdudeinteger? returns true for all longs?
12:39Bronsaborkdude: the docstring never mentions any concrete java class
12:39borkdudek, I'm looking at the source now
12:40borkdudeBronsa what do you mean, never?
12:40dbaschborkdude: yes
12:40Bronsainteger doesn't mean Integer
12:40virmundiHello. 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:41dbaschvirmundi: no, side effects usually mean changing state
12:41dbaschlog is similar to print
12:42virmundiOk. Thanks.
12:43borkdudeBronsa k
12:49TimMcSo it's really . that has the smarts.
12:50Nova_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:52gfredericksAny guesses why adding lein-cljsbuild repl-listen code to the om tutorial gives me a repl that hangs on eval?
13:05mdeboardgfredericks: It's because you don't have a browser window open to the page I bet
13:05mdeboardthe right port etc
13:06mdeboardit's just waiting for a browser to eval the code in, I think.
13:13michaelmeixnernewbie has a short question
13:14michaelmeixnerI want to calculate the deltas between the elements of a vector
13:14michaelmeixnersay [2 3 5 8]
13:14michaelmeixnerI found I can do :
13:15michaelmeixner(partition 2 1 [2 3 5 8])
13:15ben_m(map - coll (rest coll))
13:15michaelmeixnerah ...
13:16ben_mChange - to a lambda if you want absolute deltas of course :)
13:16michaelmeixnergreat, thanks - I knew there had to be a simple solution
13:17michaelmeixnerthanks again
13:17justin_smithmichaelmeixner: there is also (map #(apply - %) (partition 2 1 coll))
13:17ben_mmichaelmeixner: You're welcome
13:27literaryhelp
13:27ben_m911?
13:28lavokad:D
13:28literaryCaused by: java.lang.IllegalArgumentException: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil
13:28literarywth
13:28literaryjava.lang.ExceptionInInitializerError
13:29nooniansounds like some sort of null pointer exception
13:29noonianyou are passing nil to something where you think you have a non-nil value
13:29literaryits on line 1 of a file
13:29literarythe (ns) line
13:36literaryit fails consistently, and did not fail on friday.
13:36literaryi have no understanding of why it fails.
13:36justin_smithcan you share a paste of the ns declaration?
13:37noonianliterary: 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:42Bronsaliterary: are you using core.typed?
13:43literaryno
13:43mdeboardhm
13:43Bronsaliterary: you need to post the source that's causing that exception anyway, we can't help you only with that exception
13:44mdeboardCan someone help me understand why this happens
13:44mdeboard&(apply Math/abs [-1 -2 -3])
13:44lazybotjava.lang.RuntimeException: Unable to find static field: abs in class java.lang.Math
13:44Bronsamdeboard: methods aren't first class objects like functions
13:44justin_smithmdeboard: methods are not first class
13:44mdeboardI see
13:44ben_m&(apply #(Math/abs %) [-1 -2 -3])
13:44lazybotclojure.lang.ArityException: Wrong number of args (3) passed to: sandbox5671$eval12864$fn
13:45ben_mWell whatever but that.
13:45Bronsamdeboard: there's really no good wayt to use apply with static methods
13:45mdeboardwell yeah but I got that too, and don't understand
13:45mdeboardBronsa: I see, ok
13:45mdeboardyou can't use map either right
13:45mdeboardor reduce
13:45mdeboard(no reduce implies no map, you're right
13:45mdeboard)
13:45Bronsamdeboard: well you can, you just have to wrap the method call in an anonymous function
13:46justin_smithmdeboard: only first class Objects can be arguments to functions
13:47mdeboardOh right
13:47mdeboard&(apply #(Math/abs %) [-1])
13:47lazybot⇒ 1
13:47literaryBronsa, noonian, https://gist.github.com/anonymous/4f4463805ba92ca1036b
13:47mdeboardunderstood
13:48mdeboardI got nerd-sniped
13:48Bronsamdeboard: 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:49TimMcDon't tell me what I have to do!
13:49mdeboard&(let [coll [2 3 5 8]] (map (comp #(Math/abs %) -) coll (rest coll)))
13:49lazybot⇒ (1 2 3)
13:50mdeboardben_m nerd-sniped me
13:50mdeboardwith the absolute value thing
13:50ben_mI knew why it didn't work but I didn't immediately know how to fix it.
13:50noonianliterary: 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:51literaryyes
13:52TimMc&"you there?"
13:52lazybot⇒ "you there?"
13:52TimMcBronsa: ##(apply #(clojure.lang.Reflector/invokeStaticMethodVariadic "java.lang.Math" "abs" (object-array %&)) [-1])
13:52lazybotjava.lang.SecurityException: You tripped the alarm! class clojure.lang.Reflector is bad!
13:52grandy___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:52grandy___ideas?
13:52TimMcoy
13:52noonianliterary: 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:53literarythank
13:53TimMc,(apply #(clojure.lang.Reflector/invokeStaticMethodVariadic "java.lang.Math" "abs" (object-array %&)) [-1]) ;; let's try the other parent
13:53clojurebot1
13:53literarylein repl fails for me
13:53literaryException in thread "main" java.lang.ExceptionInInitializerError
13:53literary(inc TimMc)
13:53lazybot⇒ 72
13:54noonianliterary: if you have a :main key in your project.clj just comment that out for now
13:54noonianliterary: then your repl should start up in the 'user namespace
13:54BronsaTimMc: c.l.Reflector is cheating
13:54literarydoes
13:54TimMcliterary: I wonder how many of my karma points are for awful ideas I give to people.
13:54TimMcBronsa: :-D
13:55literaryTimMc: 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:57literaryfound it
13:57literary(slurp nil)
13:57literaryclojure.java.io/resource stopped working in tests at some point
13:57noonianliterary: nice!
13:57literarynot that it ever was *executed* during tests,
13:57literarybut now it no longer even compiles during tests
13:57jba-123what's the recommended way to have multiple core-async listener ?
13:57literaryoh wait its not in a funciton its in a def
13:57literarythanks you noon ian
13:58noonianno problem
13:58literaryi really think this is the worst error message
13:58literaryi think even perl is more readable
13:58literaryand nobody can read perl not even perl parsers
14:01bbloomseems like puredanger is going around bumping tickets to 1.8
14:02bbloomi guess that means a 1.7 release is eminent
14:03Bronsabbloom: yeah, I'm a bit disappointed that critical bugs are getting postponed once again though :/
14:04bbloomBronsa: i'm only disappointed b/c i know how slow the release cycle is. i understand the desire to ship transducers though
14:04bbloommaybe 1.8 will be a quick follow up to 1.7, we'll see
14:04BronsaI hope that too, but I won't bet on it
14:05bbloomme neither
14:05hiredmanit never is
14:05BronsaI'm a bit tired of having to rework all my patches all the times because they break with the last master
14:06bbloomyeah, 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:06gfredericksmdeboard: I *think* I had it open; doesn't it not show the repl prompt at all until a browser connects?
14:09mdeboardgfredericks: mmm maybe!
14:09Bronsabbloom: I only keep contributing patches because I know that a ticket without patch will rot forever
14:09bbloomyup
14:09hiredmanwatching http://dev.clojure.org/jira/browse/CLJ-1297 comments roll through my inbox every morning always makes me shake my head
14:11hiredmanI guess today wasn't a comment, just alex bumping it
14:18m1dnight_So _tried_ reading the paper on Actors by Carl Hewitt but it just does not make sense to me..
14:29danneuif 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:31nullptrdanneu: that's my understanding -- it will be "waiting forever" in that case
14:31nullptryou can just close the channel in IWillUnmount and abort the go-loop
14:32nullptri haven't confirmed that though
14:32turbofailm1dnight_: haven't read it myself, but from what i've heard you're in good company there
14:33danneuit'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:35nullptre.g. https://github.com/swannodette/om-sync/blob/master/src/om_sync/core.cljs#L121
14:38danneunullptr: thanks, will copy the master
14:41m1dnight_turbofail: It's really messy. Imagine a paper written on a typewriter, pulled through OCR 10 times. It's something like that :p
14:41m1dnight_There is a "summary" by Gul Agha and Rasjesj Karmani which is very readable and to the point.
15:09danneui 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:12nullptryou need to add a key so react knows the canonical identity -- you probably have a warning about that in your js console
15:12nullptrhttp://facebook.github.io/react/docs/multiple-components.html#dynamic-children
15:19danneunullptr: thanks for the help. got it working
15:19danneu(got no console err, though)
15:20borkdudecfleming dunno what this is https://www.dropbox.com/s/obicqrmq8ujc741/Screenshot%202014-10-06%2021.18.45.png?dl=0
15:20borkdudecfleming cursive still seems to work ;)
15:23liflashhi everyone
15:26liflashi'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:27danneunullptr: 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:27nullptrliflash: you're wrapping your routes with wrap-edn-params?
15:27liflashexactly
15:30danneu(the gist works now)
15:30liflashdo you need some more info to think of possibilities?
15:31nullptrdanneu: cool -- you might also be interested in: https://github.com/Prismatic/om-tools#mixin-tools
15:31nullptrliflash: what's your route definition look like?
15:31danneunullptr: thanks
15:33liflash(defroutes some-routes (POST "/timeline/updaterank" [edn-params :as para]
15:33liflash (println "update-rank request parameter map: " edn-params "\npara: " para)))
15:33liflash
15:34nullptri have a working project where it's defined as:
15:34nullptr(POST "/rsvp" {edn-params :edn-params} (rsvp edn-params))
15:35liflashyeah, 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:35liflash
15:35liflashbut good to know it works for you
15:36nullptrif the mime types are right and the middleware is installed properly not sure where else it'd go awry
15:36nullptrminimal: (def app (-> routes wrap-edn-params))
15:36liflash(wrap-edn-params routes) should work, too, right?
15:43d0kyhello 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:47danneuliflash: 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:47justin_smithd0ky: I'd assume you want persistence, which probably means a real database of some sort
15:48liflashdanneu: thanks, will have a look
15:49d0kyjustin_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:53liflashdanneu: any idea why pprint is unknown?....
15:54noonianliflash: you need (:require [clojure.pprint :refer [pprint]])
15:55borkdudehow does one combine core.typed with prismatic/schema? when I use a s/defn core.typed gets screwed
15:55liflashdanneu: oops, thought it was available by default, thanks
15:57borkdudeI must say I like both approaches: core.typed for static checks, schema for run time checks
15:59mr_rmis this the right place to ask a question about the library "Liberator"?
16:00mr_rmdon't see a dedicated irc channel
16:00borkdudemr_rm sure, ask
16:01mr_rmi 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:02liflashdanneu: 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:03liflashdanneu: nullptr on my side, of course ;)
16:04mr_rmborkdude: sorry, i should have posted the defresource for user too: http://pastebin.com/2TjNLfF2
16:04jlongsterI 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:04jlongsterdnolen_: ^
16:04danneuliflash: can you substantiate that the request has header "Content-Type": "application/edn"?
16:05ale`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:05borkdudemr_rm aren't the :allowed-methods etc supposed to be in the liberator resource rather than in the compojure route?
16:07borkdudemr_rm if you can just post your whole namespace it's easier to see
16:07borkdudemr_rm because namespace definitions matter
16:07dnolen_jlongster: a problem how?
16:08danneuliflash: 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:09jlongsterdnolen_: 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:09jlongsterI need to write more code with buffers
16:09mr_rmborkdude: 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:10borkdudemr_rm also :handle-ok etc
16:10borkdudemr_rm you should call the resource from liberator and then the resource decides via the liberator decision tree what to return
16:10liflashdanneu: in fact i can't. regarding the output of your debugging lines, the request before the handler has content-type nil
16:10borkdudemr_rm call the resource from the compojure route I mean
16:11dnolen_jlongster: right this is why it's preferred that an api receive a pre-allocated channel
16:12dnolen_jlongster: buffering is a property of channels not go blocks themselves
16:12liflashdanneu: 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:13mr_rmborkdude: gotcha. yes i see that i skipped the resource entirely in the process. that helps
16:14jlongsterdnolen_: 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:14jlongsterit feels weird to resize the buffer automatically, but if the user shouldn't care about it, cool
16:14liflashdanneu: thanks a lot for your help. will have a look at it on my own for now
16:21mr_rmborkdude: 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:21mr_rmborkdude: thanks again
16:24mr_rmborkdude: 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:25mr_rmborkdude: 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:26mr_rmborkdude: s/space\./space\?/
16:27kenrestivoare there any gotchas i should look out for when backing a core.async channel with an inputstream?
16:29hiredmanwhat does backing mean?
16:31ppppaulanyone here use lighttable ?
16:31hiredmanin any case you'll want to use a ReadableByteChannel and bytebuffers, not an InputStream
16:37borkdudemr_rm yes, I view liberator as a good library for creating REST services
16:39ppppaulliberator 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:40borkdudemr_rm take a look at the decision tree of liberator, that's really the main idea of it
16:42perplexahello. 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:42borkdudeperplexa I'm using cursive, but I didn't use "import"
16:43borkdudeperplexa I just open the project.clj
16:43borkdudeperplexa ask cfleming
16:44dbaschhttp://diegobasch.com/random-partition-of-a-sequence justin_smith gfredericks
16:45perplexaborkdude: how do you just open the project.clj? :P
16:45borkdudeperplexa File -> Open or something
16:45liflashdanneu: still there?
16:45perplexaborkdude: it doesn't really create a project from that, though
16:46hiredmanperplexa: likely your repl has *ns* set to a namespace that doesn't have anything refered in to it
16:46borkdudeperplexa no, I create projects with leiningen from the shell
16:46hiredmanperplexa: you should be able to call core functions if you fully qualify
16:46hiredman(clojure.core/+ 1 2)
16:46gfredericksdbasch: woohoo I'm internet famous!
16:46perplexaborkdude: me too ;P
16:46hiredmanhow or why your repl is in that state, I dunno
16:47perplexamh
16:47borkdudeperplexa ah, well, then you're good to go
16:47gfredericksdbasch: (random-partition (range)) is a cool idea I wouldn't have thought of
16:47liflashdanneu: 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:47dbaschgfredericks: you should expect 0.2 new twitter followers from my post :P
16:50gfredericksdbasch: hey there the are right now
16:50perplexaborkdude: yeah, was using vim + leiningen's repl so far. but wanted to give cursive a shot
16:55dogonthehorizonGreetings 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:56amalloydogonthehorizon: clj-type->java-type returns nil for anything but a map or vector
16:56borkdudeperplexa I've been working with it for a few days, and I like it so far
16:56amalloybut like...just don't write this function at all. clojure's lists implement j.u.List, etc
16:57dogonthehorizonamalloy: 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:57amalloyjust don't. give them the clojure types
16:58dogonthehorizonWouldn't that require me to import clojure.lang and friends in my Java code?
16:58amalloyno
16:58amalloythe point is that an IPersistentVector *is* a j.u.List, and it's Iterable, and all that good stuff
16:59amalloyso you can iterate over it with like: for (Long l : coll) ...
16:59justin_smithdbasch: re: the blog post, very cool
16:59hiredmanI dunno
17:00hiredmanwill javac let you do that without generics?
17:00liflashhow can i find out what's in the :body #<HttpInput org.eclipse.jetty.server.HttpInput@155b539> of a request?
17:00amalloyhiredman: just lie about the types: List<Map<String, Integer>> loms = f.invoke(x)
17:01hiredmanamalloy: ah, sure
17:01dogonthehorizonamalloy: ...ah. Well now I feel silly for going through all this work, heh. Thanks for walking me through that! :)
17:03borkdudedogonthehorizon 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:04noonianliflash: according to the docs that is a subclass of java.io.InputStream so you can probably just use slurp to read it
17:05dbaschjustin_smith: thanks
17:05liflashnoonian: thanks, didn't know where to look at
17:05dbaschjustin_smith: btw, I ended up bringing that geohash code down to the same speed as the java version https://www.refheap.com/91288
17:05noonianliflash: np
17:06dbaschthanks to Bronsa who pointed out that bit-flip and bit-test are not inlined
17:06dogonthehorizonborkdude: 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:06clojurebotNo entiendo
17:06borkdudedogonthehorizon makes sense
17:11liflashis #<HttpInput org.eclipse.jetty.server.HttpInput@155b539> the expected :body when using http-kit?
17:12noonianliflash: are you using ring? you should get a map with a :body and :status key if so
17:12liflashi would expect to get the body i send from the client, like for example a map
17:13liflashyes, i use ring
17:14noonianliflash: try (println (slurp (:body request)))
17:14liflashthis returns the expected body
17:16justin_smithliflash: 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:18liflashi see
17:18brehaut$seen technomancy
17:18lazybottechnomancy was last seen talking on #clojure 4 hours and 41 minutes ago.
17:19liflashmy core problem is that wrap-edn-params seems to be able to extract the edn from that inputstream
17:19rurumatehow to define riemann zeta function in clojure?
17:20rurumatemathematica has it built in it seems
17:20liflashseems not to be, sorry
17:22hiredmanliflash: are you setting the content type?
17:23liflashi'm using om and the content-type is set to application/edn
17:24hiredmanwhat edn params middleware are you using?
17:24liflashcompojure
17:24liflashno, sorry
17:24liflashring
17:25hiredmanliflash: I don't think ring has such a thing
17:25hiredmanhttps://github.com/ring-clojure/ring/tree/master/ring-core/src/ring/middleware
17:25liflashi required [ring.middleware.edn :refer [wrap-edn-params]]
17:26hiredmanliflash: ok, but where did ring.middleware.edn come from?
17:27justin_smithmaybe this one ? https://github.com/tailrecursion/ring-edn/tree/master/src/ring/middleware
17:27liflashoh, i see what u mean. i think it comes from [fogus/ring-edn "0.2.0"]
17:28liflashi'm working with a friend of mine, he added it
17:28liflashand he says all this already worked
17:28liflashdon't know what the problem is
17:28liflashthe content type is correct, but the resulting map only contains :edn-params nil
17:29hiredmansounds like the inputstream is empty or contains nil
17:29hiredman(or you are printing out the contents of the inputstream before the middleware can read it)
17:30justin_smithyeah, input streams are stateful, so be careful of emptying it prematurely
17:32justin_smithdbasch: cool - at least to me the clojure version is nicer than the java. Pity it took more work to make it perform.
17:33dbaschin fact with the latest feedback from amalloy it’s now faster than the java version https://www.refheap.com/91289
17:34liflashhiredman: hmmm... currently looks like a mess and i don't know where to start. will have deeper look first. thanks for your hints
17:40turbofailhuh. why aren't bit-test and bit-flip inlined?
17:41turbofailjust an oversight?
17:41dbaschturbofail: they are not
17:41hiredmanlikely
17:41hiredman(which is why a machine shoud be generating all this)
17:41dbaschoh, why, yeah most likely an oversight
17:41amalloyi'd guess it's because there's no single jvm bytecode for them
17:42amalloythe others are inlined so that they can be removed entirely and replaced with a bytecode instruction, via intrinsics
17:42amalloywhereas inlining this one doesn't buy you anything more than letting hotspot inline it
17:42Bronsaamalloy: them being not inlined prevents the unboxed arities to be used though
17:42turbofailyeah, their function definitions don't do any type hinting
17:43amalloyah, yes indeed, since there are primitive versions that definitely should be inlined
17:46hiredmanit should all be machine generated
17:50akurilinHas anybody here succeeded with disabling connection pooling done by Korma?
17:50akurilinTrying to figure out if I'll have to fork the lib to do it
17:52akurilinHm I guess there's :make-pool? in there
17:54gfrederickshuh. I've never noticed a lib with no dependencies before
17:54gfredericksonly lists clojure under :dev
17:55gfredericks(test.check)
17:57amalloygfredericks: that seems like a decent idea, really
18:02TimMcI only just introduced a dependency on cloure.set into org.timmc/handy, which surprised me.
18:03TimMc*clojure, why does my typing suck so much these days
18:04technomancyfor once we can't blame nil
18:12vIkSiThello all
18:12vIkSiTwhat's the easiest way to add a snapshot build of a library using lein?
18:12vIkSiTeg, om 0.7.3 is stable, but the github master branch is on 0.7.4 snapshot
18:13nullptryou can just pull the code and run: lein install
18:13vIkSiTwhat can I do to add the latter to my project.clj?
18:13vIkSiTnullptr, ah - and then it get's installed as a dep into .m2?
18:13nullptryup
18:13technomancyvIkSiT: it depends on whether the snapshots are published
18:13vIkSiT(and project.clj will pull it once the entry is added?)
18:13vIkSiTtechnomancy, right, the snapshots aren't published in this case
18:13technomancyif they are, it will just work
18:13em-dashI’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:13technomancyyeah, in that case manual lein install
18:13vIkSiTcool, ty
18:14justin_smithem-dash: are you looking for it once, or looking repeatedly?
18:14em-dashI expect it to appear once in the vector
18:14justin_smithhow often do you look it up?
18:15justin_smithfor finding it once (first (filter ...)) if repeatedly, (group-by :your-key vec-of-maps)
18:15em-dashoh, I want to extract it and build a map with the value I find (I’m parsing horribly formatted XML)
18:15vIkSiThas anyone here used clojurescripts nativestore btw?
18:15em-dashjustin_smith: thank you! that’s exactly the nudge I needed :)
18:16vIkSiTand 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:16justin_smithem-dash: for example if you are finding many items by the same key, group-by is a huge win
18:17vIkSiTany ideas on why repl/running program state wouldn't get updated through cider, C-c C-k? or even C-x C-e?
18:17em-dashjustin_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:17em-dashjustin_smith: thanks again :)
18:18justin_smithvIkSiT: 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:18justin_smithfor example
18:18justin_smithalso look out for things that have defonce semantics
18:19vIkSiTah
18:19justin_smithfor example defmulti
18:19vIkSiTit's basically a defroute, yes - using ring
18:19justin_smithpass #'handler to the server process rather than handler
18:19justin_smithring will dereference the var instead of using the value of the var
18:19justin_smith*do a dereference of the var for each request, that is
18:23vIkSiTjustin_smith, not sure I understood that last part
18:23vIkSiThow do you mean pass the deferenced handler to the server?
18:24justin_smithI mean the server derferences on each request
18:24dbaschwhenever I see defonce I think of beyonce
18:24vIkSiTI just go to the (deroute my-app ... (GET "/route" [] (my-handler)) and C-x C-e
18:24justin_smithrather than getting the immutible fn value and just using that
18:24justin_smithright, and that changes a var
18:24vIkSiTright
18:24justin_smithit does not alter the fn that you passed to the server
18:24seangrovedbasch: But isn't it true that you're just generally thinking of beyonce?
18:24vIkSiTah
18:24justin_smiththe server is still using the old fn
18:24vIkSiTwell.
18:24dbasch(beyonce put! “a ring on it”)
18:24justin_smithif you pass in a var, it can deref for each request
18:25vIkSiTC-x C-k should do the right thing though?
18:25dbaschseangrove: no, just this once
18:25seangroveDamn, outclassed
18:26justin_smithvIkSiT: how can it if the ring process did not receive a var?
18:26justin_smithif it does not get a var, and only an fn, it has no way to see a new value
18:26justin_smithunless you kill and restart the server on every ns refresh
18:29grandy___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:29vIkSiTjustin_smith, I think I see your point
18:29vIkSiTtrying to wrap my head around it..
18:29grandy___using secretary + reagent on the client side and compojure+yesql on the server side
18:30justin_smithvIkSiT: if the server process was using your handler function directly, it would see the update (as long as it had not been inlined)
18:31justin_smithvIkSiT: but when it gets a function as an argument, it only gets the fn
18:31vIkSiTah
18:31justin_smithvIkSiT: 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:31vIkSiTit gets the defintion of function f at time t1.
18:32justin_smithright
18:32vIkSiTand then at time t2, i add a new route
18:32vIkSiTnow, i cx ce the function
18:32justin_smithand the fn does not change - the var just points to a different fn now
18:32vIkSiTthe function itself uptakes the value at t2, ie, if I were to use it now, it would work fine
18:32vIkSiTbut ring still has the pointer of fn at time t1?
18:32cflemingborkdude: 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:33vIkSiTso I need some way to update ring's pointer from fn at time t1 to t2
18:33cflemingperplexa: Did you get that cursive problem sorted out?
18:33vIkSiTjustin_smith, does that make sense? ^
18:33justin_smithyeah
18:34justin_smithvIkSiT: 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:35vIkSiTjustin_smith, ah
18:35justin_smithif 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:35justin_smithluckily we don't have to mess with that
18:35vIkSiTah
18:35vIkSiTfrom what I can see, handler.clj contains (def app (app-handler [home-routes base-routes] ... )
18:36vIkSiTand (defroutes home-routes ... (..routes..))
18:36amalloyjustin_smith: amusingly, (defn super-handler [req] (handler req)) would work as well as passing the var
18:38amalloyalso, 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:38vIkSiThmm
18:38vIkSiTso this is actually compojure, and I see this: (defn get-handler [] (-> #'app ... ))
18:38vIkSiT(def app (app-handler [home-routes] .. ))
18:39vIkSiTso ultiamtely, the var here IS being passed in
18:39vIkSiTbut still no joy in code reload. hmm
18:40hiredmanvIkSiT: no, it isn't
18:40vIkSiThmm?
18:41vIkSiTthe var is for app but not home-routes?
18:49tuftdoes anyone know of a library for collecting/deferring side effects within a particular scope? nothing as hard core as the IO monad
18:50tuft(which i assume someone has recreated in clojure somewhere =)
18:57justin_smithtuft: how about building a sequence of thunks (functions of one argument) and later running them all in series?
18:59nkozois possible to reference the instance created by proxy inside one of the proxy methods?
19:01nkozofound it, you can using "this"
19:02tuftjustin_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:03justin_smithheh
19:03justin_smithclearly, you also need (defonce dead-puppy-count (atom 0))
19:04amalloyi'm not sure dead puppies are better in a var than on the call stack anyway
19:04amalloyyou just want them out of your program entirely
19:06justin_smithtuft: 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:07dbaschjustin_smith: (defonce shrodingers-cat (atom (rand-nth [:dead :alive])))
19:08technomancydbasch: no, you need to make it part of a lazy seq
19:08technomancythat way it's literally in both states until it's observed
19:09justin_smithdbasch: (defer (rand-nth [:dead :alive])) both :alive and :dead until you deref it
19:09dbasch(inc justin_smith)
19:09lazybot⇒ 86
19:09dbasch(inc schrödinger)
19:09lazybot⇒ 1
19:10justin_smith(defer ((rand-nth [#(System/exit 0) #(println "survived")])))
19:11tuftjustin_smith: yeah i guess returning data instead is the way to keep puppy mortality down
19:11dbaschjustin_smith: that reminds me of my macro to execute the body or throw an excepton 1/n of the time at random
19:12justin_smithdbasch: the purpose?
19:12dbaschan excepton: a fundamental component of exceptions
19:12justin_smithdbasch: large exepton collider
19:12dbaschjustin_smith: test random failures of a process that was trying to fetch stuff from the network
19:13justin_smithahh, of course - simulate unrepliable infrastructure
19:13cbp(doc defer)
19:13clojurebotNo entiendo
19:14dbasch(doc recursion)
19:14clojurebotExcuse me?
19:14dbaschwrong answer clojurebot
19:14justin_smithI don't know why I was doing "defer" - it's delay (and it does deferred evaluation)
19:15justin_smith(doc delay)
19:15clojurebot"([& 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:18amalloyjustin_smith: just (def defer delay), so that you can run into the same problems with var redefinition
19:19justin_smithheh
19:19amalloy(modulo the baloney about setting ^:macro)
19:22justin_smithI refuse to look up "modulo the baloney" on urbandictionary
19:23dbaschamalloy: for proper behavior, wrap that in without-redefs from useless
19:23amalloyhah
19:24dbasch(defn maybe-or-maybe-not [x] true) <- also for useless
19:25justin_smith(def calculate (constantly 42))
19:25dbasch(defn perhaps [x] false)
19:30amalloyi 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:31amalloyhow am i supposed to type stuff like ∀x i really don't recommend you look up x on urban dictionary
19:33justin_smithheh
19:33justin_smithhttp://www.urbandictionary.com/define.php?term=%E2%88%80
19:37dbasch∃x such that the urban dictionary entry for x is ∅
19:38dbaschor maybe ⊂ ∅
19:39dbaschno, belongs dammit
19:39dbasch∰ whatever
19:40justin_smithdbasch: x is a proper subset of the null set?
19:42dbaschI meant ∈
19:42dbaschbut I can barely type regular ascii characters
19:43justin_smithdbasch: do you use emacs?
19:43dbaschI do
19:44justin_smithM-x insert-char allows globs and tab completion
19:44justin_smithyou type in the name of the unicode symbol to insert it
19:44justin_smith☃ (SNOWMAN)
19:44caternwoah
19:44dbasch∀your base, your base ∈ us
19:44caternthat's cool
19:45justin_smithalso M-x describe-char tells you the UNICODE NAME of the char so you can insert-char another time
19:45nullptrwow, never knew that λ
19:45dbaschI need to drop colloquy and consolidate inside emacs
19:45nullptr(inc emacs)
19:45lazybot⇒ 4
19:45justin_smithie. ∈ is ELEMENT OF
19:48justin_smithat 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:49justin_smithfor ideas on how we could generalize clojure for more collection types
19:49justin_smithturns out there are hundreds of them...
19:51vermaI've seen in some tbaldrige screencasts the fn is replaced by the lambda symbol, what sorcery is that?
19:51justin_smiththere is an emacs mode for that (it only effects display, not file contents)
19:52justin_smithverma: http://www.emacswiki.org/PrettyLambda
19:52vermanice
19:53justin_smiththat links to the more general pretty-symbol, and I think that has a clojure specific variant
19:53vermathanks!
19:53vermafound this for vim: http://demonastery.org/2012/07/lambda-conceal-in-vim/
19:54justin_smithhttps://github.com/jimweirich/emacs-setup-esk/blob/master/pretty.el here's one for clojure lambda
19:54vermanice, thanks justin_smith
19:55amalloyjustin_smith: that one refers to functions that don't exist unless you install ESK, like esk-pretty-lambdas
19:55justin_smithoh, yeah, don't use that
19:56vermaoh no way! https://github.com/fwolanski/vim-clojure-conceal
19:56verma:)
19:57technomancyracket lets you just put λ directly in your code
19:58justin_smithclojure would let you do that too, but any collaborators would hate you for it
19:58technomancypfff, collaborators
19:58vermais racket .. umm .. popular?
19:58amalloyprobably has more users than clojure? i guess i'm not sure
19:58technomancyverma: it's got roughly 50% as many projects as clojure on github iirc
19:58amalloyit's in the ballpark, anyway
19:58technomancyso less popular, but not by an order of magnitude
19:59vermanice, it looks fun
19:59technomancyverma: it's great
19:59amalloyjustin_smith: collaborators will hate you regardless
19:59vermatechnomancy, you writing any fun stuff in it?
19:59justin_smith,(def ☠ "touch this and die" ())
19:59clojurebot#'sandbox/☠
19:59technomancyverma: yeah. working on a hypercard clone.
20:00nullptrif you are using a very recent version of emacs, `prettify-symbols-mode' is a built-in
20:00technomancyverma: https://github.com/technomancy/cooper
20:00nullptrand by default you get lambdas in lisp-modes (clojure included)
20:00technomancythe gui and drawing libs especially are great
20:00amalloylike 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:00vermatechnomancy, sweet! taking a look
20:00amalloyand it's like...do you *really* want to start every project at a base abstraction level of zero?
20:01justin_smithamalloy: but you define a function here - how can someone use that function without reading and understanding your code?
20:01amalloyjustin_smith: that argument never convinces anyone, it turns out
20:01amalloyso anyway, those people will hate you regardless of what you do
20:01hiredmanI love my unicode joins https://github.com/hiredman/graph/blob/master/src/com/manigfeald/graph.clj#L286-L296
20:01caternjustin_smith: I can see you're putting to use the function you mentioned in #emacs
20:01technomancyamalloy: well, obviously the more you diverge from clojure.core, the more you're asking people to keep in their heads
20:02technomancyit's a matter of cost/benefit
20:02justin_smithcatern: I'm in #emacs?
20:02dbaschamalloy: 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:02vermahiredman, how do people type those in?
20:02justin_smithcatern: or you mean I used insert-char SKULL AND CROSSBONES - yeah
20:02hiredmanI read somewhere if you use non-blocking io you can scale up human understanding by 10x
20:03hiredmanverma: I use M-x ucs-insert and completion
20:03caternjustin_smith: yeah, sorry, I just assumed that I was in #emacs when I saw that before
20:03vermahiredman, hmm, nice
20:04dbaschtechnomancy: 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:04amalloytechnomancy: 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:04amalloy(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:05amalloyin all cases, whoever reads my code has to understand whatever the utility function would do
20:05technomancyamalloy: oh you're talking about separate libs specifically
20:05justin_smithcatern: #clojure goes off topic a lot but not nearly as much as #emacs
20:06caternjustin_smith: hey what's wrong with that
20:06technomancyverma: let me know what you think if you try it
20:06vermatechnomancy, sure, starting to play with racket a little bit
20:07technomancyverma: 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:07technomancyverma: take a look at fstruct.rkt for more on that topic; should help you feel more at home coming from clojure
20:07vermanice
20:08technomancystructs that are callable like functions and support the dictionary interface
20:09technomancyracket is mostly FP-friendly, but the default structs feel like they're more designed for imperative work
20:09technomancyeasy fix though =)
20:16kenrestivohiredman: what is this ⨝ ?
20:19amalloykenrestivo: 0x2A1D JOIN
20:21dbaschI just realized that the ‘decode’ part of this library doesn’t even work https://github.com/talkto/geohash
20:22dbaschthe example given in the readme encodes something and then decodes to something different
20:25hiredmanhttp://en.wikipedia.org/wiki/Relational_algebra
20:25hiredman(not that I used it as a natrual join)
20:26hiredmanhttp://en.wikipedia.org/wiki/Relational_algebra#.CE.B8-join_and_equijoin
20:30kenrestivohiredman: thanks
20:41YmesioHi all
20:41YmesioSo I have a collection of numbers, say 1,2,3,4
20:42YmesioI need to map over it, but what I need is not the Nth value, but aclually the list with Nth value removed
20:42YmesioSo I would get 2 3 4 then 1 3 4 then 1 2 4 then 1 2 3
20:42YmesioWhat would be the best way to do that?
20:43justin_smithis the order important?
20:44YmesioNot really
20:45justin_smith,(let [input [1 2 3 4]] (map #(disj (set input) %) input))
20:45clojurebot(#{4 3 2} #{1 4 3} #{1 4 2} #{1 3 2})
20:45justin_smithyou could do something less elegant with remove and an equality predicate if ordering was important
20:49Ymesiojustin_smith: Looks like that could work thanks a lot
20:49justin_smith,(let [input [1 2 3 4]] (map #(remove #{%} input) input))
20:49clojurebot((2 3 4) (1 3 4) (1 2 4) (1 2 3))
20:49justin_smithan alternative
20:49justin_smithI like the former better though (as long as unordered sets are OK of course)
20:52YmesioI’d assume disjunction is be constant
20:52Ymesio* should be
20:54Ymesiojustin_smith: Thanks, will use the first one
20:54justin_smithyeah, there is the overhead of creating the set once, but disj is constant time
20:55justin_smithexactly
20:55amalloyjustin_smith: that's not much good if you have duplicate elements
20:56justin_smithyes, that's also an important point
20:56amalloyyou knida need a frequency map instead of a set, if you want to handle that possibility
20:56YmesioI don’t have any duplicates
20:58weidid filter-key get removed?
20:58Ymesiojustin_smith: thanks again
20:58justin_smithYmesio: np
20:59justin_smithwei: looks like it is private? http://www.clodoc.org/doc/clojure.core/filter-key
21:00justin_smith(doc clojure.core/filter-key)
21:00clojurebot"([keyfn pred amap]); "
21:00justin_smith$source clojure.core/filter-key
21:00lazybotclojure.core/filter-key is http://is.gd/VSfdpE
21:00justin_smithwell, lazybot gives us the 1.4 version...
21:01dbaschYmesio: you can do (concat (take n x) (drop (inc n) x))
21:01justin_smithhttps://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L3923 but yeah, still private
21:01weiis 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:01dbaschor something to that effect
21:01Ymesio,(concat (take n x) (drop (inc n) x))
21:01clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: n in this context, compiling:(NO_SOURCE_PATH:0:0)>
21:02justin_smithYmesio: definitely not constant time, but that is definitely another approach
21:03dbasch,(let [n 2 x (range 5)] (concat (take n x) (drop (inc n) x)))
21:03clojurebot(0 1 3 4)
21:04justin_smith,(let [input {1 :a 2 :b 3 :c 4 :d}] (select-keys input (filter even? (keys input)))) ; wei
21:04clojurebot{2 :b, 4 :d}
21:04weijustin_smith: fair enough, thanks
21:04wei(inc justin_smith)
21:04lazybot⇒ 87
21:16gfredericksreiddraper: 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:21justin_smithgfredericks: out of context you sound like a weird parent talking about his kid's psychologist
21:21caternyes
21:21caterni just flipped to this channel in IRC and that's how I interpreted
21:21caternit
21:25danneui 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:25danneuhttps://dl.dropboxusercontent.com/spa/quq37nq1583x0lf/oth82eom.png
21:27justin_smith~cider
21:27clojurebotcider is Cider is unstable and broken right now, most things don't work. Use the last stable version of nrepl.el for now.
21:27justin_smithheh, I wondered what clojurebot had to say about that
21:27amalloyprobably not far off
21:28justin_smith~nrepl
21:28clojurebotnrepl is a network REPL implementation: http://github.com/clojure/tools.nrepl
21:28justin_smith~slime
21:28clojurebotTitim gan éirí ort.
21:28arrdemdbasch: any solutions to that recovery prolblem?
21:28dbaschnot yet
21:29dbaschin casee someone is interested here, I shuffled a paragraph from a fairly popular book: http://pastebin.com/raw.php?i=GGhh3WA2
21:29dbaschthe idea is to recover it
21:30justin_smithtranslation of that factoid above: "May you fall without risinge"
21:30justin_smith(sic)
21:32grandy___anyone here used secretary?
21:32grandy___~secretary
21:32clojurebotHuh?
21:32dbaschI believe seangrove did
21:32grandy___seangrove: true?
21:33grandy___trying to figure out the best way to navigate between "pages" and update the url shown in the browser
21:33dbaschgrandy___: at least it’s in this app https://github.com/sgrove/omchaya/blob/fe5861e7f483e0f6ac2b1685dfaca2c680e36c32/src/omchaya/routes.cljs
21:34grandy___dbasch: hmm looking
21:34grandy___dbasch: he's not handling the use case i'm curious about
23:02cflemingarrdem: 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:12arrdemcfleming: yeah that is an old version.. I thought it was redirecting
23:12arrdemcfleming: I'll check it out, thanks
23:12cflemingarrdem: NP
23:13cflemingarrdem: 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:13cflemingarrdem: The crossclj integration is awesome BTW.
23:35celwellHow could I make map that returns a certain value when a requested key does not exist?
23:36justin_smithcelwell: it takes an extra arg for that
23:36justin_smith,({} :a :not-found)
23:36clojurebot:not-found
23:36justin_smithif you need to hard code a default, maybe you need a function and not a map?
23:38celwelljustin_smith: maybe, i was hoping to not use a function though. I'd like to have something like:
23:38celwell(def form-id-aliases
23:38celwell {1 {:patient-questionnaire [2 4 5 6 7 8 9 11]}
23:38celwell 2 {:patient-questionnaire [2 4 5 6 7 8 9 11 13 14]}
23:38celwell :not-found {:patient-questionnaire [2 4 5 6]}})
23:38celwellI guess there's no simple way to do that?
23:39justin_smithyou could use a custom lookup function and pass both the map and key, and let the lookup function specify or find the default
23:39justin_smithfinally, 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:39celwellis it possible to make a 'lazy-map
23:40celwell' ... that fills in all the missing vals
23:40justin_smithnot with the standard map type, no
23:40celwellhmm.. ok I'll probably have to just use the :not-found thing in a ll my lookups
23:41justin_smith(defn get-with-default [m k] (m k (:not-found m)))
23:41justin_smithyou can probably give it a less messy name
23:42celwellyeah, thanks
23:43ToxicFrog,(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:43clojurebot[1 "kittens"]