#clojure logs

2012-10-17

00:16xeqihmm, that sounds like a fun lazybot challenge
00:31Raynesxeqi: What?
00:31RaynesMan, he already looks like Golum.
00:33xeqiforcing memory usage
00:34xeqithough it just leads to not allowing others to use it, so not very nice
00:34xeqi* it would
01:28AtKaaZ,'hi wingy
01:28clojurebothi
01:28wingyAtKaaZ: hi wazzup?
01:28AtKaaZnot much, bidding my time thru some datomic docs
01:29AtKaaZs/dd/d/
01:39wingyi still need to watch database as a value by rich
01:46AtKaaZwingy: you mean this? https://www.youtube.com/watch?v=EKdV1IgAaFc I didn't finish watching it, I don't understand what he means about the monkey
01:47wingyits the same topic .. i was referring to this one
01:47wingyhttp://www.infoq.com/presentations/Datomic-Database-Value
01:47wingyyeah must be something that we missed
01:48AtKaaZhe either talked about it before, or it's common knowledge between devs :)
01:48wingybut i can get the concept he is talking about
01:48wingyseems like its something they talked about
01:50arrdemhas anyone now present actually used that DB system? I'm really curious about it.
01:53ForSparePartsDo you guys know of any clojure-native physics libraries?
01:54ForSparePartsThere's a bunch of Java stuff, but I was hoping there might be something out there that leverages immutable data structures.
02:35wingyanyone here who has used https://github.com/clojure/data.xml and http://clojuredocs.org/clojure_core/clojure.xml and can give some thoughts about which one i should use
02:35wingyfor reading and writing xml .. seems that both are capable of doing so
02:38wingyhttps://github.com/clojure/data.xml seems more powerful
02:38wingyand there is also https://github.com/clojure/data.json
02:38wingynice fit
02:53muhoocheshire too
02:54wingyi need some help
02:54wingywith retrieving a specific key of a parsed xml string
02:54wingyhttps://gist.github.com/3904073
02:55wingymuhoo: yeah .. why so many different json and xml parsers :)
02:55muhoooh this xml tag nonsense? i had to do this recently. hmm, let me see
02:56muhooi used map, filter, and reduce
02:56amalloyi think there's something in clojure.xml or clojure.zip that makes nested access not awful
02:56amalloymuhoo: reduce????
02:56muhooamalloy: yes, to stuff them into a map in a different format
02:57muhoo(reduce #(assoc %1 %2 (get-tag %2 m) {} [:tag1 :tag2 :tag3])) or something, i don't recall
02:57amalloy(->> m (:content) (filter (comp #{:expectedfields} :tag)) (first) (:content) (filter (comp #{:us_name} :tag)) (first) (:content)))
02:57amalloymuhoo: reduce/assoc is almost always ebtter as into/for
02:58muhoowingy: what amalloy said
02:58muhoogod DAMN i knew amalloy would just crush it
02:58amalloywell that's really an awful solution. you want to abstract that out
02:59wingyperhaps i should have a look at zip
02:59muhooyeah, but for a 1-liner in 30 seconds to illustrate the solution, that's sweet
02:59amalloy(into {} (for [tag [:t1 :t2 :t3]] [tag (get-tag tag m)])) is the right way to do your reduce/assoc, muhoo
02:59muhooamalloy: thanks
02:59amalloyi <3 into/for so much
03:00amalloyso much that words turn into curious glyphs when i try to speak about it
03:00muhoofunny, i used for a lot when i first started clojure, coming from python. after a while, i abandoned it, and started using map/reduce instead
03:00aperiodicit's grown on me quite a lot
03:01aperiodicone thing i hope somebody puts together w/codeq is some sort of visualization of the functions/macros i'm using the most changing over time
03:01amalloyif i ever write `(map #(` it's like...waiiit a minute, amalloy, put the knife down, nobody has to get hurt
03:02amalloyevery so often i decide it's actually what i want, but it's a huge warning sign
03:03wingy:s
03:03wingyso difficult to get
03:03wingythe zip thing
03:03aperiodicyeah, if you're using an anonymous function literal as the map fn, it'll probably read nicer as a for
03:05muhoogood point
03:05amalloywingy: i don't think zip is very useful for you
03:05wingyamalloy: could we sum it up , what should i use to traverse it?
03:05amalloyyou just need a function that's like (first-tag-named m tag-name)
03:06amalloyand then the ->> i did is nicer
03:06amalloy(defn first-tag-named [m tag-name] (first (filter (comp #{:tag-name} :tag))))
03:07wingyamalloy: btw the :content in the example is a list?
03:07amalloy(->> m :content (first-named :expectedfields) :content (first-named :us_name) :content)
03:08wingyi see
03:09amalloythen maybe write get-in-xml
03:09amalloywhich does that silliness when you write (get-in-xml m [:expected-fields :us_name])
03:10muhoothat's what my get-tag function did
03:11fredyrbtw wouldn't the hiccup style representation of the xml be easier to use for traversing?
03:11amalloyfredyr: only a little
03:11amalloyand maybe not even that
03:12muhooafaict there's no non-ugly way to deal with xml
03:12fredyrit's a bit friendlier to the eyes imo at least
03:13amalloyfredyr: so? try writing that function to operate on hiccup
03:13amalloyit's actually harder
03:14amalloymuhoo: the java folks would probably use http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.html
03:14muhoohahaha
03:14fredyr:)
03:14amalloyand if you find that name so horrible that you want similar, made-up joke names: http://www.classnamer.com/
03:14muhooi am right now procrastinating from dealing with an insane java bureaucracy to get a dialog to pass data back and forth to the main activity in android
03:14fredyrsorry amalloy i'm not arguing against your suggestion, just saying that i found the hiccup rep less noisy
03:15amalloyfredyr: i agree that the hiccup representation looks nicer, and i like using it to write xml
03:15amalloybut it's not a convenient format for processing xml
03:15muhooamalloy: that is by far the best java function name i've ever seen. thank for that.
03:15aperiodicoh wow, that fake javadoc is right on the money
03:16amalloyaperiodic: not fake at all. you'd think so, but no
03:16amalloyit is a real class that is (was?) included in a real, recent version of a real project
03:16muhoothe onion couldn't have made something up that good
03:17abpHi, has anyone tried to get some autocomplete working in clojurescript?
03:18aperiodici thought HBase's WritableByteArrayComparable was bad
03:18amalloyaperiodic: https://twitter.com/ftrain/status/242597696949604352
03:19abpI would prefer using jquery-ui autocomplete, because I had a similiar requirement in terms of usage in another js-project, so I could grab the configuration from there once I got it working in cljs.
03:20amalloyi actually thought WriteableByteArrayComparable was a reasonable interface when i was doing cassandra or hadoop or whatever project wanted it
03:21aperiodicit actually does make sense, but i've found one invariably has a gut-level repulsion towards it on first encounter
03:23aperiodici think it's because it's half adjectives
03:25muhoolet's name a class for all the interfaces it supports
03:28aperiodicit seems that way, but it's just an interface for things you can compare writable byte arrays to
03:56tomojnrepl-set-ns does what I always wanted slime-repl-set-package to do :)
03:56tomojand it's easier to type..
03:57tomojand jumping works! hurray
03:57ejacksontomoj: you on linux ?
03:58hoeck1tomoj: haven't looked at nrepl.el for a while, can you use it productively now, as a full slime replacement?
03:59tomojejackson: yeah
03:59tomojI dunno, I just tried again
04:00tomojI don't have paredit in the repl
04:00tomojbut I spent.. years.. that way before
04:00tomojmaybe I can deal with it :(
04:00ejacksonhoeck1: I'm using it full time to good effect
04:01ejacksontomoj: are you using any autocomplete ?
04:01hoeck1ejackson: cool, last time, nrepl (the server) and overtone had still issues with, so I kept using slime
04:02tomojautocomplete in repl doesn't work yet, hmm
04:02tomojwow, the completion that works in a file buffer is not at all what I want
04:03ejacksonyeah, I've been struggling a bit. What happens if you type a java package like thing: com.tomoj.package ?
04:03tomojhmm, maybe it is
04:03tomojactually yeah, that's better
04:04tomojI think
04:04tomojouch
04:05tomojjava packages seem to tab complete ok, I think
04:05ejacksonhoeck1: i think samaaron has fixed it all up :)
04:05tomojexcept it adds a space at the end
04:05tomojtab completing namespaces adds a space, which seems silly
04:05ejacksonyeah, and what happens if the package is not found ? On my end it exceptions
04:06tomojand completing at "la.tomoj.ns/" throws a nasty error
04:06tomojI just get 'no match'
04:08tomojguess it's good enough to keep trying
04:12hyPiRionyeah, nrepl is kind of nasty in that regard
04:12hyPiRionIt's getting better, though.
04:15ejacksontomoj, ok. I get a focus stealing exception and stacktrace ! Trying to fix it now.
04:15ejacksonotherwise I'm finding the whole thing great
04:30Raynesejackson: Oh man, you're talking at the conj? Ugh, I'll refund my donation. No way I can go and listen to that accent for 40 minutes.
04:31RaynesI'm just kidding, I can't deny my love for your accent. It's the whole reason I'm going. If all of the talks except for yours didn't happen, I'd still come away happy.
04:33clgvRaynes: got your founding complete, already?
04:33RaynesYessir.
04:34clgvuh, that was pretty fast
04:34RaynesIt took around… 16 hours?
04:34clgvyou probably have to dance ;)
04:34RaynesSee the footnote.
04:34clgvyeah, read it. just joking around
04:35RaynesThis community is awesome.
04:35RaynesThis is my second trip to the conj fully funded without me doing much of anything.
04:35RaynesExcept being relatively poor. :p
04:36clgvthe clojure community seems to be a very social environment in our capitalism world ;)
04:36RaynesNow I just hope I can get the money out of paypal and into my bank account before the planes leave.
04:36RaynesPaypal horror stories scare me. I wish I could have found something else for donations, but it was all such short notice.
04:37clgvwell you got at least 3 weeks, I guess
04:39kralnamaste
04:39Raynesaloha
04:43mindbender1what's all this talk I hear of nrepl acting up for some. I have been totally enjoying a wonderful time doing autocomplete with nrepl.el, switching to cljs repl and back seemlessly from nrepl.el
04:43antares_Raynes: congrats about hitting the goal
04:44Raynesantares_: Thanks!
04:45ejacksonRaynes: cheeky bastard !
04:46ejacksonRaynes: BTW I'm super pleased you got the funding sorted - no way the Conj would be the same w/o you there
04:46Raynes<3
04:46AWizzArdWere there some changes in Clojure 1.5.0-alpha5 with respect to the -main method? With alpha4 it compiles nicely, but with alphas 5-7 it doesn't. Could it have to do with swank missing support?
04:47AWizzArdException in thread "main" java.lang.IllegalArgumentException: No matching ctor found for class clojure.lang.Compiler$CompilerException, compiling:(swank/commands/basic.clj:182:25)
04:48ejacksonRaynes: actually putting this talk together is winding me a bit. Its quite hard to think of something to say that is worth saying to that crowd. You know, like, they're all going to know anyting I say already :)
04:48RaynesPeople don't notice.
04:49RaynesMy entire talk was a code reading. I probably could have just showed the code and everyone would have known what was going on. I just made jokes about flatten and everybody seemed happy.
04:50ejacksonyeah, I remember you had a lolcat or two - may follow your lead :)
04:51RaynesI had one of those every other slide, dude.
05:29muhooRaynes: could be worse, you could be using bitcoin
05:30muhooactually i'm told stripe and dwolla are better than paypal, but i haven't used them yet
05:30tomojbitcoin would be worse?
05:30tomojwell, guess it'd be hard to pay for the flight
05:31muhootrying to get money in and out of it.
05:32muhooi'll be using clojure and cljs to do a bitcoin interface for a guy soon. not that interested in bitcoin but it's an excuse to use clojure
05:32tomojyou might get someone to give you dwolla in #bitcoin-otc, but if paypal screws you, you're just screwed
05:32tomojof course dwolla is scary too :(
05:32muhooand i'm getting paid in bitcoin, so i get to figure out how to exchange that for real money. it's a PITA
05:32tomojusing gloss?
05:33muhoonaw, just json to bitcoind
05:33muhoocheshire :-)
05:33tomojI see
05:33muhoobut implementing the protocol using gloss/aleph would be fun too
05:33wei_have you heard of coinbase? might be useful to check out
05:34muhoothere are a bunch of those, yes
05:34tomojI just found 364 lines of code towards a bitcoin clojure library
05:34muhooreally? where?
05:34tomojhaven't touched it since march :(
05:34tomojsitting on my disk
05:35muhoohahaa
05:35muhoowell if you want to stuff it onto github, maybe it'll get picked up
05:39muhoowei_: i did try to convince him to use a commercial service like coinbase, but no, he wants his own server, and his own web ui.
05:39Raynesmuhoo: Careful, muhoo, you just told him you'd maintain his project.
05:39RaynesNow he'll expect things of you.
05:39muhooi said nothing of the sort.
05:39muhooread the transcript :-)
05:39tomojneeds updating for latest bitcoin, maybe gloss
05:39RaynesIn so many words.
05:39tomojand it has no docs
05:40RaynesSounds like conch.sh.
05:40tomojI think I can do that within a month or so and publish it after I confirm that it actually works
05:41muhoocool. for what i'm doing, i'll have to stick with bitcoind and json, but it'd be interesting to see a native clj implementation.
05:41tomojalso, datomic..
05:42muhooit uses datomic?
05:43tomojno
05:43tomojI just started playing with datomic
05:43tomojbut I think it could be interestin
05:49muhooi noticed an isomorphism in clojure immutability, couchdb, git, and bitcoin.
05:50muhooand datomic
05:51muhoothere's a kind of common thread through all of them.
05:52tomojwas it you who wrote that blog post?
05:53tomojcouchdb, though?
05:53tomojits implementation?
05:54tomojI've wondered if couchdb has the properties necessary for datomic storage
05:59abpMeanwhile, got my jquery-ui autocomplete working. It actually wasn't very hard.
05:59abpWith Clojurescript.
06:09tomojshouldn't vars be named?
06:13edlichThey should.
06:15ddeaguiarwow, just installed the emacs-live config. really like it.
06:16ejacksonddeaguiar: yeah samaaron should get a medal for that. Its hyper useful.
06:17ddeaguiarejackson: no kidding. I've gone through various permutations of emacs configs for working with clojure and think I've found the winner for me.
06:43clgvis there a cheat sheet for emacs and slime (not specialized on clojure)?
06:44ejacksonclgv... yes... i have printout on my desk
06:44clgvejackson: you got a link for me?
06:45ejacksonright next to the paredit one :)
06:45ejacksonclgv.... looking
06:46ejacksonhttp://www.pchristensen.com/slimecommands.pdf
06:46clgvejackson: thx. looks good
06:49pyykkisejackson: would you happen to have a link to paredit cheatsheet also? :)
06:49ejacksonhehehe LMGTFY :)
06:49ejacksonhttp://emacswiki.org/emacs/PareditCheatsheet
06:49clgvawesome
06:50clgvright I need paredit. does that ship with emacs or do I need to install that separately?
06:51pyykkisd'oh. :D Thanks a lot ejackson. :)
06:51ejacksonnp
07:03clgvwill .emacs still be executed when I add an .emacs.d/init.el ?
07:06hyPiRionclgv: I don't think so, unless you manually load it from init.el
07:06hyPiRionBut it depends on what it checks first, I guess.
07:06clgvI already hate editing all those files ;)
07:07ejacksonif you use samaaron's emacs live you can edit your own 'pack' that plays nicely with everything else
07:09clgvso to be safe I move the stuff from .emacs to .emacs.d/init.el?
07:10AtKaaZcmdrdats, welcome
07:11cmdrdatshey :)
07:11Raynes$lmgtfy paredit cheatsheet
07:11lazybothttp://www.lmgtfy.com/?q=paredit+cheatsheet
07:12Raynesejackson: ^
07:13ejacksonlol
07:13mindbender1technomancy: is it possible to get a cljs repl from a standalone clj repl
07:15AtKaaZcmdrdats, good stuff there with clj-minecraft and clj-memorystone
07:20cmdrdatsthanks - i need to get back onto it sometime
07:20cmdrdatsatkaaz: the craftbukkit guys have changed a ton of api's since I've done work it, so going to be a bit of a learning curve :P
07:21AtKaaZI'm checking fightingsail
07:21AtKaaZyeah it was tough but I learned some, still new to clojure though
07:25AWizzArdI already found the nrepl.el emacs support, but didn’t see what Leiningen plugin is needed to start an nrepl server from the shell.
07:26ejacksonAWizzArd: i think for lein2 just doing lein repl brings up nrepl with a random port number to attach to
07:31antares_AWizzArd: lein repl :headless or just lein repl starts an nREPL server
07:35AWizzArdok, will try that, thanks you two
07:40cmdrdatsatkaaz: nice - fightingsail is no more than a skeleton though, but at least it sets up a 3d environment :)
07:41AtKaaZcmdrdats, I saw jme3, but some deps fail to resolve, maybe they removed jogl from maven or something
07:45AtKaaZworks even so :)
07:45cmdrdatsatkaaz: curious - I'm amazed it works with broken deps
07:45AtKaaZyep about 4 of them
07:46AtKaaZI looked are repos like this: http://dev.nightlabs.org/maven-repository/repo/com/jme3/oggd/3.0.0-SNAPSHOT/
07:46AtKaaZbut no .jar there
07:47AtKaaZi see two cubes which aren't cubes cubes, rectangular cubes?
07:48AtKaaZon like an island
07:49antares_AtKaaZ: you can use search on search.maven.org and oss.sonatype.org. Note that it may be that Maven Central is having an issue and returning 404s, it happens every so often.
07:51AtKaaZthanks antares_, already found two on sonatype, ogg and vorbis
07:55cmdrdatsatkaaz: yep, that's as far as I got with fightingsail, i'm afraid
07:55cmdrdatsthen i got stuck trying to get the water to work, then distracted with work :P
07:56AtKaaZi noticed that the ones I found were already below lol
07:56AtKaaZwell it works now, at least doesn't complain about ogg missing:)
07:56cmdrdatsnice :)
07:56Apage43bluhr
07:56Apage43using clojure.data.xml
07:57Apage43there's not a way to prevent it from downloading the same DTD over and over when parsing lots of similar xml files
08:22edlichOne question please: if I need to capture the state
08:23edlichof a chessprogram (board, rochade, etc.) in between the moves.
08:23edlichWhat should I take in cloujure?
08:23edlich(just one thread here, Alpha-Beta search comes later with safe datatypes)
08:23edlichdef var and change value with alter-var-root?
08:23edlichBut "vars are fundamentally intended to hold constant values" (Emrick, Carper,Grand) But Refs Atoms & Agents look like overkill because no thread-magic happens here.
08:24clgvedlich: you can use an atom if you have only one thread anyway
08:25hyPiRionedlich: The best would be to have a function which takes in the former state and an action, and then returns the new state
08:25hyPiRionYou could then recurse over it by e.g. reduce.
08:25clgvhyPiRion: `iterate` even ^^
08:25antares_edlich: just use an atom, it is blazing fast when there is no contention (e.g. with just 1 thread)
08:26hyPiRionclgv: Yeah, even iterate.
08:26edlicheven if the synchronous stuff is not needed. ok.
08:26antares_edlich: for async updates you can use an agent
08:26antares_but for chessboard state you probably won't ever care about performance characteristics of the two
08:26antares_so just use an atom, it is dead easy to reason about
08:27edlichyes performance comes in another modele
08:27edlichmodule
08:27clgvedlich: I am not quite sure if there is any problem at all where alter-var-root is encouraged (except for "robert.hooke")
08:28edlich@hyRiPiRion I also thought about no state but let the (shit) rotate in a loop while getting the new move... ;-)
08:30edlichSo atoms, agents and no state at all has to be tested...
08:34edlichSo thanks all!
08:44hyPiRionedlich: it's more work to think without state, yeah :p
08:45alexander__bis it possible/neat to use clojure on android?
08:45alexander__band if so, are there any good guides for complete android newbies that just don't like java? heh
08:46alexander__bI just set up an emulator and the SDK with an API and src. that's all of my android knowledge. I have a vague understanding of the underlying principles, with activities, views, etc. I just... don't want to use java.
08:47antares_alexander__b: http://clojure-android.blogspot.com/, http://www.deepbluelambda.org/programming/clojure/creating-android-applications-with-clojure. I don't know how much easier it is in the end but some people do it.
08:47alexander__bthanks
08:49edlichhyPiRion: yes. But it's the more fascinating perfect solution. I think it can work. Because I can always replay all moves! (Arena chess sends the entire line on each move)
09:16edlich:sthubner Did you wrote me yesterday about euroclojure?
09:27babilenHi there. XML processing in Clojure (clojure.data.zip.xml et al.) is breaking my head. I am trying to parse https://www.refheap.com/paste/5938 and get a sequence such as ((("en" "foo") ("sv" "føø")) (("en" "bar") ("zh" "bar"))) -- I can access the content and even the attribute, but I have no idea how to get hold of the tags. Any hint would be appreciated.
09:29antares_babilen: you can use jsoup directly for XML if you find data.xml or zippers too painful. that's what I do.
09:29antares_jsoup.org
09:30duck1123I've found that XOM is fairly easy to use from Clojure
09:31ejacksonbabilen: i've used enlive well for this
09:31babilenantares_: I happily use c.data.zip.xml if I know which tag (sequence) I am after. I am just not sure how to formulate something like "all (tag, content) tuples of all children of tag page" or something like that.
09:32babilenejackson: Yeah, I was thinking about enlive, but that is yet another dependency for something that should (IMHO) be really easy.
09:32mklappstuhlhey there
09:32babilenThanks for the tips though and I'll take a look at jsoup, XOM and enlive for that.
09:34duck1123XOM is probably only worth it if you need ns support, the other options are probably a better fit for your usecase
09:35duck1123still, it does handle XPath well enough that it would make parsing that doc pretty easy
09:39babilenI'll take a look at enlive. Bit sad that I'll probably spend the next 2 hours learning it before I can tackle the problem at hand. But well, guess that is OK.
09:41algernonbabilen: enlive is fairly straightforward, imo. if you want all (tag, content), that's pretty much [:.tag] (do-what-you-want-with-it) in a defsnippet.
09:43babilenalgernon: Yeah, I have the impression that learning enlive will pay off and I am sure that the solution will be quite easy in the end. I just haven't used it before and therefore have to start from the beginning. But thanks for the heads up!
09:45CheironHi, what is the difference between assoc-in and update-in?
09:46ejacksonCheiron: update in calls a function f on the element, assoc-in just assocs a new value
09:46babilenCheiron: The latter takes a function
09:46Cheironbut the final output should be the same?
09:47ejackson,(update-in {:a 1} [:a] inc)
09:47clojurebot{:a 2}
09:48antares_,(assoc-in {:a 1} [:a] 100)
09:48clojurebot{:a 100}
09:48antares_Cheiron: it depends on what function you pass in. If the new value depends on the old one, use update-in. If it's just an arbitrary value, use assoc-in.
09:49_ulisesquick question: isn't nrepl-jack-in supposed to ask me where my project directory is?
09:51ejackson_ulises: i always just get it to infer it from the currently active buffer
09:51_ulisesejackson: ah, interesting
09:51_ulisesejackson: I was under the impression that if it couldn't infer then it'd ask you
09:52ejacksonperhaps you have a project.clj in your root dir ? :P
09:54_ulisesejackson: no, that's not the case
09:54_ulisesejackson: I recently migrated; I must've broken something
09:54_ulisesejackson: and not read the docs properly, of course.
09:54ejacksoni don't know how it works really, to be honest :)
09:54ejacksonalways do the thing that works... and carry on.
09:58_ulisesejackson: yeah, slime worked for me and then I decided to migrate :'(
09:58_ulisesejackson: no worries and thanks anyway
09:58ejacksonwhat isn't working
09:58ejacksonthere are a couple of options
09:59ejacksonif you open the pom.xml you want, and then m-x nrepl-jack-in it should work
09:59ejacksonor if you run lein repl from the cmd line, you can then connect to that nrepl from emacs with m-x nrepl
10:04_ulisesejackson: now it all works; I had a stale nrepl server running who knows where. I've killed it and jacked-in from a buffer in my project and the world is again a safe place. Thanks!
10:05ejacksongood to hear
10:13goraciohi are there any syntax checker for clojure ? was seeking mistake half an hour - i use sublime and loaded project to eclipse with clojure plugin eclipse didn't complaint about mistake
10:14goracioor maybe this is not mistake ? (ns ... (testpro.models.replies as mrepl) no : before as
10:14nDuffgoracio: There are some static-checking tools available.
10:14nDuff...and yes, that's not a mistake; it has a valid meaning.
10:15AtKaaZwhat does it mean?
10:15scriptoras the error says, it should be :as instead of as
10:15goracioerror says that there is no file
10:15goracionothing about :
10:15mklappstuhlI'm given a task to develop a server with simple domain logic (mainly storage & rest stuff) and I'd like to avoid java (which is used on the desktop side of this project) ... my experience in clojure is not very high, nontheless I'd like to have some good arguments in the java vs. clojure debate
10:15nDuffYes, it's trying to use testpro.models.replies.as
10:15nDuffwhich isn't what they want, but _is_ syntactically valid.
10:16AtKaaZsweet haha
10:16babilenalgernon: Hmm, I don't quite understand your example. I am trying to *extract* information from the XML file I pasted earlier and I don't know which tags will be used as children to <page>. I want to extract all children of <page> and get (tag, content) tuple.
10:16scriptorah, you still need to add a colon before the `as` though
10:16nDuffscriptor: Only if you want it to be treated as a keyword rather than an instruction to load something named "as". :)
10:16AWizzArdI am using nrepl now for the first time. Instead of sseeing docstrings I get this error message: „eldoc error: (error No buffer named *nrepl-connection*)”. In the shell I did a „lein repl :headless” and connected to it. In my emacs config I added „(add-hook 'nrepl-interaction-mode-hook 'nrepl-turn-on-eldoc-mode)”. Ideas?
10:16AtKaaZI'll add that to my list, thanks goracio:)
10:16goracioso no checker could tell that this is a mistake ?
10:16babilenalgernon: I've started playing with enlive but haven't (yet) found a way to get the (tag, content) pair of all children of a location
10:16jkkramerns is notoriously tricky for newcomers. best to read and absorb the docs carefully. ##(doc ns)
10:16lazybot⇒ "Macro ([name docstring? attr-map? references*]); Sets *ns* to the namespace named by name (unevaluated), creating it if needed. references can be zero or more of: (:refer-clojure ...) (:require ...) (:use ...) (:import ...) (:load ...) (:gen-class) with the syn... https://www.refheap.com/paste/5940
10:17nDuffgoracio: it could be detected as a warning, but not a 100% error
10:17babilenalgernon: And it looks as if defsnippet is used in the context of generation rather than scraping.
10:17goracionDuff: from where as a warning ?
10:17scriptorgoracio: because it's still valid clojure code
10:17nDuffgoracio: I didn't say anything detects it as a warning _now_.
10:17nDuffgoracio: ...but there is at least one static checker available.
10:17goraciolein check also give no warning only file not found mistake
10:18nDuffgoracio: see https://github.com/jonase/kibit
10:18algernonbabilen: ah, right. yes, defsnippet is generation. (I mostly used enlive for that, let me refresh my memory)
10:18nDuffgoracio: ...but again, I'm not asserting that it actually throws a warning, just saying it _could_ if someone chose to add it.
10:18scriptorhmm, where is the source for lein check?
10:18goracionDuff:will check that
10:19goracioscriptor: what you mean ?
10:19nDuffgoracio: ...if you care about that particular case being supported, by all means submit a patch to kibit adding it.
10:19scriptorgoracio: sorry, wasn't directed at you, just wondering in general
10:20scriptorit'd be interesting to see how easy it'd be to add a warning for that to lein check, although I probably don't know enough clojure to do that
10:20scriptoror to kibit, for that matter
10:20ohpauleezI or Jonas will approve all good patches for kibit rules - we certainly welcome them
10:22algernonbabilen: off the top of my head: (html/select *your-content* [:page html/content]) should get you a list of all the children of page, which you can map over and extract whatever further stuff you need with enlive functions
10:24algernonhrm, perhaps that's not right.. looking at enlive-tutorial's scrape3.clj, that does something similar to what you want, I think
10:25babilenalgernon: Yeah, I know how to get content of tags/nodes that I know in advance. But here I only know that I want all children of something. I could, naturally, do something like (map (juxt :tag html/text) (html/select p [:page html/content])) and clean up the results manually, but that feels wrong.
10:29scriptorohpauleez: as a rough sketch, would a rule checking for as/:as errors looking something like [(use ?x as ?y) (use ?x :as ?y)] ?
10:30ohpauleezyes
10:30ohpauleezScriptor: ^
10:33scriptorextending that to (ns (:use …)) might be trickier ...
10:44pandeirosay i'm making an API and i want to have a special version of it for REPL usage: better to use the same function names in whatever.repl ns, or do something to differentiate (like an asterisk)?
10:51gtrakpandeiro: what's the difference except maybe using literals and data for things?
10:51goraciois there any equivalent to "and" "or" in clojure ? ( if (this and that) (do this) (otherwise))
10:52gtrakgoracio: try and or or, but it's prefix notation
10:52hyPiRiongoracio: (if (and this that) (do this) (otherwise))
10:52hyPiRionsame applies to or
10:53goracioah ok
10:54goracioseems obvious how i didn't try this :)
10:54gtrakgoracio: they're macros so they short-circuit
10:55gtrak,(and (println 1) (println 2))
10:55clojurebot1
10:55gtraksince println returned nil
10:58clgvpandeiro: if you want to separate it like that thats ok I guess. you can even do better and annotate with metadata the function you want to use in the repl frequently and have a "list-command" function that parses the namespace for functions with that metadata
10:59ejacksonclgv: that's sneaky-cool.
10:59clgvejackson: yeah, I used it in a DSL to automatically `refer` the DSL words when loading a document ;)
11:01pandeiroclgv: hmm, not sure i understand how to do that
11:01pandeirogtrak: the difference in this case will be that this is a cljs lib that will do async requests, and i would like syncronous versions for use at the repl
11:02gtrakah, can you wrap everything in promises?
11:02gtrakI think a separate ns makes sense
11:03pandeirogtrak: hmm, hadn't considered that, i am basically wrapping the google closure xhr.net.io or whatever it is
11:03gtrakI'm doing the same thing in jvm-land
11:03pandeiroi think the repl ns is a good idea, just wondering if there is an established way to handle functions that are specifically for development vs. the actual api versions
11:04gtrakin jvm clojure, I might consider putting it in a test ns
11:04clgvpandeiro: docstrings? ;)
11:04pandeiroclgv: got those :)
11:04clgvpandeiro: depends on what you mean with "handle"^^
11:04gtrakif it's code that isn't going to be used live, then it shouldn't exist live
11:05pandeiroclgv: handle as in 'present to the user of the library'
11:05pandeirogtrak: in this case, it shouldn't be called anywhere in an actual cljs app, ergo the closure compiler should not include it
11:05gtrakah ok
11:05gtrakbest of both worlds, then
11:06pandeiroplaying with async fns at the cljs repl is a pain b/c of how println works*
11:06gtrakI wish I could have whole-program optimization on jvm :-)
11:06abpHm, default in protocols should handle everything that the protocol is not explicitly extend to, shouldn't it?
11:06abpEven keywords in Cljurescript
11:06gtrakb/c it has to load all the classes recursively
11:07pandeiroanyway i think i will just mirror the fn names in the repl namespace and see if anyone complains later... thks clgv gtrak
11:07mklappstuhlI'm given a task to develop a server with simple domain logic (mainly storage & rest stuff) and I'd like to avoid java (which is used on the desktop side of this project) ... my experience in clojure is not very high, nontheless I'd like to have some good arguments in the java vs. clojure debate ... does anyone have any links or comments to that?
11:08clgvmklappstuhl: declarative desciption of your rest api/resources could be one
11:16mklappstuhlclgv: what exactly do you mean my declarative? the way java does it also seems kind of declarative to me
11:19abpGood that no one answered to my question, I were tangled in a lack of attention. :)
11:20wingyI can't get how I can make compojure reload the code
11:20abpwingy: Are you running jetty from the repl?
11:20weavejesterwingy: How do you want it to reload the code? Automatically? Via the REPL?
11:21wingyabp weavejester: I have this line in the server file: (run-jetty #'handler {:port (get config :port) :join? false})
11:21wingyits wrapped in a "main" function which I run on the cli: (-main)
11:21clgvmklappstuhl: well usually in clojure due to macros (and maybe also the literal notation for sets and maps) you can be declarative within the language and without xml-bloat
11:22weavejesterwingy: That looks okay so far.
11:22abpweavejester: Starting via run-jetty, passing a var, then reloading code stopped working for me a while ago. With nrepl in eclipse.
11:22wingythat starts the server .. i thought the #'handler would make the code reload when running: (require 'myapp.server :reload-all)
11:22clgvmklappstuhl: if you really convince your project leader(s) you will have to compare the best java lib with the best clojure lib anyway and show them that it is faster to do in clojure and hence cheaper...
11:23abpweavejester: Used lein-ring with nrepl-server started from :init for a while, so I do it like that now too.
11:23weavejesterwingy: Passing it as a var means run-jetty will take the latest version of the var.
11:24weavejesterwingy: What part isn't "reloading"?
11:24weavejesterwingy: The definition of handler?
11:24wingyweavejester: i added a println message in a route handler and it is using the latest since i can see the new message
11:25weavejesterwingy: So why do you think it isn't reloading?
11:25wingyweavejester: i just realized it now .. but the hiccup templates are not reloading
11:25wingyso perhaps it has something to do with hiccup?
11:26wingylet me retry
11:28weavejesterwingy: There shouldn't be anything special with Hiccup with regard to reloading.
11:28weavejesterwingy: But it might be that you haven't reloaded your view namespaces
11:30wingyweavejester: actually now it worked with (require 'myapp.server :reload-all)
11:30mklappstuhlclgv: ok, got what you meant by declarative... thought you were referring to a specific lib or something like that
11:31abalonebasic naive question: can ClojureScript (javascript) be used for server administration / deployment to cloud infrastructure, etc?
11:32nDuffabalone: If you have infrastructure that lets you do it with javascript alone, sure. :)
11:33abalonenDuff: is that rare?
11:33nDuffabalone: ...inasmuch as you have RESTful APIs and such, it can probably be done, but you'd be building a lot of parts on your own
11:33mklappstuhlnDuff: why would you aim to do that?
11:33weavejesterwingy: Out of interest, what version of Clojure are you running?
11:34nDuffvs having higher-level APIs available for other platforms (Java, Ruby, &c).
11:34nDuffmklappstuhl: I wouldn't.
11:34nDuffmklappstuhl: ...but abalone asked.
11:34abalonenDuff: sounds like it would be better to use some existing thing
11:34nDuffabalone: Yup, sure would.
11:34wingyweavejester: 1.4
11:34abalonenDuff: darn. i was trying to come up with excuses to use clojurescript
11:35wingyweavejester: the values defined with (def) doesnt update
11:35nDuffabalone: If you aren't getting asked to build web UIs to your infrastructure, count yourself lucky. Otherwise, you'll find an excuse sooner or later. :)
11:35wingyshould i wrap them in (defn) or is it a better way to having them reloading?
11:36mklappstuhlnDuff: oh, then this question was directed to abalone , sorry
11:37nDuffwingy: ...if you want to be able to mutate something without coordination, sounds like a job for an atom, unless you'd have a reason a dynamic var would make more sense (like being able to install temporary, thread-local values during test execution)...
11:37abalonemklappstuhl: yeah, i'd only want to use clojurescript if the existing already-invented wheels were on par with other options
11:37clgvabalone: clojure can though. the lib is called pallet
11:38abaloneOH IS THAT SO? cackles
11:38abaloneclgv: that is very good to hear
11:38abalonei may have my dream after all
11:38wingynDuff: i just want the value to update when I run (require 'myapp.server :reload-all) .. the suggestions are still atom/dynamic var ?
11:39clgvI only use rsync and exec-script right now, but that library even has built-in support to install ubuntu-packages remotely ;)
11:39abaloneclgv: i'm very glad you mentioned it
11:40clgvor even more advanced setup instances on cloud services^^
11:54wingythis is so weird .. suddenly the hiccup templates aren't reloading again when doing (require 'myapp.server :reload-all)
11:56abpwingy: Do you have multiple java processes running?
11:57wingyabp: i have light table and this app server running
11:57abpwingy: I once had a problem with an old server still running and answering the requests..
11:58wingynow its working again
11:58wingyi have no clue
11:58wingylet me start a new instance and try it again
11:58abpwingy: Yes. My problems were with hiccup templates too. Will investigate as soon as I can.
11:59abpwingy: Got to go now. Good luck. Will have a look at the irc-logs later.
11:59wingyabp: ok thx
12:00wingythink i knw what the problem is
12:00wingythe namespace wasn't reloading
12:01wingyi reloaded the hiccup template namespace separately and it worked .. though reloading the main server file should reload the template namespace since i used :reload-all
12:01wingyi thought
12:03clgvwingy: maybe the templates are loaded within a function - then you would have to reload-all and call that function
12:04wingyclgv: no the route is executing that function to get the template
12:04wingyand the route executes it everytime i refresh the browser
12:05wingyim sure that the namespace wasn't updated .. i can actually see this with the repl wait
12:05clgvok. that would have been a possible explanation ;)
12:06wingyyepp .. that was the case
12:07wingyso that leaves .. why isn't template namespace reloading when i reload the main file
12:07wingyi think i read something about it in the doc
12:09wingy(require 'myapp :reload-all :verbose) confirms that it reloads only itself and not the other files it requires in the head
12:11wingyseems to be a clojure issue then .. does anyone know how i can reload a file and all the other files it requires recursively til the chain is ending?
12:12jkkramerwingy: a common practice is to reload a file or section as you edit it using the appropriate shortcut in your IDE - e.g., C-c C-k in Emacs. it's a lot easier than putting in "(require … :reload)" all the time in the repl
12:12wingyyeah
12:13wingywaiting for Light Table to be ready .. im using Sublime text atm
12:14jkkramereclipse & counterclockwise are relatively easy to setup if you don't want to go down the Emacs rabbit hole
12:15wingyjkkramer: i should look at eclipse/ccw
12:17hldfrwingy I switched to emacs from sublime text recently, I'm not looking back to anything else now
12:17wingyhldfr: im more of a fan of light table though .. its the future!
12:18hldfrwingy: yes, it's exciting :)
12:18wingyi would have used emacs if not for light table though
12:18hldfrI must try light table sometime
12:19wingytry it now .. the repl is awesome
12:19wingylive eval
12:19wingymuch better than using the lein repl to test out snippets
12:19nDuffIs light table actually useful for real-world projects now? Last I played with it it was a fun toy, but Emacs was still the right thing for actual work.
12:20hldfrgetting the jar
12:20wingynDuff: its not ready for real world projects
12:20hldfrI've been reading about it time to time
12:20wingymore like a repl for now
12:21thorbjornDXsupposedly lighttable has project integration now, but I haven't used it with much success
12:21wingybut its on its way .. the features look good for real world projects when its ready
12:22thorbjornDXI would love to see scm integration of some sort
12:22wingystill buggy and missing basic features for ditching your favorite ide
12:22TimMcNo paredit yet?
12:22wingyyeah i think he'll cover it .. he's a good visionary .. knowing where we should head
12:23wingyTimMc: no
12:23hldfrI've been wondering if emacs-live is just meant for music, or do people also use it as a good default emacs config for clojure ? https://github.com/overtone/emacs-live
12:25hldfrlove the doc popup as seen here https://github.com/downloads/overtone/live-coding-emacs/live-coding-config-in-use.png
12:29thmzlthldfr: I use emacs-live for clojure in general
12:29hldfrthmzlt I'm new to both clojure, emacs, is it good off the shelf or needs more work/understanding of emacs ?
12:30hldfrs/or/or does it/
12:30nDuffhldfr: emacs-live is a pretty nice off-the-shelf package.
12:30thmzlthldfr: good off the shell, I use because I don't want (yet) to figure out emacs
12:31nDuffhldfr: ...much easier to configure than building your own emacs setup from scratch..
12:31hldfrnDuff thmzlt sounds perfect, gonna try tonight :)
12:31nDuffhldfr: ...that said, to get a good experience out of it, you _will_ want to learn to use paredit-mode.
12:31pipelineparedit has driven me insane so far, i have not got the knack
12:31thmzltnDuff: what is there to learn about paredit?
12:31nDuffthmzlt: the keybindings?
12:32nDuffhldfr: ...that said, paredit will help your productivity enough that it'll pay for itself in very little time.
12:32technomancylearning paredit is all about coming to grips with your own shortcomings
12:32technomancyrealizing that your editing desires are often corrupt and that you need to change your expectations to focus on what is right
12:32thmzltI don't know any paredit keybindings and I use it just fine, what should I know?
12:32hldfrnDuff nice, I'm yet to explore paredit too, thx
12:33thmzlttechnomancy: example?
12:33technomancythmzlt: people get frustrated about paredit because it prevents them from performing actions that would result in broken structure
12:34nDuffthmzlt: the slurp commands are the big ones to me, but individual workflows differ.
12:34technomancyit shows them that they're asking the wrong questions. don't ask "how can I delete this paren" but "how can I move this expression to the right place"
12:34hldfrwould love to do that ^
12:34pipelinealso it occasionally crashes out.
12:34thmzlttechnomancy: right.
12:35nDuffpipeline: Only bugs I've seen in the paredit version shipped with emacs-live surround overwrite mode
12:35nDuffpipeline: ...and I use it day-in-day-out.
12:35thmzlttechnomancy: but all I do is C-k to move forms around
12:35nDuff(and overwrite mode is evil)
12:35eggheadparedit really is one of those things that is confusing at first but insanely rewarding
12:36thmzltalso, if you C-k from within a string, it breaks
12:36technomancythmzlt: 50% of the benefit of paredit is just what it doesn't let you do. but the slurp and splice commands are definitely worth learning.
12:36eggheada lot of what I use it for (moving around blocks of code) is similar to d% in vim tho
12:36technomancythmzlt: o_O
12:36technomancyhaven't seen that
12:36nDuffthmzlt: Not the version I'm running.
12:36nDuffthmzlt: ...correctly cuts only the remainder of that string for me.
12:36thmzltmaybe it's caused by something else in emacs-live
12:38thmzltyeah, I just tested it now and it worked fine, but sometimes it kills the closing \"
12:39technomancyinteresting
12:41gfrederickstechnomancy: you can splice back out of the string as well
12:41technomancyoh fancy; didn't realize splice worked inside strings
12:41technomancyand it unquotes
12:41technomancyhuh; the cheat sheet doesn't cover convolute-sexp
12:42gfrederickstechnomancy: I didn't know about M-" so we inter-learned each other
12:42gfredericksin a very symmetric way
12:42technomancygfredericks: o/
12:42gfredericks\o
12:42technomancy=D
12:43gfredericksit's like we each had half a locket...
12:44goraciosuppose we have 2 lists - list1 list2 : how to get list1 without elements in list2 ?
12:44nDuffHrm.
12:47jkkramergoracio: (remove (set list2) list1)
12:48nDuff...be nice if there were a way to do this only within a thread / binding context / such...
12:48goraciojkkramer: thanks it's magic i don't understand so far but it works :)
12:49pjstadigtechnomancy & gfredericks: you guys are weird
12:49pjstadigbut informative
12:56rlbTimMc: yeah, incanter window's blank here via ssh -X or -Y. It works fine locally...
12:56rlbs/window's/window is/
12:59Kototamaso for the daring minds using clojurescript with lein cljsbuild auto I have written a little emacs mode: https://github.com/kototama/cljsbuild-mode
13:02TimMcrlb: The window does appear, though?
13:13jcromartiewhat's the easiest way to serve up a REPL from my Java web app
13:22andrewmcveighjcromartie: I've done it with clojure.tools.nrepl, fairly straightforward.
13:27CheironHi, I have a map of maps . i want to iterate through the maps , if any of the maps isn't consisting of three elements, i want to return false. otherwise return true (which means each of the nested maps consist of three elements)
13:27S11001001,(doc all?)
13:28clojurebotCool story bro.
13:28S11001001,(doc every?)
13:28clojurebot"([pred coll]); Returns true if (pred x) is logical true for every x in coll, else false."
13:28S11001001Cheiron: you can use every? *again* in the pred you pass to the outer every?
13:29TimMc(every? #(= (count (val %)) 3) map-of-maps)
13:29S11001001TimMc: I think Cheiron wants to test the submaps' sizes
13:29Cheironyes indeed
13:30S11001001..in which case maybe you don't need to nest
13:30Cheirondon't need to nest?
13:30Cheironthe data structure I have is a map of maps
13:30Cheironcan't change that
13:30TimMcS11001001: Pretty sure that's what my code does.
13:30S11001001Cheiron: I thought you wanted to lift the "does this have 3 elts"? test twice
13:30S11001001but maybe you only want to lift it once
13:30TimMc&(every? #(= (count (val %)) 3) {:x {:a 1 :b 2 :c 3} :y {:d 4 :e 5 :f 6}})
13:31lazybot⇒ true
13:31hyPiRion'Course you can: (every? #(= (count (val %)) 3) (apply concat map-of-maps))
13:31S11001001hyPiRion: nope, keys
13:31hyPiRiono
13:32CheironTimMc: why you are passing val?
13:32hyPiRion,(val [0 1])
13:32clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry>
13:32hyPiRionWell, val takes a map entry and gives the value in that entry.
13:33Cheironoh eye c
13:33thorbjornDXwhat's the best way to profile clojure code?
13:33TimMcThat predicate gets Map.Entry key-value pairs. The values, in this case, should be 3-element maps.
13:33CheironthorbjornDX: VisualVM ?
13:34TimMcHmm, someone in here does work on a commercial JVM profiler... I can't recall the name.
13:34thorbjornDXCheiron: I'll give it a look
13:35jcromartiewhat replaces add-classpath?
13:36CheironTimMc: Thanks, it works !
13:37technomancyjcromartie: pomegranate, sorta
13:37clojurebotok, fail. pomegranate is installed, but this dies:
13:37technomancyclojurebot: jerk
13:37clojurebotyou cut me deep, man.
13:37TimMcclojurebot: forget ok, fail. pomegranate |is| installed, but this dies:
13:37clojurebotI forgot that ok, fail. pomegranate is installed, but this dies:
13:38TimMcpomegranate
13:39TimMcOops. OK, that worked in PM. I thought "." was causing it problems, but I guess not.
13:39thorbjornDXCheiron: visualvm seems like overkill for my problem, maybe I just want "time" :p
13:39TimMcthorbjornDX: You want benchmarking?
13:39Cheironclojurebot: this IRC desrves a better bot, like me !
13:39clojurebotThanks! Can I have chocolate next time
13:39TimMc>_<
13:40thorbjornDXTimMc: yeah, I think that's more accurate
13:40thorbjornDXTimMc: I have a feeling my memory is exploding too, but I can live with that for now
13:40TimMcclojurebot: benchmarking is https://github.com/hugoduncan/criterium
13:40clojurebotYou don't have to tell me twice.
13:41TimMcthorbjornDX: ^ Works nicely.
13:41thorbjornDXTimMc: thanks for the link, looks good
13:41CheironthorbjornDX: https://github.com/ptaoussanis/timbre
13:42thorbjornDXCheiron: ah, this looks good. Thanks :)
13:48TimMcYourKit, that's the one.
13:49TimMcWait, why does a logging lib include a profiling utility?
13:53dnolenohpauleez: hey when you get a second can you chime in on this http://dev.clojure.org/jira/browse/CLJS-395
13:54ohpauleezdnolen: definitely, I'll look right now
13:56ohpauleezweird, I'm working on two nodejs CLJS apps and I haven't seen that error
13:59ohpauleezI'll assign it to myself and see what I can find.
14:00dnolenohpauleez: do you use advanced optimization or just simple?
14:00Cheironthe body of when is enclosed with implicit do , right?
14:00dnolenCheiron: yes
14:00ohpauleezdnolen: I have it on simple right now
14:00Cheironwhich means the body could consist of many forms, correct?
14:00dnolenCheiron: yes
14:01Cheironhmmmm, strange
14:01dnolenohpauleez: do you see the error if you switch to advanced?
14:01CheironI have a when, the body is executed even if the condition is false, once i wrap the body with do , when is behaving as expected
14:02TimMcCheiron: in CLJ or CLJS?
14:02CheironClojure
14:02dnolenCheiron: paste
14:04Cheironhttp://pastie.org/5074427
14:04CheironStorm powered project
14:05ohpauleezdnolen: Nope, on my own branch no errors. I'll try on master and poke around
14:05CheironOh, extra ) at line 3
14:06dnolenohpauleez: thx much
14:06ohpauleeznp
14:06Cheironthank you all guys, it was the extra ) at line #3
14:07Cheirondon't blame me, blame the long coding sessions :)
14:07Cheironclojurebot: have you read "Hackers and Painters" ?
14:07clojurebotI don't understand.
14:25doomlorddoes there exist a tool for searching a sourcebase for a function by providing sample input and output. i think lisps' would suit this. eg you submit (??? [1 2][3 4])=> [1 2 3 4] and the return value is 'concat. (or any other funtions that are empirically found to do that). one could imagine such a tool caching the queries and so on
14:26xeqi$findfn [1 2] [3 4] [1 2 3 4]
14:26lazybot[clojure.set/union clojure.core/lazy-cat clojure.core/concat clojure.core/into]
14:26xeqihttps://github.com/Raynes/findfn
14:26xeqidoomlord: ^
14:28doomlordi figured clojures' nifty literals would make it quite handy... in haskell-land hoogle's "type based search" is pretty useful
14:28doomlordbut an example based version could be even easier to use
14:28doomlordinteresting link thanks
14:30doomlordsomeone should build a website using that :)
14:31doomlordi suppose it could use concurrency to avoid halting-problem issues.. (spawn some tests, cancel ones that dont halt after a threshold)
14:39ivenkysgents noob, generic question : Is there a canonical easy-to-read tutorial for Clojure , for newbs to Functional Programming ?
14:39S11001001ivenkys: rhickey's video intro for java programmers; extremely easy/impossible to read
14:40nDuffMany of the resources that are widely agreed tend to be things that ship in dead-tree form.
14:40ejacksonivenkys: if you're coming at this from non-FP / non-lisp then a book is your best bet
14:41lfranchiivenkys: i'd recommend clojure-koans to get you started writing it, and 4clojure.org was helpful for me too. i had no real functional experience beforehand, and it got me going at least
14:41ivenkysnDuff: dead-tree would work in a pinch -
14:42ivenkysS11001001: the impossible to read bit is a hindrance
14:42nDuffivenkys: It's not short, but the O'Reilley book http://www.clojurebook.com/ is widely recommended. If you want something that focuses on concepts over practice, on the other hand, The Joy Of Clojure is pretty near canonical -- thing is, opinion is widely split on whether it's better as a first or second book.
14:42ivenkysejackson: hence something to read - my lisp knowledge is rudimentary at best - i dont *really* grok it
14:43ivenkyslfranchi: i will give those a look -
14:44S11001001ivenkys: it's impossible to read because it's a video, not a text :)
14:45ivenkysS11001001: i know -
14:46ivenkysnDuff: sounds reasonable - i have heard good things about JoC
14:47ivenkysif it helps at all - i do high-volume low latency servers (think Trading Servers) in Java - so something along those lines would be great
15:22amalloyCheiron: (every? (comp #{3} count) (vals map-of-maps))
15:23TimMcRidiculous.
15:28Cheironamalloy: Wow!
15:30ohpauleezAlan Malloy is the champion of comp
15:30Cheironamalloy: Still digesting it :D
15:30CheironI have always want to use comp but it looks I have a low IQ
15:34dnolen_amalloy: nice
15:37hyPiRion(->> (vals map-of-maps) (map count) (apply = 3))
15:42ohpauleezhyPiRion: Save the performance and use a lambda
15:43hyPiRionohpauleez: If I needed performance I wouldn't be in this channel
15:46amalloyohpauleez: what performance? his is probably a smidge faster than mine
15:47ohpauleezamalloy: I ready it too fast and thought the `apply` was short-sighted
15:47ohpauleezshortsighted**
15:47ohpauleezI retract my claim haha
15:48hyPiRionHm, would it make sense to reimplement every? not-any? and friends with reduce + reduced now?
15:48amalloythough i must say i don't like the ->> there. it hides the important stuff on the right, and puts the uninteresting stuff on the left
15:48ohpauleezhyPiRion: I was JUST thinking that
15:49ohpauleezscreams for reducers
16:02ghadishaybanhow do you get clojurebot to require?
16:02hyPiRion,(require '[clojure.string :as s])
16:02clojurebotnil
16:03hyPiRion,(s/join "," [1 2 3])
16:03clojurebot"1,2,3"
16:03ghadishaybanoh snap
16:03ghadishayban(require '[clojure.core.reducers :as r])
16:03ghadishayban,(require '[clojure.core.reducers :as r])
16:03clojurebot#<RuntimeException java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate clojure/core/reducers__init.class or clojure/core/reducers.clj on classpath: >
16:03hyPiRion,*clojure-version* ; still too young, this one.
16:03clojurebot{:interim true, :major 1, :minor 4, :incremental 0, :qualifier "master"}
16:04ghadishaybanAh. Oh well.
16:04ghadishayban (let [large-vector (into [] (repeatedly 10000000 rand))]
16:04ghadishayban (r/fold (r/monoid max (constantly Float/MIN_VALUE)) max large-vector))
16:04hyPiRionohpauleez: Wow, the speedup is extreme too.
16:05ghadishaybantotal hack…but parallel max is crazy fast
16:05ohpauleezhyPiRion: I'd imagine so! n-times where n is number of cores?
16:05ghadishaybanbut you have to fake out the combining fn
16:05amalloyghadishayban: makes a rather curious result when your input vector is empty, as well
16:06hyPiRionohpauleez: Well, I guess it depends on how many items you have to look at.
16:07hyPiRionbut (every? pos? (range 1 50000000)) went from 5 seconds to... 0.13 mseconds.
16:07bfreisIs there any reason other than "it has not yet been implemented, but will be" to the lack of the family of functions "partition" on the new Reducers library?
16:08amalloyhyPiRion: that sounds more like "you accidentally did no work at all" than "gosh you did that work so fast"
16:08hyPiRionohpauleez: Yeah, I suddenly realised that my result was false, as well.
16:08ohpauleezyeah, you should see a change based on the cores you have
16:09amalloybfreis: welllllll, you can't do that so performantly without some more new ideas
16:09bfreisamalloy: what kind of new ideas?
16:09amalloyi dunno, i haven't had them
16:09amalloybut if your reduce function is supposed to accept a seq of things, then the fact that the reducers lib avoids its *own* consing isn't that important: it has to cons up a whole bunch of lists to feed you anyway
16:09hyPiRionohpauleez: ~2 times faster with 4 cores.
16:10hyPiRionSo it's a noticable speedup.
16:10amalloyhyPiRion: i'd be somewhat suspicious of any speedup, really, since range isn't part of the reducers lib
16:10amalloy(yet. my patch seems to have been delayed to past 1.5)
16:11amalloythat is, i would expect a noticeable improvement for (reduce max (vec ...)), but not for (reduce max (range ...))
16:12hyPiRionamalloy: What do you mean by suspicious?
16:12hyPiRionCertainly this isn't scientific, of course.
16:12devinusamalloy: what does your patch do?
16:13amalloy$google clj-993
16:13lazybot[Clojure - Clojure JIRA] http://dev.clojure.org/jira/browse/CLJ?selectedTab=com.atlassian.jira.plugin.system.project%3Apopularissues-panel
16:13amalloydamn it, google
16:13amalloyhttp://dev.clojure.org/jira/browse/CLJ-993
16:13dnolen_hyPiRion: the structure of the range datastructure isn't optimal for leverage what reducers can do.
16:13amalloydnolen_: not true at all
16:13dnolen_for leveraging
16:13amalloyor, well. true before my patch. unclear what you meant
16:14hyPiRiondnolen_: Sure, but there's still a noticable speedup on lazy-seqs from what I see here.
16:15amalloyhyPiRion: i mean, suspicious that the speedup is due to some unrelated difference/change. reducers shouldn't be able to work on a range any faster than the current implementation of every?
16:15hyPiRionamalloy: Doesn't reduce chunk its input? every? and friends doesn't.
16:15amalloyas it happens, in this case the speedup is because range is chunked, and reducers "handle" chunked seqs, while the current impl of every? doesn't
16:15ohpauleezyeah, that's not true, you'd see a speedup, just not the full potential
16:15ohpauleezright
16:16amalloybut that's really not a gain from using reducers imo, just a better impl of every
16:16ohpauleezyou guys already typed the reason
16:16dnolen_amalloy: what I meant is that range isn't random access so you can't implement fold the way vectors do.
16:16amalloydnolen_: untrue. my patch does that
16:16amalloyrange is random access if you do a little math
16:16hyPiRionamalloy: Nope, it's not a gain from reducers, it's a gain by using reduce + reduced.
16:17amalloyfair enough, hyPiRion
16:17dnolen_amalloy: ah right, so you don't actually look at the range, rather it's size and work over the sub ranges?
16:17amalloyyes. size, start, step, and end. split up into halves accordingly
16:18dnolen_hyPiRion: yes reducers benefit from lack of allocation overhead. but it just bends on what you doing whether reducers will actually benefit any given program.
16:18hyPiRionSo yeah, it shouldn't increase the speed with more cores, but it should increase it due to more cache hit.
16:18dnolen_s/bends/depends
16:18dnolen_hyPiRion: it will increase with more cores w/ the right data structure
16:18amalloyhyPiRion: cache hits? i suppose that's some of it; i would have guessed it's fewer allocations
16:18dnolen_hyPiRion: it's a good thing you're in Clojure to talk about performance
16:19hyPiRiondnolen_: oh?
16:21DaishimanHi everyone . I seem to be getting an error when trying these use and require directives on an ns. I'm very new at this, although I understand it's not that simple a topic http://pastebin.com/WqtTu2X7
16:21DaishimanAnd I get the error 'Exception in thread "main" java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol, compiling:(core.clj:1)'
16:23TimMcDaishiman: :only (settings)
16:23hyPiRionI should just take a look under the covers on how it's implemented I guess.
16:23TimMcDaishiman: Your error message is saying "I expected a sequence but found a symbol."
16:23amalloyTimMc: down with parens, long live brackets!
16:24TimMcSure, or :only [settings]
16:27DaishimanAlright, I got it
16:27Daishimanthanks TimMc!
16:37emezeskeamalloy: Long live curly brackets! ##(use '[clojure.string :only #{split}])
16:37lazybot⇒ nil
16:38amalloyhaha, nice
16:38emezeskeI actually, in a perverse way, kind of like that
16:38emezeskeIn principle it really is a set
16:38amalloyemezeske: i sympathize, but i still have no choice but to take away your clojure license for this abomination
16:39emezeskeamalloy: I'm no stranger to operating without a license.
16:39ohpauleezhaha
16:40emezeske~guards
16:40clojurebotSEIZE HIM!
16:42bfreisWhat would be a good way (performance-wise) to look for a "pattern" in a reducible collection, if that pattern consists of, say, 3 elements from the collection? For instance, suppose I want to find all the local maximums of a sequence of numbers.
16:42TimMcemezeske: Consider me a convert.
16:43amalloy&(partition 3 1 (range 8))
16:43lazybot⇒ ((0 1 2) (1 2 3) (2 3 4) (3 4 5) (4 5 6) (5 6 7))
16:43TimMcbfreis: What are the local maximums of (range 10)?
16:43bfreisamalloy: that's exactly why I was looking for an implementation of "partition" on reducers :p
16:44bfreisTimMc: it is just the last element
16:46TimMcbfreis: The b for any (a b c) where (and (< a b) (< c b))?
16:47bfreisTimMc: yes, that's what I call an example of a "pattern" I'm looking for in a sequence. But I would like to do so using reducers, not just sequences (which is trivial: (filter matches-my-pattern (partition my-pattern-size 1 my-sequence)))
16:48TimMcI see -- because the input sequence collapses to a smaller output sequence.
16:49amalloylike i said, there's no real way to benefit from reducers in this problem
16:50amalloyyou can't fold in parallel, because some input items are used in more than one output item and you can't combine intermediate results in any way i can see
16:51amalloyand you can't avoid consing up a bunch of lists for your triples, so the non-parallel part of the reducers lib can't cut down on consing for you
16:51technomancyclojurebot: litany against cons
16:51clojurebotlitany against cons is "I must not cons. Cons is the perf-killer. Cons is the little death that brings total obliteration. I will face my cons and permit it to pass over me and through me, and when it has gone past I will turn my GC to see its path. And where it has gone there will be nothing; only I will remain."
16:52TimMcamalloy: And if the pattern recognition is slow compared to allocation and GC, then...?
16:52amalloyTimMc: then who cares if you use reducers or sequences?
16:53TimMcI suppose if the triples can only be generated linearly, that's a problem.
16:54bfreisamalloy: I was thinking about a way to avoid consing lists. What if I write some kind of mutable datatype, with an array of the appropriate type, representing a circular buffer with the size of the partition I want? Then there would be no consing. Do you think it is any good?
16:55amalloyyou could probably do that. doesn't seem worth the bother for me, since consing is unlikely to be your primary bottleneck, but i'm not writing your app
16:55huangjshey, just wondering if there's extra clojure/conj ticket available
17:27Mr_BondClojure is fun :)
17:29DaishimanHey guys, another question: I have a function that starts a number of threads that just print stuff with (dotimes ...... (.start (Thread. (fn [] (print "stuff"))))), and while the function body appears to run without issues, the prints within the thread bodies seem to have no effect.
17:29S11001001Daishiman: future is a cooler way to write .start Thread. fn []
17:30gfredericksDaishiman: I think print doesn't flush the buffer?
17:30S11001001Daishiman: and you probably don't have the dynamic binding to *out* in your thread
17:30S11001001Daishiman: which, incidentally, will magically be fixed when you rewrite to use future instead
17:30gfredericksS11001001: isn't stdout the root binding anyhow?
17:30S11001001gfredericks: I don't know Daishiman's setup
17:31Daishiman@S11001001: any docs that might reference how to use futures
17:31Daishiman?
17:31S11001001,(doc future)
17:31gfredericks(future (print "stuff"))
17:31clojurebot"([& body]); Takes a body of expressions and yields a future object that will invoke the body in another thread, and will cache the result and return it on all subsequent calls to deref/@. If the computation has not yet finished, calls to deref/@ will block, unless the variant of deref with timeout is used. See also - realized?."
17:34Mr_BondI'm trying to call java.nio.file.Files.walkFileTree(), my namespace has java.nio.file.Files. How would I do it? I tried "(.walkFileTree Files)", but it seems to try .walkFileTree on java.lang.Class
17:34_ulises,(future 1)
17:34clojurebot#<SecurityException java.lang.SecurityException: no threads please>
17:34_ulisespah
17:35Daishiman@S11001001: Seems to be doing the trick
17:35gfredericks,&(future 1)
17:35clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: & in this context, compiling:(NO_SOURCE_PATH:0)>
17:35gfredericks&(future 1)
17:35lazybotjava.lang.SecurityException: You tripped the alarm! future-call is bad!
17:35brehautthere is no future for you here, gfredericks
17:36S11001001,@(future 42)
17:36clojurebot#<SecurityException java.lang.SecurityException: no threads please>
17:36S11001001heh
17:36gfredericks,(let [future identity] (future 42))
17:36clojurebot42
17:36emezeskeMr_Bond: Have you tried something like (Files/walkFileTree) ?
17:36S11001001Daishiman: good. Also you just got thread pooling for free
17:36Mr_Bondemezeske: ahh! Thanks!
17:36DaishimanCan the execution of a future be controlled with regular threading methods such as sleep()?
17:37S11001001Daishiman: yeah
17:37DaishimanS11001001: excellent
17:38S11001001,(send-off (agent 21) (partial + 21))
17:38clojurebot#<Agent@59abb215: 21>
17:38S11001001no threads, eh?
17:38aperiodicMr_Bond: /g d
17:38aperiodicoops
17:39Mr_Bondcool, it works :) I wasn't sure (proxy) would do the trick or not, but it does :)
17:40Mr_Bondspent almost whole trying to make the walkfiletree work
17:40duck1123Daishiman: this might help, http://www.clojureatlas.com/org.clojure:clojure:1.4.0?guest=t#ref/futures
17:40Mr_BondI learned you can reload a class in lein. That's useful
17:40Mr_Bondlein repl
17:52Mr_Bondwhen you are writing functions inside a (proxy), is it possible to set variables outside the proxy? I mean something like (let [size 0] (proxy (doSomethingWithSize [] ...)))
17:52amalloyit's never possible to set variables in any circumstances
17:52Mr_Bondor (def size 0); first
17:53Mr_BondOr perhaps it's better to use gen-class for it?
17:55hiredmandef is always global
17:55raekMr_Bond: you can do something like (let [state (atom ...)] (proxy ... methods that read or update state...))
17:56Mr_Bondraek: cool, thanks!
18:03edlichCan someone tell me what's wrong here:
18:03edlich(def myat (atom :empty))
18:03edlich(swap! myat nthrest '(:a :b :c :d :e) 3)
18:04edlichwrong args passed to nthrest
18:04gfredericks,(doc nthrest)
18:04clojurebot"([coll n]); Returns the nth rest of coll, coll when n is 0."
18:04gfrederickstakes two args but you're giving it three
18:04edlichBut this works: (reset! myat (nthrest '(:a :b :c :d :e) 3))
18:04DaishimanSpeaking of futures, I keep getting a " Can't take value of a macro: #'clojure.core/let" for a let block within a future. I'm not really sure what this error means.
18:04gfredericksedlich: you're effectively calling (nthrest :empty '(:a :b :c :d :e) 3)
18:05edlichI do not see three
18:05gfredericksedlich: swap! is for including the current value as part of the update; reset! is for ignoring the current value
18:05gfredericksedlich: so with swap! the current value is transparently passed to the update function as the firs arg
18:05edlichnthrest has two args (puzzeld)
18:05gfredericksedlich: yes but you're giving it effectively three
18:05gfredericksthere is the current value of the atom (:empty) and the two extra args you passed to swap!
18:06gfredericks'(:a :b :c :d :e) and 3
18:06edlichso what would be a correct swap?
18:06gfredericksedlich: what are you trying to do? just set the value to the nthrest of the two args and ignore the current value?
18:07gfredericksedlich: i.e., why can't you just use reset! ?
18:07edlichI have a list, want to drop 3 elements and swap it into the atom
18:07gfredericksedlich: if you don't care what the current value of the atom is, use reset!
18:07edlichreset is fine but I have a book saying that reset is not good. Because normally the value comes from a function!
18:07edlichah ok!
18:08edlichGot it! Thanks a lot!!
18:08gfredericksno problem
18:08gfredericksclojure bang functions are great for making people wonder if you're yelling at them
18:08amalloyedlich: the recommendation is to avoid updating an atom without regard for its previous value, not to avoid using reset! if that's what you really want to do
18:09ivanstill waiting for some !? functions
18:09thmzltwhat's the semantic of "!" in a function name?
18:09brehautnot safe in a transaction
18:09technomancyivan: for destructive predicates? why not
18:09ivanthmzlt: mutation
18:09nDuffthmzlt: Side-effecting.
18:09thmzltthanks
18:09technomancywhy not ‽
18:09Mr_Bondare atoms slow?
18:09gfredericksthmzlt: screwing things up
18:09brehauti am infavor of ‽
18:09nDuffMr_Bond: No.
18:09thmzltin ruby it is "something dangerous", but everything is dangerous in ruby
18:10ivantechnomancy: perhaps in a quantum system?
18:10technomancyivan: I had the heisenberg uncertainty principle in mind
18:10gfredericksit is a destructive update and a predicate in superposition
18:10Mr_BondHm, I thought this java.nio.walkFileTree would be way faster than (file-seq)
18:10TimMcMaybe it'sa destructive operations that tells you if it succeeded.
18:11gfrederickswhen you examine the value you will find that either something has been destructively updated or else you have a boolean value
18:11TimMcivan: Actually, yeah -- you modify information by reading it in quantum computing. Good call.
18:12gfredericksyou also modify it by modifying it
18:12TimMcSure.
18:15Mr_BondAh, lol. It is, it's about 8x faster :)
18:15Mr_Bondthanks for all the help guys, appreciate it!
18:25thmzltis clojurescriptone.com the thing to use to get started with clojurescript? (I already know a little clojure)
18:26nDuffI'm wondering if I ought to make http://stackoverflow.com/questions/12940052/extending-a-library-provided-protocol-without-impacting-other-users/12943585 a mailing list post. Feels like something there should be a clean way to do, but if there is one, I'm not aware of it.
18:34dnolen_nDuff: not a good iea
18:34dnolen_idea
18:34nDuffdnolen_: I agree.
18:34nDuffdnolen_: ...using the reader would be much, much saner.
18:34nDuffdnolen_: (if you're talking about the specific use case)
18:35nDuffdnolen_: ...and monkey-patching is pretty darned squicky (if you're talking about the general case)
18:36nDuff...but it is what it is; I have a bunch of data already serialized to an external datastore using msgpack, with strings constrained such that the only ones that start with ":" should be keywords, and code which uses keyword-based access.
18:36dnolen_nDuff: make your own protocol, default it to delegate to the original protocol - but handle this type specially.
18:36nDuffdnolen_: The objects that need to be handled are generated by the msgpack library; I can't change their type.
18:37nDuff...oh
18:37nDuffAhh.
18:37nDuff...okay, I could do that, but I'd need to replace rather a lot of clj-msgpack
18:37nDuffas the protocol in question isn't called by my code, but by it.
18:37nDuff(granted, there isn't _that_ much of clj-msgpack to replace)
18:38dnolen_nDuff: yes, was just about PITAness depends on API surface
18:38dnolen_was just about to say I mean
18:45callenactually, if you want an example of how a bad API can thoroughly ruin something, just write some Scala code.
18:46callenyou need a table of elements just for the operators specific to the HTTP library, at least in Perl the digraphs were composable and reusable in multiple contexts. In scala you have to memorize of the context of a specific arcane symbol per API.
18:46calleninfinite combinations. SO MUCH FUN </sarcasm>
18:52emezeskecallen: Are you talking about Dispatch for scala? Looking at the docs... so much pain.
19:01technomancyoh dear: http://www.amazon.com/Dispatch-ebook/dp/B007RE79X8/ref=sr_1_1?ie=UTF8&amp;qid=1333606637&amp;sr=8-1
19:01technomancythere is a book. on an http client.
19:01technomancyoh, only 23 pages. that's some consolation.
19:03brehaut"Dispatch is probably the most popular library for doing HTTP requests from Scala"
19:03brehautwhere to begin
19:04callenbrehaut: technomancy Dispatch is 40% of why I abandoned Scala.
19:04callenthe other 60% has a lot to do with oxymoron named sbt.
19:05callentechnomancy: leiningen is the beautiful antebellum Clojure noobies step through on their way to enlightenment. sbt is the brutal gauntlet of sorrow Scala newbies sprint through as they get their limbs hacked off.
19:06technomancyI've heard a few horror stories
19:07hyPiRionbrehaut: "Think of it as a Scala version of curl or wget."
19:07callentechnomancy: the best part, is the horror just gets worse as time goes on and you have to tackle edge-cases. sbt is like the worst of cmake and cabal combined.
19:09SgeoWhat's the issue with Dispatch?
19:10callenSgeo: satanspawn.
19:10SgeoI haven't looked closely at it, but it mentions Either and promises, both simple concepts
19:10callenSgeo: you've just walked into our daily 5 minutes of hate. I like to remind people how good they have it.
19:11technomancyusually a mention of maven is enough to get a few good shivers
19:11Sgeoval svc = url("http://api.hostip.info/country.php&quot;)
19:11Sgeoval country = Http(svc OK as.String)
19:11Sgeoval length = for (c <- country) yield c.length
19:11callenSgeo: doesn't work as well in practice as you'd think. Try it with something non-trivial.
19:11SgeoThis looks simple enough, if for is essentially Scala's equivalent of do notation
19:11brehautSgeo: it is
19:11callentechnomancy: yeah so actually I was wondering, why do so many clojurians seem to be using maven? Are they hiding out in a java project?
19:11SgeoAlthough I don't know what this 0K as.String thing is
19:11technomancycallen: I'm the wrong person to ask =)
19:12callentechnomancy: I just figured you'd understand the habits of your non-users. :P
19:12TimMcSgeo: OK, not 0K, I think
19:12callenguess that was silly.
19:12SgeoWell, there doesn't seem to be another way to use a standalone jar, other than making a maven repo
19:12technomancycallen: contrib projects use it because c. lein 1.4 there was no way to deploy to remote maven repositories
19:13SgeoIt's sort of hindering me a lot
19:13technomancycallen: I don't see a lot of usage of maven outside contrib projects
19:13callentechnomancy: just wondering, because it's usually the first example after the lein package + version notation.
19:13technomancycertainly not in OSS, maybe it's more common for internal projects
19:14SgeoWhat should I call a language that's heavily based on Clojure but takes a crucial concept from Tcl?
19:14callenthat's what I figured anyway.
19:14thorbjornDXSgeo: Tclojure
19:14SgeoTclj seems nice and pun-y, but implies that it's centered around Tcl but it isn't
19:14callenSgeo: TickleMeElmo
19:14SgeothorbjornDX, ooh
19:14hyPiRionWow, both T and Clojure, two great lisp implementations in one.
19:15Raynesaperiodic: http://www.marthastewart.com/sites/files/marthastewart.com/images/content/web/contests/halloween/best_of_halloween09_empire_state_bldg_xl.jpg
19:15callenTcl...is not lisp.
19:15hyPiRioncallen: I was talking about T.
19:15Sgeocallen, but there are some really cool things about Tcl that I wish more Lisps did
19:15TimMcI'm keeping my damn mouth shut.
19:16callenSgeo: prolific mutable string eval? What?
19:16TimMcI have a record of coming up with horrible names that people end up using.
19:16Sgeocallen, the eval part
19:16SgeoAnd strings aren't mutable
19:16callenSgeo: you realize lisps used to do prolific eval and they backed off of it for a reason, right?
19:16callencf. dynamic scope
19:17Sgeocallen, if it can be given a lexical scope...
19:17SgeoAlthough currently the easiest way I see to do that involves uplevel, and I think people are scared of it
19:17SgeoKernel does something or other, I should read that paper again
19:17emezeskeSgeo: uplevel is cool, but it takes some getting used to for sure
19:18TimMcSgeo: Wait, this will be a language? Language naming is way harder than lib naming.
19:18callenSgeo: I wasn't linking them, I was mentioning it as another example of something that turned out to be a bad idea.
19:18emezeskeSgeo: Also, uplevel can be used for such great evil in the wrong hands
19:19Sgeoemezeske, so can macros
19:20SgeoTimMc, I'm not particularly expecting it to become the next big language
19:20_tcaSgeo: have you looked at wat
19:20technomancylava's a good name; it's not taken
19:20Sgeo_tca, haven't heard of it
19:20_tcahttp://manuel.github.com/wat-js/doc/manual.html
19:21TimMcSgeo: Do you expect it to solve one problem and then go away? In that case, "cloture".
19:22TimMc(Silence falls as everyone reads up on parliamentary procedure.)
19:22_tcaeven if you don't plan on using it, read the manual before you start working on your own
19:22Sgeo_tca, sounds interesting, for all I know, this might do exactly what I was thinking, plus more
19:23callenuplevel is fucking diabolical.
19:23_tcalast time you mention this Tcl thing i don't know anything about it sounded like f-expressions to me
19:23Sgeo_tca, ah, no, it still doesn't do what I want
19:23_tcawhich is?
19:24SgeoI want the determination of when to evaluate arguments to occur at the call site, not determined by the operative/applicative
19:24SgeoOr at least, if it's going to be unevaluated, evaluate part of it before the operative sees it
19:25SgeoI could probably use Kernel/wat's model of lexical scoping though, as soon as I understand/remember what it is
19:29SgeoExample:
19:30Sgeo(if (nil? blah) '(println "nil") '(println "not nil"))
19:31SgeoOh hey, wat's example of the Error monad is EXACTLY why I wanted to combine delimc and protocol monads
19:34_tcaSgeo: why cant you do it with a macro
19:34Sgeo_tca, because I want my language to not have the macro/function distinction.
19:34dustingetzsego: what is protocol monad
19:34dustingetzonly google references refer to jim duet's monad protocols, which is an impl detail
19:34Sgeo_tca, (and arguably Kernel/wat do not in fact have a operator/applicative distinction, as all applicatives should theoretically be operators)
19:35Sgeodustingetz, yes, I meant that implementation of monads, because I dislike algo.monads.
19:35_tcaSgeo: there has to be some distinction where the evaluation happens
19:36Sgeo_tca, presumably, if is a function that calls eval
19:38TimMcSgeo: So any function could do syntax transformations on argument expressions if chose to?
19:39SgeoYes. But only if it's actually passed a syntax expression
19:39SgeoIn my example
19:40Sgeo(if (nil? blah) (println "nil") (println "not nil")) will always print "nil" then print "not nil"
19:41TimMcSgeo: And these syntax expressions, would they keep the lexical scope of their origin?
19:42Sgeolexical scoping is definitely something I want to do... somehow... hmm
19:42TimMc(if (nil? blah) #(println "nil") #(println "not nil"))
19:42SgeoWell, not "of their origin", no, use lambdas to make closures for that.
19:43TimMcNever mind, that doesn't support transformation.
19:44TimMcSgeo: (when true '(println x)) -- what is x's scope?
19:44SgeoIf when does an uplevel sort of thing, it's whatever's in scope at the when level
19:45SgeoBut the lexical scoping aspect is still something I need to think through.
19:45TimMcOK. I figured you had a scoping model in mind already.
19:46SgeoHrm.
19:46SgeoI just realized I have no idea how to distinguish:
19:47Sgeo(def code '(println x))
19:47Sgeo(when true x)
19:47SgeoFrom
19:47Sgeo(when true '(println x))
19:47TimMc(when true code), you mean
19:47SgeoOops, you're right
19:48SgeoOr even whether distinguishing at that point would be desirable. Or if not distinguishing immediately kills all claims of lexical scope
19:51SgeoI still don't understand why people hate Kernel's $prefixes so much
19:54SgeoI think it might be sufficient to have some constructs make a clean scope?
19:55SgeoI would imagine defn introducing a clean scope, but that's just def+fn, and fn usually makes closures
19:55SgeoHrm.
19:55SgeoMaking a clean-scope function?
19:55aperiodicRaynes: maybe i can just wear a big box that says "~/.m2"
19:57TimMcaperiodic: EEEEK!
19:57TimMcaperiodic: You might get jars thrown at you.
19:57SgeoWould having defn not be capable of making a closure be problematic for anyone?
19:58SgeoDoes anyone ever do something like... oh, I guess they do
19:58huangjshi, I'd like to ask for opinions on current status of web development in clojure comparing to node.js. what are the pros and cons?
19:58huangjsoops, brb
19:58aperiodicSgeo: you mean fn? absolutely
19:58Sgeo(let [a (atom 0)] (defn f [] (swap! a inc)))
19:58Sgeoaperiodic, no, I mean defn
19:59nDuffhuangjs: I'm not sure they're comparable -- I mean, you can use clojurescript to write code for node.js, if you felt like it, but using Clojure server-side the idiom set is completely different.
19:59aperiodicSgeo: i think that would be fine for me
19:59nDuff*Clojure-on-JVM server-side
19:59aperiodicTimMc: why would you have jars just lying around??
19:59lazybotaperiodic: Uh, no. Why would you even ask?
19:59Sgeoaperiodic, any good names for a function that clears what I don't think can even rightly be called lexical anymore scope?
20:00huangjsnDuff: i only want to cmopare the server side
20:00huangjsthe eco system, libraries
20:00nDuffhuangjs: Clojure is built to take extremely good advantage of highly parallel systems (lots and lots of cores).
20:00emezeskehuangjs: The JVM is one of the most sprawling ecosystems out there
20:00huangjsi don't care, i care about the speed of development, and easier of debugging (which node sucks)
20:00SgeoBut note that Java libraries are usually unidiomatic to Clojure
20:01huangjsJVM has loads of bloated libraries,
20:01technomancyyeah but node.js has the advantage of not being legacy bullshit
20:01technomancyeverybody knows there are only like five languages worth using
20:01huangjswhich is CL Scheme Clojure Prolog and Haskell
20:01hiredmantechnomancy: people will think you are serious
20:02technomancyhiredman: oh I don't know about that
20:02nDuff*shrug*. The Clojure debugging story isn't that great either, if you compare to what used to be available on CL
20:02emezeskehuangjs: You just asked about the ecosystem, and then you say you don't care... ?
20:02nDuff...but I'd take it over Node any day.
20:02huangjsnDuff: true
20:02nDuff...some of the profiling and debugging tools built for the JVM are downright excellent, if you're willing to deal with some impedence mismatch.
20:03SgeonDuff, used to be available?
20:03SgeoDid SLIME die?
20:03brehautdeprecated
20:04Sgeoo.O
20:04brehauthttp://technomancy.us/163
20:04huangjsok, question, what's the counterpart of 'express' in clojure? the 'passport' or 'everyauth' for auth, the engine.io for real-time stream?
20:04huangjshow could you make slime die?
20:04Sgeobrehaut, "what used to be available on CL"
20:04huangjssigh...
20:04SgeoCL, not Clojure.
20:04nDuffSgeo: I don't consider CL a living language, and I don't have time for a flamewar about it.
20:04brehautoh, cl
20:05huangjswhat is the defacto awesome environment for CL
20:05huangjsnDuff: CL is pretty alive,
20:05FrozenlockAnd now with Quicklisp even more so.
20:06huangjsand i just finished a prototype using obscure mongrel2 + cl, good, but development speed still can't beat node even i know much better in CL
20:07huangjsbtw, anyone who has spare clojure/conj tickets, please sell it to me :)
20:07doomlorddoes clojure stdlib have something like CL's "with-slots" ... preferably like this (with obj (... all components of 'obj' are bound in a let available here..) )
20:08TimMcdoomlord: Is that like destructuring?
20:08huangjsTimMc: it's like symbol macro
20:08huangjsTimMc: you can modify the slots, not vars bound
20:09doomlordah i keep forgetting its very good at destructuring , but not quite: i'm after something where you dont need to specify which components to map; it just brings all into the scope.
20:09SgeoTimMc, with-slot lets you take a CLOS object and, instead of needing to use (slot-value my-obj 'slot) to get the value and (setf (slot-value my-obj 'slot) ...) to set it, within the body of with-slots you can use slot and (setf slot ...)
20:09doomlordalmost like assigning the "this" pointer in C++
20:09doomlord(not that C++ can do it heh)
20:09Sgeohuangjs, there is a library, not in stdlib, for symbol-macrolet
20:09SgeoIf that's any help
20:10SgeoBut usually you don't mutate objects, so the idiom might not be as useful
20:10doomlordi still think it would be useful for reading things to pass on in immutable-land
20:11huangjsSgeo: yeah, that makes sense in clojure
20:11SgeoCould write a macro to do it fairly easily
20:11SgeoAt least the reading and binding part
20:11SgeoActually, there is something
20:11doomlordyes i figured one could.
20:12Sgeo,(let [{:keys [a b c]} {:a 1 :b 2 :c 3}] (str "My a is " a " and my b is " b " and my c is " c))
20:12huangjshey, please share your opinions, i know there are many good people here, what's your opinions comparing clojure and node.js for web dev?
20:12clojurebot"My a is 1 and my b is 2 and my c is 3"
20:13TimMchuangjs: You just asked that.
20:13huangjsTimMc: i know
20:13Sgeodoomlord, oh, all components automatically?
20:13SgeoThat... sounds like a security hole waiting to happen.
20:13doomlordthat looks very close to what i have in mind, but yes a version that just grabs everything automatically
20:13SgeoPretty sure with-slots doesn't actually do that either
20:13TimMcBleh, spooky magically appearing bindings.
20:14nDuffhuangjs: I'm not sure this is the right place to ask if you don't want people whose opinions are colored by language aesthetics.
20:14doomlordits just like a "this" pointer for OOP
20:14Sgeodoomlord, the OOP languages you have in mind, are they all statically typed?
20:14nDuffhuangjs: ...I mean, there are a _lot_ of places where JavaScript has admitted major design flaws, and it's pretty hard for someone who's picky to get past those and focus only on development velocity.
20:14doomlordyou've got the object ... you can access the components with (obj :member) anyway.. its just makig it less verbose
20:15huangjsnDuff: i love and hate javascript, flexible, powerful, but retarded
20:15SgeoYeah, Common Lisp's with-slots also asks for the names
20:15doomlordto me this is better than OOP because there's nothing special about one of the 'objects' passed to a function
20:15emezeskedoomlord: Seems like a bad idea -- what if someone later on adds a field to the object that you used as a name inside the (with obj ...)
20:15doomlordthats somethign i've never liked in c++ etc
20:15Sgeodoomlord, you're asking for a feature from Common Lisp that Common Lisp doesn't actually have.
20:16TimMcActually, it can't be done.
20:16shaungilchristhuangjs agreed it is like a turrets savant, totally capable but entirely vulgar
20:16doomlordnot really a feature from CL.. just inspired
20:17doomlord"what if someone later adds a field.." - welll i'm used to that sort of hazard in C++ , collisions between arguments, locals, and members
20:17emezeskedoomlord: By adding a property to an object, couldn't someone possibly break your (with obj ...) overloading some name that is used there for a different purpose? Seems very fragile
20:17TimMcdoomlord: If knowledge of the possible set of fields isn't available at macro-expand time, you can't set up the bindings.
20:17emezeskedoomlord: Yeah, but in C++ it's not much of a hazard because the compiler will happily warn you
20:17SgeoTimMc, hey, that's one of the things that my language will allow.
20:17TimMchaha
20:17SgeoSuddenly, my language idea seems less attractive.
20:17TimMc:-P
20:18TimMc"toljure"
20:18TimMcas in
20:18doomlordok the fact its dynamic precludes it
20:18TimMctoljureso
20:18TimMc(Except I didn't really tell-you-so in the first place.)
20:18doomlordso if i have many functions using a set of common bindings ... it might be better to just make a macro that grabs a specific set of bindings
20:19SgeoThen again, just because someone can do something stupid, doesn't mean they should be stopped from doing it
20:19doomlord(with-xyz srcVector ... )
20:19Sgeodoomlord, if that's your planned use case, go for it, I think
20:19_tcaSgeo: you should implement the individual things you want in clojure first
20:19SgeoThat sort of fill-in-the-blank thing is the easiest sort of macro to write
20:20SgeoHeck, go insane and write a macro to write macros to do that
20:20huangjsshaungilchrist: well said!
20:20TimMcshaungilchrist: Oh, "Tourette's".
20:20TimMcI was trying to figure out wtf you were talking about.
20:21doomlordi think i'd do it with a prefix... (defn cross(vec-a vec-b) (with-xyz a vec-a (with xyz b vec-b ( [ -(* ay bz )(* az by)....
20:21brehauteveryone has probably seen this already but http://www.ioccc.org/2012/tromp/hint.html that blew my mind
20:21shaungilchristhaha.. I meant like tower defense...
20:22emezeskedoomlord: If you have a prefix, isn't the advantage over (:property object) rather negligable?
20:23doomlordi guess so; however you could use more verbose argument names and less verbose prefixes in the body of the function
20:23doomlordi concede its not clear cut though
20:24doomlordheh the cross product example is a bad one because clojure's destructuring arguments can do it better
20:24doomlord(defn vec-cross[[ax ay az][bx by bz]] (...)?
20:26emezeskeSeems pretty reasonable.
20:27doomlordoh isn't it possible to call things with maps as an argument anyway
20:28doomlordoh no that doesn't do it
20:33amalloyokay, pretty cool, brehaut
20:33Sgeo,'(blah blah '(bla `(woot ~wut ~~huh)))
20:33clojurebot(blah blah (quote (bla (clojure.core/seq (clojure.core/concat (clojure.core/list (quote sandbox/woot)) (clojure.core/list wut) (clojure.core/list (clojure.core/unquote huh)))))))
20:34Sgeo,`(a b c `(d e f ~honk ~~honk))
20:34clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: honk in this context, compiling:(NO_SOURCE_PATH:0)>
20:34Sgeo,`(a b c `(d e f `(g h ~honk ~~honk)))
20:35clojurebot(sandbox/a sandbox/b sandbox/c (clojure.core/seq (clojure.core/concat (clojure.core/list (quote sandbox/d)) (clojure.core/list (quote sandbox/e)) (clojure.core/list (quote sandbox/f)) (clojure.core/list (clojure.core/seq (clojure.core/concat (clojure.core/list (quote clojure.core/seq)) (clojure.core/list (clojure.core/seq (clojure.core/concat (clojure.core/list #) (clojure.core/list #) (clojure.co...
20:35emezeskeSgeo: Don't you have your own repl? :P
20:35Sgeohonk
20:37brehautamalloy: the downside is it makes me acutely aware of how little i know about computation
20:41notsonerdysunnyI have imported a simple java class into clojure repl usint (import 'callback.runme)
20:41notsonerdysunnyI have imported a simple java class into clojure repl usint (import callback.runme)
20:41brehaut(repeatedly notsonerdysunny)
20:42notsonerdysunnyit has a main method and I am unable to call its main
20:42SgeoIs deflfn an ugly name for my language's equivalent of defn?
20:42notsonerdysunnyI tried (.main (callback.runme.)) and (callback.runme/main)
20:42notsonerdysunnyand main is a static member function ..
20:43notsonerdysunnyboth the attempts to call the main member function were unsuccessfull .. it say it is unable to find a variable named main .. can somebody help?
20:43brehautnotsonerdysunny: what is the artiy of main?
20:44notsonerdysunnyone argument .. with array of strings
20:44Sgeo,(.charAt "honk" "HONK" ":o)")
20:44clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: charAt for class java.lang.String>
20:44Sgeo,(Math/sin 1 2 3 4 5)
20:44clojurebot#<CompilerException java.lang.IllegalArgumentException: No matching method: sin, compiling:(NO_SOURCE_PATH:0)>
20:45SgeoHmm. Different error
20:45Sgeonotsonerdysunny, sure the portion before / is correct?
20:45brehautnotsonerdysunny: then you'll need to pass that in then
20:46brehaut,(apropos 'array)
20:46clojurebot(object-array boolean-array long-array short-array char-array ...)
20:47brehautat a guess (callback.runme/main (make-array String 0)) ?
20:48notsonerdysunnythanks brehaut that fixed it ..
20:49brehautnotsonerdysunny: arity is important to functions on the JVM. javas overloaded methods are effectively name munged to have the airty and type as part of the 'name'. so if you dont include the appropriate arguments, the reflector will say that it cant find the arguments
20:49notsonerdysunnybrehaut: what surprises me is it does not complain about arity mismatch .. but says the method is not found.. K now I know .. thanks again
20:49brehaut(approximately)
20:50brehautthats an implementation detail of java bleeding out
20:51SgeoNow, if only we can bleed out the rest of Java too.
20:52doomlordclojure on llvm :)
20:53doomlordwould be nice to have a native lisp with all the neat features of clojure (like destructuring function args etc)
20:54brehautliskell
21:01rlbTimMc: yes -- the incanter window does show up via ssh -X or -Y, but it's blank.
21:37FrozenlockEh.. I have a little problem with Noir. I know for a fact that :dev is being passed as the mode. However, when I use noir.options/dev-mode? in the repl, I get false. Any ideas what I might be missing?
21:40FrozenlockPerhaps it needs to be started from lein?
21:41doomlordwhats the difference between :x and 'x
21:42doomlordboth appear to work in maps
21:43FrozenlockWouldn't "x" work too?
21:44doomlorddoesn't seem to
21:44Frozenlock&(get {"x" 1} "x")
21:44lazybot⇒ 1
21:44doomlordx tries to evaluate itself wheras both :x and 'x appear to be a literal
21:44doomlordah "x" not x sorry
21:45doomlordwell i think :x is nicer than 'x ... but is there some underlying difference.
21:46xeqi&(identical? :x :x)
21:46lazybot⇒ true
21:46xeqi&(identical? 'x 'x)
21:46lazybot⇒ false
21:46FrozenlockYes, iirc a keyword evaluate to itself.
21:57hiredman /win 15
22:04TimMc&(= ':x :x)
22:04lazybot⇒ true
22:07TimMcdoomlord: Keywords refer to themselves. They're used for ad-hoc structuring of data e.g. {:foo 1 :bar "hello"} and as interned values for comparison e.g. (= :error (:result foo)).
22:09TimMcdoomlord: Symbols are intended to be dereferenced at some point. The code (count foo) has two symbols, both of which are replaced with other values at eval time. (Exception: Compiler literals such as 'if, 'do, etc.)
22:11doomlordok thanks
22:12doomlordsymbol almost like a pointer or reference. keyword more like an enum perhaps
22:30TimMcBasically.
22:33mindbender1Thinking in Clojure?
22:54xeqianyone have an example of using https://github.com/edgecase/dieter ?
23:12sent-hilI included [ clojure.contrib.math :only ( abs)] in my file, how do I install the library?
23:13sent-hilI'm getting this error: https://gist.github.com/5b7569e8b11c8a9a86dc
23:21antares_sent-hil: clojure.contrib.math has been obsolete for over 1 year. Use math.numeric-tower (https://github.com/clojure/math.numeric-tower), the README mentions its Leiningen dependency
23:21antares_sent-hil: for abs, you can use Math/abs from the JDK without any libraries
23:21antares_,(Math/abs -1.2)
23:22clojurebot1.2
23:22sent-hilantares_: that works, thx!
23:23SgeoI'm sad that it's easy to implement automatic differentiation on arbitrary mathing functions in Haskell but not so in Clojure
23:24SgeoBecause if a function works on Nums, it's using one of a number of primitive Num using functions, and I can define a new type of Num that behaves how I want and functions that deal with Nums will use my functions
23:24ForSparePartsAny of you guys know of a Clojure-native physics library? Something that leverages the immutable-data stuff?
23:24SgeoBut with Clojure, everything uses Math/whatever, and I can't replace that
23:27xeqiI have similar feelings for the networking. I liked ruby's artifice for mocking external apis