#clojure logs

2013-06-22

00:00hiredmanI played with a lisp that did the source to source thing to go
00:00bbloomhiredman: 1) it's more mature, if that's what you mean and 2) the hotspot JIT really helps dynamic languages, which go's runtime likely won't
00:00hiredmanway to static, and not enough of a platform to really leverage
00:00hiredmanno dynamic code loading
00:01Qortznivcallen, how did you know it was i?
00:01bbloomhiredman: which is essentially true of cljs when deploying too
00:01technomancydynamic code loading is a pretty important prerequisite for any platform I'd touch with a ten-foot pole
00:02hiredmanthe reflection facilities in go are super primitive
00:02hiredmananyway, I did not care for it
00:04bbloomi think you just need to use a slightly different strategy: you can do incremental compilation in memory & then communicate via channels. in production builds, you can statically link, like in cljs
00:05bbloomi really love the incremental work flow in clojure, but i fully appreciate the static-everything approach for deployments
00:05bbloombut still, you're right, it probably wouldn't be great for a dynamic language at all
00:05bbloomnot without a lot more work
00:06hiredmanbbloom: you would have to write an interpreter, but the interpreter would not be able to call go functions that where not already used in the executable
00:06bbloomhiredman: the interpreter would surely be compiled with a full list of stubs in a dev build, so there would be no dead code to remove
00:07hiredmanbbloom: gross
00:07bbloomanyway, let me retract my statement about me wishing golang was the compilation target of choice
00:07bbloomyou're right
00:07tomjackis 'dynamic language' about more than the type system?
00:07hiredmanbbloom: and what about interoping with go libraries outside of the standard lib?
00:07bbloomwhere i was really coming from was this: i wish every java (the language) shop magically became a go (the language) shop
00:07bbloom:-P
00:08hiredmanI started on this, and it sucked, with exactly that a list of stubs for the interpreter to use, etc
00:08cneirais there any roadmap for clojure the future features in clojure , like continuations ?
00:08bbloomtomjack: if you care about performance, you need a runtime that is defined for dynamic call sites and stuff
00:09bbloomcneira: you can assume that full continuations will never happen & that delimited continuations are mildly unlikely
00:09Pupnik_clojure on luajit!
00:10tomjackspeaking of that, shouldn't it be pretty easy to build delimited continuations using ioc-macros?
00:10hiredmanhttps://github.com/hiredman/qwerty/blob/master/src/qwerty/lisp/golib.q
00:11hiredmanit is kind of gross because I was waiting to get the interpreter working to add macros
00:13tomjackbbloom: so could you have a 'dynamic' language with a type system more like what we expect from a 'static' language?
00:14tomjackor are they conflated for a good reason
00:14bbloomtomjack: maybe it's this delicious gin, but i'm going to ignore your question and instead say that it's kinda a false dichotomy to describe dynamic vs static
00:15bbloomeverything is always some shade of gray
00:15bbloomthere are things you know statically and things you don't know statically
00:16bbloomgo has interface{} which is basically the same as "object" in java, which is essentially dynamic typing
00:16tomjackok, 'false dichotomy' is sort of the answer I was hoping for anyway :)
00:17jimrthyIt seems like Qi at least sort-of takes that approach: common lisp with static typing.
00:18jimrthyBut I've never gone any further than skimming its web page a few years back.
00:19bbloomtomjack: consider (pop 1 2) for example.
00:19bbloomtomjack: in clj that throws an error at runtime, but there isn't really any strong reason that can't be an error at compile time
00:19bbloomtomjack: module re-defining vars :-/
00:20bbloomtomjack: but in clojurescript! lol you know what var values are, so if you know you have a var, you can look at it's arities. and in fact, cljs does
00:20tomjackif IPersistentStack were a protocol like it wants to be..
00:20bbloomtomjack: cljs will emit direct dispatch to a particular arity
00:20bbloomtomjack: ignore protocols, it could be (defn f [x] ...)
00:20bbloomtomjack: in cljs, if you call (f 5) we emit f._some_magic_thing_for_arity_1
00:20tomjackoh yeah, missed that that was the error
00:21bbloomthe point is that we know, statically, some stuff, so we can use that to optimize
00:21bbloomthe difference between "static" and "dynamic" languages is one of philosophy
00:21bblooma static language tries to prevent as many errors as possible at compile time and to perform as many optimizations as possible then too
00:22bblooma dynamic language tries to stay out of your way at compile time
00:22bbloomand as such, needs to recover error detection and performance at runtime
00:22bbloomthis is why i'm a big believer in pluggable type systems
00:22bbloomand extensible compilers
00:23bbloomin theory, if my app is too slow, i want to be able to make it faster by adding static information
00:23bbloomand in fact, clojure does precisely this with type hints
00:23bbloomhowever, there are non-type related examples of things that you can use as static hints
00:24bbloomlike consider the old C macros for LIKELY and UNLIKELY
00:24tomjackI hope someday your dreams about the cljs analyzer/compiler come true
00:24callenclojure -> asm.js?
00:24bbloomcallen: you wanna write a garbage collector & compile it to asm.js? :-P
00:24callenclojure -> emscripten JVM implementation?
00:25bbloomcallen: honestly, i think it makes much more sense to compile to js directly for a dynamic language. for a static language, sure, compile to asm.js
00:25callenborrow that 30 petaflop chinese supercomputer. should get 30 fps on Minecraft.
00:25callen(30 fps'ish)
00:25bbloomtomjack: check out my little secret project here: https://github.com/brandonbloom/ascribe/blob/cljs/test/ascribe/cljs/attrs/clj.clj
00:26bbloomtomjack: basically finished macro expansion, starting on primitive analysis
00:27bbloomtomjack: my goal is no more than twice as slow as CLJS (without the google closure step) but 100X easier to extend w/ new analysis, better errors, etc
00:28bbloomtomjack: anyway, are you familiar with likely and unlikely?
00:28bbloomhttp://stackoverflow.com/questions/109710/likely-unlikely-macros-in-the-linux-kernel
00:28tomjacknope
00:28bbloomthat's non-type-related static info used for optimization
00:28tomjackmakes sense though
00:29bbloomi'm also not a believer that type systems need to be complete/sound/whatever
00:29bbloomi think it's totally fine if a type system runs a core.logic style search & just gives up after some amount of time & compiles the best code it can with the info it gathered in the time it had
00:30tomjackin that case, nothing is non-type-related :)
00:31bbloomsure
00:32tomjackreading ekman now, ascribe looks very interesting
00:32tomjackdon't understand it at all but the code you linked looks very clean, especially compared to the macroexpansion code I'm writing
00:33bbloomtomjack: clean is the goal :-)
00:35tomjackholy shit 151 pages
00:36bbloomhaha
00:36bbloomyeah, it's a full thesis, lots of individual papers
00:37bbloomtomjack: https://code.google.com/p/racr/ is probably a pretty short intro to the bag of ideas
00:38tomjackI wonder if it's a coincidence that the first paragraph ends with "DADA"
01:35tomjackouch, nrepl.el doesn't yet support previous-error/next-error?
01:41Raynestomjack: sofixit
02:15spoon16anyone know if it's possible with compojure to have a set of middleware applied only to the routes defined within a given (context) expression?
02:19SegFaultAXspoon16: Routes and middleware are just functions.
02:20SegFaultAXYou can wrap the middleware around the route directly (my-middleware (GET ...))
02:39spoon16thanks SegFault
02:46snake-johnhow do I do in emacs "select whole s-expr under cursor" … I've got clojure mode and paredit on…
02:48tomjackI think you probably want expand-region
02:49tomjack"whole s-expr under cursor" is ambiguous, right?
02:49tomjackif you mean point is on/before the opening paren, C-M-SPC
02:51snake-johnyes that is what I meant! But when I hit continuously C-M-SPC I would like the selection to expand to the parent s-exp.
02:52tomjackyeah that's expand-region I believe
02:52tomjackit's not bundled with emacs
02:52tomjackhttps://github.com/magnars/expand-region.el
02:53snake-johnthanks a lot just give me 5 minutes I will try it out
02:53tomjackI've never used it, just heard about it
02:53tomjackhopefully it actually does what you want..
03:13callenhttps://github.com/bgschiller/latex-therefore
03:13callendnolen_: technomancy ^^
03:13snake-john@tomjack ha great it works thanks a lot again. One minor thing : I tried to bind it with (global-set-key "\M-C-SPC" 'er/expand-region) in my init.el. but unfortunately when I restart and do a c-h k M-C-SPC I see "C-M-SPC runs the command mark-sexp"
03:16tomjackI'd try (global-set-key (kbd "C-M-SPC") ...)
03:17tomjackno need to restart, just put point on that and do C-M-x
03:18snake-johnthank you so much it works now!
03:21francis_wolkehas anyone worked with three.js and clojurescript
03:21francis_wolke? I'm having some issues, but no errors or anything to work from to tell me what I'm doing wrong
03:22francis_wolkethe #clojurescript channel is dead - else I'd ask there.
03:24murtaza52hi I need help with creating a leiningen plugin
03:25murtaza52I have created a plugin which watches for any changes in a dir, thus the thread needs to keep on running, and not exit.
03:26murtaza52The main thread actually creates futures which watch for changes.
03:26murtaza52When i execute the code from repl ( not lein $task), it works well.
03:26murtaza52However when I run it from another project as lein $task, it doesnt work.
03:27murtaza52First question how do I get a long running blocking process, like lein cljsbuild :auto ?
03:43murtaza52got it to work (when true) did the trick !
03:43callenhttp://prog21.dadgum.com/3.html
03:46tomjack(when true) ?
03:49tomjack"And what is this really gaining you over C?" -- missing the point
03:49tomjackwell.. part of the point
03:51tomjackto be fair I missed that point to when I looked at ztellman's asteroids
03:52murtaza52I wanted an infinite loop, when the plugin task was run. So (when true) does it.
03:53tomjackif we look at something like ants.clj I think that's a very good point
03:54tomjackrefs pointing to persistent data is obviously a lot we gain over C, but ignoring that, what we gain seems to be sanity in the face of parallelism
03:54tomjackwhich is not enough!
03:55tomjackwell maybe it's enough for ants.clj
03:55francis_wolkeRE: what I said earlier, figured it out
04:01rurumateI want to add clojure to an existing JAX/RS project. It needs to be a servlet so I can integrate it via web.xml. Is there a elegant / fun way, other than (gen-class :extends HttpServlet)?
04:04ddellacostaaws s3 permissions #*$@%!
04:04ddellacostathat's all I got
04:08tomjackrurumate: you might have a look at https://github.com/ring-clojure/ring/blob/master/ring-servlet/src/ring/util/servlet.clj
04:08tomjackeither for inspiration, or just use it
04:09callenddellacosta: your first mistake was using S3. Your second mistake, and this is the really critical one, was to not anticipate its failure. This damaged your karma.
04:09ddellacostacallen: *sob*
04:09tomjackwhat's wrong with S3?
04:09ddellacostaddellacosta: I don't know how to use it for one
04:10callentomjack: not enough monads.
04:10SegFaultAXddellacosta: What are you trying to do?
04:10ddellacostawhoops, just addressed myself
04:10ddellacosta brilliant
04:10tomjackah, true..
04:10callenddellacosta: sign of a magnificent conversationalist when they can efficiently pare down the minimum by (dec 2)
04:10ucbmonads and S3. Yes.
04:11tomjackhmm, core.logic bug? https://www.refheap.com/84fdcc8257787e30e53187611
04:11callenucb: you're in for it now.
04:11ddellacostaI am trying to set ACL for public read on putting an object to S3 using clj-aws-s3. And I just get permission denied, no matter how I try to massage the permissions.
04:11rurumatetomjack: neat, thanks
04:11ucbcallen: ruh-roh
04:11ddellacostasorry, that was to SegFaultAX
04:11ddellacostacallen: I try to be efficient
04:12ddellacostanothing to do with Clojure really, just felt like venting to someone, anyone (apologies)
04:12SegFaultAXddellacosta: Is it possible that the access key and secret you're using don't have sufficient permissions on the bucket?
04:12callenddellacosta: default bucket policy has read access for everybody
04:13callenddellacosta: so unless your policy is set to something other than the default or the ACL was previously modified, you're failing to modify the ACL of something you shouldn't modify.
04:13ddellacostaSegFaultAX: one can imagine this as a possibility, which is why I explicitly enabled the user whose credentials I'm using to read the bucket list, upload and set permissions
04:13tomjackddellacosta: dunno if you already know, 404's will look like permission denied too
04:13ddellacostacallen: as far as I can tell, the images are definitely not read-all--tried looking at them without setting permissions
04:13callenddellacosta: please check the bucket policy.
04:14ddellacostatomjack: definitely getting a 403 here.
04:14SegFaultAXddellacosta: ddellacosta Does that mean s3*?
04:14SegFaultAXs3:* rather
04:14tomjackthat's what I mean
04:14callen403s are now 404s? Sweet.
04:14SegFaultAXNo, they aren't.
04:14SegFaultAXYou'll get a perm denied if that's the case.
04:14tomjackyou won't get a 404, you get a 403
04:15callenddellacosta: and the bucket policy iiiiiiissssss?
04:15ddellacostacallen: https://www.refheap.com/16010
04:15ddellacostayeah, sorry I'm using s3
04:15ddellacostabut I'm a total beginner, so it's not surprising I'm doing something stupid…
04:15callenddellacosta: broskie, that's read access to everyone.
04:15ddellacostacallen: *sob*
04:16callenddellacosta: that's the default policy. uhm. mostly. the Sid is unfamiliar to me.
04:16callenaction, effect, principal all mean what I think they mean though.
04:16ddellacostacallen: yeah, the principal thing seems to be the user/role this is being applied to
04:16ddellacostaif I understand it properly
04:17ddellacostameh, gonna take a break. Maybe I'll have an epiphany and figure it out later.
04:17callennot to be a bore, but you're sure you 1. Need to set the ACL (this isn't publicly accessible?) and 2. You're using the right keys to set the ACL if #1 is true?
04:17ddellacostathanks for your help, callen, SegFaultAX, tomjack
04:17callenddellacosta: but now I'm interested.
04:17callengerd dermert.
04:17ddellacostacallen: heh
04:17SegFaultAXddellacosta: You didn't say that accessing a blob from the bucket was an error. You said setting the perm was an error. Which is it?
04:17callenddellacosta: while you're going, I'm going to own your box, steal your keys, and figure it out for myself.
04:18ddellacostacallen: WELL then, the thing I'm getting stymied on is exactly setting the ACL--that's where I get the 403 actually
04:18callenddellacosta: okay fuck the ACL. Can you load the file as a public reader?
04:18callenddellacosta: verify that the ACL is a problem to begin with.
04:19ddellacostaSegFaultAX: that's it exactly. I think we got derailed a little when I posted the bucket policy, but that is and was my main problem.
04:19SegFaultAXddellacosta: Can you change it from the console?
04:19SegFaultAXddellacosta: Or the API?
04:19callenI asked for the bucket policy to verify the necessity of even touching the ACL.
04:19ddellacostacallen: yeah, I definitely can't get to files by default, and I'd rather be explicitly setting the policy on files in any case. Ah, gotcha.
04:19callenI still want to resolve the ACL permissions issue, mind, I just want to gather more data.
04:19SegFaultAXcallen: Entirely irrelevant to the problem.
04:19ddellacostaSegFaultAX: I can change it from the console. Not from the API--that's where I get the 403.
04:20SegFaultAXddellacosta: Sounds like your access key and secret aren't properly configured.
04:20callenddellacosta: and you're sure the keys are proper? do the keys work for any other part of the AWS API?
04:21SegFaultAXddellacosta: Check for stupid stuff, like missing the first/last letter of either the key or the secret during copy/paste.
04:21ddellacostaSegFaultAX, callen: the creds I'm currently using are a separate user I set up just for this bucket. They have allowed me to do stuff like access the list, upload objects, up until now, but now setting this permission seems verboten.
04:21callenddellacosta: re-verify that other things work (just like one or two) please.
04:21SegFaultAXddellacosta: Did you add change permissions for this IAM account for this bucket?
04:21ddellacostasure
04:22ddellacostaSegFaultAX: I explicitly added a permission so that this user can list, upload/delete, view permissions, and edit permissions.
04:23ddellacostacallen: just tried uploading a file via my app again, works fine, as long as I don't attempt to set the permissions. Listing all the current objects works fine too (that's my default view).
04:23callenddellacosta: dump the user policy please.
04:23SegFaultAXddellacosta: And you can, from the console, change the perms /as this users/?
04:23SegFaultAXUser*
04:23callenSegFaultAX: I think it's a one-off IAM thing he made
04:23callenI don't think he's logged in as this credential in the user in question
04:23ddellacostacallen: that's exactly right
04:24callenddellacosta: user policy prz.
04:24ddellacostacallen: one sec, getting' it
04:24callencool.
04:27ddellacostacallen: sorry, not sure exactly how to dump these
04:27SegFaultAXddellacosta: Easiest from the console.
04:28ddellacostacallen: basically, there's me ddellacosta, and "Authenticated Users", which have all List, Upload/Delete, View Permissions, and Edit Permissions set. That's it on this bucket.
04:28callenddellacosta: https://aws.amazon.com/iam/ ?
04:28ddellacostaI am using an IAM user to access this, which I *assumed* qualified as an "Authenticated User"
04:28SegFaultAXddellacosta: What arns?
04:29ddellacostacallen: yeah, just one user there, nothing in particular set--so I have to explicitly enable that user to access the bucket?
04:29ddellacostaSegFaultAX: what's arns, sorry?
04:30SegFaultAXddellacosta: The thingies in the "Resource" part of the policy.
04:30callenddellacosta: you need to add the bucket to resource
04:30callenddellacosta: http://mikeferrier.com/2011/10/27/granting-access-to-a-single-s3-bucket-using-amazon-iam/
04:30callenSegFaultAX: I'm not paid enough.
04:31SegFaultAX?
04:31ddellacostacallen: I owe you a beer(s) or, maybe knowing you, tea(s)…
04:32ddellacostaSegFaultAX: https://www.refheap.com/16010, but I'm going to try and update this now after reading the thing callen linked me to
04:33SegFaultAXddellacosta: Your resource is wrong.
04:33SegFaultAXBut try the link first.
04:33SegFaultAX(Your bucket is its own resource separate from its contents)
04:34ddellacostaSegFaultAX: yah, clearly I have more reading to do on AWS. In any case, I think between your pointers and callen's doc I'll be able to get this going…thank you both!
04:34SegFaultAXYou mean Mike Ferrier's doc.
04:34callenSegFaultAX: I'm enjoying the attribution/credit - sshhhh
04:35callenSegFaultAX: if Stack Overflow is be taken as an example, discovery and aggregation is as valuable as creation.
04:35SegFaultAXOk.
04:35callenddellacosta: so while trying to learn the underpinnings of AWS APIs, it's worthwhile to remember that a lot of this stuff fell out of internal SOA stuff.
04:36ddellacostacallen: interesting…I have to be honest, I've kind of put off learning the AWS security stuff, which is bad form, I know...
04:36ddellacostamy excuse is that I haven't used it to any great extent until now.
04:37callenddellacosta: I had the same attitude, we're all sinners and all that.
04:37ddellacostayah, exactly.
04:37callenddellacosta: I got tired of letting AWS APIs make me play the fool so I paused for a breather and just read for awhile.
04:37ddellacostacallen: yeah, I think I'm at that point too. *sigh* Here we go...
04:38callenddellacosta: ever work with SOA before?
04:38callenddellacosta: service composition, policies, etc?
04:38ddellacostanot in any deep way
04:38ddellacostacallen: I've dabbled with the architecture in a few projects here and there, but nothing that really implemented it seriously. More like, "SOA-lite"
04:39callenddellacosta: I've been meaning to do a tutorial on writing your own micro-SOA but I feel like nobody would read it because nobody really cares until they're forced to about that sort of thing.
04:39callenddellacosta: yeah I'm usually "SOA-lite" as well.
04:39ddellacostacallen: I think that is sad but true.
04:39callenddellacosta: well it's not like most projects need it or anything.
04:39callenwe're engineers, not cathedral designers.
04:39callenor architects, rather.
04:40callenalthough if you ask a country with professional engineers, we're not engineers either.
04:40callenso we're just here, futzing around with our code. :)
04:40callenddellacosta: hear about the smog in Singapore?
04:40ddellacostacallen: yeah, exactly, and after my early career I've actually grown more wary of architecture…
04:40ddellacostacallen: no, although I've been to Singapore a good number of times in the past few years, didn't notice a *ton* of smog
04:41callenddellacosta: it's a recent phenomenon, AQI of like 200+, hit a peak of 415 the other day.
04:41ddellacostacallen: on the other hand, I spent most the time indoors, as people in Singapore are wont to do
04:41callenddellacosta: the agricultural field burning in Indonesia is practically killing Singapore.
04:41ddellacostawooah, no *shit*
04:41callenyeah I think some records for worst AQI were set for SG in the last two weeks
04:41callenterrifying stuff.
04:41ddellacostaugh
04:42ddellacostacallen: you know, now that you mention it, I recall seeing someone tweet about the smoke
04:42callenI had the same experience where exposure to architecture astronomy scared me off. I re-acclimated to an appreciation of the nicer parts after having to build a larger-than-I-was-used-to service backend
04:42ddellacostamade a scotch joke
04:42callenearly exposure, specifically.
04:43ddellacostacallen: yeah, I think that it's about calibration…lots of developers (myself included) start off thinking they can build these big cathedrals, or even that that is worthwhile
04:43ddellacostathen you realize you don't need it for most stuff, and actually it causes huge problems, and you scale back
04:43ddellacostathen you start to realize when you can and can't use it. I'm between that 2nd and 3rd phase I think, still have lots to learn
04:44ddellacostaalright, it's sunny, I'm going out for a change.
04:44callenddellacosta: cheers.
04:44ddellacostathanks again for the help. :-)
04:44callenddellacosta: glad I could be useful. Enjoy your sunny weather. Ours has been great too.
04:44ddellacostacallen: thanks. :-)
04:45callenSegFaultAX: SF was beautiful yesterday. 80% of passersby were remarking upon it.
04:45SegFaultAXcallen: Yes.
04:48callenSegFaultAX: how is pair-programming treating you?
04:49SegFaultAXcallen: Good.
04:49callenSegFaultAX: well?
04:50callenSegFaultAX: how are you handling the constant stimulus and lack of music?
04:51SegFaultAXCommunication, mostly.
05:46tomjackhttp://www.insteadofawesome.com/
05:51noonianwizard!
09:20jouiswalkerdo monads solve any problems in clojure?
09:25Bodiljouiswalker: Yes, but considerably fewer than in Haskell.
09:27jouiswalkerBodil: thanks
09:38RogachQ: I tried to use import-static like this: (require 'clojure.contrib.import-static) (import-static ...), but it gives me "Unable to resolve symbol: import-static in this context". Why is this happening?
09:38hyPiRionRogach: do (require '[clojure.contrib.import-static :refer [import-static]]) instead
09:39hyPiRionOtherwise you'd have to fully qualify the namespace each time you invoke a function from it (e.g. you'd have to do (clojure.contrib.import-static/import-static ...))
09:39RogachhyPiRion: I tried (use ...), to the same effect.
09:40hyPiRionRogach: okay, then the function name is possibly different
09:40RogachNow I have another funny problem - one of the imported symbols collides with clojure.core/once :)
09:42RogachAh, it doesn't collide, it is not surrounded with parentheses.
09:42hyPiRionRogach: a word of advice though, clojure.contrib.* is not maintained anymore. As for import-static, it hasn't been moved over, but most other contrib libraries have
09:43RogachhyPiRion: Hm. And why import-static hasn't moved?
09:43hyPiRionhttps://github.com/richhickey/clojure-contrib/blob/master/src/main/clojure/clojure/contrib/import_static.clj
09:43RogachhyPiRion: It's too small to bother moving? ;)
09:43hyPiRionBecause that's it: It's not really much to fix in that library :p
09:43hyPiRionyeah
10:46gfrederickswhat is the expected behavior when a memoized function throws an exception?
10:49gfredericksin particular if I have (def g (memoize f)) where f throws an exception only on the first invocation, what should I expect g to do on the second invocation?
10:57TimMcRogach: https://github.com/baznex/imports might be what you want.
10:59hyPiRiongfredericks: oh, hahah
10:59hyPiRiongfredericks: http://dev.clojure.org/jira/browse/CLJ-1053
11:01hyPiRiongfredericks: Well, it's not referentially transparent then, is it?
11:05gfrederickshyPiRion: what isn't?
11:06gfrederickshyPiRion: with clojure.core/memoize the second invocation of g calls f directly and returns the result
11:07gfredericksbut I don't think this is the case with clojure.core.memoize/memo-ttl
11:07gfredericksthe latter fact woke me up at 1am a couple nights ago
11:12hyPiRiongfredericks: f is not referentially transparent
11:15gfrederickshyPiRion: that's fine
11:15hyPiRionthat's not fine for memoize
11:15gfredericksokay so you're saying the behavior is undefined for good reason?
11:16clojurebotsame reason we don't wear animal skins or hunt the wooly mammoth. because we're not savages.
11:16gfredericksand I should use some other abstraction for what I'm doing?
11:22hyPiRiongfredericks: I'm not sure what you mean. Memoize should generally keep the exception and throw it every time you attempt call with the same parameters again
11:22gfredericksoh okay
11:22gfredericksso clojure.core/memoize is the bad one then
11:22gfredericksis core.cache a decent thing to use directly?
11:23gfredericksI want to cache the result of a failable thing such that failure causes it to retry the next time
11:24pellishello
11:25pellisso i know there are a couple book authors here :), i'm wondering what kind of toolkit to use for self-publishing a clojure mini book (would be my first book)
11:32Okasupellis: Latex and editor of choice.
11:33pelliswas thinking more in the direction of asciidoc
11:40Morgawrcan somebody provide me an example of cond-> and cond->>? I don't quite understand how they work
11:42gfredericksMorgawr: they're like -> and ->> but you add a boolean expression before each threading form, which can "turn it off" if it's false
11:42gfredericks,(-> 3 (* 2) (inc))
11:42clojurebot7
11:42gfredericks,(cond-> 3 true (* 2) true (inc))
11:42clojurebot7
11:42gfredericks,(cond-> 3 true (* 2) false (inc))
11:42clojurebot6
11:42gfredericks,(cond-> 3 false (* 2) true (inc))
11:42clojurebot4
11:42Morgawrokay so, as soon as it hits a "false" expression it returns?
11:42pdkso it lets you switch them off individually to control threading at runtime
11:42gfredericksMorgawr:
11:42gfredericksno
11:42Morgawroh
11:42gfredericksit skips that one
11:42pdkit sounds like it simply skips all falses
11:42Morgawroh okay, so it just skips
11:42pdkand continues on with the trues until the end
11:42pdksame for cond->> i imagine
11:43gfredericksyep
11:43Morgawrthanks, that's what I really wanted to know
11:43Morgawr:)
11:43Morgawr(inc gfredericks)
11:43lazybot⇒ 25
11:43pdkthat's a clever mecro
11:43Morgawr(inc pdk)
11:43lazybot⇒ 1
11:43pdkmacro
11:43pdkis it able to use a list or something to give it a series of boolean values
11:43pdkas opposed to threading them in piecemeal
11:44pdkor a generated seq for that matter
11:45gfredericksnope
11:45gfredericksI think the idea is instead of simple booleans you'll have more complex expressions
11:48gfredericksthe macros aren't really meant for data-oriented algorithms
11:48gfredericksyou could easily use reduce for that
11:51Morgawrgfredericks: do I need an :else in cond->/cond->>?
11:51gfredericksnope
11:51gfredericksyou don't need an :else in cond either
11:52Morgawrwell, as far as I know without a :else (or anything that self-evaluates as true, like any keyword) it will throw an uncaught type exception (or something like that) if no condition matches
11:52gfredericks,(cond false :not-this)
11:52clojurebotnil
11:52gfredericks,(cond)
11:52clojurebotnil
11:53gfredericks,(case :foo :bar :not-this)
11:53clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching clause: :foo>
11:53Morgawroh
11:53Morgawrohhhh
11:53MorgawrI was confusing it with condp
11:53Morgawrcondp will throw an exception
11:53Morgawrsorry
11:54gfredericks,(condp = :foo :bar :baz)
11:54clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching clause: :foo>
11:54gfredericks,(condp = :foo :foo :baz)
11:54clojurebot:baz
11:55gfredericksanyhow no you definitely don't need an else. Even if all your exprs are falsy you'll just get the threaded value back
11:55gfredericksI'll sometimes use cond-> with just one pair because it's a bit less repetetive than the if version
11:55gfredericks,(cond-> 12 (pos? -4) inc)
11:55clojurebot12
11:55gfrederickscompared to ##(if (pos? -4) (inc 12) 12)
11:55lazybot⇒ 12
11:56pdkit sounds like it only threads through trues
11:56pdkso if everything's false you just get out what you put in
11:56gfredericksyes that's the idea
11:56Morgawrcool
11:56gfredericksit also works nicely with ->
11:56gfredericks,(-> 12 inc inc dec (cond-> false (* 23)) inc)
11:56clojurebot14
11:57gfredericksI'll do that to add a condition to just one or two clauses
11:57Morgawrmmm.. weird, I'm using ClojureScript and it doesn't seem to be working with cond->
11:58gfredericksdo you know for sure it's defined?
11:58gfredericksit's new in 1.5
11:58Morgawrin the clojurescript source I've seen it referenced with import-macros
11:58Morgawrand I'm using Clojure 1.5.1
11:59gfredericksI haven't used CLJS lately
11:59gfredericksdon't have an easy way to try it out
11:59gfrederickshimera doesn't have it
12:02Morgawrit's weird, it just says "cannot call undefined"
12:02gfredericksprobably gets compiled to a runtime call to cond->
12:02Morgawreven in the repl when I do a simple (cond-> true true true) or whatever
12:03gfrederickscljs does not check that things exist I don't think
12:03gfredericksso if you call a nonexisting macro it just compiles it to a function call on an undefined thing
12:03Morgawryes, probably
12:03Morgawrbut the question is... why it's not there?
12:03gfrederickscorrect.
12:04Morgawrhttps://github.com/clojure/clojurescript/blob/master/src/clj/cljs/core.clj#L56 it's clearly referenced here
12:10Morgawrmaybe dnolen_ knows? :(
12:18Morgawrgfredericks: mm.. I just copy-pasted the cond-> definition from clojure into my own macros file and it seems to be working
12:26tmciverWhat's the preferred way of working with json in clojure these days?
12:27tmciverIs it clojure.data.json?
12:35Okasutmciver: Cheshire.
13:06tmciverOkasu: thanks.
13:09luxbockI installed Cygwin and I'm now using Emacs through it (emacs-w32)
13:10luxbockI installed leiningen using the shell script, but now nrepl-jack-in doesn't work anymore
13:10luxbockI get: /usr/bin/env: bash: No such file or directory
13:10luxbockin my *nrepl-server* buffer
13:10luxbockany ideas why this might be?
13:17luxbock'lein repl' in the cygwin terminal works fine, but not when I call it from Emacs via M-x shell (which is set to use bash as well)
13:48luxbockgot it working, had to remove the #!/usr/bin/env bash part from the lein file
15:18bbloomdnolen_: it's really such a bummer that core.async has to copy paste so much code to support cljs :-/
15:18bbloomi know that 100% cross plat is a NON-goal, but avoiding copy paste seems like it should at least be a goal
15:19bbloomi hope this core.async effort spurs some progress there
15:26tomjackI think it is
15:27tomjackspurring I mean
15:28tomjackor maybe it's just a coincidence, but shared code is a priority for 1.6
15:35bbloomtomjack: i've heard ppl say that, but i dunno where the evidence or progress is :-)
15:36bbloombesides some notes from stuart halloway on the design wiki, i guess that's the best there is
15:36bbloomgranted, async is on that list, so maybe it's partially accurate :-)
15:39tomjackoh nice, new asm as well
15:40tomjackcinc coming soon? :)
15:52OneFourSevenHey guys. I'm running lein uberjar to package my web application. But the problem is that I'm using a local jar that I've included by adding the :source-paths line to project.clj. This jar isn't included in the uberjar. Is there a way to package the jar with it?
16:07Bronsatomjack: I'm working on CinC as my GSoC project
16:07tomjacksweet, didn't notice that one
16:08tomjackare you moving to the new asm?
16:09BronsaI don't see what would prevent me from using the lastest version
16:09Bronsaso, yes.
16:10tomjackexciting :) best of luck
16:10Bronsathanks :)
16:11bbloomBronsa: how's it going so far?
16:12Bronsabbloom: I'm backporting the Compiler.java analysys phase in a clojurescript-ish style right now
16:13Bronsaby next week hopefully the basic analyzer should be done
16:14Bronsanext I'm going to write locals-clearings, constant inlining etc as optional additional passes over that clojurescript-ish AST
16:14bbloomBronsa: cool!
16:15Bronsaright now I'm trying to come up with a sane way to analyze '.
16:15Bronsathe clojure Compiler is kinda derp about that :/
16:15bbloomBronsa: the clojure (and clojurescript) compilers are derpy about a bunch of things :-P
16:16bbloomBronsa: i'd probably try a direct 1-to-1 syntax port at first & then refactor from there
16:16bbloomtrying to keep it working as i go
16:16Bronsabbloom: right, that's somewhat what i did for tools.reader
16:17BronsaI planned on taking the same approach with CinC but.. I decided I wanted to get rid of C.EVAL since the beginning
16:18bbloomi'm not super familiar w/ compiler.java, would have to study it
16:20Bronsawell, clojure right now has an interpreted eval for some ops
16:20hiredmanBronsa: how are you getting rid of C.EVAL? explicit statement/return things?
16:20Bronsae.g. def
16:21hiredmanoh, you mean the eval method on Exprs?
16:21Bronsahiredman: I'm wrapping every top-level in a ((^:once fn* [] ..))
16:21Bronsayeah.
16:21hiredmansure
16:21bbloomyea, i saw that at somepoint, but wasn't sure how much of it was still being used. seemed like it was largely vestigial
16:21Bronsabbloom: when you eval (def foo 1) it's actually interpreted
16:22hiredmanit is only used in the repl for some simple toplevel forms
16:22bbloomBronsa: heh. what's that quote? "The top-level is hopeless"
16:24tomjackso will analysis be side-effect free?
16:25bbloomtomjack: i don't think it can be in the face of def
16:25Bronsano, there's no way that can be done
16:25hiredmanwell
16:27hiredmanyou can have a var environment that is ultimately backed by the real enviroment, but when you add vars they co in some kind of map, and analysis would come with a :vars {} map
16:28Bronsasure
16:28hiredmanwhich, uh, maybe clojurescript already does?
16:28Bronsabut then you have to put that map in an atom
16:28bbloomhiredman: no, clojurescript uses a global namespaces atom w/ swap!
16:28Bronsaand that's still.. side-effects
16:29hiredmanBronsa: no, you can push it down through the tree, I believe
16:29bbloom(when false (def x 1)) still defines x in clourescript....
16:29hiredmanbbloom: well, but that doesn't have to happen as part of analysis
16:29tomjackI don't care if there are side-effects when my actual top-level clojure code is analyzed, I'd just like to be able to use the analyzer in macros
16:29bbloomyes: you can have env-in and env-out for every ast node
16:29hiredmanright
16:30Bronsahiredman: you'd have to pass to the next call to analyze the previously returned map?
16:30hiredmanBronsa: depends on what you are doing with the analysis results
16:31bbloomyou can definitely make analysis pure, but there are other weird things that can happen in that case too
16:31hiredmanfor the compiler, you are compiling a toplevel form at a time, so analysis->compile->run for every top level form, so you will get the side effects
16:31Bronsaright
16:31Bronsayeah, I suppose it would be trivial to make a side-effect free version to be used for static analysis of single forms
16:32tomjackcool. not that that's really important compared to the larger goal of CinC :)
16:32bbloommore important than side effect free is idempotent and deterministic :-)
16:33bbloomlike in cljs, the analyzer used to do gensym, so multiple calls w/ the same input produced differing results
16:33bbloomi fixed that & was considering fixing the side effects for def, but decided it would only matter if you were doing speculative analysis and then not going to commit creation of those vars via compilation
16:36jtoywhat is the best interface for clojure to store data, like a database
16:36wei_jtoy: edn?
16:36wei_does anyone have an example of using the :if :then :else construct in clojure.algo.monads? trying to figure out the syntax
16:36bbloomjtoy: need lots more info from you
16:37jtoyi want to program in pure clojure and not have to deal with creating tables, running sql to update the database,etc
16:37finishingmovewhat's this error?
16:37finishingmoveUnable to resolve symbol: union in this context, compiling:(NO_SOURCE_PATH:11:1)
16:37finishingmovei just try to use the union function
16:37finishingmovefirst i thought something was wrong with my project setup, so i made a new one with lein new
16:38arrdemfinishingmove: clojure.set/union?
16:38finishingmovebut the error remains
16:38bbloomjtoy: do you need durability? do you need queries? how much data? what are your access patterns?
16:38finishingmovearrdem yes, thanks... i thought it was in core
16:39arrdemfinishingmove: np
16:39arrdemfinishingmove: that's what IRC is for :P
16:39bbloomjtoy: "what type of vehicle is best?". -- "do you want to go to japan or to the grocery store?" …. "oh, you want to go the bottom of the ocean?"
16:40arrdembbloom: bottom of the ocean pah. TO THE MOON!
16:40jtoybbloom: i need durability so i can query later , the queries could be sql or something else, but i want a clojure interface, the db would be small,i like using sqlite but i hate with any sql i need to continuously alter tables as im buidling the code
16:41jtoybbloom: i am using korma on anohte project, it is nice, but still not easy enough
16:41bbloomjtoy: do you want easy or do you want simple? :-P
16:41jtoysimple
16:41arrdemjtoy: what kind of scale? single local db or do you need a real db?
16:41jtoysingle local db
16:41jtoyfor now:)
16:41SegFaultAXI feel mongo coming on...
16:42arrdemSegFaultAX: nope
16:42bbloomhow much data? a meg? 10? 100? 1,000?
16:42SegFaultAXarrdem: Thank you. :)
16:42bbloomSegFaultAX: mongo should never be coming on
16:42arrdemSegFaultAX: I can play nice :D
16:42ohpauleezhaha
16:42SegFaultAXThe questions were going all mongoy. I was afraid for a moment.
16:42arrdemSegFaultAX: I'm not blind to Mongo's failings, I just don't care abou tmost of them.
16:43arrdemibdnox's simpledb?
16:43jtoyto store my browser history, so title,url, and timestamp, it would grow at probably 1 meg a week
16:43bbloomjtoy: why not try a simple atom in memory, plus prn and clojure.edn/read
16:43SegFaultAXjtoy: Sounds like you need something webscale, then.
16:43arrdemjtoy: simpledb is probably right up your alley
16:43arrdemSegFaultAX: gtfo :P
16:43arrdemjtoy: it's an in memory atom that gets dumped to a file by a worker
16:44bbloomjtoy: you can write to /tmp/whatever then atomically file-move over the old version of your file
16:44SegFaultAXjtoy: Have you considered MangoDB?
16:44arrdemSegFaultAX: .......
16:44ohpauleezHA!
16:44SegFaultAXarrdem: https://github.com/dcramer/mangodb
16:44jtoySegFaultAX: i tried it a few years ago, data loose
16:44SegFaultAXjtoy: I promise you, Mango is webscale.
16:44arrdemSegFaultAX: raw terminal on an abandoned server atm. will look later.
16:45bbloomyou could also try the free/embedded datomic, if you don't mind closed source, but really, flyswatter vs bazooka
16:45SegFaultAXarrdem: You will appreciate it. :D
16:45jtoyI've used riak and postgresql for scaling
16:45arrdemSegFaultAX: I'm sure I will
16:45bbloomsince when did people become afraid of file systems? :-P
16:45SegFaultAXarrdem: (Wrapper for /dev/null)
16:45bbloomdon't they teach anybody fopen in school anymore!?
16:45SegFaultAXbbloom: Filesystems aren't webscale.
16:45arrdembbloom: lol wut iz posix?
16:45jtoybbloom: since coming to clojure i have, it is so much easier to deal with files in ruby/python
16:45arrdemSegFaultAX: ah so it's really nulldb
16:46bbloomjtoy: you need spit and slurp. how much easier does it get?
16:46jtoybbloom: it is painful for me when i use files in clojure, probably bc im still new
16:46bbloom(doc spit)
16:46clojurebot"([f content & options]); Opposite of slurp. Opens f with writer, writes content, then closes f. Options passed to clojure.java.io/writer."
16:46bbloom(doc slurp)
16:46clojurebot"([f & opts]); Opens a reader on f and reads all its contents, returning a string. See clojure.java.io/reader for a complete list of supported arguments."
16:46SegFaultAXThe file interface designed by my x-wife.
16:46bbloomwhen you outgrow split & slurp, you can A) learn how to use the file APIs better or B) choose a bigger solution
16:46jtoybbloom: using doseq, doall, do*, and lazy data, resource files vs io ,etc
16:47arrdem(dec SegFaultAX)
16:47lazybot⇒ 1
16:47bbloomjtoy: don't bother with lazy io
16:47SegFaultAXarrdem: Learn to laugh, yo.
16:47jtoybbloom: I have to because I am processing "bigdata" often
16:47bbloomjtoy: with your browser history?
16:47arrdemSegFaultAX: your inuendo is bad and you should feel bad
16:47SegFaultAXarrdem: I let myself out, didn't I?
16:47jtoybbloom: no with my projects
16:47bbloomjtoy: ok, well for *this* project: forget lazy IO :-P
16:47arrdemwait. shit. copying a running mongo file ain't gonna work.
16:47SegFaultAXarrdem: Unfortunately for you I have IRC on my phone. So there.
16:48jtoybbloom: haha, I will
16:48arrdemSegFaultAX: Q_Q irssinotify is the bomb
16:48bbloomi know startups who spend 73895783573 hours doing shit that could be solved w/ spit and slurp and would scale better than whatever nonsense they came up with :-P
16:48jtoyarrdem: that db has no examples, hard to tell
16:48SegFaultAXarrdem: I <3 irssi+znc
16:48bbloomhell, hacker news basically runs on the spit/slurp model with binary encoding
16:49arrdemjtoy: chris's noir demo blog uses it
16:49arrdemjtoy: I swear that's how it works 'cause I ported that blog from simpledb to mongo for lulz one time
16:49SegFaultAXbbloom: Yea, but arc.
16:49jtoyruby has a library called datamapper that will read in an sql definition and auto migrate the tables so you dont have to deal with manually updating the db
16:49arrdemjtoy: it's really just spit and slurp in a library.
16:51jtoyarrdem: where is the blog post about simpledb?
16:52SegFaultAX$google chris granger simpledb
16:52lazybot[Commit History · ibdknox/simpledb · GitHub] https://github.com/ibdknox/simpledb/commits/
16:52arrdemjtoy: just read the sauce. it's 52 lines and I'm on my phone
16:52jtoyi saw that, didnt explain anything about what it is
16:53jtoyill just use koram for now then
16:53jtoykorma
16:53SegFaultAXjtoy: It's brief, read harder.
16:53arrdem(inc SegFaultAX)
16:53lazybot⇒ 2
16:53SegFaultAX(inc arrdem)
16:53lazybot⇒ 5
16:53arrdemwelcome to clojure, where the source is probably the only docs.
16:53arrdembut that's ok 'cause the source is readable :D
16:54SegFaultAXDidn't Holloway once say that the ratio from psuedocode to production code should be 1:1?
16:54SegFaultAXClojure is often pretty damn close.
16:54jtoyi dont mind reading source
16:54arrdemSegFaultAX: could be. I'm still trying to pseudocode in python because interviewers look at me weird when I start writing lisp
16:55arrdemjtoy: it's really just all the clojure.core maps functions wrapping a defonce'd atom
16:55tomjackalso, it seems hard to write clojure on a whiteboard :(
16:55bbloomarrdem: fuck 'em, i pseudo code in whatever formalism i make up at the moment
16:55SegFaultAXarrdem: Most of the time I'll code in whatever the primary domain language is. When I use lisp, they think I'm a wizard.
16:55amalloytomjack: no harder than it is to write it in notepad :P
16:55arrdemSegFaultAX: bust out some macros on that bitch and make 'em figure it out :D
16:56tomjackyes, harder, I claim
16:56finishingmoveI'm trying to solve the first euler problem, and I get a weird result
16:56tomjackbecause you can't move text around, you may have to erase large sections and start over
16:56finishingmove,(reduce (partial +) 0 (clojure.set/union (range 3 1000 3) (range 5 1000 5))))
16:56clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.set>
16:56arrdemjtoy: the init() just kicks off a worker thread that dumps the atom to the db as the clojure prn render
16:56arrdemfor "db" being defined as "./sdb.db"
16:56SegFaultAXfinishingmove: Whoa, inefficient much?
16:56finishingmovegives me 266333
16:57finishingmoveinstead of 233168
16:57arrdemjtoy: so you just put! and get, for some implicitly defined record structure which you create.
16:58finishingmoveSegFaultAX isn't the point of high-level programming to write code that is easier to reason about rather than being more efficient?
16:59SegFaultAXfinishingmove: Um, no?
16:59Cr8no reason you can't have both
16:59finishingmoveanyway, what's wrong with my function? why is it not giving the expected result?
16:59finishingmoveCr8, sure, if there's a more efficient solution, I'd like to know about it
16:59arrdemfinishingmove: only if you are willing to live with a shitty compiler....
16:59arrdemok gents, say goodby to this host. catch yall later.
17:01amalloyfinishingmove: well, math. math is the more efficient way. you can easily enough derive a simple formula with just a couple multiplications, divisions, and additions, for the "fizzbuzz sum" up to any N you want
17:01finishingmoveSegFaultAX do you have a more efficient solution?
17:01finishingmovewhat's so bad about my approach?
17:01SegFaultAXfinishingmove: Well first of all, you're duplicating a shitload of work.
17:02SegFaultAXfinishingmove: Don't worry about the summing part, that's trivial.
17:02SegFaultAXfinishingmove: How can we efficiently find all the numbers between 1 and N that are divisible by 2 co-primes A and B?
17:03SegFaultAXfinishingmove: Assume this constraint, you can iterate through the numbers 1 to N at most a SINGLE time.
17:03finishingmovei don't want to iterate at all
17:03finishingmoveanyway, can u explain what you mean about duplicate work in my function?
17:03finishingmovehow does it execute?
17:04finishingmovei see it as a simple 1-2-3-4-5 done
17:04SegFaultAXfinishingmove: If you read what I just said, you might gain some insight.
17:04finishingmovei have, and i haven't
17:04finishingmove:s
17:04finishingmovehow about being more concrete?
17:05finishingmovei believe you, but i don't see the problem
17:05n_bfinishingmove: What's faster, counting out everything from 3,6...999, or finding the total via the formula for an arithmetic progression?
17:05tomjackclearly the former?
17:06SegFaultAXtomjack: Let finishingmove work it out.
17:06finishingmovei wouldn't think it's slower at all
17:06finishingmovemaybe less memory efficient
17:06tomjackmaybe you're much faster at algebra, but I can do very little algebra in the time it would take to count everything out
17:08tomjackoh, I misread :)
17:08SegFaultAXtomjack: What?
17:08n_bI should've said, counting and summing
17:08tomjackI read "finding the formula.."
17:08SegFaultAXn_b: I think your meaning was clear anyway, given the context.
17:09SegFaultAXfinishingmove: So what do we need to see if any number in our range fits the criteria?
17:11finishingmovehaven't given it thought yet
17:13SegFaultAXfinishingmove: Write a function that given some number n, returns true if and only if it is divisible by 3 or 5 (or both)
17:21n_bTrying to figure out the fast way of doing this in clojure
17:22n_bmy solution seems way slower than it should be
17:23SegFaultAXn_b: What's your solution?
17:23n_b(reduce + (for [i (range 0 1000) :when (or (= 0 (mod i 5)))] i))
17:23amalloySegFaultAX: introducing division isn't going to speed things up :P
17:24SegFaultAXamalloy: Over the original approach? How do you figure?
17:25n_bThe simplest way is just the sum of divisors of 3 and 5 minus divisors of 15 I think?
17:26amalloymaybe a little, i guess? but i'm not sure why you're leading him down this path instead of just adding and subtracting a few arithmetic series
17:26SegFaultAXamalloy: Actually let me take that back, I don't know enough about the performance characteristics of hashsets to tell offhand if it will be slower or faster.
17:27amalloySegFaultAX: you're probably right: i was thinking more about the allocation costs of the lazy-seqs, which isn't as large as you'd guess; but hashsets will need to do division anyway
17:27n_bThe traditional solution is probably ```java int acc=0; for(int i=0; i<1000; i++) { if (i % 3 == 0 or i % 5 ==0) { acc+=i }};```
17:28SegFaultAXamalloy: Oh hmm, you bring up and excellent point, though.
17:28amalloyn_b: for a laugh re the traditional solution, you might enjoy http://dave.fayr.am/posts/2012-10-4-finding-fizzbuzz.html
17:29gozalacan anyone please help me understand why does (let [x :let] (def x :def) x) evaluates to :let
17:29gozalarather than :def ?
17:30bbloom,`(let [x :let] (def x :def) x)
17:30clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
17:30finishingmove,(reduce (fn [x y]
17:30finishingmove (if (or (= (mod y 3) 0) (= (mod y 5) 0))
17:30finishingmove (+ x y)
17:30finishingmove x)) 0 (range 1 1000))
17:30clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
17:30finishingmovehow is that ^ different to
17:30finishingmove(reduce + 0 (clojure.set/union (range 3 1000 3) (range 5 1000 5)))
17:30finishingmove?
17:31finishingmoveit gives different result (former is correct)
17:31gozalait seems to define x in the top scope rather than with in the let context
17:31SegFaultAX,(time (let [sum (partial reduce +)] (+ (sum (range 3 1000 3)) (sum (range 5 1000 5)) (- (sum (range 15 1000 15))))))
17:31clojurebot"Elapsed time: 2.922747 msecs"\n233168
17:32schmirgozala: def creates a global var. read (doc def).
17:32SegFaultAXamalloy: I guess that's pretty low on a warmed jvm. 0.2ms
17:32SegFaultAXamalloy: I haven't compared it to the hashset version yet though.
17:32amalloySegFaultAX: well, yeah, but why call (range) at all?
17:32amalloyjust look up the formula for summing an arithmetic series
17:32SegFaultAXamalloy: Fewer keystrokes.
17:33bbloomgozala: what schmir says is correct, but to answer the question anyway: x is resolved when that expression is compiled. during compilation, def hasn't run yet, so there is no x var to resolve against
17:33bbloomgozala: that is, def has the side effect of creating a global called x. however, that's some.namespace/x instead of the 'x that is in the local context
17:33SegFaultAXamalloy: Oh well that wasn't the original problem we were discussing.
17:34llasramfinishingmove: your `union`-based implementation has the effect of replacing `or` with `and` in the other implementation
17:34SegFaultAXamalloy: We were specifically not talking about the closed form solution, if that's what you mean.
17:34gozalabbloom: schmir thanks
17:34finishingmovellasram, shouldn't that be intersection?
17:34gozalatrying to make up my mind what js should it compile to
17:34amalloyi didn't notice anyone stating that constraint
17:35SegFaultAXamalloy: Eh, I was addressing the set thing.
17:35n_bamalloy: That article is great; think I'll be stealing it for an Intro to FP presentation I'm doing next week. Cheers!
17:35llasramfinishingmove: Oh, you're right. Brain not at full speed, apparently
17:36SegFaultAXFood time, bbl.
17:36finishingmovethe union solution gives a higher number actually
17:42Cr8here's a weird one
17:42Cr8,(apply + (distinct (concat (range 3 1000 3) (range 5 1000 5))))
17:42clojurebot233168
17:42n_b,(clojure.set/union (range 0 20 3) (range 0 20 5))
17:42clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.set>
17:42Cr8why is (distinct (concat c1 c2)) behaving differently from (union c1 c2) ?
17:43finishingmoveI'd like to know too
17:43llasramEven better: &[(count (clojure.set/union (range 3 1000 3) (range 5 1000 5))) (count (clojure.set/union (set (range 3 1000 3)) (set (range 5 1000 5))))]
17:43llasramEr,
17:43llasram&[(count (clojure.set/union (range 3 1000 3) (range 5 1000 5))) (count (clojure.set/union (set (range 3 1000 3)) (set (range 5 1000 5))))]
17:43lazybot⇒ [532 466]
17:44Cr8AH
17:44Cr8Got it!
17:44Cr8clojure.set/union *expects to be given sets*
17:44n_byup
17:44Cr8as it's just (reduce conj <smaller set> <larger set>) when given two sets
17:44llasramAnd definitely does the wrong thing when given non-sets
17:44Cr8with two vectors you are just catting the larger one onto the smaller one
17:44n_bThis is where core.typed would help :p
17:44Cr8or lists, catting in reverse
17:45finishingmovethis is where haskell would have helped
17:45finishingmove:D
17:47Cr8except I had larger/smaller backwards for all of that
17:49finishingmovei still don't see how this:
17:49finishingmove(defn problem'
17:49finishingmove []
17:49finishingmove (reduce (fn [x y]
17:49finishingmove (if (or (= (mod y 3) 0) (= (mod y 5) 0))
17:49finishingmove (+ x y)
17:49finishingmove x)) 0 (range 1 1000)))
17:49finishingmovecould be faster than
17:49finishingmove(defn problem
17:49finishingmove []
17:49finishingmove (reduce + 0 (distinct (concat (range 3 1000 3) (range 5 1000 5)))))
17:49amalloyfinishingmove: please stop pasting large programs here
17:49amalloy~paste
17:49finishingmovenever have, amalloy
17:49clojurebotpaste is not gist.github.com
17:49amalloy$google refheap
17:49lazybot[Refheap - The pastebin for your, you know, pastes] https://www.refheap.com/
17:49finishingmoveand these are not large programs, my dear clojurebot
17:49s-h,(reduce + (filter #(or (= (mod % 3) 0) (= (mod % 5) 0)) (range 1 1000)))
17:49clojurebot233168
17:49n_bI don't see how you could see the former *not* be faster than the latter
17:50amalloys/large/multi-line
17:50llasramfinishingmove: in this channel's etiquette, anything larger than one line is "large"
17:50n_bit's doing more work, plain and simple.
17:50finishingmovethe first one generates a list of all numbers from 1 to 1000
17:51finishingmovethe other one generates 2 lists with only a portion of numbers
17:51finishingmoveand the total of the two is less than 1000
17:51llasramfinishingmove: And IMHO is less about actual size, than just line breaks. Put your admittedly-small programs on one line, and your fine
17:52finishingmovei got the memo
17:52amalloyfinishingmove: putting things into sets is not free. they have to build a data structure that supports conj/disj/contains? operations quickly
17:52Cr8finishingmove: it's easier to see the difference if you go higher than 1000
17:52Cr8https://www.refheap.com/16020
17:54fbernierso... what's the difference between a mutex and a clojure "dosync" ?
17:55finishingmoveinteresting, Cr8
17:55bbloomfbernier: a lot. go read about dosync and "software transactional memory"
17:55bbloomfbernier: but if you're new to clojure, you can basically just ignore dosync… it's pretty rare in most clojure code these days
17:56devnignore that! :)
17:56devnlook into refs, build a simple in-memory db with them
17:56devnit's fun
17:56fbernierbbloom: Ok thanks ... I am new to clojure but will be giving a presentation about it soon.
17:56fbernierlooking for cool examples to show off
17:57devnfbernier: i have one for you
17:57hyPiRionfbernier: so with mutexes you may deadlock, but that's impossible with STMs (dosync blocks)
17:57devnfbernier: https://github.com/Licenser/stupiddb
17:57devnfbernier: that's an old project, but a fun one
17:57bbloomfbernier: clojure's concurrency primitives are only one of many interesting things in clojure. however, most would agree with me when i say that immutable/persistent data structures are of far deeper importance and are a prerequisite in understanding
17:58llasram+1. I have yet to need dosync or the STM to solve a real problem
17:59fbernierbbloom: Alright, I'll look into that and see how I can explain it easily.
17:59llasramBut persistent data structures fundamentally change how you approach problems
17:59devnwhat about an agent llasram? an atom?
17:59bbloomfbernier: http://www.infoq.com/author/Rich-Hickey is the place to start if you like videos
18:00devn^-watch Are We There Yet
18:00bpr^ this
18:00bbloomyup, then "simple made easy"
18:00Cr8Atoms are quite useful
18:00devnmy brain was like this: http://slackwise.net/files/images/Tim%20and%20Eric%20-%20Space%20Explosions.gif
18:00llasramdevn: Sure, but those are different. Agents can participate in STM transactions, but STM isn't fundamental to them. Atoms have nothing to do with either the STM or dosync
18:00Cr8agents I don't think I've really used "correctly"
18:01bprimo, rich's "simple made easy" has a larger impact if you watch Stu Halloway's talk about that topic first (iirc it was delivered in the first conj)
18:01bprhttp://www.youtube.com/watch?v=cidchWg74Y4
18:01devnllasram: meh, datomic uses refs from what i understand
18:01devnand that is certainly real world
18:01llasramdevn: Hmm, I thought I read that the in-memory state is all just in an atom
18:02devni might have that wrong
18:02fbernierthanks for the infos everyone
18:02devnyou're probably right
18:02llasramdevn: But I was specifically talking about my own production Clojure code. I wrote Clojure every day, and never used a ref
18:02llasrams,wrote,write,
18:02finishingmovei did "lein repl" in my project folder, but how do i call functions from my namespace?
18:02devni wrote refs and then was like: oh, i could write this a different way
18:02tomjackI'd be surprised if datomic didn't use refs
18:02devnslowly unlearning my imperative BS
18:03tomjackthey say you should have multiple transactions in flight for best performance
18:03devn^-that
18:03tomjackwhich suggests refs underneath to me (though I too have never actually used them)
18:03llasramfinishingmove: `require`, then probably `in-ns`
18:03finishingmovethanks
18:03hyPiRionfinishingmove: (require '[my.namespace :as my]) then (my/function args)
18:03finishingmovety!
18:04devnanyone here in SF?
18:04bbloomdnolen_: is refer-clojure not supported in cljs?
18:04tomjackI'm in berkeley, looking for a place in SF now
18:04bbloomdnolen_: the assert string says it is, but the code seems to strip it out
18:06tomjackor maybe pods replace refs in datomic's internals?
18:06devnmy guess is: unlikely
18:06devnbut that'd be fun if it were true
18:06tomjackthere are definitely some things called 'pod' in there
18:06devntomjack: oh yeah?
18:07tomjack(but I don't actually know wtf pods really are, so..)
18:07tomjacke.g. the log tail is a 'tail-pod'
18:07devnheh
18:08bbloomtomjack: http://dev.clojure.org/display/design/Mutex+references+%28pods%2C+nee+cells%29
18:08devnthis is old chat
18:08bbloomtomjack: plus lots of irc discussion that was hard to find
18:09devnyeah we were talking about pods maybe 6months before the first conj
18:09tomjackI saw the talk about them but it seemed like it still was unclear what they should be exactly
18:09devnit's like transients
18:10devnexcept it ensures the thread who created it is the the thread that changes it
18:10devnthe policy of who can change it is the ref type
18:10devnthat's my dumb understanding
18:10tomjack&(let [t (transient [])] @(future (conj! t :foo)))
18:10lazybotjava.lang.SecurityException: You tripped the alarm! future-call is bad!
18:11tomjackoya
18:11bprfbernier: this is one of my fav clojure-specific talks of rich's http://www.youtube.com/watch?v=dGVqrGmwOAw
18:11bprjust fyi
18:11fbernierthanks
18:12devnfbernier: seriously though, and yes, im going to be pushy: watch "Are we there yet?"
18:12devnit's the original talk. it's THE talk
18:13bpryes, that will change how you think about concurrent programming.
18:13fbernierI will surely watch it, but should I absolutely watch it before my talk on tuesday which should be an introduction to clojure?
18:13fbernierI don't have much time to gather the best info I can ...
18:14bbloomfbernier: you're given a talk on a subject you don't know anything about? :-P
18:14fbernierI do know about basics ...
18:14mdeboardSimple Made Easy is another good talk. My fave talk actually
18:14mdeboardfbernier, I gave a talk on Clojure to a local Scala meetup, I'm a super beginner too. Don't sweat it.
18:15mdeboardI based my talk on Simple Made Easy, actually.
18:15fbernierit'll be an informal talk at a local event
18:15bprfbernier: is your talk intended to be a first introduction to clojure, or is it more about the deeper rationale behind the design choices Rich made when creating the language?
18:15devntomjack: http://www.infoq.com/interviews/hickey-clojure-reader
18:16mdeboardYeah, that's how mine was too. bbloom signing up to give a talk on a subject you're not well-versed in is a great way to get well versed :)
18:16fbernierbpr: first introduction for sure
18:16fberniermost will not be familiar with lisp
18:16fbernierit's a web crowd
18:16devntomjack: his response to the question about pods has this line in it: "Datomic has informed my thinking about pods and probably will enable me to complete them."
18:18tomjackcool, didn't notice that when I watched that interview before
18:18bbloommdeboard: yeah, but if you only have a few days to prepare, you're unlikely to become well versed enough to speak about it intelligently. the audience has to sit through your ramblings…. they came to see YOU….
18:18jtoyanyone here use ring? how am i supposed to reload the server after i change it? right now i have to kill the repl for every change
18:18mdeboardbbloom, Oh, didn't know it was short-fuse like that :)
18:19llasramjtoy: Provide the vars holding your handlers as the handler functions to whatever server you're using. Reader macro: #'my-ring-handler
18:19bprfbernier: http://bit.ly/11FVEN5
18:20llasramjtoy: When you make a change and reload the namespace, the function referenced by the var changes, and the server calls the new function
18:20bprfbernier: I haven't watched all the videos on that list, but it seems like a good model for you. It seems like it's aimed at a similar audience and has similar goals
18:21fbernierbpr: cool thanks
18:21bprnp
18:21jtoyllasram: ok, ill try that
18:23jtoyllasram: good example here: https://github.com/mmcgrana/ring/issues/72
18:26arohnercan someone remind me why take-while says the function should be pure?
18:27arohnerI have a list containing a bunch of numbers, and I want to take items off the list while the sum of the items is < N
18:27jtoyhmm, i cant get it to work though
18:28tomjackarohner: interesting!
18:28llasramarohner: Because it just makes no guarantees about when your predicate will be called
18:29llasramThat particular problem is pretty easy to lazy-seq up directly though
18:29arohnerreading the source, it seems like closing over an atom will work
18:30fsmunozwhat0s the cleanest way in Clojure to do (setq foo (or some-value some-other-value))?
18:30llasramjtoy: It does in general. Code gist-able?
18:30jtoyllasram: im testing more
18:32jtoyllasram: https://www.refheap.com/16022
18:34llasramarohner: But would be poor style! Everyone would frown at you, distressed and saddened
18:35arohnerllasram: is there a better abstraction?
18:35Cr8arohner: https://www.refheap.com/16023
18:35arohnerCr8: oh, very nice
18:35tomjack:/
18:36arohner?
18:37amalloyCr8, arohner: why define take-while-reduce at all? just use reductions+take-while
18:37tomjackhttps://www.refheap.com/861a6a77c9f571804e7b06f38
18:37tomjackI do still feel unsatisfied
18:38Cr8amalloy: well, he wanted the original list's items
18:38Cr8you could zip the reductions and the original list together I suppose
18:38Cr8then unzip
18:38arohneryeah, but that's annoying
18:38amalloy(map (fn [a b] a) xs (reductions ... xs))
18:39amalloybut, sure, it's not a ton of fun at that point
18:39Cr8then wrap the (reductions) part with the take-while
18:40tomjackoh, good idea https://www.refheap.com/a2e63743cb5dc99ff046ec31c
18:40tomjackmy gut says Data.Lens has a much more beautiful solution
18:40llasramjtoy: Oh! You still need some way of reloadig the namespaces. Something standard provides a `wrap-reload` which will reload files which change. I myself just launch the server from an editor-connected REPL and reload namespaces like for any other Clojure work
18:40tomjackand I wish we could do this with reducers
18:41devnanyone here ever use jode?
18:41Cr8,(let [xs (range 10)] (map (fn [a b] a) xs (take-while #(< % 10) (reductions + 0 xs))))
18:41clojurebot(0 1 2 3 4)
18:41devn(and are willing to admit it?)
18:41llasramtomjack: I wrote a `reductions` implementation for reducers, but it languishes in Jira
18:41devnllasram: it took me 1.5 years to get my patch on range in
18:41devndon't fret
18:41tomjackI wrote one too but that is still unsatisfying
18:42llasramWhat would you wish instead?
18:42dobry-denWhy is `doto` used here instead of the `->` macro? (let [mac (doto (Mac/getInstance hmac-sha1) (.init signing-key))] …)
18:42dobry-denseen here: https://github.com/mattrepl/clj-oauth/blob/master/src/oauth/digest.clj#L10
18:43tomjackI don't want to have to make a reducer of [reduction elem] and then project
18:43tomjackfeels like it should be fused away somehow
18:43llasramdobry-den: `doto` returns the result of evaluating it's first form-argument, while `->` returns the last
18:43bprdobry-den: prob, b/c .init returns nil (or something other than the mac object)
18:44tomjackactually I don't even see how to do it with reductions
18:44dobry-denllasram: ahh, clojure has gotten me to completely forget about mutation.
18:44dobry-denalso reminds me of how funny java apis are
18:45bprdobry-den: lol, yes. I once had to wrangle BouncyCastle... it was painful
18:46dobry-denbpr: oh man, yeah that's actually my first experience using a java api.
18:47bprwow. that musta been intense
18:48arohneramalloy tomjack: I learned something today, thanks
18:48dobry-deni dont understand how people are productive with it. there's a magical order in which you apply methods like .init() and .doFinal() and .update() yet the docs never answer simple questions like "how do you go from a string to sha512 hex hash?
18:48bpralthough, with class names like DefaultSignatureAlgorithmIdentifierFinder and BcRSAContentVerifierProviderBuilder, it wasn't without it's humor
18:49dobry-denhaha. i actually gave up trying to figure out how to implement elliptical curve signing
18:49bprdobry-den: for real
18:49bprits*
18:50tomjacks/Data.Lens/Control.Lens/
18:52dobry-denbpr: i did learn about Apache Commons, though. for instance: http://commons.apache.org/proper/commons-codec/apidocs/org/apache/commons/codec/digest/DigestUtils.html
18:52bprdobry-den: yeah, we looked at that. It wasn't sufficient for all our needs... i forget why
18:55dobry-denwith simple methods like sha512Hex("secret") => hex hash, i have to wonder how unidiomatic it is in the java ecosystem
18:56dobry-dennot enough object collaboration
18:57dobry-densorry, the topic opened up old wounds. 'doto' is great
18:57bprlet me just say: clojure does java better than java :-p
18:58Raynesdobry-den: It should definitely return a HexHashFactorySingletonHashMaker
18:59amalloydobry-den: you don't know true Java Zen until you write a single expression with two `doto` and three `->`
19:00hyPiRionRaynes: I thought it would return IPersistentHashMapMessageStrategyDefinitionIterableTest
19:01amalloyhuh. apparently i gisted https://gist.github.com/amalloy/fd3fda4c707802740874
19:01amalloyi wonder why
19:02amalloyi bet Raynes was trying to bully me into using refheap instead of gist
19:02dobry-denevery crypto lib starts like this: SomeCryptoClass.getInstance(KeyMaker.getInstance("secret", "Sha512"), SomeCryptoClass.getAlgorithm("SunSha512"))
19:03dobry-dento see the available magic strings you can get algorithms for, you do SomeCryptoClass.getProviders() and they aren't enumerating in the docs. so it leads me to wonder if the available algorithms change over time even if you don't update your crpto lib version. that's the only explanation i can think of
19:04dobry-denenumerated*
19:04gfredericksdobry-den: it sounds like idiomatic java design to me :P
19:04gfredericksthey have obviously attained maximum flexibility
19:05llasramI think it's an artifact of the old US crypto export laws
19:05dobry-denit's just a stone's throw from (do-something "(+ 1 2)")
19:05llasramSHA-2 is a munition etc
19:05bbloomis there a way to make cljsbuild completely override the source-paths? I don't want my src/clj directory on the path at all when building src/cljs
19:05amalloyllasram: probably not; i think it's just DI gone mad
19:06tomjackbbloom: and you are going to produce two separate jars somehow?
19:06llasramamalloy: That might be the simpler explanation
19:06bbloomtomjack: *shrug* i dunno. my issue is that i'm not writing a clojure.core.foo or cljs.core.foo namespace. i have myapp.foo in both clj and cljs, so when looking for macros, i'm getting the clj version from cljs
19:06tomjackmy conclusion was that you have to either have separate projects or different namespace names (e.g. cljs.core.async), if I understand the situation you're in
19:07bbloomyeah that's precisely the situtation i'm in
19:07tomjack..until 1.6, I guess :)
19:07bbloomblargh. can't come fast enough :-P
19:07bbloomi have like 375 things i'm putting off until clj/cljs cooperate better
19:08bbloomgfredericks: 370 of them are happy dance moves
19:08llasramI'm going to imagine that he's doing them in a parallel world with 10 extra days per year, and he does one per day
19:09gfrederickslet's all say our favorite thing to imagine about bbloom's list
19:09tomjackhaving separate projects would force separate projects on consumers who want both, it seems
19:09tomjackso I guess an ugly workaround could be myapp.cljs.core for now :(
19:10tomjackor core.async could maybe have gotten away with using the same namespace since it puts macros in a special cljs.core.async.macros ns anyway?
19:10bbloomtomjack: yeah, i guess that's gotta be the case. i don't want to make two separate projects, since i expect a clj server to talk to a cljs client. i guess i can just version them together...
19:12tomjackI asked about the 'take while cumulative sum' in #haskell-lens, turns out it's not lensy and the solution proposed (in non-lens haskell) was exactly the same as the solution we came up with
19:12bbloommaybe i'll just make two different git branches…. :-P
19:12tomjackactually our solution is ostensibly nicer
19:18tomjackbbloom: still going to fuck consumers, eh?
19:18tomjackI guess if you have no consumers it's ok
19:18bbloomlol
19:18bbloom*shrug* you'll just need two deps
19:18bbloomno big deal
19:18tomjackbut won't they conflict?
19:19bbloomthey will have different names
19:19bbloomfoo and foo-cljs
19:19tomjackbut the namespaces?
19:19bbloomoh right. *sigh*
19:20bbloomthe git branches are nice tho… i can use git's rename detection to ease the porting of changes :-P
19:23bbloom*shrug* consumers will just need to make two projects too lol
19:23bbloompriority 1 is the port, will worry about that stuff later…
19:24tomjackyeah, oh well
19:25tomjackglad to see an Executor protocol drafted in core.async
19:26tomjackbblöom: maybe you'll be able to swap out setTimeout for your queue thingy
19:29bbloomtomjack: where is that protocol drafted?
19:29tomjackin the forkjoin branch
19:30tomjacklooks like they make a choice of executor for you though
19:49francis_wolkeWhat are some good resources to learn how to correctly walk trees?
19:52francis_wolkeI realize that clojure.walk exists - but I'm not 'getting it' when it comes to dealing with trees - EG: the algorithms arn't jumping to mind and I think I may need to read some research papers/textbooks/articles
19:53bbloomfrancis_wolke: i've found that clojure.walk isn't super useful beyond trivial use cases
19:54bbloomfrancis_wolke: start with just a really simple recursive walk
19:56francis_wolkebbloom - That's actually what I'm having the issue with - as the tree branches I'm not 'seeing' how my program can continue to walk down the tree. I realize that this is n00b stuff, but I've never had to do it before. :/
19:57bbloomfrancis_wolke: ah ok. well there are two general approaches to two types of traversals
19:58bbloomthere is iterative & recursive, then there is breadth vs first depth first
19:58bbloomrecursive and depth first is the easiest, so start with that
19:58bbloomhere's a good comparison of iterative solutions for depth vs breadth: http://stackoverflow.com/questions/687731/breadth-first-vs-depth-first
19:58bbloomso you understand how they are related fundamentally :-)
19:58cbp`clojure.zip has functions to walk nested structures
19:59bbloomcbp`: let's not bring zip into this. he needs some practice with the fundamentals, he said
19:59bbloomzippers would dramatically complicate things at this stage of his learning
19:59francis_wolkebbloom: k. Thanks.
20:00bbloomfrancis_wolke: the wikipedia pages have good pseudo code for all 4 possible approaches
20:00bbloomstart here: http://en.wikipedia.org/wiki/Depth-first_search
20:00bbloomdon't try to be general or anything yet. just manually traverse over whatever particular structure you're trying to work with
20:03bbloomfrancis_wolke: oh actually, i showed you search. sorry. start here: http://en.wikipedia.org/wiki/Tree_traversal
20:41tomjackwhat's the point of IEnforceableConstraint?
20:41tomjackI can understand why it's there for domc
20:41tomjackbut not the rest
20:50tomjackcallen: apparently my battery was just miscalibrated, been running at 0% for like 20min
20:53tomjack`there it goes :(
20:54francis_wolkebbloom: thanks for the pointers, they set me off in the correct direction.
23:25clizzinhey all, i'm looking to set up an api service that will be an oauth2 provider. what's the state of the art out there in terms of clojure libs for oauth2 providers? i found https://github.com/pelle/clauth but it looks quite old.
23:34navgeethttps://github.com/cemerick/friend ?