#clojure logs

2014-08-09

00:02FrozenlockAnyone knows if it's possible to use Kerodon to test POST requests?
00:05justin_smithFrozenlock: the examples in the readme look like POST requests to me (one even has a file upload)
00:06Frozenlockjustin_smith: They are (the press button), but I was wondering if there was a way to give it raw maps as a post.
00:06FrozenlockWithout going too deep in the source that is...
00:06mdeboardJaood: I assume it doesn't show SNAPSHOT versions
00:06technomancyJaood: oh, no Central pays a TON
00:07justin_smithnot sure, really. I am sure it is possible. I use a lib I wrote called groundhog to record requests, and serialize to a replayable form.
00:07technomancyUS$150,000 a year and growing
00:07justin_smithFrozenlock: the advantage is that I can run any request I care to, the disadvantage is that it isn't in a nice declarative form in the source like kerodon requests are
00:08FrozenlockI understand.
00:08FrozenlockI guess I could also just make the request by hand. It's a single POST after all.
00:08justin_smiththe tricky part is that ring expects an input stream, but that's not so hard to construct
00:09Frozenlockaww
00:09justin_smithor you could splice the request in after the handler that sucks in the input stream
00:09FrozenlockWhy is it always a rabbit hole?
00:09justin_smithFrozenlock: it's just one more detail, really - you can make an inputstream out of a string or an array of bytes trivially
00:10justin_smith,(java.io.ByteArrayInputStream. (.getBytes "hello"))
00:10clojurebot#<ByteArrayInputStream java.io.ByteArrayInputStream@17c26cc>
00:10justin_smithboom, input stream, ready to use
00:13Frozenlockjustin_smith: thanks
00:13FrozenlockOh, turns out Kerodon is built on top of this https://github.com/xeqi/peridot
00:37mdeboardARGH why is cider broken for me :(((((
00:39justin_smithmdeboard: latest release?
00:39mdeboardyeah, from today
00:40mdeboardhttps://gist.github.com/mattdeboard/e7520729acf056ff45ad
00:40mdeboardidgi
00:40mdeboardI don't know what that error actually means :-\
00:41mdeboardseems like the last few times I've gone to start a project with Clojure, Cider has some breaking bug
00:43mdeboardbetween cider and elixir-mode I'm ready to switch to vim
00:43mdeboardok, that's exaggeration.
00:45justin_smithI've been planning for months now to switch to cider as soon as bug reports for 0.7.0 slow down
00:48mdeboardclojure-jack-in always seemed so stable to me :(
00:48mdeboardand nrepl-jack-in
00:48mdeboardbut really smart dudes are working on cider, I'm sure it'll get worked out
00:48mdeboardI'm actually pretty sure the problem is with how melpa does it's damned packaging
00:48mdeboardSorry, "Packaging"
00:49mdeboardbecause I don't understand how I can possibly have cider 0.8.0-SNAPSHOT when the latest release is v0.7.0
00:51mdeboardand as we all know, the problem will definitely pan out to being something I'm doing wrong
00:51mdeboardevery time i get worked up about something, it turns out I'm just an idiot
00:54jeremyheilermdeboard: are you using melpa-stable?
00:55mdeboardjeremyheiler: idk, am I? `(setq package-archives '(("melpa" . "http://melpa.milkbox.net/packages/&quot;)))'
00:56jeremyheilerhttp://melpa.milkbox.net/#/getting-started
00:56mdeboardidk what you mean by using melpa-stable, i'm just using package.el
00:56mdeboardoh for heaven's sake
00:56mdeboardthanks.
00:56mdeboardI'll try that.
00:56mdeboardthanks melpa
00:56mdeboardthat's really, really productive.
00:56mdeboardI hate melpa :)
00:59mdeboardturned out not to matter
00:59mdeboardmelpa-stable has the same version
00:59mdeboardwhich is pretty bizarre.
01:01jeremyheilerare you sure about that?
01:01jeremyheilerhttp://melpa-stable.milkbox.net/#/cider
01:02mdeboardyeah I just deleted cider, restarted emacs and checked again and it had the new version
01:02mdeboarder, stabl version
01:02mdeboardmaybe it was caching or something.
01:02justin_smithmdeboard: elisp compilation and the caching of .elc files is pretty much magic to me
01:02mdeboardOne might expect "show me the stable package versions" to be the most sensible default
01:02mdeboardprinciple of lease surprise etc.
01:02mdeboardYeah ditto
01:03justin_smithI mean even more so than cached clojure compilation artifacts (which are weird enough already)
01:03jeremyheilerhmm yeah, the recipe seems to be the same for both *shrug*
01:04mdeboardI never really noticed any glitches or hitches with melpa until I started maintaining a language mode and publishing it to melpa
01:04mdeboardnow it's a circus of frustration
01:05mdeboardARGH
01:06mdeboardThe fundamental, underlying problem still exists.
01:06mdeboardhttps://gist.github.com/mattdeboard/d86b07a9b9a0cb663697
01:08technomancyoh cool a hashbang *and* serving packages over http.
01:08technomancy=(
01:08technomancyon the bright side supposedly support for signed packages is landing in emacs trunk
01:09technomancybut I'm seriously considering switching to submodules until that lands in one of the friendlier archives
01:09mdeboardyeah i used to run submodules
01:09mdeboardbut everyone told me what an idiot i was being because emacs has a package manager now
01:09mdeboardso here we are.
01:09mdeboards/package manager/well-maintained package repository/
01:14mdeboardturns out i was missing a configuration subtlety
01:15mdeboardwell, subtlety to me, tl;dr pebcak https://github.com/clojure-emacs/cider/issues/722
01:16mdeboardI can't even remember what iw as wanting to do
01:21Jaoodmdeboard: really, read the READMEs
01:24mordocaiHey, quick question. Is https://github.com/clojure/tools.cli still the recommended command-line arguments parser?
01:43mdeboardJaood: I DID read the readme. I mean, have you never had the experience where you read through something but don't pick up on everything? Especially late at night?
01:47Jaoodmdeboard: and instead of rereading it instead of skimming it you open a github issue? no
01:49mdeboard:)
01:49mdeboardI'm sorry that this transgression has rustled your jimmies so
01:49mdeboardi think it's probably just late.
01:55Jaoodmdeboard: nah its okay :)
02:22athinggoingonhi all, I'm trying to learn cider. I have nrepl server running (using lein) ina project. I'm trying to connect to the server but there's no cider-connect.
02:23bozhidarathinggoingon: what cider version are you using?
02:23athinggoingonCIDER 0.5.0 (Clojure 1.5.1, nREPL 0.2.3)
02:23bozhidarway to old
02:24bozhidarcider-connect was known as simply cider back then
02:24Jaoodathinggoingon: try M-x cider return
02:24bozhidaryou should be using the new cider 0.7
02:24bozhidar(btw, there a separate channel #clojure-emacs, that mostly dedicated to cider)
02:25athinggoingonI used the built-in package manager in emacs.
02:25bozhidarguess you're using Marmalade, right?
02:26bozhidarI think I uploaded cider 0.6 there, but I couldn't upload 0.7
02:26bozhidaras noted in cider's documentation - you're advised to use melpa-stable to get the stable releases
02:26bozhidarnikolayb: fancy seeing you here :-)
02:37piranha(Could not find artifact org.clojure:clojurescript:jar:0.0-2307 in central (https://repo1.maven.org/maven2/))
02:37piranhahow do I fix this?
02:37piranhathis is with new leiningen (2.4.3)
02:37piranhait seems to be in place: http://search.maven.org/#artifactdetails%7Corg.clojure%7Cclojurescript%7C0.0-2307%7Cjar
02:42TEttingerpiranha, odd. maybe the new maven https thing, I dunno
02:43piranhaTEttinger: I thought so as well, especially with lein 2.4.2, it tried to download from http
02:43piranhabut then after update to 2.4.3 it tries to download from https
02:46TEttingerpiranha, yeah this shouldn't be needed with 2.4.3 http://central.sonatype.org/pages/consumers.html#leiningen
02:46piranhaTEttinger: yeah, error reports https://repo1... :)
02:47TEttingeris this cljs version brand new?
02:56piranhaTEttinger: yep, released yesterday
06:22knoboIs there any swank backend for cljs?
07:14hellsomI'm toying around with Clojure and gvim + plugins, everything is working fine. I've created a infinitive loop. After evaluating, gvim freezes and interaction is not possible . Is there an other way of breaking out of that loop without killing the whole repl process?
08:01sm0keC-c?
09:21meingbgI need help with a failed cider install. I have no clue why this isn't working.
09:21meingbgI need help with a failed install. I have no clue why this isn't working.
09:22meingbg(package-install 'cider) => Package `emacs-24' is unavailable
09:28Frozenlockmeingbg: Does it work by 'M-x package-list-packages'?
09:30meingbgFrozenlock: package-list-packages show cider available in version 0.6.0
09:30meingbgFrozenlock: I assume I'd want 0.7
09:31FrozenlockDoes the installation work?
09:31FrozenlockBut yeah, you probably want a recent version.
09:32FrozenlockOr a very old one... nrepl.el forevaaaaar!
09:32meingbgFrozenlock: No, the installation fails with the error message "Package `emacs-24' is unavailable"
09:33FrozenlockAre you not on 24?
09:33FrozenlockEmacs 24
09:38meingbgFrozenlock: I am on emacs 24. That's the weird part.
09:38Frozenlock:-/
09:38FrozenlockMaybe open an issue on github? I can't really help with that; I'm still rocking nrepl.el
09:55meingbgFrozenlock: Alright, issue opened.
09:55meingbgFrozenlock: Thanks for trying
10:06TEttingermeingbg, someone else had a recent cider install error
10:07TEttingerbut theirs was an issue with the snapshot not being up to date on melpa or something?
10:07jkjstill haven't gotten it to work - ever.
10:07jkjhave to try again
10:07jkjnrepl works though
10:34meingbgjkj: What happens when you evaluate this over nrepl?: (print-str '(a b c))
10:34jkj"(a b c)"
10:35jkjmeingbg: in the minibuffer
10:36jkj...when evaluating in buffer
10:38meingbgjkj: Then maybe nrepl works. It didn't in cider 0.6, getting me to upgrade to cider 0.7, which required but didn't support emacs 24... sometimes I hate what we deal with in the emacs community
10:39FrozenlockEmacs is the best thing since sliced bread :-D
10:40FrozenlockLook 'ma, my text editor is also a webserver!
10:42sh10151s/webserver/symbolic algebra system/
10:42sh10151irc client? :-D
10:42FrozenlockOf course
10:45SagiCZ11Frozenlock: emacs is too hard
10:47FrozenlockSagiCZ11: Which part? the keybindings?
10:49SagiCZ11Frozenlock: yes, and how the buffers work.. i had to give up.. also the implementations for windows are lacking in stability
10:55inchfwdThere's no clojure.* javadoc is there?
10:55TEttingerinchfwd, for using clojure data structures from java?
10:56inchfwdTEttinger: The actual clojure source. I was trying to figure out what all classes implemented an interface.
10:56TEttingerright, that seems handy
10:57TEttingertbh I would just do a github search, or download the source and find in files
10:57TEttingerwhich interface?
10:57inchfwdTEttinger: Sequential
10:58inchfwdTEttinger: I'm writing a game that tests clojure form evaluation ability, and I realized I was using improper terminology for sequences/collections/seqs, etc.
10:59TEttingeroh yeah, and map/map is a mess
11:02TimMc~seqs and colls
11:02clojurebotseqs and colls is seqs
11:03TimMc~botsmack
11:03clojurebotclojurebot evades successfully!
11:03justin_smith~seqs
11:03clojurebotseqs is http://www.brainonfire.net/files/seqs-and-colls/main.html
11:03TimMcinchfwd: ^
11:03TimMcIt's not authoritative, but it might help.
11:04inchfwdTimMc: Yeah, I saw that page. A github search on "Sequential" looks pretty good, too.
11:12arrdemoh gods... there's a symbolic algebra system in here too? I'm already using the IRC/DB/email clients..
11:12FrozenlockEmacs Calc IIRC
11:13Bronsaarrdem: are you using mu4e or gnus?
11:13SagiCZ11is there anyone not using *unix* in this channel?
11:13arrdemif so, the door's over there
11:13arrdemBronsa: I gnus but I'm still like 50% on thunderbird
11:13SagiCZ11except me i wanted to add
11:13sh10151arrdem: M-x calc but you'll probably want to review the info pages too
11:14Bronsaarrdem: give mu4e a try then, it's really good
11:14arrdemBronsa: I'll check it out
11:14TEttingerSagiCZ1, I'm on windows
11:14Bronsaarrdem: http://www.djcbsoftware.nl/code/mu/mu4e.html
11:15arrdemBronsa: cheers
11:15SagiCZ11TEttinger: great :)
11:15FrozenlockSagiCZ11: I was on windows before. Win7 was great.
11:16TEttingerI downgraded intentionally from 8.1 to 7
11:16FrozenlockIncidentally, Ubuntu looks more like Win7 than 8 does.
11:16FrozenlockYeah 8 is terribad
11:16arrdemshrug... 8 isn't designed for hardcore desktop like 7 was
11:17arrdempart of this whole microsoft trying to be mobile thing
11:17arrdemtaken in that context it could be a lot worse
11:17arrdemalso some good internal cleanups...
11:17arrdembut yeah shit UI for desktop. my win8 install lasted 72hrs
11:17Frozenlockhardcore desktop? Is that how normal use is called now?
11:41gfrederickson top of a hardcore desk
11:48justin_smithFrozenlock: a hardcore desktop is designed to survive binge drinking, mosh pits, and high decibel levels
11:48arrdemlol
11:51csd_What's the easiest way to reduce a vector in the form [[:a 1] [:a 2] ... [:b 10] [:b 20]] to {:a [1 2] :b [10 20]}?
11:51justin_smithcsd_: reduce it to what?
11:51justin_smithoh, sorry, my bad
11:53justin_smith,(reduce (fn [m [k v]] (update-in m [k] (fnil conj []) v)) {} [[:a 1] [:a 2] [:b 10] [:b 20]])
11:53clojurebot{:b [10 20], :a [1 2]}
11:56csd_thank you
11:57technomancy(inc mu4e)
11:57lazybot⇒ 1
11:58arrdem(inc justin_smith) ;; nice fnil
11:58lazybot⇒ 58
13:00nkozocore.async question: is safe to put using >! inside a go block called from one thread and take using <! using another go block called from another thread?
13:02justin_smithnkozo: go blocks use a thread pool, the thread they are created in doesn't affect them running (it only affects where they return their output channel to)
13:04nkozojustin_smith: ok, thanks
13:16elsenHey clojurers! Quick question, I'm experimenting with clojure & uberjar and deployement using docker
13:17elsenHow hard would it be to run my webapp uberjar from a docker container, and open a remote repl for debugging?
13:18justin_smithelsen: it's easy to open an nrepl server inside your app at runtime, but you should use ssh to connect. The nrepl defaults only allow connections from localhost and that is a good thing.
13:19justin_smithregarding running it from a docker container, it shouldn't be any easier or harder than using an uberjar in any other scenario
13:20elsenso for example, right before starting my jetty app in main, I boot an nrepl server?
13:20justin_smithno, you boot an nrepl server from inside -main
13:20justin_smiththat way you can actually access your running process
13:21elsenNice, I'll give it a shot, thanks!
13:21justin_smithhttps://github.com/clojure/tools.nrepl you want clojure.tools.nrepl.server/start-server
13:21Frozenlockjustin_smith: I often connect to another machine's repl directly... are you sure the default allows only localhost?
13:21justin_smithbut instead of their defonce (which breaks with aot), start the server inside -main
13:21Frozenlock(or maybe I changed that config and don't remember...)
13:22justin_smithFrozenlock: I have in the past failed to connect to an nrepl on another machine on my lan
13:23justin_smithFrozenlock: it could be this changed, but I would consider that a security issue
13:23FrozenlockIf someone's on my LAN, I'm in deep trouble :-p
13:23justin_smithI mean, it means that anyone using the same LAN (ie. connected to the same wifi access point) could trivially root your machine
13:24justin_smithdon't forget that someone using the same wifi you are is also on your lan - you don't run clojure from a laptop while at a café or anything?
13:24FrozenlockNope
13:25FrozenlockI'm a man, I use real computers. The huge heavy stuff.
13:25Frozenlock:-p
13:25Frozenlock(Private LAN in my house)
13:25arrdempls open nrepl port on public wifi
13:25arrdempls
13:25arrdemi will have good tome
13:25arrdem*time
13:25jeremyheilerFrozenlock: you'll have to bind the repl to 0.0.0.0 in order to access it externally
13:26xeqiFrozenlock: did peridot do what you needed earlier?
13:26Frozenlockxeqi: Yup!
13:26justin_smithFrozenlock: regardless of your macho practices, nrepl should bind localhost as a default, anythng else would be insanei
13:26FrozenlockLooking my project config now...
13:27jeremyheilerFrozenlock: at least that's how our vagrant dev machines are set up
13:29FrozenlockHmmm I don't see anything other than a given port in my config
13:30FrozenlockAgain, rabbit hole...
13:43FrozenlockDoesn't this mean that it's public by default? https://github.com/clojure/tools.nrepl/blob/master/src/main/clojure/clojure/tools/nrepl/server.clj#L125
13:45justin_smithFrozenlock: ugh - I could have sworn I had tried to use it from another machine and failed in the past. I wonder why they would use a permissive default mask for such an insecure service.
13:45FrozenlockThis. is. clojuuuuure
13:46FrozenlockIIRC, this issue was fixed for slime.
13:46gfredericks~clojure
13:46clojurebotclojure is the best
13:48elsenjustin_smith: the repl works like a charm from docker, thanks again!
13:51justin_smithnp
13:53pandeiroanyone played with devcards?
13:55donkey_boyburn all jews in oven
13:55donkey_boyallahu akhbar
13:55donkey_boyi throw stones to jews
13:55donkey_boydeath to infidels
13:57michaelrdonkey_boy: so.. you fuck donkeys right?
13:57donkey_boyCLOJURE IS INFIDEL PROGRAMMING LANGUAGE
13:57donkey_boyCLOJURE IS INFIDEL PROGRAMMING LANGUAGE
13:58donkey_boyCLOJURE IS INFIDEL PROGRAMMING LANGUAGE
13:58donkey_boyDEATH TO INFIDELS
13:59donkey_boyFECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES
13:59donkey_boyFECES
13:59donkey_boyFECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES
13:59rpaulokick?
13:59Bronsatechnomancy: your services are required
13:59Frozenlocktechnomancy: dad, we need a kick
13:59donkey_boyFECES FECES FECES FECES FECES FECES FECES FECES FECES
13:59donkey_boyFECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES FECES
14:00donkey_boyburn all jews in oven!
14:00donkey_boyburn all jews in oven!
14:00donkey_boyburn all jews in oven!
14:10slpsyshey, that's great
14:32andyfBronsa: Was trying out t.a(.j) 0.5.0 in Eastwood last night, and came across an exception thrown near here: https://github.com/clojure/tools.analyzer.jvm/blob/master/src/main/clojure/clojure/tools/analyzer/passes/jvm/emit_form.clj#L79
14:32andyfI tried replacing class with (:val class) and it seemed better, but I'm just hacking right now and not sure if that is correct.
14:33Bronsaah yeah
14:33Bronsaandyf: I'll fix emit-form, thanks
14:43Bronsaandyf: fixed emit-form in t.a 0.5.1-SNAPSHOT and t.a.j 0.5.2-SNAPSHOT
14:44andyfthanks, I'll try it out. Might have an exception or three that I found while running the crucible that I'll let you know about.
14:52Bronsaandyf: bah, t.a was actually fine, just try t.a.j 0.5.2-SNAPSHOT
14:53andyfBronsa: I'll just try latest master of both unless you think that is a bad idea.
14:54Bronsaandyf: won't hurt but t.a master is identical to 0.5.0
14:54BronsaI just pushed a commit and reverted it immediately because it was useless
15:16michaelris there an example out there somewhere of using secretary with om?
15:41pandeiromichaelr: https://github.com/sgrove/omchaya
15:42konrwhat do you guys use with clojurescript for design? Plain css?
15:43pandeirohey konr: there's garden https://github.com/noprompt/garden ; i still use less
15:43konrhi, pandeiro! happy to see you!
15:44pandeirofor me the advantage of less is that you have the option of offloading compilation to the browser if you want
15:44konrthanks for the suggestions
15:44pandeironot sure if garden can do that
15:44pandeiroif it works with edn i guess it can, too, not sure if you would have to write the poller though
15:44pandeirokonr: np :)
15:50michaelrpandeiro: thanks
15:52michaelrpandeiro: I also found this: http://squirrel.pl/blog/tag/clojurescript/
15:53pandeiromichaelr: you may want to also check out https://github.com/DomKM/silk
15:53pavanhi all
15:54gfrederickshello
15:54pavantrying to run a clojure project with core.async
15:54pavanran into
15:54pavan'clojure.core.async' containing period with prefix 'quote'. lib names inside prefix lists must not contain periods
15:54pavanany ideas or fixes
15:55gfrederickssounds like you quoted something inside your ns form
15:56gfrederickse.g., I get the same message for (ns foo.bar (:require 'clojure.string))
15:56gfredericksremoving the ' should fix it
15:56gfredericks~ns
15:56clojurebotns is unfortunately more complicated than it needs to be, but http://blog.8thlight.com/articles/2010/12/6/clojure-libs-and-namespaces-require-use-import-and-ns may be helpful.
15:58pavanthanks gfredricks that fixed it
15:58gfredericksthanks clojurebot for having that link handy
16:05wagjo~fn
16:05clojurebotexcusez-moi
16:05SagiCZ11~help
16:05clojurebotNobody can help with "X doesn't work". Please provide context: what you did, what you hoped would happen, and what happened instead. A stack trace is especially helpful, if applicable.
16:06SagiCZ11in cases where apply and reduce return the exact same results, what is preffered? for example summing a collection (apply + coll) or (reduce + coll) ?
16:07rhg135apply i'd think, since it involves less fn calls
16:08SagiCZ11rhg135: makes sense
16:08H4nsSagiCZ11: apply probably has a limit on the number of elements that it can process.
16:08H4nsSagiCZ11: reduce works with any number of elements in the argument sequence.
16:08rhg135ofc the jvm is great so either'd be ok
16:10H4nsSagiCZ11: it may be that i'm wrong - apparently, apply can take very large numbers of arguments. sorry for misleading.
16:11SagiCZ11H4ns: alright no problem
16:11SagiCZ11reduce can take any number of elements right?
16:12michaelrpandeiro: nice..
16:12H4nsSagiCZ11: for sure, it definitely has no limit, but it needs to invoke the function for each argument.
16:12SagiCZ11H4ns: yeah
16:17SagiCZ11is there a function that divides collection into n pieces?
16:17SagiCZ11(foo 2 [1 2 3 4]) => [1 2] [3 4]
16:18gfrederickspartition-all is related
16:18gfredericksyou give it the piece-size though, not the piece count
16:19Bronsa((juxt take drop) 2 [1 2 3 4])
16:19Bronsa,((juxt take drop) 2 [1 2 3 4])
16:19clojurebot[(1 2) (3 4)]
16:19SagiCZ11nice
16:19SagiCZ11thank you
16:21SagiCZ11no that does not divide it into n pieces of equal size
16:21hyPiRionsplit-at does the same trick
16:21SagiCZ11,((juxt take drop) 2 [1 2 4 5 6 7])
16:21clojurebot[(1 2) (4 5 6 7)]
16:21hyPiRion,(partition 2 (range 10))
16:21clojurebot((0 1) (2 3) (4 5) (6 7) (8 9))
16:21SagiCZ11nope
16:21SagiCZ11i want to specify the number of pieces.. not the size of pieces
16:22Bronsaah, sorry I misread you SagiCZ1
16:22hyPiRionSagiCZ11: oh -- there are many edge cases here though. Must n always divide the size of a collection?
16:23hyPiRionif not, how do you split the collection up in n equal pieces? Let the last one contain less elements than the others?
16:24SagiCZ11split the element
16:24SagiCZ11for example from "8" u could make "E" and "3" right?
16:25BronsahyPiRion: (f 2 [4 4 4]) ;=> ([4 2] [4 2]) obv
16:25wagjoSagiCZ1: H4ns: both reduce and apply can have any number of elements in the collection which is passed as a last argument
16:25hyPiRionBronsa: ([4 2] [2 4]) I presume?
16:25SagiCZ11wagjo: thanks
16:26SagiCZ11hyPiRion: yeah it just gets trickier with non-number elements :]
16:26hyPiRionalright
16:27wagjoSagiCZ1: H4ns: apply converts coll to the seq, which reduce does not, so the reduce should be faster.
16:29SagiCZ11what colls are not seqs?
16:29wagjonot necessarily
16:29Bronsa,(seq? [])
16:30clojurebotfalse
16:30wagjoBUT sometimes apply is faster, as it may use call more optimized fn than reduce :) so it depends.
16:30SagiCZ11,(seq? (seq []))
16:30clojurebotfalse
16:31SagiCZ11O.o
16:31wagjohehe
16:31wagjo,(seq [])
16:31clojurebotnil
16:31wagjothats why
16:31Bronsa,(time (do (apply str (repeat 1e4 "foo")) nil))
16:31clojurebot"Elapsed time: 16.178562 msecs"\n
16:31hyPiRionOnly one I know which runs append faster is `str`. So unless you do (reduce str my-coll), then reduce is good.
16:31Bronsa ,(time (do (reduce str (repeat 1e4 "foo")) nil))
16:31clojurebot"Elapsed time: 285.509604 msecs"\n
16:31gfredericks,(list? (list* 3 ()))
16:31clojurebotfalse
16:31SagiCZ11,(seq? (seq [1 2 3]))
16:31clojurebottrue
16:31gfredericks,(list? (cons 42 [42]))
16:31clojurebotfalse
16:31hyPiRion,(boolean? (Boolean. false))
16:31clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: boolean? in this context, compiling:(NO_SOURCE_PATH:0:0)>
16:32gfredericks,(string? string?)
16:32clojurebotfalse
16:32SagiCZ11,(type (cons 42 [42]))
16:32clojurebotclojure.lang.Cons
16:32gfredericks,(integer? 42.0)
16:32hyPiRion,(false? (Boolean. false)) ;; that was it.
16:32clojurebotfalse
16:32clojurebotfalse
16:32SagiCZ11there is type "cons" ?
16:32wagjoSagiCZ1: Seq is a particular type of a persistent collection
16:32gfredericks,(-> false Boolean. false?)
16:32clojurebotfalse
16:32gfredericks,(-> false Boolean. false? Boolean. false?)
16:32clojurebotfalse
16:32gfredericks,(-> false Boolean. false? Boolean. false? Boolean. false?)
16:32clojurebotfalse
16:32SagiCZ11(echo false)
16:33hyPiRionecho false
16:33lazybotfalse
16:33wagjoCons, PersistentList, LazySeq - these are all Seqs
16:33SagiCZ11gosh
16:33gfredericksecho ,'foo
16:33lazybot,'foo
16:33clojurebotfoo
16:33SagiCZ11what is cons for?
16:33SagiCZ11gfredericks: neat!
16:33wagjoSagiCZ1: for creating Seqs :)
16:33gfredericksecho ,(println "echo twice")
16:33lazybot,(println "echo twice")
16:33clojurebotecho twice\n
16:34gfrederickscarp
16:34hyPiRionSagiCZ11: gosh, that function you'd like does actually require some thought
16:36wagjohyPiRion: how about partition using count/n as a chunk size?
16:36SagiCZ11hyPiRion: in my case i really wanted just to split lists in half.. so that wasnt so hard.. only one edge case
16:36SagiCZ11wagjo: thats kinda what i did
16:37hyPiRionwagjo: doesn't work if you want all sizes to be exactly equal. You'll have to "split" the elements somehow
16:37wagjo,(#(partition (/ (count %2) %) %2) 5 [1 2 3 4 5])
16:37clojurebot((1) (2) (3) (4) (5))
16:38wagjo,(#(partition (/ (count %2) %) %2) 2 [1 2 3 4 5])
16:38clojurebot()
16:38SagiCZ11,(def "racecar")
16:38SagiCZ11,((juxt take drop) (/ (count x) 2) x)
16:38clojurebot#<CompilerException java.lang.RuntimeException: First argument to def must be a Symbol, compiling:(NO_SOURCE_PATH:0:0)>
16:38clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0:0)>
16:38SagiCZ11,(def x "racecar")
16:38SagiCZ11,((juxt take drop) (/ (count x) 2) x)
16:38clojurebot#'sandbox/x
16:38clojurebot[(\r \a \c \e) (\c \a \r)]
16:38SagiCZ11this is enough
16:39wagjo,(#(partition (int (/ (count %2) %) %2)) 2 [1 2 3 4 5])
16:39clojurebot#<CompilerException clojure.lang.ArityException: Wrong number of args (2) passed to: core/int--inliner, compiling:(NO_SOURCE_PATH:0:0)>
16:39wagjo,(#(partition (int (/ (count %2) %)) %2) 2 [1 2 3 4 5])
16:39clojurebot((1 2) (3 4))
16:39hyPiRion,(split-at (/ (count x) 2) x)
16:39clojurebot[(\r \a \c \e) (\c \a \r)]
16:39wagjo,(#(partition-all (int (/ (count %2) %)) %2) 2 [1 2 3 4 5])
16:39clojurebot((1 2) (3 4) (5))
16:41wagjo,(#(partition-all (int (/ (+ (count %2) (dec %)) %)) %2) 2 [1 2 3 4 5])
16:41clojurebot((1 2 3) (4 5))
16:41wagjo,(#(partition-all (int (/ (+ (count %2) (dec %)) %)) %2) 1 [1 2 3 4 5])
16:41clojurebot((1 2 3 4 5))
16:41wagjo,(#(partition-all (int (/ (+ (count %2) (dec %)) %)) %2) 3 [1 2 3 4 5])
16:41clojurebot((1 2) (3 4) (5))
16:41wagjo^there
17:05SagiCZ11is there something that acts like "when" but doesnt return anything when the test is false?
17:06kristofIn an expression based language, "doesn't return anything" makes no sense
17:07SagiCZ11i have an expression (conj [] (when test x)) and if test is false it shouldnt conj anything... but it adds nil
17:08gfredericks(cond-> [] test (conj x))
17:08kristof^. Your conj was in the wrong place, then
17:09justin_smithSagiCZ11: why should conj ever not conj something?
17:11SagiCZ11this clears duplicates from a collection, only those that are next to each other
17:11SagiCZ11,(filter (complement nil?) (reduce #(conj %1 (when (not= (last %1) %2) %2)) [] [1 1 2 3 3 2 2 3]))
17:11clojurebot(1 2 3 2 3)
17:11SagiCZ11i just have to filter out nils, because "when" returns them there
17:14gws,(map first (partition-by identity [1 1 2 3 3 2 2 3]))
17:14clojurebot(1 2 3 2 3)
17:14gfredericksSagiCZ11: you want to just not call conj in the first place
17:14justin_smith,(reduce #(if (= (last %1) %2) %1 (conj %1 %2)) [] [1 1 2 3 3 2 2 3])
17:14clojurebot[1 2 3 2 3]
17:15gfredericks,(reduce #(if (not= (pop %1) %2) (conj %1 %2) %1) [1 1 2 3 3 2 2 3])
17:15clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IPersistentStack>
17:15gfredericks,(reduce #(if (not= (pop %1) %2) (conj %1 %2) %1) [] [1 1 2 3 3 2 2 3])
17:15clojurebot#<IllegalStateException java.lang.IllegalStateException: Can't pop empty vector>
17:15gfredericks,(reduce #(if (not= (last %1) %2) (conj %1 %2) %1) [] [1 1 2 3 3 2 2 3])
17:15clojurebot[1 2 3 2 3]
17:15justin_smiththat empty pop error thing is annoying
17:16SagiCZ11oh ok.. so the first hint you gave me still applies.. i thought i couldnt move it in my case.. now i see i could.. thanks
17:17SagiCZ11 ,(reduce #(if (= (last %1) %2) %1 (conj %1 %2)) [] [1 1 2 3 3 3 3 3 3 3 3 3 2 2 3])
17:17clojurebot[1 2 3 2 3]
17:18SagiCZ11,(reduce #(if (= (last %1) %2) %1 (conj %1 %2)) [] "Heeeeeeeeeeeeeeeeeeeello")
17:18clojurebot[\H \e \l \o]
17:24hyPiRionhm
17:25hyPiRion,(map first (partition-by identity "Heeeeeeeeeeeeeeeeeeeello"))
17:25clojurebot(\H \e \l \o)
17:29PigDude,(set "Heeeeeello")
17:29clojurebot#{\e \H \l \o}
17:30PigDude,(apply sorted-set "Hello")
17:30clojurebot#{\H \e \l \o}
17:31gfredericksha
17:31gfredericks,(sort "Hello")
17:31clojurebot(\H \e \l \l \o)
17:31gfredericks,(sort "hello")
17:31clojurebot(\e \h \l \l \o)
17:32justin_smith,(sort "☃☕✈🐱")
17:32clojurebot(\☃ \☕ \✈ \? \?)
17:33justin_smithit did something weird with CAT FACE
17:33justin_smithhttp://shapecatcher.com/unicode/info/128049 (this one)
17:35gfredericksI got a pair of \? at the end
17:35PigDudehm i'm getting somewhere with this
17:35PigDude,(clojure.string/split "Heeeeellllloooooo" #"(?<=(.))\1+")
17:35clojurebot["He" "l" "o"]
17:36justin_smithgfredericks: even in the tryclj repl, where the cat face displays properly, clojure splits it into two unprintable characters
17:45gfredericksunicode; can anybody truly know how it works?
17:52gwswell java chars can only represent code points inside the basic multilingual plane (up to 0xFFFF) and the cat face is outside that
17:53gfredericksin the "more complicated multilingual plane"
17:53gwsyeah or "second circle of hell" however you want to pronounce that
17:55gwskinda curious what the "right" answer is for sorting strings by char but preserving those higher code points - wonder if it's "use ICU"?
18:01justin_smithhttp://icu-project.org/apiref/icu4j/ looks promising
18:02justin_smithnext time I need to sort emoji (or support something outside the basic multilingual plane) I'll be sure to check it out
18:11itrusloveAnyone know the status of ritz or swank? Do they with recent versions of clojure?
18:22amalloyitruslove: swank works fine on 1.6. most folks these days use cider, though
18:24itrusloveamalloy: thanks, I do too, I'm just trying to scope out the landscape
20:04fifosineI have a list of elements that on each I need to perform a specific function upon. This problem seems to lend itself to using the higher-order function 'map', but for the fact that besides for the first element of the list, the rest of the computations depend on the computation before it—i.e., the function takes as input the result of the last function evaluation. Is there a way to use map in this instance?
20:05fifosineOr is there another high-order function that I'm looking for
20:05fifosineI kind of need a mix of reduce and map
20:07JohnTalentIs it possible to embed html from another server?
20:09dbaschfifosine: you can construct a function that you call with iterate
20:10fifosinedbasch: ok, imma read the docs, I've never used iterate
20:10fifosinecan f have arity >1?
20:12dbaschfifosine: it can, but iterate will call you with one argument
20:12dbaschso it has to have 1 as possible arity
20:13fifosinehow do I use iterate with a list already defined?
20:13fifosineI perform the function on each el of the list
20:13fifosinethe examples of using iterate each take an initial constant
20:14dbaschnow that I read your question again, it sounds more like you could use reductions
20:15fifosinewhy do I want the intermediate results?
20:16dbaschfifosine: you said you have a sequence, and each result depends on the previous one
20:19fifosinedbasch: I'm still not clear on how reductions helps
20:20fifosinethe function mapped for each element in the list takes two parameters [element last-result]
20:21dbaschfifosine: just like this:
20:21dbasch,(reductions + (range 10))
20:21clojurebot(0 1 3 6 10 ...)
20:21dbasch&(reductions + (range 10))
20:21lazybot⇒ (0 1 3 6 10 15 21 28 36 45)
20:22fifosineI'm dumb
20:22fifosinethanks, dbasch
20:29fifosinedbasch: mmm, this makes it a little tougher: the function outputs *two* values, one that should be used in the subsequent calculation and the second is what should be returned in the sequence
20:30dbaschfifosine: why don’t you write it in an old fashioned loop?
20:30dbaschno need to overthink it
20:31fifosinedbasch: I prefer not to use for-loops
20:31fifosineis that silly?
20:31dbaschfifosine: what do you mean for loops? I mean loop/recur
20:33fifosineok, and then just use an accumulator for the result?
20:33dbaschyes. You may not even need the loop, you can just have a tail-recursive function
20:40fifosinedbasch: What do you mean? What would be a tail-recursive function without the loop?
20:41dbaschfifosine: a simple tail-recursive function
20:42fifosinecan the factorial function be defined tail-recursively?
20:42fifosinehow would it be?
20:45fifosinedbasch: Is there an advantage to defining the function as tail-recursive versus using loop/recur?
20:48dbaschfifosine: if your function is nothing but a loop, you don’t need the loop construct
20:52dbaschfifosine: here’s a tail-recursive factorial
20:52dbasch,(defn fact [n & r] (if (= 1 n) r (recur (dec n) (* n (or r 1)))))
20:52clojurebot#'sandbox/fact
20:52dbasch,(fact 10)
20:52clojurebot3628800
20:53fifosineoh just use recur
20:53fifosineok
20:54fifosineis there a clojuric way to format output if a function outputs two distinct values that each mean something different?
20:54fifosinejust putting them in a list seems silly since they're not the same "type"
20:57fifosinewith a map I guess?
20:58justin_smithdbasch's fact function above fails on (fact 1) (returns nil)
21:01justin_smithalso, is recur doing something weird there? because usually [n & r] would mean r is always a sequence, but it is successfully used as a number
21:01justin_smithwhat am I missing?
21:02justin_smithdoes recur not use the same destructuring rules that regular function calls do?
21:05amalloyjustin_smith: it doesn't. it turns out it would be pretty useless if it did; let me see if i can find the log of the last discussion on that topic
21:08justin_smithyeah, I get the exception I would expect if I call (fact 2 3), but (fact 3) works, despite the fact that it invokes (recur 2 3)
21:09amalloyoh, i see. i hadn't quite noticed the issue you were asking about
21:09amalloyjustin_smith: http://logs.lazybot.org/irc.freenode.net/%23clojure/2014-07-10.txt, starting at around [16:51:53] is the discussion i meant, although i'm not sure it's relevant anymore
21:11amalloybasically (fn [x & y] (recur a b)) sets y equal to b, not to [b] (for reasons discussed in that log). since this happens with a goto rather than a method call, this has the surprising effect in your example function that b is successfully set to a non-list
21:12justin_smithmy takeaway from this is to prefer an explicit loop statement if my function uses & for varargs - seems much easier to reason about
21:13amalloymmmmm, or you could just pretend that your function's arglist is the list of bindings for an explicit loop, since in fact it is
21:14justin_smithright, but overlaying destructuring on top of that feels weird
21:17dbaschjustin_smith: pretend (or r 1) was my return value, I’m dumber since I started using ruby for my regular job :P
21:19justin_smithdbasch: I know it was just a quick example anyway, my own confusion with how the recur and parameter declaration interact hurt my head though
21:19dbaschjustin_smith: ruby hurts my head but more like a hammer would
21:20justin_smithheh
21:20justin_smithwere you the one who mentioned the term "duck punching" recently?
21:20dbaschjustin_smith: no, but I do have a rubber duck for debugging
21:20justin_smithnot quite the same, but I find it very amusing http://www.paulirish.com/2010/duck-punching-with-jquery/
21:21justin_smith"… if it walks like a duck and talks like a duck, it’s a duck, right? So if this duck is not giving you the noise that you want, you’ve got to just punch that duck until it returns what you expect.
21:21justin_smith"
21:21dbaschjustin_smith: https://twitter.com/HackerNewsOnion/status/476835980863733761
21:22justin_smithheh
21:23dbaschthat’s the problem with a language that has no entry barrier
21:24justin_smiththat's why all the extra ((())((()))) help keep clojure on a higher standard - it weeds out some of the more mentally challenged (though it picks up some of the perversely obfuscatory in the process)
21:24dbaschI found code that was doing different things depending on the values of two booleans. It had an if with FOUR elses
21:25kristofjustin_smith: I think there's actually an equivalent amount of delimiters in clojure and in Java.
21:25dbaschin case they encountered a case in which one of the variables was neither true nor false I suppose
21:25justin_smithkristof: it's not the bracket count - it's the
21:25justin_smith"weirdness
21:25justin_smith" of placement (sorry my ring finger is sloppy right now for some reason)
21:26kristofI don't think it's so weird. I think Rust is weird.
21:26gfredericksfoo.bar(baz,bang) ==> (bar foo baz bang)
21:26gfrederickssomething got swapped
21:27kristofI have a friend who never understands what I mean when I say that a method is just a function that parameterizes on its first argument.
21:27kristofNot even when I explain where the obj.method() syntax comes from.
21:29gfrederickswhere does it come from?
21:32kristofgfredericks: An object can literally be thought of as a struct with a field called "method" that is a function pointer to the ad-hoc implementation of that method.
21:33kristofgfredericks: When you say obj.method(arg), you are instructing the computer to place arg on the stack, and call the function located by dereferencing obj's method
21:33justin_smithkristof: well, in most cases you would be puttin obj on the stack too, it's an invisible argument
21:34JohnTalentdo you people know what cheap hostings of clojure are?
21:34kristofjustin_smith: Right, that too. But the point remains :)
21:36justin_smithJohnTalent: anything with a jvm, just make an uberjar and run java -jar
21:36justin_smithJohnTalent: for extra credit wrap it up in the os specific server process wrapper appropriate for that server
21:37dbaschJohnTalent: you can deploy an app to heroku for free if it’s a toy app
21:37kristofDoes anyone know of any software that is actually meant to be operating system agnostic?
21:37justin_smithkristof: all of my clojure deploys are (backends to serve database driven web sites)
21:38dbaschkristof: all software that directly uses hardware is operating system atheistic
21:39dbaschI should say that only interacts with hardware without an OS layer in between
21:39amalloykristof: lisps have more parens because the "operators" like ||, &&, +, *, and so on, need parens
21:40amalloyfor method calls it's the same, but that's hardly the only thing you ever do
21:41kristofjustin_smith: I just have trouble justifying the JVM. The JVM was designed when people were using a million different flavors of UNIX, DOS, Apple operating systems, BSD . . .
21:41kristofamalloy: I hardly ever use arithmetic and lobical operators.
21:41kristof*logical.
21:42justin_smithkristof: the jvm means my coworkers did not have to stop using their macbooks or deploy to expensive apple hardware
21:42dbaschkristof: I have a hard time imagining how someone can write software without arithmetic or logical operators
21:42amalloyokay? but people writing java use them an awful lot, for all them for loops. so it really does mean they need a lot more parens to do whatever
21:43dbaschkristof: I have one word for you: Android
21:43kristofHrm.
21:44amalloyhe doesn't use that either
21:44kristofamalloy: I can see that.
21:45amalloylisp also has way more parens than ruby, with all those implicit parens
21:47dbaschamalloy: and the lack of parentheses often makes ruby harder to read
21:47justin_smithalso, my point (admittedly a bit glib) was meant to be as much about unconventional placement of parens as number
21:47amalloydbasch: i mean, i don't totally disagree with that claim, but it's a matter of perspective. i'm pretty sure you would be outvoted by people saying "the surplus of parentheses often makes lisp harder to read", which is just as reasonable
21:48amalloysurface syntax is just not an important thing to worry about
21:48dbaschamalloy: I found this line in a method, and it wasn’t immediately obvious what it did:
21:48dbaschprofile.is_private? != true if profile
21:49amalloywell, that's just bad style. surely it'd be better as: profile && profile.is_private?
21:49amalloyadding a != true in there or whatever
21:49dbaschamalloy: yes, the problem with ruby is the low barrier to entry for people with little experience programming in the large
21:50amalloyyou can write equally stupid things in clojure. one of my hobby horses is the overzealous use of ->> to reduce nesting (and, topically, parens!) at the expense of readability
21:51dbaschI suppose that if clojure were as popular as Ruby there would be more examples of bad style in the wild
21:51dbaschhttp://spectrum.ieee.org/computing/software/top-10-programming-languages
21:51dbaschclojure is not even on that list
21:51amalloy"the problem with language X is that it's easy for people to use" is not an argument that convinces me
21:52justin_smithwow they list arduino and processing as languages - there is something sad about that to me
21:53dbaschamalloy: I agree. In the case of Ruby I think the language is too lenient without necessarily being easier to use
21:54justin_smithdbasch: https://twitter.com/HackerNewsOnion/status/395719209411301376
21:55dbaschit’s not that the language it’s easy to use, but that it makes it really easy to create undebuggable code
23:43lpvbI'm really starting to ignore the do block inside the let form and instead using it as an identity monad
23:49justin_smithlpvb: got a good example of what that looks like?
23:54lpvb(let [c constant, x (pure-computation c), _ (side-effect c), _ (more-side-effects etc.)] nil)
23:56jeremyheilerlpvb: why not just do the side effects in teh body?