#clojure logs

2011-06-27

00:30davekongI have a function that is working fine in the REPL, but if the pcall version of it is called from a java class, it hangs after printing the result. Also, from java, whether calling the parallel version or not, it gives grossly inacurrate results, despite all of the number manipulation being done in clojure (the function is just passed arrays of strings). Any hints on how to fix these issues? Should I
00:30davekongpaste my code?
00:34amalloydavekong: ##(doc shutdown-agents)
00:34sexpbot⟹ "([]); Initiates a shutdown of the thread pools that back the agent system. Running actions will complete, but no new actions will be accepted"
00:35amalloyprobably why it's "hanging". no ideas about the other thing
00:43davekongamalloy: thanks that seems to have fixed the first issue
00:45amalloydon't do that unless you want to shut down the system, though
00:45davekongoh
00:47davekongwell I don't want to until much later except now while I am testing
00:48davekongI am doing some calculations in clojure but the main program is on java
00:50davekongOr you just mean shut down all the agents?
00:54davekongseems like half the time I get a bad result and half the time it is good
00:56davekongand it has been regular for several runs good, bad, good, bad
01:00symboleWhy does (defn foo [&{:keys...}] work? Isn't everything after & collected into a list, and you can't destructure a list using {:keys...}?
01:06davekongWould java be less safe with memory or something like that and maybe memory is getting corrupted?
03:00amalloy~source destructure
03:00amalloysymbole: it works because the above makes it work
03:00amalloy(i haven't looked actually, but where else can the logic be)
03:17amalloyfor the curious, it looks like line 3434 there says, "if you destructure a seq into a map, apply hash-map on it first"
03:20amalloy&(let [{:keys [test]} '(:test 1)] test)
03:20sexpbot⟹ 1
05:48rfgpfeifferclojurebot: seen drcode
05:48clojurebotPardon?
05:49rfgpfeiffer~seen drcode
05:49clojurebotExcuse me?
07:32tomojhow does this make sense? https://gist.github.com/d24bf93fb851b9835305
07:32tomojI realize it's silly to create a bunch of new Randoms
07:33tomojbut still, shouldn't I sometimes see more positive than negative?
07:33tomojevery time I look for positives I get less positives than negatives
07:33tomojless positives than nonpositives I should say
07:34tomojevery time I look for negatives I get fewer negatives than nonnegatives
07:34tomojyet every time I look for zeros I get zero...
07:37tomojif I instead use just one Random, the results make sense
07:37tomojhah
07:55tomoj(repeateadly #(.nextLong (java.util.Random.))) is a strange thing
07:56tomojs/ead/ed/
07:57raektomoj: I think that when a Random is instantiated the random seed is initialized with the current time
07:57raektomoj: so if you instantiate a lot of them in the same millisecond/microsecond, the will give the same values
07:57raek*they will
07:59tomojstrange thing is, I can't ever see any dups
08:01tomojbut since the behavior depends on how you consume the seq...
08:03raek,(java.util.Random.)
08:03clojurebot#<Random java.util.Random@1746634>
08:03tomojI think there's just some weird dependency where if you take longer to consume positive values, and so delay generation of Randoms a bit more for positive values than negative values, fewer positive values are produced in general
08:03tomojs/in general//
08:04raek,(let [f #(.nextInt (java.util.Random.))] (loop [l (), n 10] (if (zero? n) l (recur (cons (f) l) (dec n)))))
08:04clojurebot(1135657559 -1653233976 1129285394 1624057155 -285451636 110824407 -1401623519 -906851758 1078467891 -246900125)
08:06raek,(map #(.nextInt %) (loop [l (), n 10] (if (zero? n) (recur (cons (java.util.Random) l) (dec n)))))
08:06clojurebot()
08:06raek,(map #(.nextInt %) (loop [l (), n 10] (if (zero? n) l (recur (cons (java.util.Random) l) (dec n)))))
08:06clojurebotjava.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn
08:06raek,(map #(.nextInt %) (loop [l (), n 10] (if (zero? n) l (recur (cons (java.util.Random.) l) (dec n)))))
08:06clojurebot(1079184460 -905735116 -412502350 -735306677 -337491639 2058739835 1328101674 1724377717 608990656 386974692)
08:07raekok, I can't seem to construct a example of what I'm thinking about... :-)
08:08rpglover64interop question
08:10rpglover64I (by which I mean my friend's students) have been given a jar, with the assignment that they should write program logic conforming to the api provided by the jar in java; I'd like to try to do this in clojure.
08:10rpglover64suggestions on how to start?
08:18gfrlogrpglover64: can you be more specific? like, are you already familiar with clojure's interop features, or do you need help with those?
08:19gfrlog(e.g., have you already read http://clojure.org/java_interop ?)
08:20rpglover64no, I'm not
08:20rpglover64in fact, I'm not familiar with java classloaders
08:20rpglover64I have read that
08:21rpglover64and my tripup right now seems to be getting access to the java api from within clojure
08:21gfrlogrpglover64: do you have the jar on the classpath? have you tried importing the relevant classes?
08:22rpglover64ah, the answer is simple. I'm an idiot who tries importing packages as if they were classes
08:22gfrlog:)
08:22rpglover64thank you
08:23gfrlognp
08:52gfrlogI wish (for) had an implicit do :(
08:53rpglover64can't you write a macro for that?
08:53rpglover64(I know I can't, but shouldn't it not be too difficult?)
09:00teromgfrlog`: what do you mean? doseq has similar bindings as for
09:00gfrlog`terom: does it return a seq?
09:00gfrlog`,(doseq [x (range 5)] (inc x))
09:01clojurebotExecution Timed Out
09:01gfrlog`??
09:01gfrlog`is it too early for writing code?
09:01gfrlog`my repl says it returns nil
09:01gfrlog`so doseq would not be a good substitute
09:01teromMaybe... doseq returns nil, it's for side effects.
09:02gfrlog`terom: right. I want to use for primarily, but adding debugging statements is a pain
09:02gfrlog`I cannot say (for [x (range 10)] (prn x) (inc x))
09:04teromWell.. you could say (do (prn x) (inc x)), but the results can be a bit suprising.
09:04gfrlog`terom: that's what I do. I know that for is lazy.
09:04gfrlog`When my lazy seq crashes in some completely other part of the code because of something in the body of the for, adding the (prn) there can usually help
09:09rpglover64looks like you've run into a problem common in haskell
09:31tomoj&(= (Long/toBinaryString -9223372036854775808) (Long/toBinaryString 27670116110564327424))
09:31sexpbotjava.lang.Exception: EvalReader not allowed when *read-eval* is false.
09:32tomojoh, unsigned..
09:32tomojwait..
09:33tomoj,(long 27670116110564327424)
09:33clojurebotjava.lang.ExceptionInInitializerError
09:34gfrlog`tomoj: I've noticed the bots don't like reading big numbers
09:34gfrlog`,2823589289358923847289348923523423423
09:34clojurebot2823589289358923847289348923523423423
09:34gfrlog`okay nm I don't know what I'm talking about
09:35gfrlog`,(first (range 8923895829348929835982389498234923))
09:35clojurebotjava.lang.ExceptionInInitializerError
09:44mattmitchellanyone know of a good validation lib? I want to do things like, make sure input is of a certain type, provide defaults, provide useful error messages etc.. This will be used in a library full of search finder functions
09:52jcromartie-> and update-in are just about the best things ever
09:52jcromartienext to Nutella
09:56gfrlog`mattmitchell: I know clojure provides function preconditions built in
09:56gfrlog`mattmitchell: but that's probably not as extensive as what you want
09:58mattmitchellgfrlog`: yeah I want to play with the preconditions a bit. The simpler the better for sure.
10:00gfrlog`mattmitchell: the defaults you could probably handle with a macro pretty simply
10:01gfrlog`I think clojure.core had a private method that it used for declaring constraints for inputs and reporting errors
10:01wastrelhi i stopped learning clojure because of busy
10:02mattmitchellgfrlog`: interesting, that'd be a good thing to have
10:02mattmitchellgfrlog`: could you show me an example of using a macro for defaults?
10:02gfrlog`sure, one sec
10:02gfrlog`the clojure.core macro is here: https://github.com/richhickey/clojure/blob/master/src/clj/clojure/core.clj#L1383
10:03gfrlog`I can't guarantee that one's a good idea though; some of the code in core is primitive
10:04gfrlog`mattmitchell: what kind of default behavior do you want? do you just want nil args to be converted to something else, or do you want the function to be able to accept any number of args?
10:06mattmitchellgfrlog`: well for example, if I have a param called :sort, I want to make sure it is an array, and contains valid sort fields: [:score.dec :price.asc]. If the values aren't valid, then fallback to a default like [:score.desc]. But it'd be great to throw an exception if needed too.
10:09gfrlog`mattmitchell: so for each arg you want to define what valid means and you want to provide an alternative for invalid inputs?
10:09gfrlog`or you want to throw an exception? :/
10:10mattmitchellgfrlog`: yes, the former. The exception stuff isn't as important, thanks :)
10:15edwI'm consistently getting a "No value supplied for key: <PORTNUM>" exception when using M-x clojure-jack-in. Anyone else run into this? This is new to me; I've been using jack-in for a while now.
10:16gfrlog`mattmitchell: try this and tell me how it breaks :) https://gist.github.com/1048931
10:17edwHmm, seems related to incanter-1.2.3... Hmm.
10:19pyrwhenever timers are brought up
10:19pyrconcurrency issues are mentionned
10:20raekedw: iirc, incanter has an old version of swank-clojure as a dev-dep
10:25mattmitchellgfrlog`: thanks!
10:25mattmitchellgfrlog`: will check it now
10:25gfrlog`yepps
10:31mattmitchellgfrlog`: OK running your example I get "Can't let qualified name: user/arg-nam"
10:31mattmitchellsorry, that last part was "arg-name"
10:31gfrlog`mattmitchell: that sounds plausible. Kay I'll put it in my repl and beat out the problems :)
10:31mattmitchellgfrlog`: cool thanks!
10:32gfrlog`mattmitchell: you see what it's trying to do though right?
10:32mattmitchellgfrlog`: yes i think i understand the idea there and how it works. I'm not real experienced with macros though, so the quoting throws me off a bit
10:32gfrlog`yeah it's a bit weird
10:35gfrlog`mattmitchell: okay, I updated it. Seems to work now.
10:35mattmitchellawesome i'll check it
10:36gfrlog`mattmitchell: using macroexpand probably makes it more explicit what it's doing
10:36mattmitchellgfrlog`: good idea
10:37gfrlog`mattmitchell: maybe renaming it let-defaults would make more sense :/ dunno
10:37gfrlog`or....whatever you want
10:37mattmitchellok sure yeah. i'm going to play around with this. thanks for taking the time to write this up :)
10:38gfrlog`no problem
10:55mattmitchellis there a predicate for testing if something is an array-like type?
10:56mattmitchellOr is it just (or (vector? x) (list? x) ?
10:57pcavs_mattmitchell: (seq? my-list) I believe
10:57mattmitchellthat's what i thought too, but then:
10:57teromseq? returns false for vectors
10:58mattmitchell,(seq? [1])
10:58clojurebotfalse
10:58mattmitchellyeah
10:58pcavs_well it depends what you're testing
10:58pcavs_,(seq? (list 1 2 3))
10:58clojurebottrue
10:58pcavs_is because it implements (head my-list) and (rest my-list)
10:58pcavs_,(head (list 1 2 3))
10:58clojurebotjava.lang.Exception: Unable to resolve symbol: head in this context
10:59pcavs_doh
10:59teromfirst
10:59pcavs_w/e it's called in clojure
10:59pcavs_there we go
10:59pcavs_,(first (list 1 2 3))
10:59clojurebot1
10:59pcavs_,(rest (list 1 2 3))
10:59clojurebot(2 3)
10:59pcavs_,(type [1])
10:59clojurebotclojure.lang.PersistentVector
11:00mattmitchell,(first [1])
11:00clojurebot1
11:00mattmitchell,(rest [1 2 3])
11:00clojurebot(2 3)
11:00pcavs_mattmitchell: now I'm confused myself... =\
11:01mattmitchellok :). yeah I was totally expecting seq? to return true for vectors
11:01teromfirst and rest probably call seq on the vector
11:03bsteuberwhat you want is sequential?
11:03bsteuber,(sequential? [1 2 3])
11:03clojurebottrue
11:04bsteuber,(sequential? (list 1 2 3))
11:04clojurebottrue
11:04bsteuber,(sequential? {:a 4})
11:04clojurebotfalse
11:07rfgpfeiffer,(doc sequential?)
11:07clojurebot"([coll]); Returns true if coll implements Sequential"
11:08mattmitchell,(sequential? "test")
11:08clojurebotfalse
11:08mattmitchellgood
11:10rfgpfeiffer,(seqable? ())
11:10clojurebotjava.lang.Exception: Unable to resolve symbol: seqable? in this context
11:10raekre. seq vs seqable, I recommend this post: http://kotka.de/blog/2011/06/On_types.html
11:10pcavs_raek: thanks
11:11bsteuber,(clojure.contrib.core/seqble? "foo")
11:11clojurebotjava.lang.ClassNotFoundException: clojure.contrib.core
11:12raekwhen the ISeq is eventually protocolized, checking for "seqable" would be more intuitive
11:12rfgpfeifferis there a way to refer to array types in multimethod signatures?
11:13raekrfgpfeiffer: what do you mean by "multimethod signatures"? dispatch value? type hints?
11:13bsteuberrfgpfeiffer: clojure.lang.Sequential
11:13rfgpfeifferdispatch value
11:14rfgpfeifferI can write (def bytes (type (byte-array 0)))
11:14rfgpfeifferand use that as a dispatch value
11:14raekI think the easiest way is to create an instance of an array with the correct type and then store the (class the-array) in a var
11:15raekI've seen this in clojure core code, I think
11:15rfgpfeiffer,(type (byte-array 0))
11:15clojurebot[B
11:16raek,(resolve '[B)
11:16clojurebotUnmatched delimiter: )
11:16raek,(resolve (symbol "[B"))
11:16clojurebot[B
11:16raek,(Class/forName "[B")
11:16clojurebot[B
11:16raek,(Class/forName "[Invalid")
11:16clojurebotjava.lang.ClassNotFoundException: [Invalid
11:17raekhrm, this might work too
11:17rfgpfeiffer,(= (Class/forName "[B") (type (byte-array 0)))
11:17clojurebottrue
11:17rfgpfeifferinteresting
11:19raekmattmitchell: for macros, one idea is to define cases for seq? (lists), vector?, map?, set?, and everything else.
11:20raekif you want to define new meaning for clojure source code data structures
11:26sritchiehey all -- is there some way to get metadata at read-time, for a function passed in to another function as an argument?
11:27sritchie(defn get-meta [x] (retrieve-meta x))
11:27sritchiewhich would just be retrieve-meta, of course
11:28sritchieoh, actually, better question -- can function values hold metadata?
11:28pdkthe return values or the functions themselves
11:29pdkalso (meta x) returns a map with the metadata of x
11:29sritchiethe functions themselves
11:29gfrlog`,(vector (meta cons) (meta (var cons)))
11:29clojurebot[{:line 28} {:ns #<Namespace clojure.core>, :name cons, :file "clojure/core.clj", :line 22, :arglists ([x seq]), :doc "Returns a new seq where x is the first element and seq is\n the rest.", :added "1.0"}]
11:29pdkfunctions can carry metadata
11:30sritchiepdk: cool, that's perfect
11:30sritchiethanks
11:30gfrlog`I'm curious why one is :line 28 and the other is :line 22
11:30gfrlog`the function seems to be about six lines long...
11:31rpglover64how is proxy expected to be used (there seems to be a dearth of examples); I'm slightly confused as to what would be the equivalent of (in java) writing a class which implements an interface.
11:32gfrlog`rpglover64: I think you can implement java interfaces with defrecord
11:36raekrpglover64: a typical usage is to interface with swing, e.g. you might need to implement ActionListener
11:37raekhttp://www.dreamincode.net/code/snippet3252.htm
11:37raek(example by Raynes)
11:38rpglover64ah; illuminating
13:10derp__I want to try and make a simple project using lein, but I don't really know where to go after creating my main function in core.clj
13:10derp__would anyone recommend a small example project using lein for me to look at?
13:10technomancyclojurebot: google mire
13:10clojurebotFirst, out of 4660000 results is:
13:10clojurebotMire | Define Mire at Dictionary.com
13:10clojurebothttp://dictionary.reference.com/browse/mire
13:10technomancyoops
13:10technomancyclojurebot: google mire clojure
13:10clojurebotFirst, out of 103 results is:
13:10clojurebotin which slime and mire and other sludges come into play - Technomancy
13:10clojurebothttp://technomancy.us/122
13:12technomancyderp__: lame link, but whatever; what I meant to say is that I built mire as a sample type app
13:12derp__technomancy: thank you, this looks like a great place to start
13:12wastrelis clojurebot yours ?
13:12wastreltechnomancy: ^^
13:13technomancywastrel: I convinced hiredman to implement it.
13:14gfrlog`clojurebot belongs to whoever feeds him the most
13:15wastrelbotsnack?
13:15wastrel!botsnack
13:15gfrlog`~botsnack
13:15gfrlog`clojurebot does not belong to me
13:15raekclojurebot: have some botsnack
13:15ejackson$botsnack
13:15sexpbotejackson: Thanks! Om nom nom!!
13:15justinlilly,botsnack
13:15ejacksonhaha !
13:16gfrlog`,(prn "botsnack")
13:17pjstadig`~ping
13:17manutterclojurebot: say something foreign...
13:17gfrlog`this is what happens when you forget to love your bot
13:17manuttersigh, he died
13:18gfrlog`manutter: is that the one phrase that he will absolutely always respond to unless he is completely dead?
13:18hiredmanI suspended the screen it runs it
13:19manuttergfrlog`: I dunno, whenever I try to have a conversation clojurebot always says somthing foreign to me
13:19gfrlog`oh right
13:20derp__I'm trying to start using slime/swank, but for some reason this tutorial isn't helping me: http://data-sorcery.org/2009/12/20/getting-started/
13:20derp__specifically launching "lein swank" in the mire directory isn't working, I get "That's not a task. Use "lein help" to list all tasks."
13:20manutterclojurebot: welcome back.
13:20technomancyaquamacs? =\
13:20clojurebotTitim gan éirí ort.
13:20derp__nope
13:21derp__emacs23 on 11.04
13:21gfrlog`~botsnack
13:21clojurebotThanks! Can I have chocolate next time
13:21technomancyderp__: https://github.com/technomancy/swank-clojure#readme
13:21raekderp__: try "lein plugin install swank-clojure 1.3.1"
13:25derp__okay, I tried that command and lein swank, but I got this error: https://gist.github.com/1049322
13:25technomancyderp__: see "known issues" in the readme
13:27derp__technomancy: okay, I removed the swank requirement in mire, but now I get this error
13:27derp__https://gist.github.com/1049325
13:27derp__woops
13:30derp__technomancy: I assume you were referring to the :dev dependencies bug, just to be clear
13:30technomancyright
13:31derp__but this new error, is that related to my own mistake or an actual bug?
13:33technomancyyour last gist is also caused by having more than one copy of swank installed
13:35derp__uh, I guess I had it through elpa (totally forgot about that). when I do M-x package-list-packages, what is the command to delete/remove a highlighted package?
13:36technomancynot sure; rm -rf ~/.emacs.d/elpa/foo works for me
13:37technomancybut that problem is caused by the swank-clojure lein plugin, not the swank-clojure elisp package
13:37derp__that okay to do? emacs isn't going to throw a fit about a package being removed unceremoniously or whatever?
13:38technomancyyou should definitely get rid of the swank-clojure elisp package
13:38technomancyit's been deprecated for over a year
13:39technomancyif I could delete it off elpa I would
13:52derp__now I am getting "symbols value as variable is void: slime-clj"
13:52derp__but lein swank works, so I'm halfway there
13:53technomancynever heard of that one before
13:56derp__I have clojure-mode (1.9.1), slime (20100404.1), slime-clj (0.1.6), slime-fuzzy (20100404), slime-repl (20100404) installed
13:56technomancyI have never heard of slime-clj before
13:57hiredmanlooks like it comes from swank-clj
13:59hugodslime-clj is from swank-clj
14:00derp__ooh, now I think I got it almost working
14:00derp__it says Host: 127.0.0.1
14:00derp__but the mode-bar thingy hasn't changed
14:01derp__now it just has (Lisp Interaction ElDoc Paredit AC yas Fill)
14:02raekderp__: note that swank-clojure and swank-clj are different projects
14:03davekongIf I have a function that takes an argument of type {[""] <double>} what would be the type I would pass from java to call it?
14:03hugodI think I should rename swank-clj to something completely different…
14:03raekclojure-mode, slime and slime-repl are the elisp packages you would use with swank-clojure
14:04raekderp__: http://dev.clojure.org/display/doc/Getting+Started+with+Emacs
14:05amalloydavekong: huh? what type is that?
14:05amalloya map from vector of string to double?
14:07amalloyjust pass it an IPersistentMap, or a j.u.Map if your java code is lazy
14:08davekongamalloy: yea
14:23mattmitchellis it possible to do nested destructuring for function args?
14:25raekmattmitchell: yes
14:26raekeach parameter can be destructured with the usual rules
14:27raekbut the whole "paramter vector" is not a destructuring form, so you can't do something like (defn foo [a b c :as all] ...)
14:27amalloy&((fn [{[x] :values}] x) {:values [1 2 3 4]}) ;; mattmitchell
14:27sexpbot⟹ 1
14:27fmw`I'm trying to add a test to https://github.com/clojure/tools.logging, but it doesn't seem to be run when I execute mvm install or mvn test. I can't find where the test functions are called either. any suggestions?
14:28mattmitchellok thanks. I'll play around with that for a bit
14:42wastreldo you use emacs GUI or cli?
14:44sritchiegui
14:47amalloyeven the cli is pretty gooey
14:48gfrlog`:-|
14:52sritchieon OS X, I like using command as the meta key
14:52sritchieand terminal likes escape
14:52sritchie(though this sounds like a fixable issue :))
14:59hugodfmw`: you could try mvn clojure:test if it is using the clojure-maven-plugin
15:53randoI'm building a project using leiningen and I'm trying to add the S3 wagon following the steps here: http://blog.anzix.net/2010/12/07/using-amazon-s3-as-a-maven-repository/ How can I add the extension to my pom.xml without lein clobbering it?
16:13symbolerando: You might be able to include that in your settings files.
16:14randosymbole: Yeah, i was trying that, but there's no place to put build/extensions in settings.xml that it won't yell at me
16:16symbolerando: It probably goes inside a profile.
16:17randosymbole: any idea where? http://maven.apache.org/ref/2.2.1/maven-settings/settings.html#class_profile
16:18symbolerando: http://maven.apache.org/guides/mini/guide-building-for-different-environments.html
16:18randooh, look at that
16:20randosymbole: nope, still yells: Caused by: org.codehaus.plexus.util.xml.pull.XmlPullParserException: Unrecognised tag: 'build'
16:21randothats annoying that the docs say its possible
16:21derp__so in emacs, what's the key combo to go to a function definition?
16:21amalloyM-.
16:21amalloyin slime, anyway
16:22randosymbole: yeah, that example is for the pom.xml
16:23derp__okay when I type M-. I get "Find tag (default server)" and I have slime/swank talking to each other I think
16:23derp__but I don't know where this tag file is or how to generate it
16:24amalloythen slime and swank aren't talking to each other
16:24amalloyif slime is going in the current buffer then M-. doesn't try to do tags stuff
16:26scgilardifor OS X, I use https://github.com/aim-stuff/cmd-key-happy as part of a setup to allow my cmd key to act as a meta key with terminal-based emacs.
16:26derp__okay, now it's working
16:26derp__so how do I do the opposite of M-. and go backwards?
16:27scgilardiM-, (or meta *)
16:33derp__when would one use defn-?
16:35amalloymad cow disease. (an overstatement, but generally don't use it)
16:35dnolenderp__: I see it as a way to control which definitions get imported w/ use. Better I think to lift private stuff into a separate ns I think.
16:36Somelauwdefn is private so that it won't conflict with methods of other modules and namespaces
16:36Somelauwand reduces complexity
16:36symbolerando: Maybe this will help http://maven.apache.org/guides/mini/guide-wagon-providers.html
16:37SomelauwI think
16:43randosymbole: I'll give it a shot
17:21sjlUgh, this "no unsigned bytes datatype" is really annoying.
17:28derp__what does the # sign do?
17:28amalloylike a hundred things
17:28derp__I tried (doc #) but got a weird error from slime
17:28derp__well what's it called?
17:28derp__if I want to google it
17:29sritchiethe dispatch macro
17:29amalloyderp__: it's a "reader macro": based on the next character in the file, it reads forms specially
17:29sritchiesearch for that here: http://clojure.org/readera
17:29sritchiehttp://clojure.org/reader
17:29amalloyeg, {a b} is a map, but #{a b} is a set
17:31derp__okay, thank you
17:35Cozeyhello. what's the best way to return json under compojure?
17:36Cozeymiddleware or overriding render ?
17:36Cozeyor .. ?
17:38amalloyuhhhh?
17:39amalloyjust return a string, possibly by using a middleware that converts your map to json, and add a middleware that adds a content-type header
17:39sjlWhat's the best way to say: "split this byte into (int top-four-bits) and (int bottom-four-bits)"? I must be missing something simple...
17:41sritchie(juxt #(bit-and % 0x1100) #(bit-and % 0x0011) )
17:42sritchiesorry, missing some two ones and zeros from each
17:42sritchies/some//
17:42sexpbot<sritchie> sorry, missing two ones and zeros from each
17:42sjlhmm
17:43sritchiedon't trust that guess, actually, I think something's wrong there
17:43amalloysritchie: the problem that hex isn't binary, i think :P
17:44amalloy&(let [b 137] (map #(bit-and b %) [0xf0 0x0f]))
17:44sexpbot⟹ (128 9)
17:45sritchieamalloy: haha, yes, there we go
17:45sjlsritchie: the tricky part is that (byte 137) doesn't work :\
17:45amalloy&((juxt quot rem) 137 0x10)
17:45sexpbot⟹ [8 9]
17:46sritchiesjl: amalloy's got you covered -- bit-masking the number will wipe out the first two and last two bits, giving you back the ints you wanted
17:46amalloysritchie: only if he has an int, though - it won't work with a byte
17:47sritchietrue. back to observation mode for me :)
17:48sjlGrrrr (.toString (BigInteger. (byte-array [(byte -122)])) 2) -> "-1111010"
17:48amalloysjl: working with unsigned numbers in java is terrible, yes
17:48sjlIs there a "just show me the damn bits you're using to represent this" function somewhere?
17:49amalloy&(.toString (BigInteger. (byte-array [(byte 0) (byte -122)])) 2)
17:49sexpbot⟹ "10000110"
17:49amalloysjl: not really. a number of libraries have implemented it
17:49sjlHmm, ok, that's a start. Thanks
17:50sjlStupid Minecraft protocol and its using nibbles for data.
17:50amalloy*chuckle*
17:50justinlillywait what? They have a protocol which uses the nibbles game?
17:51justinlillyseems really interesting to transport information as 100x100 grids of a nibbles game in progress :)
17:53fmw`hugod: Sorry, got interrupted by a long skype conversation with the girlfriend. I've added a test function, but it doesn't seem to be run, however the other 21 functions are run, so the tests themselves are running fine
17:57fmw`hugod: but it seems the test is within a comment function, so the current tests aren't all being run either
17:57fmw`hugod: so sorry for bothering you ;)
18:01hugodfmw`: no bother :) mvn test should work too, looking at the parent pom
18:29DerGuteMoritzhello everyone, I am trying to install http://search.maven.org/#artifactdetails%7Cjavax.ws.rs%7Cjsr311-api%7C1.1.1%7Cjar via leiningen like this: lein install javax.ws.rs/jsr311-api 1.1.1
18:29DerGuteMoritzhowever, I get this error: Exception in thread "main" java.lang.NullPointerException (NO_SOURCE_FILE:0)
18:29DerGuteMoritzam I doing something wrong?
18:31dnolensjl: https://gist.github.com/1050007
18:31DerGuteMoritzhm putting it into a project.clj and running lein deps works though
18:32dnolensjl: not sure if you need something perf conscious, but if all you want to do is introspect this should be fine.
18:32sjldnolen: Ohh, nice. But is that extremely slow compared to magical bit shifting?
18:32dnolensjl: if you want something fast you need to bit-and then shift.
18:33dnolen(bit-and n 0xf0) and (bit-and n 0x0f)
18:34dnolenI'm sure there are faster ways, I'm not a bit-twiddling expert
18:35sjlhmm, (defn top [b] (bit-shift-right (bit-and b 0xf0) 4))
18:38dnolensjl: yeah that's about 2 orders of magnitude faster.
18:40sjlyeah, that's much more workable
18:41RaynesDerGuteMoritz: lein and cake's install features are meant to install a jar created from a Clojure project's project.clj file.
18:41sjlthanks!
18:41dnolensjl: np
18:43DerGuteMoritzRaynes: I see - that's a little odd as at least on my installation the maven.org repository is included by default and it does indeed work through lein deps. cljr install javax.ws.rs/jsr311-api 1.1.1 also works though.
18:44RaynesDerGuteMoritz: I was wrong anyway. The lein install task works a little differently than the cake one now.
18:44RaynesSo, you have reason to complain, methinks. :p
18:45seancorfieldanyone using clojure.contrib.sql with SQL server or PostgreSQL?
18:45DerGuteMoritzRaynes: I was just surprised by that, not really complaining :-)
18:45seancorfieldi just pushed a fix for clojure.java.jdbc for generated keys which needs testing against those DBs... 0.0.3-SNAPSHOT
18:45DerGuteMoritzthe reason why I wanted that package in the first place is more complaint-worthy
18:47dnolensjl: yeah the issue is that a bit-shift-right on a negative number fills w/ 1
18:47sjlyep
18:47technomancyDerGuteMoritz: thanks for the bug report; just fixed it
18:47technomancyI don't think anyone's ever tried to use that task on a non-clojure project
18:47DerGuteMoritztechnomancy: oh, it was an actual bug? you're welcome then! :-)
18:48DerGuteMoritzok looks like I am way off common territory here so I might as well ask for advice, maybe I am doing something wrong
18:48Raynestechnomancy: Man, you should really let me know when you add functionality like that so that I can do the same for cake. Stop being competitive! <3
18:48DerGuteMoritzI'd like to construct an URI (well, URL to be more precise) from a given one
18:49DerGuteMoritzturns out that java.net.URI and URL are not quite up to that
18:49technomancyRaynes: changelog's that way =)
18:49RaynesI'm allergic to changelogs.
18:49DerGuteMoritzso I found out about javax.ws.rs.core.UriBuilder
18:50DerGuteMoritzwhich, judging from the API, looks quite promising
18:50DerGuteMoritzfirst question!
18:51DerGuteMoritzhow do I know from that reference page (which looks kind of official to me) that it is indeed not part of the standard Java distribution? http://download.oracle.com/javaee/6/api/javax/ws/rs/core/package-tree.html
18:51DerGuteMoritzor is my JDK version too old or something?
18:51technomancyDerGuteMoritz: IIUC "javax" means "not part of the JDK"
18:51technomancykind of like clojure.contrib
18:51DerGuteMoritza-ha!
18:51seancorfieldbtw, if anyone does want to test that, they'd need to pull from sonatype snapshots :)
18:52DerGuteMoritzthanks technomancy
18:52DerGuteMoritzso has anyone ever used UriBuilder?
18:53carllerchetechnomancy: Any idea how I might be able to have lein deploy use an s3 wagon? It seems that it requires setting build extensions in the pom file
18:54carllercheor is that something that would require writing a plugin for?
18:54DerGuteMoritzI am new to Clojure but the reference page has this example at the beginning: UriBuilder.fromPath("{arg1}").build("foo#bar"), which I converted into this hopefully idiomatic Clojure call: (. (UriBuilder/fromPath "{arg1}") build "foo#bar")
18:54technomancycarllerche: hmm... it could probably go in a plugin and/or future lein version
18:54DerGuteMoritzthis results in this interesting exception: java.lang.ClassNotFoundException: com.sun.ws.rs.ext.RuntimeDelegateImpl
18:55technomancycarllerche: pom entries usually correspond to pretty straightforward calls on the Model object, so often it's easy to translate to the Java API
18:55randotechnomancy, carllerche: specifically, the pom entry in step 1 of this: http://blog.anzix.net/2010/12/07/using-amazon-s3-as-a-maven-repository/
18:56DerGuteMoritzdoes that mean that the jsr311-api jar is missing a dependency perhaps?
18:57amalloytechnomancy: that's not accurate. javax.swing.*, for example, is part of the jdk
18:57DerGuteMoritz; just in case
18:57DerGuteMoritzhehe
18:57DerGuteMoritz!
18:57technomancyamalloy: huh; didn't know that.
18:57DerGuteMoritzthen what is javax? hm
18:57DerGuteMoritzJava + Chemical X
18:57RaynesIt means the developers got sick of typing 'java' and wanted to spice things up a bit.
18:58amalloyi think it's like..."stuff that not every deployment platform is required to have"? or "less stable"? i dunno
18:58DerGuteMoritzsearching the tubes for com.sun.ws.rs.ext.RuntimeDelegateImpl yields all kinds of results referencing something named "Jersey"
18:59Bronsahttp://mindprod.com/jgloss/javax.html
18:59carllerchetechnomancy: Alright, I will take a stab at writing a plugi
19:00technomancycarllerche: start a mailing list thread if you get stuck
19:00carllerchecool, will do, thanks
19:00technomancywill probably have 1.6 released in a few days, otherwise I'd consider putting it in leiningen itself
19:00DerGuteMoritzBronsa: thanks! why does that page contain a link to file:///J:/mindprod/jgloss/javax.html?
19:00BronsaDerGuteMoritz: i have no idea.
19:00Bronsajust found it on google
19:01DerGuteMoritzoh it seems to be some kind of offline cache
19:01carllercheha, well, i'll see if i can get it done tonight :P I have yet to dig into maven though... so we'll see
19:01technomancyif you want to do it in a fork of lein rather than a plugin that could work too; less messing with hooks that way
19:02technomancybecause that really should be built-in
19:02technomancybut then it won't work with older versions.
19:07DerGuteMoritzok, apparently I need an implementation of JAX-RS
19:07DerGuteMoritzany recommondations?
19:10DerGuteMoritzok, Jersey it is
19:56XPheriorCan anyone point me to a good place to learn lambdas? I couldn't find anything good on Google. Maybe I'm just blind.
19:56amalloyXPherior: new to functional programming? what other languages are you used to?
19:57XPheriorI've been trying out Lisp for a few weeks. I sort of understand functional programming. Used to Ruby, Python, Java, C#
19:57XPheriorFor the record, Clojure is the coolest thing I've seen in a while. It just gives me shivers looking at how idiomatic it can be.
19:58amalloyXPherior: don't python and ruby have lambdas? are you just looking for clojure's syntax?
19:59XPheriorEr, yeah. Looking for how it's done in Clojure.
19:59XPheriorSorry for not being clear.
19:59amalloy,((fn [x y z] (+ x (* y z))) 1 2 3)
19:59clojurebot7
19:59DerGuteMoritzXPherior: it's called `fn' in Clojure
20:00XPheriorWoah, evaluator bot. Cool.
20:00XPheriorWhy's a function definition called defn and a lambda fn, then?
20:00gfrlog`,(let [f (fn [x y] (- x y))] (+ (f 12 15) 9))
20:00clojurebot6
20:00XPheriorHa! That's brilliant.
20:00gfrlog`XPherior: "defn" sorta means "def fn"
20:01DerGuteMoritzXPherior: (defn foo ...) is short for (def foo (fn ...))
20:01XPheriorDoes that imply that all functions return functions?
20:01DerGuteMoritzClojure is a weird mix of Common Lisp and Scheme in that regard
20:01gfrlog`XPherior: no
20:02DerGuteMoritzXPherior: depends on what you mean by that :-=
20:02DerGuteMoritz:-)
20:02XPheriorDerGuteMoritz: Do all functions return a (fn ...) ?
20:02gfrlog`XPherior: do you understand the expression (def foo "bar")?
20:02DerGuteMoritzXPherior: no, `fn' constitutes a function, (fn ...) *is* a function
20:02XPheriorI think. It's a function named foo that's given a string "bar" parameter?
20:03DerGuteMoritznote the difference between def and defn!
20:03XPheriorMind boggling!
20:03XPheriorI don't think I quite got it.
20:03gfrlog`XPherior: no; it's a lot closer to setting a variable to a value like foo = "bar"
20:03amalloyDerGuteMoritz: i don't think your distinction between "constitutes" and "is" makes any sense
20:03XPheriorOh! Right. foo would be like a global, correct?
20:03amalloyright
20:03gfrlog`XPherior: sort of -- it's still qualified by whatever namespace you're in
20:03DerGuteMoritzamalloy: that's possible, I made that up :-)
20:04gfrlog`so not like a $global in ruby
20:04XPheriorOkay, wait. So if fn is lamba, what's the hash do?
20:04gfrlog`XPherior: syntactic sugar
20:04gfrlog`#(+ % 6) <=> (fn [%] (+ % 6))
20:04amalloy,'#(inc %)
20:04clojurebot(fn* [p1__72#] (inc p1__72#))
20:04XPherior,(reduce (fn + %1 %2) (range 100))
20:04clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.UnsupportedOperationException: nth not supported on this type: Symbol
20:04XPheriorAh D:
20:05XPheriorHm.. That's interesting
20:05amalloydemonstrations in #clojure: if you can still read it, there isn't enough punctuation
20:05DerGuteMoritzamalloy: wait, it makes a little sense. "constitutes" emphasizes the function of fn while "is" emphasizes the result of the expression, or something like that!
20:05XPheriorHaha
20:06gfrlog`,(#(% %) #(% %))
20:06clojurebotjava.lang.StackOverflowError
20:06amalloyDerGuteMoritz: whatever helps you sleep at night. if you said "constructs" instead of "constitutes" i might buy it
20:06XPheriorIs it correct to say the body of defn is always a fn, and the fn's result is returned?
20:06DerGuteMoritz("function of" not to be taken literally there)
20:07DerGuteMoritzamalloy: ok, let's say that instead!
20:07DerGuteMoritzXPherior: defn doesn't return anything, it binds a function to a name
20:07gfrlog`XPherior: (defn foo [x] (bar x)) <==> (def foo (fn [x] (bar x))) <~~> foo = lambda{|x|bar(x)}
20:07DerGuteMoritzhm wait, I haven't actually verified that
20:07gfrlog`DerGuteMoritz: I think it returns the var
20:08DerGuteMoritzI see
20:08DerGuteMoritzwell, but that's secondary anyway
20:10XPheriorOkay. So what's with all the wacky %s?
20:10amalloyXPherior: gfrlog` is just being a smart-ass
20:10XPheriorAh
20:10amalloybut when you use the #(...) syntax for a lambda, the paramters are implicitly named %1, %2, %3...
20:10amalloyand % is short for %1
20:10XPheriorBut even (fn [%] (+ % 6) uses it
20:10XPheriorAhh, cool
20:10XPheriorSo I can still do (fn[name age] (...)) if I wanted?
20:10amalloyright
20:10XPheriorThat's nice that I can still name arguments in anonymous function
20:10XPheriorFunctions* Keeps the code more understandable sometimes
20:10amalloyXPherior: in *that* context, % is just a symbol like any other. you could replace % with a, or with lkdfahfakf, or with -!$+
20:10XPheriorThat makes sense.
20:10amalloyonly in #(..) does it have special meaning
20:10XPheriorIronically, I really didn't want any documentation of lambas in Clojure.
20:10amalloyhaha
20:11XPheriorHmm
20:11XPheriorWhat's the purpose of the body being a fn?
20:11XPheriorI mean, why would we want that?
20:11amalloyXPherior: "the body being a fn" is something you keep saying that i don't understand
20:11XPherior(def foo (fn [x] (bar x)) ... (fn [x] (bar x)) <- I'm calling that the body
20:12XPheriorWhat would one call that?
20:12amalloydon't. call it the value
20:12amalloybecause def just assigns a value to a var
20:12DerGuteMoritzXPherior: in your example, (bar x) would be the body of the function actually
20:13amalloydefn does the work of turning the body into a function and then calling def
20:13XPheriorOkay. So def assigns a variable, fn is a lambda, and defn assigns a fn to a def'ed var?
20:13amalloyfull marks
20:13hiredmanexcept for the use of the word variable
20:14XPheriorWhat do Clojure people call it?
20:14amalloywe call it "oh god, please no, never let anything vary"
20:14DerGuteMoritzheh
20:14XPheriorHahaha
20:14gfrlog`unless you call def again
20:14hiredmanXPherior: def creates a var
20:14technomancyvaries-but-not-at-runtime-able
20:14DerGuteMoritzand var is not short for variable?
20:14hiredmanno
20:15DerGuteMoritzaha!
20:15XPheriorI really like this language. I hope I go far with it.
20:15hiredmana var is a specific thing with precises semantics, a variable is not
20:15amalloypresumably var was short for variable when it was named, but they are now two distinct concepts
20:16DerGuteMoritzas opposed to atoms and refs and whatnot?
20:16amalloyDerGuteMoritz: those aren't variables either
20:16DerGuteMoritzyeah
20:16gfrlog`well how do I get my hands on a damn variable then??
20:16DerGuteMoritzI mean err
20:16amalloyclojure doesn't have variables in the classic sense; just locals, which don't vary
20:17amalloyand reference types
20:17DerGuteMoritzyou have things like vars, bindings, refs and atoms which are lumped together as "variables" in most other languages
20:17XPheriorSo it's like Haskell in its emphasis on immutability?
20:17gfrlog`guess it's time to "lein new variables-clj"
20:17amalloyXPherior: a little less so
20:17amalloybut a lot more than scala, say
20:17DerGuteMoritzgfrlog`: I hear there are transients which are mutable
20:17amalloyor, god forbid, ruby
20:17XPheriorThink reading Programming Clojure is the quickest way to really learn the details of the language?
20:18technomancygfrlog`: there's with-local-vars, but you didn't hear that from me
20:18amalloyJoy of Clojure
20:18gfrlog`DerGuteMoritz: ah yes. So my library will just figure out how to make transients less restrictive
20:18XPheriorI kind of want to make an IRC bot in Clojure. Seems like an alright first project.
20:18amalloyXPherior: fork sexpbot or clojurebot
20:18technomancygfrlog`: *whimper*
20:18amalloy$whatis source
20:18sexpbotsource is http://github.com/cognitivedissonance/sexpbot
20:18gfrlog`:)
20:18amalloyclojurebot: source?
20:18clojurebotsource is http://github.com/hiredman/clojurebot/tree/master
20:18XPheriorThanks!
20:18DerGuteMoritzgfrlog`: why not use Scheme then ;-)
20:18gfrlog`DerGuteMoritz: clojure is the hipster language right now
20:19XPheriorI notice Clojure's author didn't write any books on it. Wonder why
20:19DerGuteMoritzgfrlog`: ah okay, I didn't know that was a requirement
20:19gfrlog`XPherior: he didn't have to?
20:19XPheriorIt's just kind of common, I guess.
20:19amalloybusy writing it, i imagine
20:19DerGuteMoritzby the way, on the clojars site there are no links to the project sites or upstream repositories, or am I mistaken?
20:19amalloyhe's done several good lectures, which are online
20:20gfrlog`"The Richness of Clojure"
20:20technomancyDerGuteMoritz: clojars needs help
20:20XPheriorI'll check those out.
20:20technomancythere's a list of "somebody needs to implement this please" features
20:20XPheriorAre there any good IDES for Windows other than Enclojure?
20:20technomancynobody's bothered yet
20:20gfrlog`VirtualBox?
20:20halfprogrammerBut he has released a bunch of wonderful videos :-)
20:20DerGuteMoritztechnomancy: cool, where is that list kept?
20:21halfprogrammerI mean Rich ^
20:21technomancyDerGuteMoritz: http://groups.google.com/group/clojars-maintainers/browse_thread/thread/d4149ec96316d5b1
20:21XPheriorDoes Rich ever come in here?
20:21gfrlog`yes
20:22gfrlog`it makes all but the most confident of us shut up for 30 minutes
20:22XPheriorHahah
20:22XPheriorI think Clojure is going to take my skills to the next level.
20:22technomancyif anyone is interested in hacking clojars, I've got an automated VM setup for hacking clojars that I'm working on
20:22technomancywill publish it soon
20:23technomancyit's a bit of a bear to config by hand
20:23gfrlog`clojars isn't a 30-line compojure app?
20:24cemerickXPherior: check out Counterclockwise for eclipse
20:24technomancygfrlog`: there's a bunch of scp-handing stuff necessary to handle deploys
20:24technomancygfrlog`: ~900 LOC
20:24gfrlog`technomancy: in clojure?
20:24technomancyaye
20:25gfrlog`that's respectable
20:25gfrlog`c.c.shell-out ftw
20:25technomancygfrlog`: no, scp *server* handling
20:26technomancycan't shell out for that
20:26gfrlog`it'd be fun to have a repl plugin where any command that throws an exception gets retried as a shell command
20:26gfrlog`s/command/expression
20:26gfrlog`sexpbot: botsmack
20:26gfrlog`worthless
20:27gfrlog`technomancy: I see.
20:27amalloygfrlog`: i remember someone trying to do that as a macro
20:28amalloybasically impossible for about ten reasons
20:28gfrlog`haha
20:28gfrlog`wait really?
20:28gfrlog`it sounds too easy
20:28technomancygfrlog`: eshell accepts shell commands and lisp in the same prompt
20:28DerGuteMoritzdoes anyone know of a maven repository that has Jersey 1.8?
20:28technomancyit's awesome
20:28gfrlog`technomancy: I bet
20:28technomancyapart from the lack of lexical scope, I mean. =(
20:29gfrlog`I once tried to write a macro that would allow any [sub-]expression to be in reverse order; THAT was impossible
20:29DerGuteMoritzlexical-let ftw :-)
20:29DerGuteMoritzgfrlog`: you mean a reverse polish notation macro?
20:29gfrlog`DerGuteMoritz: (defmacro with-dyslexia ...)
20:30scgilarditechnomancy: any way to compare the awesomeness of eshell with, say, the awesomeness of the piranhamoose?
20:30DerGuteMoritzhm
20:30technomancyscgilardi: that's hard! the piranhamoose is _pure_ awesome, whereas eshell is extremely awesome but not 100%.
20:31XPheriorcemerick: I'll check it out now.
20:31scgilardigot it, thanks.
20:31amalloygfrlog`: interesting. i would have guessed the "optional reversing" would be totally viable. what problems did you have?
20:31amalloyi mean, aside from compile times in the 2^n range
20:31gfrlog`amalloy: well the strategy would be to wrap every [sub-]expression in a try-catch, where the catch tries in reverse
20:31DerGuteMoritzthat's what I expected
20:32technomancyclojurebot: piranhamoose is unadulterated awesome: http://blog.howfastareyou.net/wp-content/uploads/2009/08/piranhamoose.jpg
20:32clojurebotOk.
20:32technomancyattaboy
20:32gfrlog`you could do that, but higher order functions might run in reverse-form as well
20:32gfrlog`maybe something about special forms as well? :/ I dunno, maybe it'd be halfway workable
20:33DerGuteMoritzooh, like that, I see. that's ambiguous then
20:33gfrlog`I guess you could do better than try-catch some of the time by resolving the symbol and seeing what it means
20:35gfrlog`...if it's even a symbol
20:37DerGuteMoritzjust make it a one character macro that reverses the current expression
20:37gfrlog`DerGuteMoritz: well the idea was that you could accidentally input things in reverse, so you wouldn't be indicating it explicitely
20:38DerGuteMoritzright but that's not possible
20:38DerGuteMoritzbecause of ambiguities
20:38gfrlog`so yes, redefining the goal does make it easier :)
20:39DerGuteMoritzor ... unintended reverse evaluation
20:39amalloyDerGuteMoritz: a risk you have to take when you're dyslexic. not a failing of the library
20:39gfrlog`(defmacro <> [& forms] (map reverse forms))
20:39amalloythings often work, but then sometimes for reasons you don't understand you have to manually reverse the order to make it work
20:40amalloysounds like dyslexia to me
20:40amalloygfrlog`: that is like 17 steps away from working
20:40gfrlog`((forms reverse map) [forms &] <> defmacro)
20:40gfrlog`maybe it'll work that way
20:41amalloyhah
20:41gfrlog`it can't be seventeen, it's more like 3
20:41amalloyyes, first step when defining a new macro: see if it's already included in the language
20:41gfrlog`I think it's two, but I said three just to be safe
20:41amalloyi'm choosing to count each irc message you send as a step in adjusting your thinking the right way
20:42gfrlog`I don't accept the rules of your game
20:42gfrlog`okay let's try my two fixes
20:43gfrlog`(defmacro <> [& forms] (list `do (map #(if (list? %) (reverse %) %) forms)))
20:43gfrlog`aw crap
20:43gfrlog`s/list/list*
20:43gfrlog`or s/list/cons
20:43amalloys/list*/cons
20:44gfrlog`list* in case I decide to put anything else in there :)
20:44amalloygfrlog`: you could do a good job of making it totally unreadable with postwalk-replace
20:44gfrlog`amalloy: but then I'd have to learn how to do that
20:45amalloyjust wrap the top-level form with (<> ...) and then you'll have a terrible time making anything work
20:45hiredman,(pl (↕map (replicate 3 (↕apply vector $ (↕map range $ 10 inc · inc · inc) call · ⌽* $ 10 · call · (⌽+ -2) map)) shuffle)))
20:45clojurebot([80 50 100 60 10 40 70 30 20 90] [80 90 30 60 20 100 10 50 70 40] [70 50 20 100 30 90 40 80 60 10])
20:45gfrlog`&(pl (↕map (replicate 3 (↕apply vector $ (↕map range $ 10 inc · inc
20:45sexpbotjava.lang.Exception: Unable to resolve symbol: pl in this context
20:46gfrlog`it's clojurebot voodoo
20:46amalloygfrlog`: (use 'clojure.walk) (defmacro <> [& args] (postwalk-replace reverse args))
20:46XPheriorThanks for your wonderful help everyone! You've been excellent. I shall be back!
20:46XPheriorGood bye.
20:46gfrlog`XPherior: bye
20:46gfrlog`amalloy: ahh -- that's different from mine too isn't it?
20:47amalloyquite
20:47gfrlog`reversing at all levels instead of top
20:47amalloyyeah
20:47gfrlog`I will submit a talk to clojure conj offering to compare and contrast the two approaches
20:48hiredman,(pl inc $ inc $ 1)
20:48clojurebot3
20:48gfrlog`hiredman: what's going on?
20:48hiredman,(macroexpand '(pl inc $ inc $ 1))
20:48clojurebot(do (inc (inc 1)))
20:49hiredmanI like to trot pl when people talk about crazy macros
20:49hiredmanpl out
20:49gfrlog`ah ha
20:49amalloyhaha
20:49gfrlog`very good
20:49amalloyoh, i read that as "pl out"
20:49amalloylike "it's done its job and it's leaving"
20:52gfrlog`alright fine I'll go mudge around in hiredman's github account looking for pl
20:53hiredman~functional
20:54clojurebotI don't understand.
20:54hiredman~pl
20:54clojurebotexamples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples
20:54hiredman~transform
20:54clojurebottransform is http://github.com/hiredman/odds-and-ends/blob/8a84e6ddbad9d71f714ba16c3e1239633228a7eb/functional.clj
20:56gfrlog`that kevin.clj is pretty weird
20:56gfrlog`maybe using emacs results in files like this...
21:03tomojgfrlog`: like what?
21:03gfrlog`tomoj: lots of functions mixed with expressions trying them out
21:04gfrlog`I think emacs lets you highlight stuff and eval it, so it makes sense of that
21:04gfrlog`I only use stone-age tools, so I don't know what it's like to have that kind of power.
21:04tomojnot exactly good to stick them in toplevel
21:04gfrlog`tomoj: I don't think it's serious code at all
21:04tomojbecause e.g. they might run on uberjar and stuff
21:04tomojsure
21:05tomojbut if one expression takes a long time to run and you C-c C-k (loads the entire file)
21:05tomoj...
21:05tomojbetter to stick those in (comment ) blocks
21:05tomojwhere they still work just as well for emacs
21:05tomojs/blocks/forms/
22:42symboleIs there a lazy http library for Clojure? I looked at clj-http, but it seems like it downloads entire files before returning.
22:51symboleclojure.contrib.http.agent seems to be what I want.
23:06mrnex2010are there functions to modify a fn, such as to add an arity overload to a fn?
23:08mrnex2010(im building an util to add arity overload to all the functions that use a fn that has been overloaded, all the way up to the functions that use it
23:08mrnex2010)
23:14symbolemrnex2010: I don't quite follow.
23:15symboleClojure has arity overloading, which is specified during function definition.
23:21mrnex2010symbole: sorry for the vaguity, what i meant was a function that returns a function with another arity
23:22mrnex2010overload
23:23mrnex2010i can do it inserting it into the function as a string, but i got curious if we had higher order fns that did that kind of stuff
23:23symboleYou can use macros to do that for you.
23:24symboleMake a macro that creates a function with however many params you want.
23:24amalloythis sounds like the sort of thing that doesn't need a macro, but it's hard to understand what the goal is. are you just reinventing partial?
23:25amalloyeg, maybe you could gist an example usage of your function and the desired result
23:25mrnex2010no, supose you have a fn with 2 params, another fn uses it, and yet another one uses the intermediate fn
23:26mrnex2010then you make an overload on the first
23:26mrnex2010but your fingers are too delicate to rewrite the other fns with overloads that reflect the overload on the first fn
23:27amalloymrnex2010: you're looking for like a refactoring tool that will add a default argument?
23:27amalloyor pass along an argument, i guess
23:28mrnex2010amalloy: yes a refactoring tool but not necesarilly a default arg but the arg that is added on a fn yes to pass it along
23:28mrnex2010sorry for the boraty writing on the prev line lol
23:29amalloyi see. on the one hand, i can see why that would be convenient. on the other, if you have N functions calling each other, and a change to function f requires a change in the api to all N functions, you're probably doing something wrong
23:30mrnex2010yeah i can imagine that stuff
23:30mrnex2010i just meant it for abstractions like the ones on SICP first chaps
23:31mrnex2010and hacking libs
23:36amalloyi don't think there's any nice way to do it. you could write a macro which wraps a defn, adds an extra arg to it, and is told what function to internally pass along that function to
23:36amalloybut i think it will be less readable and more work
23:37amalloy* pass along that arg to