#clojure logs

2012-11-15

00:00yedihow do you print the current directory? (i swear i googled)
00:00yeditryna debug FileNotFound error
00:02mpanyedi: the jvm knows and you could query it through interop
00:02mpannot sure if there's a more idiomatic way, though
00:03mpan#(System/getProperty "user.dir")
00:03mpan,(System/getProperty "user.dir")
00:03clojurebot#<SecurityException java.lang.SecurityException: denied>
00:03mpanwell ok the bot doesn't want me doing it here, but you could do it locally
00:04mpanin general, a lot of "low-level" stuff can be done directly through interop, and if you use it often, maybe you might want to make yourself a wrapper
00:06mpanI suppose there are probably other properties of the system they wouldn't want folks querying the bot for
00:08yedisweet, thanks mpan
00:32yediwhen using nrepl on emacs, how can you get the output from eval to print to the repl instead of the 1 line echo area?
00:35ivanyedi: when you nrepl-eval-expression-at-point? good question
00:39ivanyedi: you can get it to output to your source file by hitting C-u first and then undo :/
00:39ivanmight have to write some elisp to do what you want
00:50Lajjlaivan, I am the second best programmer in the world, bested only by the microsoft chief software architect.
00:50LajjlaAnd I do worship His Shadow.
01:38mpanis it considered good/bad practice to use _ with let to interleave something side-effectful in a series of bindings?
01:39mpangiven a case where something does require the side-effectful call to be done, and the question is just how
01:40mpanvs nesting lets and dos
01:43echo-areampan: AFACT it is recommended as idiomatic in some Clojure text books
01:43echo-areampan: ... to use _ with let
01:43echo-areaAFICT
01:43echo-areaOh sigh, As far as I can tell
01:47mpanecho-area: Thanks!
02:36mpancan someone help me with a runtime cast error please? note that the cast it's trying to do should be valid according to instance? yet it fails. https://www.refheap.com/paste/6723
02:42mattmossmpan: The "to" class is an array, not a single object.
02:42mattmossmpan: See the [ in front of the long name for TerminationCondition? Array.
02:42mpanmattmoss: oh! thank you!
02:43mattmossnp
02:43mpanactually, bit of further confusion
02:43mpanthe javadoc has the signature defined as a single object w/ an ellipsis
02:44mpandid java add varargs generally? not just for printf now?
02:44mattmossYeah, the ellipses is varargs, which is basically an array, I believe.
02:44mattmossI'm not up on my Java standards. :)
02:44mpanme neither
02:45mpanI write to java 5 because that's what college taught me
03:12BuckToothCan you recommend any free books on Clojure for beginners?
03:15BuckToothCan anyone recommend any good clojure books for beginners? (I am looking for a free one...)
03:17TichodromaBuckTooth, Programming Clojure
03:17Tichodromahttp://www.clojurebook.com/
03:18BuckToothTichodroma: My finacial condition dosen't allow me to buy books :(
03:19TichodromaPerhaps http://clojure-doc.org/articles/content.html#tutorials has something
03:21BuckToothThere is no Clojure book in the library too....
03:21SegFaultAXBuckTooth: That's a pretty shitty financial condition if you can't even buy a book.
03:22BuckToothSefFaultAX: What can I do.... I have to eat or I have to read.. I have to decide :(
03:24BuckToothIll try to buy that anyway....
03:31Bergle_1I enjoying the book Programming Clojure by Stuart Halloway and Aaron Bedra - im a nooby :)
04:19wingy_Bergle_1: good books are valuable
04:36alex_baranoskywhat's a good way to find the memory size of some Clojure maps?
04:36clgvalex_baranosky: on the repl?
04:36alex_baranoskythat'd be best, but whatever works
04:37alex_baranoskyI'm trying to figure ou how much memory my 450,000 maps are taking up
04:37clgvalex_baranosky: I think your best chance is using a profiler.
04:38clgvI'd suggest jvisualvm (free) or yourkit (commercial with trial period)
04:38alex_baranoskymaybe this: http://stackoverflow.com/questions/52353/in-java-what-is-the-best-way-to-determine-the-size-of-an-object
04:39clgvalex_baranosky: you can try that. though they say the size estimate may change on repeated invocations. but maybe it has sufficient quality for your estimation
04:40clgvalex_baranosky: you could also use java serialization - but that one will replace repeated occurences of the same object with a reference
04:40RaynesYou can get a license for yourkit if your project is open source.
04:41clgvRaynes: yes thats true. although I dont know how much momentum your project needs to get that license
04:41RaynesI expect that having enough momentum to need yourkit is probably enough.
04:41clgvRaynes: I just bought an academic license which wasnt that expensive
04:43alex_baranoskyno dice, this is for work
04:43RaynesThis hotel room thermostat is either lying or I am currently incapable of producing body heat.
04:43hyPiRionI hope it is the former, for your sake.
04:44RaynesWould it be weird if I wrote some Haskell while here at the conj?
04:44RaynesFeels weird.
04:44clgvRaynes: the right tool for the job ;)
04:45RaynesWell, it is replacing a Ruby thing I wrote ages ago.
04:45RaynesSo it has to be for a good cause.
04:45RaynesIt isn't in Clojure because of startup time.
04:45alex_baranoskyman, this Instrumentation interface is awkward
04:46hyPiRionRaynes: I don't think it should be an issue, unless you're oozing betrayal afterwards.
04:46Raynes:p
04:47hyPiRionI don't think the Clojure community has done any "witch hunt" yet though. Maybe mr. Yegge qualifies for that position.
04:47hyPiRion(The witch position)
04:47alex_baranoskyRaynes: yeah I heard they can smell the betrayal on you
04:48RaynesThat's a group of people armed with parentheses have been standing outside my door for hours now!
04:48alex_baranoskythe thing is, I think Haskell is sufficiently nerdy to prevent any lynching
04:48RaynesThat's why*
04:48clgvalex_baranosky: yeah that instrumentation is used weiredly.
05:25maleghastMorning All :-)
05:26zephyrWill the JVM remain the primary clojure platform in the future even after Clojure-in-Clojure is implemented?
05:27maleghastzephyr: Someone is trying to make Clojure-in-Clojure, without the JVM?
05:27RaynesClojure in Clojure will still be on the JVM.
05:28maleghastRaynes: Yeah, I figured...
05:28maleghastI just wanted to meet the magician that was able to take it out of the equation...
05:28zephyrSo Clojure is basically a JVM language and will remain so. Good.
05:30zephyrA local guild in Delhi is switching to clojure on a 10 year long mutual contract with the owner of the guild...
05:31RaynesI heard the Orcs are using it too.
05:32zephyrOrcs?
05:32maleghastzephyr: I think that Raynes is having fun with your use of the word "guild"
05:32zephyrOh Eru did not created the orcs.... They are bad :)
05:33otfromhey! Bad things/people use clojure too.
05:33zephyrGuild is a local bank of the shopkeeprs of a perticular market....
05:33Anderkent|awayno discrimination based on alignment please
05:33zephyrElves use Clojure too...
05:33otfromChaotic Neutral for life
05:34Anderkent|awayCN is just CE, but afraid of DM
05:34maleghastotfrom: O-RLY?
05:34maleghastAnderkent|away: *applause*
05:34otfromAnderkent|away: lol
05:34maleghastClearly, Clojure is the language of Tinker Gnomes (and yes I'm proud of that)?
05:34otfromI think I'm more Whimsical Apathetic
05:35otfromalignments are too much effort
05:35maleghastotfrom: "Whimsical Apathetic" - Ah, Harnmaster alignments, no?
05:37zephyrWhich DE and WM are clojure people mostly using???
05:37lazybotzephyr: Oh, absolutely.
05:37maleghastzephyr: DE? WM?
05:37mpanis there a way to forcefully unload everything in a repl?
05:37maleghastmpan: Yeah Ctrl-D
05:38maleghast(sorry)
05:38mpanmaleghast: I was afraid of that
05:38Raynesmaleghast: Desktop Environment, Window Manager
05:38antares_Raynes: how come you are not sleeping man
05:38maleghastRaynes: Ah...
05:38zephyrmaleghast: Desktop Environment. Window Manager. Add Text Editor too.
05:38Raynesantares_: What do you mean?
05:39antares_Raynes: I thought you were travelling after a sleepless night
05:39RaynesI was.
05:39antares_and you are still up?
05:39maleghastzephyr: To answer your question, I see a lot of people using OS X, Aqua and emacs - I use a bit of emacs a bit of vim and bit of Textmate at the moment...
05:39RaynesI went to sleep at 8PM and woke up at about 3:30AM.
05:39antares_ah, ok
05:39RaynesNaw, I got some sleep.
05:40mpanzephyr: I'm not sure about the relative popularity, but Eclipse+Counterclockwise was recommended to me when I started using Clojure, and there were a bunch of people using that
05:40maleghastzephyr: Some of the other regulars at the London Clojure Dojo are Ubuntu aficionados, so certainly emacs / vim for editing, but I suppose that would make them Unity users for Window Management?
05:40mpanthat's less of a text editor and more of an IDE
05:40zephyrmpan: I could not afford a Mac.. I'm OK with Ubuntu, using Xmonad, Emacs.
05:41mpanEclipse is pretty much as heavy as you can get into IDE territory
05:41mpanI think you meant that for someone else... I don't use a mac either
05:41zephyrHow's LightTable?
05:41mpanthey're nice but I'm happy with my pc and have no desire to change for the time being
05:42maleghastI have to be honest I rather detest IDEs in general, but I would also want to say that if they work for you (like any tool) then fill your boots! There are a bunch of people that are very pro Netbeans with a plugin whose name I can't remember as well
05:42mpanlight table is pretty experimental at the moment... I'd be surprised if anyone was using it in production
05:42maleghastzephyr: LightTable is not ready yet, but very exciting as a posisbilty
05:42RaynesI don't know why not.
05:42mpanit's a very interesting and unique concept but the releases so far are previews
05:42maleghasts/posisbilty/possibility
05:42RaynesThe latest iteration of light table is pretty useful.
05:42RaynesIt has an editor, can open and save files, an excellent evaluation mechanism, a repl.
05:43mpanRaynes: seems it would be such a huge mental adjustment from whatever they were using before, though
05:43maleghastRaynes: Yeah, I guess that's true, but I had it freeze-up a couple of times and it didn't feel, well "ready"
05:43RaynesIsn't that the point?
05:43mpansure
05:46mpenetDE/WM you choose doesn't really matter no matter what language you are using
05:46RaynesYeah, that was a pretty spectacularly weird question.
05:47otfromI use emacs on any *nix like environment
05:47maleghastYeah, you're right it's an odd question. I mean even on Windows there are strong toolsets for Clojure, so basically OS / Desktop environment is almost completely irrelevant.
05:48otfromGNU emacs 24.x and as close to vanilla as possible (no aquamacs etc)
05:48maleghastotfrom: Bringin' Da Oldskool
05:48otfrombut, I've been using emacs for about 15years so I was pre-broken. ;-)
05:48mpenetimo emacs is the way to go, if you like IDE'ish envs then go for CCW
05:48otfromeclipse+ccw is very good now
05:48otfromour intern used it for a bit and got on with it really well
05:48maleghastAll joking aside I am trying to learn emacs - there's a lot to like, particularly Slime-ing, but after a professional lifetime of Vi/Vim it's a tough learning curve...
05:48otfromlight table looks really cool
05:49RaynesDitch SLIME. Use nrepl.el.
05:49otfromthe vim support for clojure is getting better all the time
05:49otfromand Meikel (kotarak) is a *really* nice guy
05:49maleghast…I suppose I could just follow Chris's lead (from the Ldn Clj Dojo can't remember his surname) and use vim / nailgun etc...
05:49otfromif you like vim try this: http://clojure-doc.org/articles/tutorials/vim.html
05:50Raynesmaleghast: I use evil-mode. It is exceptional. I didn't even come to Emacs from Vim. I just used Vim for a while and realized how awesome modal editing in Emacs would be.
05:50mpenetmaleghast: there is evil-mode
05:50otfromChris Ford @ctford ?
05:50mpenetRaynes beat me to it
05:50maleghastThat's the chap...
05:50maleghastWhat is this "evil-mode" that Raynes and mpenet are speaking of..?
05:50Raynes$google evil-mode
05:50lazybot[EmacsWiki: Evil] http://emacswiki.org/emacs/Evil
05:51Raynesmaleghast: It's Vim emulation. It adds modal editing to Vim as you'd expect.
05:51RaynesUh
05:51RaynesTo Emacs.
05:51maleghastOh wow - that would be so awesome
05:51RaynesGo get you some.
05:52maleghastdoes it add all the keyboard stuff that I know, like "d t ^" and "24 dd" and regular expression search / replace - you know the reasons that I love vi / vim?
05:52RaynesYes.
05:52RaynesAs well as colon commands.
05:52maleghastOMG - so happy
05:53maleghastI have to go to a meeting now, but this is awesomeness incarnate… I love the internet :-)
05:53RaynesIn places where functionality overlaps with simple Emacs-native commands it may not implement the Vim way (one example is :! which evil does not implement in favor of Emacs's M-!), but it's pretty thorough.
05:54maleghastso cool
05:54maleghasteven with that caveat ^^
05:54maleghastThanks :-)
05:54Raynes<3
05:54edlothiolRaynes: how does evil interact with things like paredit?
05:55Raynesedlothiol: It is modal editing.
05:55RaynesJust like in Vim you have the command mode and the insert mode.
05:55RaynesInsert mode works as you'd expect, as normally as you'd expect.
05:55edlothiolso will paredit still work in insert mode, and not interfere in command mode?
05:55RaynesIt certainly hasn't for me.
05:56edlothiolok, thanks. I should try it out sometime too
05:56RaynesEither way, you can escape evil-mode completely by going into straight up completely normal Emacs mode.
05:56RaynesBut I've never had to do that.
05:56RaynesIt does scream "Wow, there is no way this can work this well." but it really does.
05:56maleghastRaynes: Sorry, I can't follow this properly… Does paredit work under evil-mode?
05:56Raynesmaleghast: Yes.
05:57maleghasteven more awesome
05:57maleghastI was expecting to have to make a sacrifice there
05:57RaynesI was answering his question "not interfere in command mode?"
05:57maleghast*nods*
05:57zephyr*poof*
05:57Rayneso.o
05:59AnderkentAbout evil, do people use it because it's an improvement over vim or because it's an improvement over raw emacs?
06:00Anderkent(for clojure specific stuff, don't want to start a religious argument here)
06:00_ulises_heh
06:00mpenetit's a matter of personal taste
06:00_ulises_Anderkent: difficult not to go into a religious war there :)
06:01Anderkentwhat I was really asking is whether, given I'm already comfortable with vim, evil is worth researching for me
06:02RaynesI don't carry the opinion that Emacs is better than Vim, but I do think Emacs with evil-mode is an improvement over both Vim and Emacs. But that's for me. Please don't hurt me.
06:02AnderkentI was hoping for an example :)
06:03mpenetis there an emacs "mode" for vim?
06:03mpenetclosing the circle
06:04Rayneshttp://farm4.static.flickr.com/3389/3440941212_5327dc101e.jpg emacs
06:04AnderkentI guess just getting rid of vimscript would be an improvement
06:04Rayneshttp://thumbs.dreamstime.com/thumblarge_557/129010382582FY9H.jpg vim
06:04Rayneshttp://www.yourvibration.com/images/BlueGlowingHand.jpg emacs with evil-mode
06:04RaynesAnderkent: ^ Examples.
06:04otfromRaynes: we won't hurt you just because your wrong and an infidel. ;-)
06:06RaynesI just realized I linked to a website called 'yourvibration.com'. I assure you, the picture is completely SFW.
06:10mpanI'm probably googling wrong, but what takes a seq of [k v] vectors and creates a map?
06:11edlothiol,(into {} [[1 2] [3 4]])
06:12mpanthank you!
06:12Mr_Bondwhat's the bot upto?
06:13edlothiolmaybe I did it wrong? I don't really know how to use the bots here
06:13Anderkentno that should have worked
06:13Anderkent&(into {} [[1 2] [3 4]])
06:13lazybot⇒ {1 2, 3 4}
06:13Anderkentwell, lazybot works :P
06:17Raynes$findfn {1 2 3 4} [[1 2] [3 4]]
06:17lazybot[clojure.core/list* clojure.core/lazy-cat clojure.core/sequence clojure.core/vec clojure.core/concat clojure.core/seque clojure.core/seq clojure.core/lazy-seq clojure.core/sort]
06:17RaynesDid that backwards
06:18Raynes$findfn [[1 2] [3 4]] {1 2 3 4}
06:18Anderkentalso missed a comma in your map
06:18RaynesCommas are whitespace.
06:18lazybot[]
06:18Anderkentright, confused languages.. What was the clojure syntax for a set, anyway?
06:18RaynesOh, I see.
06:18Raynes$findfn [1 2] [3 4] {1 2 3 4}
06:18RaynesThere is no function that does that, since into takes an argument in order to do it.
06:18lazybot[]
06:19RaynesAnyways.
06:19Raynes#{1 2 3}
06:19Anderkentright, ta
06:40scottjRaynes: how are you going to handle the conj with your sleep schedule?
06:40RaynesWhat do you mean?
06:41RaynesMy sleep schedule is, as of last night, relatively normal.
06:41RaynesI stayed up for 30 hours and nearly killed myself to solve that problem in one day.
06:41Raynes;)
06:47scottjthe conj appears to have a lot of new presenters this year, with a lot of regulars not presenting. and lots of logic talks.
06:47RaynesIndeed.
06:47otfromalways good to give new people a chance
06:48scottjyeah I think it's good
06:49scottjand I suspect they've been open to outsiders presenting since the beginning but didn't have as many submitters as this year
06:50RaynesYeah, the gap left by me not submitting a talk must have left a huge hole.
06:52RaynesIt's fortunate that I didn't. I just wouldn't feel right sleeping through my own talk.
06:53scottjRaynes: it appears that Rich's talk is going to be at the worst time on your sleep adjustment schedule no?
06:53RaynesThat's the least of my worries. There is a party tonight.
07:00lpetitRaynes: "sleeping through one's own talk" : that was *my* joke ;-)
07:01Raynesambrosebs: Is it okay if I sleep through your talk? scottj is convinced I'll sleep through Rich's talk because of how late it is relevant to how early I woke up and his little I slept over the past two days, so I figure if I nap through someone's talk I should be able to prove him wrong and you smell like a martyr for the greater good.
07:02ambrosebsRaynes: will you be front row?
07:02ambrosebs:D
07:03RaynesI'll probably lay behind you during your talk, so as to not bother anyone with my snoring.
07:03ambrosebsThis sounds helpful.
07:03ambrosebsRaynes: just read my dissertation and you'll be up to speed, k?
07:04RaynesWhat if I fall asleep while reading it?
07:04ambrosebstrue
07:04RaynesIn all seriousness, I slept straight through Chas's talk last year. I felt so horrible.
07:05RaynesBut PDF analysis and late nights = zzzzzzzrrrrr
07:05ambrosebsI don't want to know which timezone my body clock is in.
07:06RaynesI think you and I probably have similar body clocks, despite the distance.
07:06RaynesAt home I'd be going to bed right now.
07:24pingtimeoutHi guys
07:25gfredericks,(println "pingtimeout: yo")
07:25pingtimeout:)
07:25gfrederickslazy bot.
07:26teromclojurebot is not here...
07:26pingtimeoutOh so it exists ?
07:26gfredericks&(println "yeah he can eval code like this")
07:26lazybot⇒ yeah he can eval code like this nil
07:27pingtimeoutNice
07:28pingtimeoutHey, I have a question about defrecords
07:28milanjwtf, when I do "load current buffer" (emcas + nrepl) I lost my definitions
07:28pingtimeoutI'm trying to fool some people by creating a java library written in Clojure
07:28milanjI'm in right ns in *repl* and I'm getting "CompilerException java.lang.RuntimeException: Unable to resolve symbol"
07:28milanjwtf
07:30pingtimeoutI know how to create a record and aot compile it, but type hints does not seem to be used in the generated constructor
07:30pingtimeout=> Isn't there any mean to create a strongly typed constructor using defrecord ?
07:30xeqimilanj: if you kill the file buffer and reopen it does the problem continue?
07:32milanjno
07:32milanjit's ok when I reopen it
07:32xeqidid you restart nrepl at some point?
07:32milanjsure
07:33gfrederickspingtimeout: I am ashamed for not knowing :(
07:33milanjfirst I open core.clj
07:33milanjC-c C-k that one
07:33milanjthen I have all the stuff in *nrepl* buffer since I'm using it from core.clj
07:33milanjbut after editing something it screw up
07:35Anderkentpingtimeout: quoting http://clojure.org/datatypes , 'note that currently a type hint of a non-primitive type will not be used to constrain the field type nor the constructor arg, but will be used to optimize its use in the class methods
07:36Anderkent'constraining the field type and constructor arg is planned'
07:37pingtimeoutAnderkent: Aw, so I guess this would be the same for factory methods ?
07:37pingtimeoutgfredericks: np ;)
07:38pingtimeoutTo be more precise, I would like to make a presentation of a super duper java library, and at the end, tell people "Oh btw, there is no single line of Java in this library"
07:38pingtimeoutAnd immediately take a picture of the audience like "wtf ?"
07:40pingtimeoutBut this would be difficult if they see methods taking only Object as parameters
07:45gfredericksthat would be difficult :(
07:45gfredericksyou could generate java code and tell them there isn't any hand-written java?
07:46gfredericksgenerate dumb wrappers I mean
07:49pingtimeoutHmm
07:49gfredericksalso there is no non-trivial java at all
07:50Anderkentyeah doing gen-(class|interface) for your public API seems like the way to do it, at least until deftype/defrecord can do it for you
07:51pingtimeoutAnderkent: You mean that with gen-class you can strongly type methods parameters ?
07:51pingtimeoutI mean for non primitive arguments
07:53gfrederickspingtimeout: oh I bit you can yeah
07:53gfrederickss/bit/bet/
07:53gfredericksI knew I was forgetting something
07:54pingtimeoutSo I could create some static (strongly-typed) factory methods using gen-class that would call record constructors
07:54pingtimeoutHave to try that
07:55Anderkentyou can, though sometimes it gets ugly - for example a method taking a array of strings would be (:gen-class :methods [[doStuffToArray ["[Ljava.lang.String;"] void]])
07:56gfrederickseasy to make a macro for the special case you're going for
07:59pingtimeoutOk so I can do that, but it would be a good idea to say that it was only to show complete compatibility
07:59gfrederickssure
07:59pingtimeoutLike : "Clojure is dynamic, I had to do some dirty stuff to create statically and strongly type entry points, don't do that at home"
07:59pingtimeout:)
08:00gfredericksI had a library once that would take a namespace and gen-class a class with a bunch of static-method entry points to each function in the namespace
08:00gfredericksI don't remember if it supported types or not, but presumably it could be modified
08:00gfredericks$google lib-2367
08:00lazybot[fredericksgary/lib-2367 · GitHub] https://github.com/fredericksgary/lib-2367
08:00gfrederickspingtimeout: ^ that there
08:02lpetitpingtimeout: https://groups.google.com/forum/?fromgroups=#!topic/clojure/G5syTJHhG1I
08:03lpetitpingtimeout: http://docs.datomic.com/clojure-api.html as well
08:18mpenetI am probably wrong but isn't this possible using definterface as well?
08:20mpenet,(doc definterface)
08:20mpenet&(doc definterface)
08:20lazybot⇒ ------------------------- clojure.core/definterface ([name & sigs]) Macro nil nil
08:20gfredericksstill have to generate actual methods at some point
08:20Anderkentmpenet: he wanted strongly typed constructor signatures
08:21mpenetoh constructor, nevermind
08:35pingtimeoutback
08:35pingtimeout(sorry, had to attend a meeting)
08:35pingtimeoutlpetit & gfredericks thanks for the links, I'm going to have a look at it
08:46AnderkentAnyone figured out a nice way of running both java and clojure tests in maven?
08:52Guest12230hello, could anyone show me how to create a partial function in clojure using true? for example (partial true?)
08:52Guest12230i can not get it to work
08:52clgvlpetit: did you read my question in the repl history search issue?
08:53bordatoue`hello
08:53lpetitclgv: I may have missed it
08:53bordatoue`i am getting confused with partial and curry
08:54clgvlpetit: ah good, then you are now reminded to check it when you got time ;)
08:54alexnixonbordatoue`: 'partial' is clojure's implementation of currying
08:55bordatoue`alexnixon: could you please answer my question <Guest12230> hello, could anyone show me how to create a partial function in
08:55bordatoue` clojure using true? for example (partial true?)
08:55bordatoue`
08:55lpetitclgv: In fact, i'll do it right now
08:55clgv:)
08:56xeqi,(partial true? false)
08:56bordatoue`all i need to do is include a true? within a partial function
08:56joegallo,(let [plus-two (partial + 2)] (plus-two 6))
08:56xeqi&(partial true? false)
08:56lazybot⇒ #<core$partial$fn__4070 clojure.core$partial$fn__4070@1721c27>
08:56joegallo&(let [plus-two (partial + 2)] (plus-two 6))
08:56lazybot⇒ 8
08:56bordatoue`joegallo: how would you add true? to partial
08:57alexnixonbordatoue`: I'm not sure what you mean by using true?, what are you trying to achieve?
08:57bordatoue`,(def some-partial (partial true? nil)) (some-partial (= 0 0))
08:57lpetitclgv: help, where is it?
08:57bordatoue`that isn't working can someone tell me why
08:58alexnixonbordatoue`: because true? takes one argument. (partial true? nil) returns a function of 0 arguments that always returns false.
08:58xeqibordatoue`: you don't need to partial true? there. partial is useful for functions that take multiple arguments
08:58clgvlpetit: http://code.google.com/p/counterclockwise/issues/detail?id=332
08:59bordatoue`is there any way in clojure to examing the no of arguments a fn can take
08:59xeqi&(doc true)
08:59lazybotjava.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.Symbol
08:59xeqi&(doc true?)
08:59lazybot⇒ ------------------------- clojure.core/true? ([x]) Returns true if x is the value true, false otherwise. nil
08:59alexnixonbordatoue`: not in general, but you can try (doc f) or (source f)
09:00bordatoue`alexnixon: i thought partial would return a function that can take arguments
09:00bordatoue`so (partial true? nil) isn't it like saying (partial true?)
09:00alexnixonbordatoue`: if your original function takes n arguments, and you pass m arguments to partial, you'll get a function that takes (n - m) arguments
09:01alexnixonbordatoue`: in your case, true? takes 1 argument, you passed it 1 additional argument (nil), and so you've ended up with a function that takes 1 - 1 = 0 arguments
09:02bordatoue`alexnixon: thanks for the detailed explanation, is nil counted as a valid arg to a fn
09:02alexnixonbordatoue`: yes
09:02alexnixonnil is a value, like any other
09:03bordatoue`so if i use something like this (partial partial true?) will this work then
09:04lpetitclgv: I need clarifications
09:04clgvlpetit: ok
09:04alexnixonI don't understand why you're using partial with true? _at all_, given true? takes 1 argument
09:05lpetitclgv: maybe we can continue this on #ccw ?
09:05bordatoue`alexnixon: so are you saying that one should not use partial with any fn less than one arg
09:05alexnixon,(doc partial)
09:06alexnixon&(doc partial)
09:06lazybot⇒ ------------------------- clojure.core/partial ([f arg1] [f arg1 arg2] [f arg1 arg2 arg3] [f arg1 arg2 arg3 & more]) Takes a function f and fewer than the normal arguments to f, and returns a fn that takes a variable number of additional args. When called,... https://www.refheap.com/paste/6724
09:06clgvlpetit: sure
09:08bordatoue`thanks alexnixon
09:09bordatoue`((curry true?) (= 0 0)) what is the equivalent of this in clojure
09:10alexnixon,(true? (= 0 0))
09:10alexnixon&(true? (= 0 0))
09:10lazybot⇒ true
09:10bordatoue`(nice )
09:12bordatoue`what is the difference between a keyword and symbol
09:12bordatoue`can they be interchanged
09:18kofnobordatoue`, here's a stackoverflow that answers that better then I could --> http://stackoverflow.com/questions/1527548/why-does-clojure-have-keywords-in-addition-to-symbols
09:19bordatoue`just would that link
09:19bordatoue`thanks
09:23niclI come from a PHP background and to inspect variables I will usually print them out using var_dump() or some equivalent. What is the suggested way for inspecting variables in Clojure?
09:23jcromartienicl: println
09:24nicljcromartie: thanks
09:24c-romney@nicl that depends on the context in which you're building your app. println works, also the repl......
09:24foodoojcromartie: that doesn't work for nested data structures
09:24jcromartiebut if you want something more like var_dump
09:24jcromartiefoodoo: what?
09:24jcromartiefoodoo: how so?
09:24pingtimeoutpprint is very useful if you are in the repl
09:24niclto be specific, I'd like to inspect the request object in compojure
09:24jcromartieyeah, pprint is good
09:24niclrequest map
09:24jcromartieprn is useful too
09:25pingtimeout&(pprint {:foo [:bar :baz]})
09:25lazybotjava.lang.RuntimeException: Unable to resolve symbol: pprint in this context
09:25pingtimeoutfail
09:25Anderkent&(clojure.pprint/pprint {:foo [:bar :baz]})
09:25lazybot⇒ {:foo [:bar :baz]} nil
09:25jcromartiefoodoo: how does println or prn not work for nested structures? do you mean cycles?
09:25foodoojcromartie: hm. Maybe I just mixed things up. Seems you are right
09:25jcromartieyou can't appreciate pprint here with clojurebot
09:26jcromartiegotta see it in the repl
09:26pingtimeoutnicl : pprint is like print_r in PHP
09:27jcromartienicl: but let's get back to something like var_dump
09:28niclok thanks - will try them out/read the docs
09:31jcromartienicl: if you want something that prints out the expression, its value, and the type of the value, then you can use a macro like this
09:32jcromartie(defmacro dump [expr] `(let [val# ~expr] (println '~expr (type val#) "->" val#)))
09:32nicljcromartie: nice, thanks!
09:32jcromartieuser> (let [x 1] (dump x))
09:32jcromartiex (class java.lang.Long) -> 1
09:44Anderkenteh, so clojure.test.junit is remarkably useless. Anyone know of a nicer wrapper?
09:45noidiAnderkent, use midje or expectations
09:45noidihttps://github.com/marick/Midje
09:45noidihttps://github.com/jaycfields/expectations
09:46Anderkentwell, there's a bug in midje for junit compatible output, but it's been there for 7 months
09:46noidiok
09:46noidiwell, expectations seems to support junit
09:49Anderkentit says it does, but it doesn't - the wrapper provided referencens functions that were removed from core expectations... And the 'run this from a junit testcase' approach is really awkward
09:50AnderkentI don't want to run stuff in junit, I just want to have junit-like output that I can pipe into mvn surefire-report or jacoco
09:51noidiif clojure.test provides the output you need, you can write your tests in Midje, just wrap the facts with (deftest ...)
09:53noidiat least you could. I don't know if that's still supported.
09:54Anderkentyes, which is what I wanted to do, but clojure.test.junit fails to provide useful information (it takes the filename/line number from wrong place on the stack, and doesn't produce output conforming to the schema)
09:54Anderkentthus my question whether anyone knows of a better wrapper
09:55noididammit, I read your first message as "eh, so clojure.test is remarkably useless. Anyone know of a nicer wrapper?"
09:55noidisorry :)
09:55Anderkentno problem :P
10:26jcromartienicl: BTW if you haven't already improved it, I made a tweak to that "dump" macro
10:26jcromartie(defmacro dump [expr] `(let [val# ~expr] (println (pr-str '~expr) (type val#) "->" (pr-str val#))))
10:27jcromartieworks better with strings
10:27nicljcromartie: ha thanks.I'm a newbie to Clojure, haven't written a macro yet :(
10:27jcromartienicl: they are occasionally useful for things like this, when you want to do something with the actual expressions passed in
10:28niclbtw, do you know any good Compojure tutorials/examples. Struggling to find in-depth examples beyond the very basic docs on their githubs
10:37ivenkysgents - basic question - i am attempting to understand a basic HOF present here(1 liner) - http://sprunge.us/VAWE - question is , how does Clojure know "f" is the other anon. function ?
10:38ivenkysits taken from the Koans
10:39Wild_Cativenkys: decompose what the line does. First, it creates an anonymous function, (fn [f] (f 5)).
10:40Wild_Catthen, it *calls* that function (see the extra outer paren).
10:40Wild_Catwith an argument that's another anonymous function: (fn [n] (* n n))
10:41ivenkysWild_Cat: yup - i get the result in the repl as 25 - (i added the extra outer paren to call it)
10:42Anderkentso the answer is it knows f is the other function because 1. f is the name of the argument to your first function and 2. the argument to this call is the other function
10:42Wild_Catexactly.
10:44ivenkysWild_Cat: Anderkent: 2 is where i have a problem this "(fn[f] (f 5))" is valid on its own - so how does it know to look for the next argument ?
10:45Wild_Cativenkys: it is valid, as a function definition. Add extra parens and it becomes a call.
10:45Wild_Catsame difference as between foo and (foo arg1)
10:45Anderkentivenkys: it does not look for an extra argument until you call it
10:46ivenkysWild_Cat: Anderkent : Ah - ...
10:47ivenkysWild_Cat: Anderkent : so it says "give me f" and f can be anything really
10:47Anderkentyes
10:49ivenkysthats beautiful -
10:49ivenkysWild_Cat: Anderkent : gents , thanks a lot - much appreciated
11:00Wild_Catso, I'm trying to figure out two things with Light Table:
11:01Wild_Cat1. how do I disconnect from a project?
11:01Wild_Cat2. how do I set it up so that I have an instarepl that auto-reloads my project's modules whenever I save a file?
11:02rbxbxconjconjconj :)
11:02Wild_Cat(actually, if I could achieve 2. with a regular lein repl, I'd be happy enough already)
11:14dgrnbrghello clojurians! does anyone know how to get a value that tells you a scroll pane's position using seesaw (or interop)? I am trying to make a live-scrolling display that stops updating when the user moves the scrollbar, and the resumes when they scroll back to the bottom
11:17maleghastdgrnbrg: I warn you in advance I am about to be no help at all, but just wanted to say "wow, you're doing something non-web with Clojure *applause* - sincerely meant too.
11:18ucbheh
11:21dgrnbrgmaleghast: I work on tons of clojure CLI and swing applications
11:23maleghastdgrnbrg: I don't doubt you, I am just genuinely impressed as the vast majority of stuff I hear about is web or web-api based work. Is there somewhere that I could go to see your work?
11:23dgrnbrgit's mostly proprietary internal research tools
11:23dgrnbrgi do have some stuff on github that i've done for fun (also not webapps)
11:23dgrnbrg@dgrnbrg on github
11:24maleghastdgrnbrg: Thx I will go look...
11:24dgrnbrgspyscope is a tracing tool, guzheng is a code coverage tool, and piplin is a hardware description language
11:24antares_maleghast: the majority of Clojure usage I see is in data processing, nothing to do with Web apps
11:25maleghastantares_: Fair enough - was not saying "this is so", but pointing out that anecdotally, most of what I see / hear about is web focused if not outright web usage.
11:25maleghastI'd love to learn / hear more about the rest of the Clojure Ecosystem
11:38maleghastI just tend to move in webby circles, as I am a web-focused software engineer - my real area of work / interest is middleware / APIs and infrastructure - but I am interested in other uses for Clojure (and other languages that I use / hack) and that's all I was saying… :-)
12:23alexnixonis it just me that finds the syntax of let-> a bit odd? Why doesn't it take a binding form (or at least have the first two arguments swapped around)?
12:26Anderkentwhere's let-> from?
12:26alexnixonclojure 1.5 beta
12:27gfredericksoh sweet I didn't know that was already around
12:29alexnixonyeah it's incredibly useful but feels strange to use
12:31Anderkentindeed the order seems wrong for a let, though right for the arrow... (let-> (my-calculation) name (do-to-name))
12:32gfredericksit's hard to mash two syntactic concepts together and make it feel like both
12:32alexnixonI'd find this more intuitive: (let-> [name (my-calculation)] (do-to- name))
12:32alexnixonand also more powerful in that you could add support for destructuring
12:32Anderkentperhaps, but a binding form makes it look like (let-> [name 1 othername 2] (do-to-name)) should be ok
12:33Anderkentwhich it is not
12:33alexnixonI disagree, see if-let and when-let
12:34Anderkentthat's one of the things about if-let and when-let that bug you, I'd expect it to either be (if-let x y expr) or take any number of forms and `and` them together
12:34Anderkent*bug me
12:35alexnixonthat may be, but that's that status quo. I'd rather have keep syntax consistent rather than have to remember a bunch of special cases.
12:37alexnixonand destructuring in let-> would be really nice
12:37Anderkenthow do you mean?
12:40Anderkentsomething like (let-> [2 3] [x y] [(inc x) (inc y)])? I think that should work?
12:40alexnixonnot quite
12:41Anderkenti imagine it just expands into (let [name expr name form1 name form2 name form3 ...] name)
12:44alexnixon(let-> [[f & r] (list 1 2 3 4)] (do-something r (foo f)))
12:44alexnixon(and imagine more forms there)
12:44Anderkentassuming (do-something r (foo f)) returns something that can be destructured into [f & r], that should work
12:45alexnixonyeah
12:45Anderkent(let-> (list 1 2 3 4) [f & r] (do-something r (foo f)) ...)
12:47alexnixonthat doesn't work
12:47alexnixonif it did, then great - we have destructuring. But still, the syntax is weird
12:48alexnixonI imagine the macro will be of most use when dealing with state maps, in which case being able to pull out bits of the state in each form would be quite useful
12:51Anderkentah, it does'nt work because it expands into (let [[f & r] expr [f & r] f1 [f & r] f2] [f & r])
12:51alexykso, when starting nrepl in emacs with nrepl-jack-in, how do I make sure it uses a given project.clj?
12:51alexnixonAnderkent: yep
12:51Anderkentso to fix that they'd have to special case the last form
13:00Anderkenti.e. `(defmacro let-> [expr name & forms] (let [~name ~expr ~@(interleave (repeat name) (butlast forms)) name# ~(last forms)] name#))
13:00Anderkent` should be before (let, not (defmacro, of course.
13:06alexykhmm: nrepl-jack-in only seems to start in the right directory when you give it a prefix. By default it just starts somewhere… not in the current file's directory, apparently
13:24yediis there a requests (python) equivalent for clojure?
13:25Anderkentclj-http
13:39yedicool, thanks Anderkent
13:39alexnixonAnderkent: I've sent a message about let-> to the wider audience on the clojure mailing list, if you're interested in following the discussion
13:41zodiakstupid question, in the repl, how do I find out which version of the jar is require'd ? I mean, I have 4 versions of a jar, and unless they export a 'version' .. how do I know which one ?
13:42clojure-newbhey guys… just trying out : https://github.com/vaughnd/clojure-example-logback-integration, but getting 'No such namespace: logimpl', any ideas ?
13:42clojure-newbseems logging is complicated at least for me
13:46TimMc(let [& 0] (let-> [1 2 3] [f & r] [r & f])) ;; => [(2 3) 0 (0 1)]
13:46TimMcwhee macros
13:46zodiakclojure-newb, never used it, but it appears you have to setup project.clj etc
13:47zodiakpersonally, I would start off with tools.logging but.. that's using log4j so.. maybe 'eeww' ?
13:47TimMctimbre is a nice logger
13:47zodiakTimMc, is that the new one I read about a few days back on clojure.in ?
13:47clojure-newbis timbre good with clojure 1.4 ?
13:47TimMcNo faffing around with log4j.properties files.
13:47zodiakah yes.. yes it is :)
13:48winkwhoever invented log4j.properties should be stripped off his keyboard and net access
13:48TimMcwink: I'm sure it seemed like a good idea at the time.
13:48clojure-newbI'll give it a go thx guys
13:48winkI've gotten programs in a new language faster running than logged my first line with log4j
13:48winkthat is *not* an exaggeration
13:48clojure-newbhaha
13:49clojure-newbI usually find I'd rather go outside and lick the road than set log4j up
13:49TimMcwink: People overestimate the difficulty of learning languages and underestimate the difficulty of learning libraries.
13:49TimMcThis is probably because they only know one language.
13:50winkTimMc: to use a library in a sane manner, to use it to its full potential, but a simple "I was told to use this, and I relaly just want it to log anywhere, I don't care where, give me a (sane) default"
13:50zodiakto paraphrase an old unix saying; log4j is user friendly, it's jst picky about who it's friends are
13:50TimMcheh
13:50winkI don't think that's unreasonable to have it work with defaults
13:51TimMcwink: Not unreasonable, no. But the reality is that a number of libs impose weird, hidden constraints.
13:51TimMcs/hidden/non-obvious/
13:52winkyes, but I'd even prefer prepending "WARNING: CONFIGURE ME" and still have it work out of the box
13:52TimMcclojure-newb: Here's how I set up a different output for timbre in one of my projects: https://github.com/timmc/kpawebgen/blob/910701afb533c852630d3954c16a5c6c837168ad/clj/src/kpawebgen/core.clj
13:52winkI can't see how logging can be a destructive behavior
13:53zodiakheisenburg problems ;)
13:53zodiakthe act of logging/looking causes the problem to disappear. remove the logging/print statements and it works
13:53zodiakwelcome to C debugging ;)
13:54clojure-newbTimMc: thanks, I'll take a look once I get the out the box sample working
13:55clojure-newbyuck… all logging being swallowed somehow
13:55clojure-newbwondering if its because my other deps include logging libraries
13:55TimMc(timbre/set-config! [:appenders :standard-out :min-level] :debug)
13:55zodiakclojure-newb, yeah.. you only ~really~ want 1 logging lib ;)
13:55TimMc^ the only config you really need
13:56brainproxyi've implemented a custom deref for one of my deftypes, but this is causing problems with the tostring/printing methods that come stock w/ deftype; anyone got an example of how I can properly implement those things so I can get something nice in the REPL for instances of my type?
13:59zodiakso, without a def version, is there anyway to check a library version that's been req'd ?
14:00TimMczodiak: I suppose you could check the classpath.
14:01zodiakTimMc, yeah.. I mean.. I could hack around and do some funky introspection nonsense.. or jst fork the lib and stick in the def
14:01zodiakI am leaning towards #2 ;)
14:01zodiakta though.. kinda what I was figuring/fearing
14:02clojure-newbok, liking timbre, thx guys
14:02clojure-newbno config and I have logging, result
14:02TimMc,(.getResource (class reduce) "/clojure/core$reduce.class")
14:03TimMc;; => #<URL jar:file:/home/timmc/tmp/clj/lib/clojure-1.3.0.jar!/clojure/core$reduce.class>
14:03TimMcOh, purely programmatically? Yeah, don't peek at the classpath. :-P
14:40zodiakTimMc, yeah.. I jst forked the solr libs, fixed it up a bit, and put in the def for version
14:44scottjfor anyone not at the Conj you can enjoy this just uploaded StrangeLoop talk on ClojureScript by David Nolen http://www.infoq.com/presentations/ClojureScript-Optimizations
14:45rbxbxHas anyone flirted with having this channel follow the #clojure hashtag on twitter? Pros/Cons?
14:45rbxbxIt seems like a lot of people reach out on twitter for help more often than popping by here.
14:46devthi understand why this doesn't work but is there a way to make it work with quote/unquote? (doc (defn foo "some stuff" [] 1))
14:47devthseems not since the doc macro controls when the arg gets eval'd
14:47devthand to work it needs to be eval'd before going to doc. i think.
14:48TimMcrbxbx: I would be rather unhappy with that.
14:48TimMcIf I wanted twits, I'd grab the twatfeed.
14:48rbxbxTimMc fair enough.
14:49TimMcIf the room were lower traffic, I might not mind. As it is, the bots already talk an awful lot.
14:49rbxbxIt's fairly low volume/low noise, in my experience. But I suppose irc and twitter _are_ different things ;)
14:50TimMcWell, maybe I should look at the feed before saying that...
14:50TimMcOK, Twitter apparently doesn't want me to find anything on their site without having an account. Can someone link me the feed for that hashtag?
14:51scottjTimMc: https://twitter.com/search/%23clojure
14:51rbxbxTimMc https://twitter.com/search?q=%23clojure&amp;src=typd
14:51TimMcmuch obliged
14:51rbxbxTimMc bear in mind it will likely be higher volume today due to the conj.
14:51scottjor https://twitter.com/search/realtime?q=%23clojure
14:52TimMcLooks really noisy.
14:54rbxbxTimMc I guess we all have different capacities for noise ;) That said, I imagine you're not the only one here who'd feel the same.
14:57FrozenlockAre the EPL and GPL compatible? For example could I use a EPL library for a GPL application?
14:58TimMcrbxbx: The main problem is that it's not interactive. It's some random statement of happiness/distress or boost for a blog post or un/successful build notice that drops into the channel, but the originator isn't here to discuss it. Twitter is a broadcast medium; IRC is for conversation.
14:59ToxicFrog^ That. If there were a twitter<->IRC bridge it might be useful, but not when it's one-way.
14:59rbxbxTimMc you've convinced me :)
15:00rbxbxTimMc and as stated earlier, those that want to tail twitter search are able to do so on an opt-in basis.
15:00amalloyFrozenlock: technomancy likes to point out that there's some clause in the EPL intended to provide more openness, but from the GPL's point of view it counts as a restriction, and therefore the two are incompatible
15:00rbxbxWe've found it useful for my company's channel which had gotten me thinking about it, but the situation is different here.
15:00ToxicFrogFrozenlock: the EPL is not compatible: http://www.gnu.org/philosophy/license-list.html#EPL
15:02FrozenlockUnderstood, thank you very much. I suppose I could write the library under the EPL -and- the GPL, then the application under GPL.
15:02amalloyif it's your library, you can do whatever you want. write it under GPL and "i give myself a license to do whatever i want"
15:03TimMcBut is EPL compatible with the WTFPL???
15:03lazybotTimMc: How could that be wrong?
15:05TimMcamalloy: But a GPL project can link against an EPL project, right?
15:07amalloyi'm not a lawyer, mate
15:07danlarkinI'm not your mate, guy
15:08andrewmcveighguy, buddy....
15:08danlarkinjoke ruiner! get him
15:09andrewmcveighIt's my favourite joke, friend.
15:10ToxicFrogTimMc: don't know. What does the EPL say about linking against it? Does it consider the rest of the program a derivative work?
15:10TimMcamalloy: I wasn't going to *trust* you, I just wanted your opinion. :-P
15:10znDuffAre you the sole copyright holder of the GPLed work?
15:11xeqihttp://www.eclipse.org/legal/eplfaq.php#GPLCOMPATIBLE and http://www.gnu.org/licenses/license-list.html
15:13raekTimMc: I don't think so.
15:13raekyou combine two works and the GPL considers the combined work to be a derivative work of the GPL'ed code
15:13raek(but the EPL does not)
15:14TimMcI'd expect that to result in an asymmetrical situation.
15:14TimMcwhere GPL could link against EPL but not vice versa
15:23TimMc...so xeqi's first link confuses me.
15:36eggheadhey guys, I've got a question about enlive... I was previously using hiccup to swap out a variable in a piece of js via a template tag, is there any way to do this sort of thing in enlive?
15:37eggheadbasically `var data = {&var}` then rendering with {:var JSON}
15:48KowboyHello, from the conj!
15:52AndRSo light table does not like being ran from a different directory, huh.
15:52thorwilegghead: a long time ago i used this: https://gist.github.com/4081164
15:53eggheadthanks thorwil, I was thinking of just doing something like that
15:53Netfeedanyone having problems with tower? i'm getting "Assert failed: (>= (count path) 3)" erros
15:54thorwilegghead: np. it was one of the factors that made me drop enlive and use hiccup ;)
15:57TimMcegghead: Dropping JSON into HTML is a nasty business no matter how you do it. There's a weird issue with "<".
15:57amalloyTimMc: that's what CDATA is for, right?
15:58TimMcMaybe?
15:58eggheadbeen working well just using hiccup
15:58eggheadHad to bring in enlive for scraping and figured I might as well replace hiccup
15:58amalloy<script> <![CDATA[ javascript & stuff with < characters ]]></script>
15:59TimMcWhat happens when you have "]]>" in your data?
15:59amalloywell, then you're in trouble :P
15:59TimMc>_<
15:59TimMcI wish the damn browser just allowed me to use &lt;.
16:00TimMcAh well. If wishes were horses, web developers would be trampled.
16:00thorwili think the only good reason for using enlive in templating is if you have someone else writing the templates. if you do it all yourself, hiccup is just much much cheaper
16:01TimMcThe basic approachof enlive makes me happy.
16:01AndRwell, enlive also allows you to see the templates without running the app
16:01thorwilok, so 2 good reasons, then :)
16:02eggheadya TimMc
16:02eggheadI like having html be just html
16:03brehautTimMc: “Every time you write an HTML templating toolkit that doesn't escape by default, an Estonian bot herder eats a kitten.” ← high five for that quote
16:06bobbrahmsnewb question: code in http://chopapp.com/#7u7ksh29
16:07bobbrahmsIn a let make a hashmap, put something in there, define a macro that takes a single parameter, then uses it as a method name to call on the hashmap.
16:07bobbrahmsthat works fine.
16:07bobbrahmsnext I make a macro that takes a method name and an argument
16:08bobbrahmsthat one doesn't seem to work and I'm not sure why.
16:08TimMcbrehaut: 'strue
16:08xeqibobbrahms: the keys are different
16:08xeqi"asdf" vs "somekey"
16:08bobbrahmsoh whoops
16:09bobbrahmsgetting the same thing though
16:09bobbrahmsstill doesn't work for me with "somekey"
16:10bobbrahmsfixed version: http://chopapp.com/#qulzwhsz
16:11AndRthat pasting tool is really inconvenient, cant copy the core without line numbers
16:11bobbrahmswhich one should I use?
16:11znDuffbobbrahms: gist.github.com and refheap are both well-regarded here.
16:12bobbrahmshttps://www.refheap.com/paste/6747
16:12FrozenlockIt seems clojurescript (javascript) can't use UDP. Could someone confirm this?
16:12znDuffFrozenlock: What's your runtime? node.js can do it.
16:15FrozenlockHmm interesting... I would have preferred to use the browser but this might be worth looking into.
16:16bobbrahmsany macro fiends out there that can tell me what brain dead thing I did wrong in https://www.refheap.com/paste/6747?
16:16schmirhow do I depend on a private clojure library with leiningen?
16:17rodnaphschmir: you mean from your own repository?
16:17xeqischmir: do you have it in a private repository?
16:17schmirrodnaph: no, I've just got the .jar file lying around
16:18rodnaphoh. umm... you can either just put it in the classpath, or there's a localrepo thing u can google. i'm no pro though... heh
16:19AndRbobbrahms: when I try to run your code I get a compiler exception.
16:19bobbrahmsIf I set up x with a def instead of doing it in a let, then define the macro, it seems to work.
16:20bobbrahmscan you see where it's complaining?
16:22bobbrahmsit's weird that when the hashmap is defined in a let, the one macro can see it, but the other one doesn't want to play with it. but the second macro works against the hashmap when def'd
16:23AndRfor me it fails at the (callmethod size), because it doesnt know what size is. How are you running it?
16:25bobbrahmsI run lein repl. let me fire up a new one and make sure
16:25AndRyeah i think you must have def'ed x somewhere before
16:25bobbrahmsI'm getting the same as you now. OK.
16:25bobbrahmsso is there a way of referring to the "let"ted one?
16:26bobbrahmsThanks by the way
16:26AndRyou have to pass it to your macro
16:26AndRor just define a function instead :)
16:27bobbrahmsit's a lot easier to do what I'm doing now if I can just pass in method names like this from a map
16:27AndRdoing (def x) then (binding [x (new HashMap)] (...))might also work
16:29bobbrahmshmm ok.. I'd like to know what the preferred method is.. I thought let seemed right for this. I wonder why in the scope of that let, x is not visible in the macro, but a def-ed one is.
16:30Urthwhyte(fn c [a & r] (if r #(a (apply (apply c r) %&)) a)) <- the %& here is the whole argument list, right?
16:32bobbrahmsAndR: Anyhow, I think I'm un-stuck now. Thanks! anyone else who wants to chime in with a pointer to why the thing doesn't work in a let, I'm all ears
16:32AndR%& is the 'rest' arg (i.e #(foo %&) (fn [& rest] (foo rest))
16:32Urthwhyteah, ok
16:35AndRbobbrahms: I think (defmacro callmethod [name] `(. x ~'name)) could work instead, as it will prevent your name argument to be expanded into `your.namespace/name`
16:36AndRbut in general I don't think what you're doing is the right approach, and don't understand macros enough to tell you how to do it right
16:38AndRwhy not do something like this instead: https://www.refheap.com/paste/6749
16:39bobbrahmsOoo I like that
16:39bobbrahmsbut there's like 15 methods on the object I really want to use (not a map)
16:40bobbrahmsYouve given me some good ideas to use though. thanks
16:48alexykanyone using nrepl in emacs?
16:48znDuff~anyone
16:48znDuffEh.
16:48alexykI can't seem to be able to start it with a given project.clj
16:48znDuffalexyk: Do you have an actual question, or is this just a poll?
16:49znDuff...ahh.
16:49alexykthe problem is that C-u M-x nrepl-jack-in prompts with a directory and then enter just goers to another reline; it neber finishes
16:50znDuff(actually, I don't use "lein nrepl", because I don't use lein, but that's a separate discussion)
16:50xeqialexyk: what version of lein do you have?
16:50alexyk2.0.0-pre10
16:51xeqiare you running it from a buffer in a project?
16:52alexykxeqi: when I want to use a file in a project, I thought it will use project.clj in that project -- but the code seems not to show that!
16:52brehautznDuff: dont use lein‽
16:52alexykproject is just a top-level dir supposed to contain project.clj right?
16:52brehaut~guards
16:53brehautznDuff: clearly it is your lucky day
16:53alexykznDuff: starting lein manually appeals to control freaks
16:53alexykwhich I like
16:53xeqialexyk: if you have a file from a project open, then nrepl-jack-in will look for the project.clj
16:53xeqihigher in the directory treee
16:53alexykxeqi -- I thought so, but I wonder where is that in the source
16:53alexykof nrepl-jack-in
16:54znDuffbrehaut: I'm in an ant+Ivy shop.
16:54znDuffbrehaut: and much of my code is plugins for tools with large, ant-and-Maven build chains.
16:54alexykznDuff: condolences
16:54brehautinteresting
16:55brehautznDuff: is this just historical reasons, or continued choice?
16:55znDuffbrehaut: Some of each.
16:56AndRsame, I've been using maven for anything that's not toy-sized
16:56znDuffWe wouldn't be an Ivy shop if I had a choice
16:56znDuff...but we wouldn't be a Leiningen shop either; Clojure is only a tiny part of what we do.
16:57TimMclazybot, did you win some kind of Highlander bot fight???
16:57lazybotTimMc: How could that be wrong?
16:58xeqialexyk: hmm, I thought it would have been around https://github.com/kingtim/nrepl.el/blob/master/nrepl.el#L1188
17:00brehautmaybe clojurebot just had a rough night on the town at the conj last night
17:13Frozenlo`Wait what... "Sorry, names based on non-ironic *jure puns are not allowed. If you intend to use this name ironically, please set the LEIN_IRONIC_JURE environment variable and try again." technomancy, that's your doing? -_-
17:13Frozenlo`
17:14erewhonlol
17:14pjstadigtechnomancy has been on record for a long time on that issue
17:14pjstadigall the way back to the first Conj
17:15Chiron_guys, would you please help me with morphing this code to idiomatic Clojure ? http://pastie.org/5384674
17:16Frozenlo`"Project names containing uppercase letters are not recommended and will be rejected by repositories like Clojars and Central. If you're truly unable to use a lowercase name, please set the LEIN_BREAK_CONVENTION environment variable and try again." Wth is happening today??
17:16lazybotFrozenlo`: What are you, crazy? Of course not!
17:16Frozenlo`
17:17brehautxeqi: just saw lein-pedantic; looks like a great tool
17:17xeqibrehaut: thanks! hope it proves useful
17:17xeqifor you
17:19brehautxeqi: it would have caught a bug in my one clj library in the wild that was reported a couple of months back :)
17:25xeqibrehaut: out of curiousity, did you find out about it from conj tweets, or stumble on it from somewhere else?
17:26tufflaxSay I have this code http://pastebin.com/CRXxuxma It is kind of slow. It takes like 2 s to get the 100 000 first primes. Apparently, no reflection is going on. Can one make it faster with type hints or something?
17:26brehautxeqi: prismatic via conj tweets
17:28_repsacI'm having a bit of trouble with the clojurescript repl. I have it up and running but how do I reload a namespace?
17:28pjstadigtufflax: it would be dangerous to suggest anything without doing some profiling first
17:29_repsacI can't seem to get the normal (use ... :reload-all) to work :(
17:33tufflaxpjstadig, yeah maybe, but this is just toy code, not even mine. I just wanted to know more about optimizing clojure, because I found that especially arithmetic can be surprisingly slow sometimes. I was hoping someone would have some idea of why and how to fix it. I mean, I'm sure someone has done something similar before. :p
17:35pjstadigyou could add some primitive hints to save some boxing/unboxing
17:35pjstadigbut i'd guess the sequence processing is killing you
17:36pjstadigyou might be better off using a loop with primitive hints where clojure (and the JVM) can avoid boxing and inline things
17:36tufflaxWhat do you mean exactly by the sequence processing
17:36pjstadigbut you'll be doing yourself a disservice by jumping in without doing some profiling
17:36tufflaxYeah you are probably right
17:37pjstadigyou can use the built in profiler pretty easily to get a rough idea of the bottlenecks
17:37pjstadigevery?, take-while, drop, lazy-seq
17:37pjstadigare all sequence processing functions that might be too heavy weight for you
17:38tufflaxCan I get rid of boxing the numbers and still use the sequence functions?
17:38pjstadigprobably not
17:39pjstadigprimitives only work for locals and function parameters
17:39tufflaxok
17:39pjstadigif you put a number into a data structure, it will get boxes
17:39SegFaultAXIs there a hash stack implementation laying around that someone can point me to?
17:39pjstadigboxed
17:39tufflaxI see
17:41tufflaxpjstadig, the built-in profiler, what is that? You mean the one you can get with the java comman line options?
17:42pjstadigyeah
17:42tufflaxok
17:42pjstadighttp://hg.openjdk.java.net/jdk6/jdk6/jdk/raw-file/tip/src/share/demo/jvmti/hprof/manual.html
17:42tufflaxthank you, gonna see if I can make this faster then :p
17:42pjstadigit's crude, but it can work
17:46tufflaxDoes anyone know if one can see videos from clojure conj online somewhere?
17:47TimMctufflax: Wait until maybe July.
17:47tufflax:p
17:47TimMcunless you mean the last Conj
17:48tufflaxno, im talking about this conj
17:48TimMcI'm serious, it's going to be a long wait.
17:48tufflax:(
17:51alexykanybody using clojurescript to test sites?
17:51alexykdoing integration tests
17:52alexykclicking on elements in a headless browser
18:03gfredericksalexyk: I did a small bit of that
18:03gfredericksI think I used some jquery simulate library
18:03gfrederickswell maybe I only ran them in a real browser
18:03alexykgfredericks: phantom.js?
18:03gfredericksI'm not real good at getting the headless things to work :/
18:03alexykfolks pointed me at htmlunit too
18:03SegFaultAXgfredericks: Phantom is pretty cool.
18:04alexykJVM is the ultimate headless thing!
18:07gfrederickswhat are you talking about the JVM is used by web browsers that's what I read on the internet
18:07gfredericksit was even in the context of clojure
18:08TimMcgfredericks: Did you see my latest abomination with '&?
18:08gfredericksTimMc: no
18:08gfredericks&(let [&? 2] (+ 3 &?))
18:08lazybot⇒ 5
18:09gfredericks"[Clojure] good for writing really complicated web apps that support lots of concurrent users.
18:09gfredericks"
18:11TimMc&(let [& 0 ampers (memfn assoc & _)] (ampers [1 2 3] 'first 'plac
18:11lazybotjava.lang.RuntimeException: EOF while reading, starting at line 1
18:11TimMce))crud
18:11TimMc&(let [& 0 ampers (memfn assoc & _)] (ampers [1 2 3] 'first 'place))
18:11lazybot⇒ [(first place) 2 3]
18:11TimMcI'm hoping you can improve it.
18:12gfredericks&(.assoc [1 2 3] 0 'first 'place)
18:12lazybotjava.lang.IllegalArgumentException: No matching method found: assoc for class clojure.lang.PersistentVector
18:12gfrederickswat is going on here
18:12gfredericks&(doc memfn)
18:12lazybot⇒ ------------------------- clojure.core/memfn ([name & args]) Macro Expands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a Java method as a first-class fn. nil
18:13TimMcI want it to be more elegantly horrifying.
18:15gfredericksI still can't tell what it's doing
18:15gfredericksI assume the _ works because let is confused about &
18:15gfredericksbut what the heck object is .assoc being called on?
18:15gfredericksoh wait
18:16gfredericks&(.assoc [1 2 3] 'first 'place)
18:16lazybotjava.lang.IllegalArgumentException: Key must be integer
18:16gfredericks&(.assoc [1 2 3] 0 ['first 'place])
18:16lazybot⇒ [[first place] 2 3]
18:16gfredericksokay so it's something like that?
18:16TimMcYeah.
18:16TimMc&(macroexpand-1 '(memfn assoc & _))
18:16lazybot⇒ (clojure.core/fn [target__4321__auto__ & _] (. target__4321__auto__ (assoc & _)))
18:17gfredericksomg and the & is somehow causing 'first and 'place to be wraped up
18:17gfredericksI'm appauled
18:17Bronsawoah.
18:17Bronsathat's scary
18:18TimMcI've been exploring the (not very scary) implications of destructuring's special treatment of the '& symbol.
18:18gfredericksokay so this works because fn ignores the fact that & has a local binding
18:18TimMcyessir
18:19AndRTimMc: that's hilarious :)
18:20gfredericksTimMc: I'm sorry I can't fiddle with it tonight; prepping for defending my master's thesis tomorrow morning
18:21TimMcOh! Best of luck and coffee.
18:22gfredericksthanks :)
18:24Apage43memfn always seemed awkward to me, what with the specifying arg names
18:24Apage43I guess its so you can typehint them
18:26amalloyApage43: also so it knows how many args to use
18:26Apage43ah.. right
18:27amalloyif rich *really* cared about typehinting in memfn, you could typehint the target object like (memfn ^String indexOf ^String other)
19:00arohneris there a version of 'slurp out there that takes a max of N bytes?
19:03zxtxhey anyone around know why I might be getting NoClassFound exceptions for some but not all classes in a package
19:04AndRTimMc: I don't know why i find (defn suround [& rest] (let [& rest] [rest & rest])) and its 1.5 sibling (defn double-suround[& rest] (let [& rest] (let-> [rest & rest] [rest & rest])))
19:04bbloomzxtx: are the classes public? do you have the right CLASSPATH (ie. is it the right version of the package you think it is)?
19:04AndRso amusing, but i do
19:04AndRthat first message got sent earlier than I wanted ;P
19:06zxtxbbloom, the classes are public
19:06bbloomzxtx: when do you get the error?
19:06zxtxwhen I try to import the class
19:07zxtx(import 'com.amazonaws.mturk.service.axis.RequesterService)
19:07zxtxI get NoClassDefFoundError Could not initialize class
19:07zxtxbut I can import other classes in mturk just fine
19:07bbloomzxtx: does it say which class it couldn't find? are you sure RequesterService can't be found, or maybe some dependency of RequesterService?
19:07AndRah that's different than no class found
19:08zxtxbbloom, how can I check?
19:08AndRdo you have a full stack trace?
19:08bbloomzxtx: (.printStackTrace *e)
19:08bbloom(at the repl)
19:09zxtxhttp://cljbin.com/paste/50a58399e4b03f3a580b1dff
19:10ivancan I load clojuredocs examples from inside Emacs?
19:11bbloomzxtx: hm, not sure
19:12zxtxI checked the jar files and the classes are all there
19:12AndRzxtx: eh, probably a classpath issue after all
19:13bbloomzxtx: my guess isn't classpath, since it's NoClassDefFoundError, not ClassNotFoundException
19:13zxtxAndR, but why would some classes work and some not
19:13bbloomzxtx: probably a static initializer failing
19:13zxtxlike (import 'com.amazonaws.mturk.service.axis.RequesterServiceRaw) works
19:13AndRtry verifying the jar is in the classpath: (clojure.pprint/pprint (seq (.getURLS (java.lang.ClassLoader/getSystemClassLoader))))
19:14bbloomzxtx: do you have the source to RequesterService? Does it have any static field initializers, or anything like that?
19:14zxtxit does
19:15bbloomzxtx: could they be failing?
19:15AndRzxtx: http://mturksdk-java.svn.sourceforge.net/viewvc/mturksdk-java/trunk/src/com/amazonaws/mturk/service/axis/RequesterService.java?revision=91&amp;view=markup
19:15zxtxAndR, its in there
19:15bbloomzxtx: http://stackoverflow.com/questions/1401111/noclassdeffound-exception-could-not-initialize-class-error-help
19:15AndRsorry that was ment to go to bbloom
19:16antoineBhello, in clojurescript should is use (set! (.-funcName obj) (fn [] ...)) or (aset obj funcName (fn [] ...))
19:16AndRzxtx: do you have log4j on classpath?
19:17bbloomzxtx: any of those static final arrays might have missign classes, there may be a transitive dependency that you need. or maybe an exception is getting thrown during initialization
19:17bbloomantoineB: depends on your usecase
19:17antoineBbbloom: change a function of an object
19:17AndRbbloom: I'd rather look at imports - RequesterService uses log4j and sax, any of them might be missing
19:18antoineBbbloom: aset seems to not work
19:18bbloomAndR: true
19:18zxtxI have commons-logging but I don't see log4j
19:18bbloomantoineB: aset is an interop form for working with arrays. although javascript objects and arrays both have array-like get/set-prop operations, i generally avoid it for non integral keys
19:19bbloomantoineB: makes your intention clearer
19:19bbloomzxtx: ah, yeah, so some static initializer is probably trying to log something :-)
19:19AndRzxtx: just do (import 'org.apache.log4j.Logger), if that fails you need log4j jars
19:20AndRhow did you get the lib? with lein/maven or you just dropped the jar?
19:20bbloomantoineB: but your aset didn't work b/c aset is a function, not a macro
19:20zxtxthat was the issue
19:20bbloomantoineB: you need to do (aset obj "funcName" (fn [] …)))
19:20zxtxthanks! bbloom AndR
19:20bbloomantoineB: note the quoting
19:20AndRnp
19:20zxtxim going to patch the clojar for mturk
19:20zxtxstupid subtle bugs
19:20antoineBbbloom: i remmenber, i use aset/aget when the key are string
19:21bbloomantoineB: yup, set! is a special form, aset is a function
19:21bbloomantoineB: you need to use aset if you need to perform some kind of higher order operation on a js object
19:22bbloomantoineB: if you need to parameratize a set!, you need to do it with a macro
19:22bbloomzxtx: heh, line 226
19:25antoineBbbloom: if i want to use a runtime generated String or Symbol for accessing a property i need aget/aset, or could i use (.- and (set! ??
19:25lazybotantoineB: Definitely not.
19:25AndRzxtx: so com.amazon:java-aws-mturk didn't have the log4j libs? Or did you use something else?
19:26AndRthat was pretty funny from lazybot
19:26bbloomantoineB: you'd need an aget or aset, but you need to be careful b/c there is no guarentee that runtime names will match compile names
19:26bbloomantoineB: especially with advanced compilation
19:26zxtxthe pom file for the clojars was not properly defined
19:26bbloomantoineB: the Google Closure compiler is used, so you need to protect symbols from being munged. generally, you want to avoid doing that sort of metaprogramming at runtime
19:27bbloomantoineB: https://developers.google.com/closure/compiler/docs/api-tutorial3
19:28antoineBhttps://developers.google.com/closure/compiler/docs/api-tutorial3#propnames
19:28antoineBok
19:29bbloomantoineB: so i guess the short answer is: decide if you want a macro or a function, then use set! in macros and aset in functions :-)
19:31antoineBbbloom: you suggest i can do some sort of metaprogramming with macros?
19:31AndRzxtx: ah I see and the original author did not push it to any public repo, so you had to push it to clojars yourself
19:32zxtxyep
19:32bbloomantoineB: in javascript land, it's common to do things like foreach(['foo', 'bar'], (function(x) { obj.prototype[x] = …
19:33antoineByou aget/aset for this
19:33bbloomantoineB: but that doesn't work if the compiler is going to rewrite symbols to save space, so tricks like that are not allowed in Google Closure Advanced Compilation mode
19:33antoineBi understand this
19:33bbloomantoineB: so instead, you can do that at compile time
19:33antoineBhow?
19:33bbloomantoineB: you write a macro that expands to multiple set! forms
19:34bbloomthose set forms will expand to stuff like obj.prototype.foo = instead of the ['foo']
19:34bbloomso that the compiler will know they are safe to rewrite
19:34bbloomand any calls to foo would be rewritten too
19:35bbloomlazybot: ~mail
19:35bbloom~mail
19:35bbloom$mail fogus himera seems down
19:35lazybotMessage saved.
19:35bbloomheh, ok, good guess :-)
19:36antoineBso assuming you macro take a list of symbols and an object and "return" a list of obj[symbol], how do you do that?
19:36bbloomantoineB: are you new to clojure too? or just clojurescript? macros take a while to get your head around
19:36antoineBand how do you do (for [x (range 1 10)] (aget obj (str "flower" x)) ??
19:36lazybotantoineB: What are you, crazy? Of course not!
19:37antoineBbbloom: i how not new, the only "static" way to get a value in cljs is by (.- form
19:38bbloomantoineB: your macro could expand to `(for [x (range 1 10)] (~(symbol (str ".-flower" x)) ~obj))`
19:39bbloomer sorry
19:39bbloomnot that
19:39bbloom`(do ~@(for [x (range 1 10)] `(~(symbol (str ".-flower" x)) ~obj)))`
19:39bbloommore like that
19:40bbloombut that makes no sense with gets heh
19:41antoineBbbloom: the thing i want to point out is .- form is problematic for macros
19:41antoineByou need aget/aset
19:41bbloomantoineB: but aget/aset will expand to a quoted string
19:41bbloomyou can compose symbols:
19:41antoineBi know
19:42bbloom,(symbol (str ".-" "foo"))
19:42bbloom&(symbol (str ".-" "foo"))
19:42lazybot⇒ .-foo
19:42antoineB((def obj (js-obj ))
19:42antoineB(.-test obj)
19:42antoineBgive nil as expect
19:42Alkershis composing functions primarily for readability?
19:42antoineB((symbol ".-test") obj)
19:43antoineBbut this wont work
19:43bbloombut what about: `(~(symbol ".-test") ~obj)
19:43antoineBsame
19:43jbryantUsing gen-class to generate nested classes. Is this possible?
19:44bbloomantoineB: i could swear i've done that successfully....
19:44antoineBwhat is the meaning of ` ?
19:44antoineBbbloom: maybe the macro are run in clojure this may works
19:44bbloomantoineB: syntax-quote http://clojure.org/macros
19:44Alkershto tell the machine to not evaluate whatever is after the backquote
19:45bbloomAlkersh: no, that's '
19:45bbloomAlkersh: ` does more stuff
19:45Alkershoh
19:45Apage43&['(a b vector) '(a b vector)]
19:45lazybot⇒ [(a b vector) (a b vector)]
19:45Alkersham new to it
19:45Apage43oh
19:45Alkershand hoping to learn something here
19:45Apage43&['(a b vector) `(a b vector)]
19:45lazybot⇒ [(a b vector) (clojure.core/a clojure.core/b clojure.core/vector)]
19:45Apage43there
19:46Alkershbbloom
19:46UrthwhyteIs there a way to partition a list with a variable size window
19:46Alkershis there a point to composing functions other than for readability?
19:46Alkershbecause technically you could chain them and they would work the same, wouldn't they?
19:46Urthwhytei.e something like (partition-all (inc (rand-int 2)) col) to get something that would be size 1,2, or 3
19:46bbloomAlkersh: composing functions yields a new function
19:47Apage43so you can, for example, (map (comp f1 f2) …)
19:47Alkershthat i understand
19:47antoineB-> macro chain functions
19:47Alkershbut it's merely a representation of the functions yo're composing right?
19:47Alkershjust trying to clarify if it's for readability
19:47Alkershor has some other purpose
19:48bbloomAlkersh: no. composition yields an object. chaining doesn't
19:48bbloomAlkersh: Apage43 shows one usecase
19:48Alkershbut couldn't you pass both into another function if necessary?
19:48bbloomAlkersh: there are infinite :-)
19:49bbloomAlkersh: you mean with another fn form?
19:50Alkershyes
19:50bbloomAlkersh: *shrug* comp lets you omit the argument list
19:50amalloyUrthwhyte: i think your best bet is to write it yourself with lazy-seq. shouldn't take more than a couple lines
19:50Apage43(comp [f g]) => (fn [& args] (f (apply g args)) ; pretty much
19:51amalloy*cough* (comp f g)
19:51Apage43agh, right
19:51Alkershin other words, (f1 (comp f2 f3 ..) ...) is the same as calling (f1 (f2 (f3 ..)) ...)?
19:51bbloomAlkersh: no
19:51bbloom,(class (comp inc dec))
19:52Alkershsorry if i'm being a little slow here
19:52Alkershtrying to wrap my mind round fp
19:52bbloomclojurebot is the one being slow
19:52Apage43((comp f1 f2 f3) x) == (f1 (f2 (f3 x)))
19:52bbloom&(class (comp inc dec))
19:52lazybot⇒ clojure.core$comp$fn__4034
19:52Alkershok
19:52bbloomthanks for not being lazy, lazybot
19:52Urthwhyteamalloy: I figured as much; just wanted to see if there was a stdlib way before I got my hands dirty. Cheers
19:53bbloomAlkersh: play around with comp in the repl
19:53bbloomAlkersh: it will make much more sense if you play with it
19:53Apage43&((comp keyword str inc) 3)
19:53lazybot⇒ :4
19:53Alkersh&(keyword (str (inc 3)))
19:53lazybot⇒ :4
19:54Alkersh=S
19:54Apage43however, using it at the front of a form like that is atypical
19:55Alkershreadability?
19:55Apage43things that return fns are useful for things that you pass functions to, like map, reduce and such
19:56cgag_if i want to find the largest string in a collection, is there a better way to do it than (reduce (fn [s1 s2] (if (> (count s1) (count s2)) s1 s2)) coll)?
19:56bbloom,(doc max-key)
19:56bbloom&(doc max-key)
19:56lazybot⇒ ------------------------- clojure.core/max-key ([k x] [k x y] [k x y & more]) Returns the x for which (k x), a number, is greatest. nil
19:57bbloom&(max-key count "a" "bc" "foo" "xy" "z")
19:57lazybot⇒ "foo"
19:58cgag_exactly what i was looking for, thanks
20:11Urthwhyteamalloy: I forgot about 'partition-by
20:12Urthwhytethat was easy ><
20:12amalloybut...that doesn't work
20:21jbryantAnybody on nested/inner classes with gen-class?
20:24jbryantHrm… It would be the most natural way to do what I need to do, but I can hack around it.
20:25jbryantI'm generating classes based of Avro schemas, if a record has a nested record, it would be natural to have that type as a nested/inner class since it is not used elsewhere.
20:25bbloomjbryant: if you need to do heavy duty java interop & it requires an inner class, maybe it's just easiest to write that bit in java?
20:25jbryantGenerating classes off of data structures written in clojure.
20:25jbryantCan't write it in Java.
20:28Apage43at the end of the day, inner classes are really just sugar aren't they? You just need to shove the $ in the name in the right place I think
20:28jbryantTried it. Doesn't seem to compile. I think it's because gen-and-load-class isn't there.
20:28jbryantjust gen-class
20:28bbloomApage43: as far as i know, yeah. there are some oddities around statics, finals, etc
20:30Apage43bbloom: yeah, if you have a non-static inner class, instances of it are associated with an instance of the outer class
20:31Apage43sugar around the constructor
20:32jbryantthen is there any way to create static classes with gen-class or de-sugar the constructor?
20:33jbryant(without a deep dive of hooking into the compiler or anything crazy like that, of course)
21:03Urthwhyteamalloy: heh, you're totally right. Misunderstood how partition-by works (again). lazy-seq was the way to go
21:04UrthwhyteThis is what I came up with, wondering if it's idiomatic - the doall seemed wrong to me: https://gist.github.com/67ee6569d19030cb2cc4
21:20Hodappwhat idiomatic ways are there for building up maps in kind of the same way I might build up a list with 'map'?
21:22Hodappright now I have something like (apply assoc {} (mapcat (fn [a] (list key... value...)) (keys othermap))) and I doubt that's optimal
21:22bbloom&(into {} (map (range 5) (repeat "value")))
21:22lazybotjava.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn
21:22bbloomer i mean:
21:22bbloom&(into {} (map vec (range 5) (repeat "value")))
21:22lazybotclojure.lang.ArityException: Wrong number of args (2) passed to: core$vec
21:22bbloom&(into {} (map vector (range 5) (repeat "value")))
21:22lazybot⇒ {0 "value", 1 "value", 2 "value", 3 "value", 4 "value"}
21:22bbloom*sigh*
21:22bbloomthere we go
21:22bbloomheh
21:22Hodapplol
21:23bbloomanyway, use into {} and a sequence of two-element vectors
21:23bbloom&(into {} [["key" "value"] ["k" "v"])
21:23lazybotjava.lang.RuntimeException: Unmatched delimiter: )
21:23bbloom&(into {} [["key" "value"] ["k" "v"]])
21:23lazybot⇒ {"key" "value", "k" "v"}
21:24bbloomwow i suck at irc repls apparently
21:24bbloominto uses conj to be sorta like the opposite of seq
21:24bbloom&(seq {:x 1 :y 2})
21:24lazybot⇒ ([:y 2] [:x 1])
21:27bbloomHodapp: got it?
21:27Hodappyes! thanks, that's working
21:28bbloomIt's also pretty common to use a mapping function with destructuring: (fn [[k v]] …)
21:28bbloomto transform keys or maps
21:28bbloomkeys or values* rather
21:29bbloomok, my error rate is apparently 1/3 or so, which means it is time to step away from the keyboard. cya
21:29Hodappwhat I'm doing is that I have map1 and map2, and map3 gives the functions for composing map1 and map2 (i.e. every key in map3 gives a function which combines the values of map1 and map2 at that same key)
21:29Hodappit's just stuff like scale, rotation, color shifts, where it's little more than * or + as the function
21:30bbloomHodapp: hmm… merge-with maybe?
21:30Hodappe.g. map1 = {:scale 2}, map2 = {:scale 10}, map3 = {:scale *}
21:30Hodapp(compose-transform map1 map2) should be {:scale 20}
21:32Hodappthis is what the (into {} (map blahblahblah)) is doing now
22:06ekoontzhi
22:46wingy_is there a way to reload the required files in a ns form
22:47wingy_(ns repl (:require [app.server :as server]))
22:47wingy_where do i use :reload-all
22:49gfredericksat the end of it
22:49gfredericks(:require [...] :reload-all)
22:56wingy_doesn't seem to work on Light Table
22:56wingy_but thx
23:08timewarriorhi everyone.. I am new to clojure and from java world.. I am trying to implement write batching, where I collect data for 1 second and then make a request to submit the data
23:08timewarriordoes anyone know whats the best practice for doing something like this
23:17rattboiI'm a little stuck. I'm trying to do something similar to http://blog.darevay.com/2011/06/painting-widgets-with-seesaw/ for drawing things with seesaw.
23:18rattboiit has a draw function, which takes an odd # of arguments, like (draw g obj1 style1 obj2 style2 obj3 style3)
23:18rattboiI have something that is looking at an array and trying to draw a grid, and based on a sequence, it is determining objN and styleN
23:19rattboihttp://pastebin.com/7kFipJSJ
23:20rattboiI'm trying to iterate over the array, and based on the value, it determines the color
23:21rattboiI don't know how to use "cond" to return the pair of objN and styleN
23:22tmciverrattboi: one issue is that for returns a (lazy) collection; you'd have to 'apply' those args to the draw function.
23:22rattboican you give a small example? I'm really pretty new to clojure
23:22rattboi(apply draw g (for stuff)) ?
23:23tmciverrattboi: yes, that's right.
23:25rattboido you see the flatten in my code? Does that make sense to do?
23:26TimMcflatten rarely makes sense
23:26tmciver~flatten
23:27TimMcclojurebot is dead today, no factoids
23:27tmciver:/
23:27rattboiI have some ideas to clean it up a bit, just a sec
23:28TimMc"flatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with."
23:33rattboihttp://pastebin.com/hTnrWAQi
23:33rattboiI put more of the work into the let statement
23:34rattboieither with apply or not, I'm getting the error "wrong number of args (2) passed to graphics$draw
23:36tmciverrattboi: it looks like the for will return whatever the style function returns. And it looks like [rgb]-style local don't depend on any of the calculations you've done.
23:36tmciverrattboi: the 'grid' inside the let does nothing.
23:37tmciverrattboi: the let returns that value of its last statement.
23:37tmciverrattboi: it looks like you're not using line, value or grid.
23:40rattboiI want to return the pair of the rect and style
23:41rattboiarea is a list of lists that is height * width
23:41tmciverrattboi: ah, you could put 'grid' and the cond inside []
23:42tmciverrattboi: alternatively, you could have the cond return [grid r-style], for example.
23:42rattboiwhen that work is done, won't it look like (draw g [grid r-style] [grid g-style]) etc?
23:42rattboiwith the grid/style pair in a vec?
23:42rattboior am I misunderstanding this?
23:43rattboiI'm going for (draw g grid r-style grid g-style ...)
23:43tmciverrattboi: hmm, possibly. I find 'for' to be confusing and don't use it often ;)
23:43bbloomrattboi: you want an apply on that draw :-)
23:43bbloom(apply draw g (for ...))
23:43tmciverrattboi: I get by with a lot 'map's
23:46Sgeotmciver, even when you have multiple sequences you wish to use?
23:46bbloomrattboi: https://www.refheap.com/paste/6764
23:46bbloomrattboi: here's the changes i made
23:47bbloom1) i hoisted the common styles out to an outer let, so that they don't get recreated on every loop
23:47tmciverSgeo: just haven't needed it. I really need to try to use it more, though.
23:47bbloom2) i assigned the for form to the styles value, for clarity, i left out the grid from the styles stuff
23:47bbloom3) i map over each style and convert it into pairs of [grid style]
23:47rattboibrb
23:47rattboisorry
23:48bbloom4) use apply on draw, that will expand the list of arguments
23:53TimMc'for' is awesome
23:54zodiakTimMc, it is indeed.. reminds me of python's list comprehensions
23:54zodiak(whether that's good or bad, I leave upto you ;)
23:54SgeoIt pretty much is a list comprehension
23:54zodiakyup