#clojure logs

2012-09-03

00:02amalloytomoj: i think you get them mainly from git add
00:03dansalmois anyone here using light-table?
00:06RaynesSure
00:06Raynes~anyone
00:06clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
00:06RaynesUnless it isn't a question and you were just curious.
00:13tomojamalloy: huh, I wish it would do that for me (and for my coworkers..)
00:16amalloytomoj: check out apply.whitespace and core.whitespace at `git help config`, and also the --whitespace option to `git help apply`
00:16arohneroh, this is amusing
00:17arohner,(read)
00:17clojurebot#<ReaderException clojure.lang.LispReader$ReaderException: java.lang.RuntimeException: EOF while reading>
00:17arohnerhuh, that hangs my local repl
00:17amalloyarohner: known issue with (older versions of?) lein repl
00:18arohnerah, yes I am running an older version
00:18arohnerbut I'm doing lein swank
00:20amalloysame thing
00:20amalloyor maybe it's just swank? i forget
00:28dansalmoI find the insta-repl of lighttable very useful, but I can not figure out how to use the table
00:29tomojamalloy: yeah, no sign of anything about warnings on add
00:29amalloyyeah. i thought add replied on apply. but i guess only add -p does that
00:30tomojah
00:30tomojso I probably saw those warnings during rebase I bet
00:31amalloytomoj: i bet you can encourage coworkers to use add -p - it's so useful. and as a side effect they'll get warned about whitespace
00:45amalloyrare indeed is a commit from me that didn't involve git add -p at least once
00:52yankovwhen using constraints is it possible to just return a specific value instead of throwing an exception?
00:53Raynesdansalmo: What can't you figure out?
00:54tomojamalloy: I think I maybe can get one of them to use magit
01:14FrozenlockMy next goal in cljs will probably be to (try) make a graphical programming interface. Plug little boxes together... But before I paint myself in a corner, where should I store the block-functions? Directly in the DOM?
01:16emezeskeFrozenlock: Block-functions?
01:21FrozenlockKinda like this https://code.google.com/p/blockly/
01:24wmealing_dejavu, i remember something like squeak that had similar controls
01:24SegFaultAXIt's always a little strange to get a solution to a 4clojure problem, then see that one of the people that you follow got the same solution verbatim.
01:24wmealing_Frozenlock: before you write something please play with some of the current ones so you know what sucks and what doesnt
02:12SegFaultAXamalloy: Ping.
02:13amalloyheyo
02:13SegFaultAXamalloy: Are the 4clojure problems stored in mongo?
02:13amalloyyeah
02:13SegFaultAXamalloy: Is that db available somewhere?
02:13amalloyno, but most of the data is exposed via the API
02:14SegFaultAXamalloy: Oh sweet. Where can I read about the API?
02:14amalloythe source is pretty much it, i think. or check out lein-foreclojure or similar tools that use it
02:15SegFaultAXamalloy: Would you be willing to accept pull requests that extend the API to include fetching solutions for your account?
02:15amalloysure
02:15amalloyalthough i don't know how you'll do auth -sounds hard
02:15SegFaultAXamalloy: Actually, does fetching source need to be authed?
02:16amalloyhttps://github.com/4clojure/4clojure/blob/develop/src/foreclojure/api.clj is the only place we explicitly output json
02:16SegFaultAXamalloy: I mean, I can just follow someone to get the source to a problem.
02:16amalloywell, there's a checkbox to disable sharing solutions. i guess you could just have that also disable API-fetching of your solutions
02:18SegFaultAXThe unit tests aren't included in the API?
02:21amalloyhuh?
02:22SegFaultAXamalloy: Nevermind, I'm silly.
02:22SegFaultAX:)
02:23SegFaultAXFor some reason, I feel determined to be in the top 100 of 4clojure. I'm at 199 right now.
02:23SegFaultAXOf 8.6k
03:56kralnamaste
04:28john2xcan I do (case my-str "s" "S" (do-something))? execute do-something if my-str = "s" or "S"?
04:31tomojthat means (if (= my-str "s") "S" (do-something))
04:31emezeskejohn2x: case does not offer fall-through like a C switch statement if that's what you're after
04:31tomoj(case my-str ("s" "S") x y)
04:32clgv,(case "S" ("s" "S") true false)
04:32clojurebottrue
04:32john2xcool. thanks!
04:43spoon16What do you guys think of this idea? We use Gson a lot and I could not find an existing library that made it easily accessible from clojure. https://github.com/spoon16/gson-clj
04:44tomojhuh, I never knew keys worked on seqs ##(keys (concat {:a 1} {:b 2}))
04:44lazybot⇒ (:a :b)
04:45spoon16##(keys (into [] 1 2 3))
04:45lazybotclojure.lang.ArityException: Wrong number of args (4) passed to: core$into
04:45amalloytomoj: i think (keys m) is basically (map key m). ##(keys (concat {:a 1} {:a 2}))
04:45lazybot⇒ (:a :a)
04:45spoon16##(keys [1 2 3])
04:45lazybotjava.lang.ClassCastException: java.lang.Long cannot be cast to java.util.Map$Entry
04:46tomojinteresting
04:49samratin Noir how do I check whether a key(obtained from a form) is an integer or not?
04:50samratto use the key I do Integer/parseInt, but how do I check if a string has been passed?
04:50viloniswell, you could use regex to match an int. #'[0-9]+'
04:50vilonisi doubt that is the best way, but none the less
04:55clgvsamrat: you can compare the regexp approach with wrapping parseInt in a try-catch block and see what fits you more
04:56samratthanks, I'll try the checking with regex
04:57samrathttps://www.refheap.com/paste/4828 this defpage seems to work only after I refresh the page once, what did i do wrong?
05:00samratclgv: is there any way I can use a try-catch like I'd use if?
05:00samratI mean can I have it do something if an exception is thrown...like redirect to a page
05:00samratI tried that but didn't seem to work
05:01clgvsamrat: yeah. just put it in the catch part
05:01clgv,(try (Integer/parseInt "a456") (catch Exception e nil))
05:01clojurebotclgv: Huh?
05:01clgv&(try (Integer/parseInt "a456") (catch Exception e nil))
05:01lazybotjava.lang.SecurityException: You tripped the alarm! catch is bad!
05:02clgvhm ok the bot does not like it
05:06samratclgv: tried this https://www.refheap.com/paste/4829, doesn't seem to work
05:07clgvsamrat: should though. add some println statements to see what gets executed
05:09samratclgv: the catch part does get executed
05:10clgvsamrat: well, then there is probably no exception and it parses something
05:10clgv,(Integer/parseInt "12abc 34")
05:10clojurebot#<NumberFormatException java.lang.NumberFormatException: For input string: "12abc 34">
05:10clgv,(Integer/parseInt "12 abc 34")
05:10clojurebot#<NumberFormatException java.lang.NumberFormatException: For input string: "12 abc 34">
05:10clgvwell that should be the exception you get
05:10clgv,(Integer/parseInt "")
05:11clojurebot#<NumberFormatException java.lang.NumberFormatException: For input string: "">
05:24hiredmanclear
06:09hyPiRionHm, just so I'm certain: deftype is the way to go if you want objects with state, right?
06:09hyPiRion"objects"
06:10clgvhyPiRion: yes, if you want protocols + state
06:11clgvhyPiRion: but most of the time try defrecord since it has a map implementation which makes it much handier
06:11hyPiRionYeah, I know.
06:13clgvI used deftype for internal objects. defrecord was very handy for dataanalysis stuff
06:20stainsudop I thought defrecord was old-fashoined now
06:20stainsudo on irc
06:20stain:)
06:24clgvstain: nope, you get that wrong. defstruct is deprecated
06:30clgvhow can I require a (not yet loaded) namespace only once coordinated between all running threads?
06:35samratclgv: sorry, I was disconnected earlier. any ideas on the problem i was having(filtering off non-integer values passed to Noir)?
06:35clgvsamrat: did you try regexp and try-catch, yet?
06:36clgvsamrat: if regexp is not too slow I would stick with it
06:37samratclgv: i couldnt make regexp work
06:37clgvsamrat: there is a lot of info on that online. just search for java and regexps
06:39samratclgv: this is what I tried https://www.refheap.com/paste/4832
06:39samratalso tried with #"\d+"
06:40clgvsamrat: are you sure that should be written at that position of defpage? I only knew slightly older versions of noir, but there that would be wrong
06:41clgvor maybe I didnt know that feature. you should definitely check the docs on that
06:42samratclgv: http://webnoir.org/tutorials/routes, towards the end of the first section
06:43clgvsamrat: well your defpage route does not contain :minutes - so it cant work like described
06:44clgvyou should use [:get ["/read/:minutes" :minutes #"\d+"]]
06:47samratclgv: but where do I point my form-to now?
06:48clgvsamrat: concluding from that page I'd say you have to define a route that matches the complement of the current
06:49clgvor you use the pre-route functionality
06:50samratclgv: could using POST be of help?
06:51clgvsamrat: why should it?
06:52samratclgv: don't why I thought that, but didn't work anyway
06:53clgvsamrat: I would just use these pre-routes if you want to do some parameter checking and redirect on mismatch
08:17samrathow do I compare two exceptions for equality, one is https://www.refheap.com/paste/4833 and the other is expected to come from a try-catch block
08:18samratI need to find out if the two are same
08:18Chousukeuse identical? maybe. if you are sure they will be the same object
08:18Chousukebut I'm not sure what "equality" means for exceptions
08:19samratChousuke: I meant if it was the same exception
08:19nz-samrat: typically you would compare exception types and some data carried by the exception
08:20clgvsamrat: uh, what do you really want to do?
08:20noidimaybe (= (class e1) (class e2)) ?
08:20noidiif you want to see if they're both exceptions of the same type
08:20samratclgv: actually the same problem as before, filtering out string from Noir GET requests
08:20samratpre-route seems to give some solution, so trying that
08:21clgvsamrat: why do you want to compare exceptions then? that does not make much sense
08:22samratclgv: I'm getting exceptions for both strings and numbers, but they're slightly different
08:23clgvsamrat: well, usually you would handle them in the catch block or re-throw them. usually, you dont compare exception objects.
08:24samratclgv: not sure how I would handle them in the catch block
08:25clgvsamrat: well, explain the big scope. you want to render an error page, or what?
08:25samratno, redirect it to "/"
08:25clgvthen put the code for it in the catch block^^
08:26samratclgv: yes, but I get java.lang.NumberFormatException for both cases
08:26clgvsamrat: for which cases?
08:26samratfor when i pass a number and a string
08:27clgvinput, function called, expected output, error?
08:29samratclgv: passing no. of minutes via a GET request, works fine when I pass a number but I get an error when I pass a string(which is obvious), so I need to catch when a string is passed and redirect the user to the index page
08:30clgvsamrat: whats your current code?
08:33samratclgv: https://www.refheap.com/paste/4834
08:33samratthats the pre-route
08:35clgvsamrat: so why dont you just put the redirect-form in the catch block?
08:36samratclgv: for some reason, I get an exception when a number is passed too
08:36clgvsamrat: then I would check why that happens, since it shouldnt
09:23firesofmayHi, what is the right way to create a directory from clojure?
09:25algernonfiresofmay: I'm using fs/mkdirs (where fs == github.com/Raynes/fs)
09:26firesofmayalgernon, okay checking. thanks.
09:27algernonbut if you don't want an external dependency, then something like (.mkdirs (clojure.java.io/file path)) should work too.
09:28algernon(fs does have a few advantages, though)
09:28firesofmayalgernon, oh okay. and How do I find out what to add in my project.clj? Normally projects lists what to add such that it'll add itself from clojars. ?
09:28firesofmayalgernon, like for example?
09:29algernonas for project.clj: [fs "1.3.2"] - I got that by trial and error. Looked at the latest tag, and tried it like this, worked :P
09:30firesofmayalgernon, found it : http://clojars.org:8002/fs
09:30firesofmay:)
09:30algernonfs' advantages include better handling of cwd
09:30firesofmayalgernon, okay looks good to me :)
09:31algernonand fs/mkdirs is shorter than the other :)
09:31firesofmayalgernon, :)
09:34firesofmayalgernon, mailed the author of fs to add clojars version to readme page. so that others who see that library don't do "trial and error" like us ;)
09:35firesofmayalgernon, for?
09:36algernonfiresofmay: fs, to update the readme.
09:37firesofmayalgernon, Already mailed him. But good point. I am new to OSS. so learning :)
09:37firesofmayalgernon, will do that next time :)
09:45xeqi_ato: ^ should :8002 be publically accessible? it bypasses the nginx frontend
10:00xeqi_ato: ohh, right. its accessible so we can test the backup server on updates before fully moving ot the new version
10:24mindbender1 is there any library I could use to obtain a tree view in clojurescript?
10:26uvtcalgernon: re. figuring out what goes into your project.clj for a given project, the clojars page always shows that.
10:27algernonuvtc: yes, but that requires me to find it on clojars too, as opposed to just looking at the github project. I don't like searching two places when one should be enough.
10:27algernonuvtc: (I do go to clojars if a quick & dirty trial&error does not have the expected result)
10:27vijaykiranmindbender1: I think goog.ui has a tree control
10:28uvtcalgernon: At the [Dining Car](http://www.unexpected-vortices.com/clojure/dining-car.html), all links to projects point to their canonical Clojars page.
10:28vijaykiranmindbender1: http://closure-library.googlecode.com/svn/docs/class_goog_ui_tree_TreeControl.html
10:28algernonuvtc: that's good enough too
10:28mindbender1vijaykiran: thanks
10:29algernonuvtc: I still prefer if the projects' README itself points me to the right direction, be it a clojars link or a copy & pasteable leiningen :dependencies entry
10:30uvtcalgernon: I like using Clojars because it's getting the info right from the horse's mouth: that is, that's where lein gets the artifact from. :)
10:31uvtc(lazy-seq algernon) ;)
10:40john2xdoes (eval) not use the current namespace?
10:49gfredericksjohn2x: looks like it does to me
10:49gfrederickswell
10:49gfredericks"current" can be counterintuitive
10:51gfredericksit's based on the value of *ns* at the time eval is called
10:51gfrederickswhich is independent from the value of *ns* at the time that the function that calls eval was compiled
10:52gfredericksif you want to force a particular namespace at the point where you're calling eval, you can wrap it in (binding [*ns* <something-or-other>] (eval ...))
11:47DaoWenI remember reading (or maybe hearing in a webcast) somewhere that Clojure doesn't have built-in pattern matching (like in Racket) because the conditional aspect of pattern matching is bad, and instead Clojure has non-conditional destructuring. Is there anywhere I can go and read (or listen) more about the rational behind why conditionally matching is considered bad?
11:49wmealing_bad, is such a strong word
11:49wmealing_it could be slower, if that is what you mean
11:52DaoWenno, I'm pretty sure I watched a webcast thing where Rich said he doesn't like pattern matching because he doesn't like the conditional part of the destructuring, but I don't think he really elaborated on it in that particular webcast
11:52gfredericksI've heard pattern-matching poopoo'd for being closed
11:52gfredericksparticularly when discussing things like predicate dispatch
11:53DaoWenwhat do you mean by "being closed"
11:53DaoWen?
11:53SgeoDaoWen, once you make a function that uses pattern matching, you can't add onto the function later
11:53DaoWenOK, so the idea is that in simple cases destructuring should suffice, and in more complex cases multimethods are a better, more extensible option?
11:54SgeoI think the idea is that there are better options out there, we just need to work on them. But I might be wrong
11:54Sgeo(better than multimethods and pattern matching)
11:55DaoWeninteresting
11:55DaoWenthanks
11:57DaoWenis it possible to "extend" a multi-method? e.g. I have a base multi-method that covers some cases, then I want to add a few more cases in some (but not all) contexts. would I need to duplicate all the original code to do this, or is there an easy way to "extend" it while keeping the original intact as well?
11:59jcromartiewell, this was much easier than I thought it would be
11:59jcromartiehttps://gist.github.com/3610244
12:03DaoWenoh sweet, thanks
12:03DaoWenwait, was that in response to my question?
12:04DaoWenit doesn't look like it was :-p
12:05DaoWenoh well, I have to sign off—bye
12:06jcromartiehah hah, sorry
12:16tolsenHello. I'm using nrepl with nrepl.el in emacs. I think I may have messed up the state of my repl with memoization. Is there an easy way to kill my nrepl instance? I've been quitting emacs and killing java for now.
12:18uvtcWhat was the old clojure.contrib.def `defvar` for?
12:18nbeloglazov$clojuredocs defvar
12:18lazybotclojure.contrib.def/defvar: http://clojuredocs.org/v/31; clojure.contrib.def/defvar-: http://clojuredocs.org/v/25
12:18algernontolsen: killing the buffer usually
12:19algernon*usually fixed things for me.
12:19nbeloglazovuvtc: weird macro
12:20uvtcnbeloglazov: thanks. From looking at it's mention at http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go , looks like maybe it was mainly for the docstring.
12:20nbeloglazovuvtc: seems so
12:21tolsenalgernon: I kill the buffer and I still see the java process running. If I jack in again, now I have two java processes. oh well, killing the buffer and java is better than killing emacs and java
12:28xeqitolsen: kill *nrepl-server*
12:29tolsenxeql: that works. thanks!
13:34SegFaultAXIs it possible to eval something in a context? Like if I want to eval '(+ a b) in a context where a and b are bound to something meaningful, how could I do that?
13:34dnolenSegFaultAX: eval doesn't work w/ locals if that's what you mean.
13:34SegFaultAXdnolen: So what am I looking for?
13:35dnolenSegFaultAX: it's just not possible.
13:35gfredericksSegFaultAX: you can wrap your form in a let
13:35SgeoSegFaultAX, I think you're looking for the Kernel programming language?
13:35gfredericks(eval (list 'let '[a 2 b 3] my-code))
13:36SegFaultAXgfredericks: That's easy enough.
13:36nDuffSegFaultAX: ...do a and b have to be locals? It's a whole different story if they can be vars.
13:36SegFaultAXnDuff: With "binding"?
13:36gfredericksSegFaultAX: if you want to use something other than literals you'll have to be slightly more fancy with the vector
13:36SegFaultAXgfredericks: Nope, just literals.
13:37dnolenSegFaultAX: as nDuff said, if you're not trying to capture locals then you can probably get something that works for you.
13:38SegFaultAXHmm, this doesn't work &(binding [a 1 b 2] (eval '(+ a b)))
13:39SegFaultAX,(binding [a 1 b 2] (eval '(+ a b)))
13:39clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
13:39gfredericksSegFaultAX: they have to be vars to use binding
13:39SegFaultAXgfredericks: But is binding what I'm looking for?
13:39gfredericksSegFaultAX: you can use my let idea if you don't need vars
13:39gfredericksI think locals are cleaner than vars
13:40SegFaultAXIf I don't have to modify the form I'm going to eval, that would be ideal.
13:41gfredericksSegFaultAX: I could whip up an eval-let macro that would make it even cleaner
13:41SegFaultAXgfredericks: What would that look like?
13:41gfredericksoh you mean "modify" as in wrapping it in a let?
13:41SegFaultAXgfredericks: Yea nevermind, I don't wrapping it.
13:42gfredericksSegFaultAX: you could say (eval-let [a 3 b (+ a 10)] some-code)
13:42SegFaultAXgfredericks: That would be awesome!
13:42gfredericksgive me 75 seconds
13:43SegFaultAXWhat's the easiest way to turn a map into a vector?
13:43gfredericksdepends on what you want
13:43gfredericks,(vec {3 4 5 6})
13:43clojurebot[[3 4] [5 6]]
13:43SegFaultAX,(apply concat (vec {3 4 5 6}))
13:43clojurebot(3 4 5 6)
13:44gfredericksSegFaultAX: any destructuring or interdependence between the locals you're creating?
13:45SegFaultAXNope.
13:45gfredericksokay that makes less I have to think about :)
13:45gfredericksoh man writing a macro that does eval is like writing a macro macro
13:46SegFaultAX:)
13:47SegFaultAXgfredericks: Don't worry about it if it's too much trouble.
13:47gfredericksno it is fun
13:49gfredericksSegFaultAX: https://gist.github.com/3611284
13:50gfredericksI think it works fine with destructuring
13:51gfredericksbut not interdependence
13:55gfredericksoh also you don't have to worry about the distinction between literals and non-literals
14:02SegFaultAXgfredericks: Sorry, stepped away for a minute. Looking now.
14:03gfredericksI can also imagine a different macro that uses the locals currently in place
14:04SegFaultAXgfredericks: Wow, this is awesome. Thanks!
14:06hyPiRiongfredericks: you monster.
14:22hyPiRionHey, what's the preferred way of handling command line arguments? I noted that there was a clojure.contrib-library on it before, but they are surely deprecated.
14:23hyPiRionokay, nevermind - My google-fu isn't that great today.
14:23Frozenlo`https://github.com/clojure/tools.cli
14:23Frozenlo`aw
14:24arrdemyeah Frozenlock got the last thing I used..
14:25hyPiRionFrozenlock: Yeah, I got to that too.
14:25hyPiRionThanks anyway.
14:25hyPiRion:)
14:31FrozenlockAny library for engineering units manipulation?
14:37technomancyFrozenlock: there's that frink port
14:40FrozenlockI guess this is https://github.com/martintrojer/frinj :)
14:40FrozenlockLooking now, thanks!
14:40Frozenlockhttp://onclojure.com/2010/03/23/computing-with-units-and-dimensions/ is also really promising
14:49uvtcI'm trying to use clostache with a templates/foo.html template. Within my code I've got `(render-resource "templates/foo.html" {...})`, but am getting the following exception:
14:49uvtcjava.lang.IllegalArgumentException: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil
14:51uvtcThe top of the stack trace (up to where `render-resource` is called) looks like this: https://www.refheap.com/paste/4848
14:52uvtcAnyone have any ideas what might be causing that?
15:01xeqiuvtc: does "templates/foo.html" exist?
15:01xeqiusually I see that when the file can't be found
15:01uvtcxeqi: Yes. And if I intentionally misspell the filename, I get the same error.
15:02uvtcThe clostache `render` function works fine for me.
15:03xeqidoes (clojure.java.io/resource "templates/foo.html") throw the same exception?
15:05uvtcxeqi: No. In my repl, if I run that I get nil back.
15:06jeremyheilerThat's the problem, then. For it's trying to call make-reader with a nil argument.
15:08jeremyheilerAlthough passing nil into make-reader gives me a differently worded exception message. (using 1.4)
15:09uvtcI'm using 1.4 here.
15:09xeqiuvtc: is this a lein project w/ default resource-paths ?
15:10uvtcxeqi: It's in a fresh `lein new compojure myproj` project.
15:10xeqiwhats the path from project root to foo.html ?
15:12uvtcmy code is in src/myproj/handler.clj
15:12uvtcSo, that's myproj/src/myproj/handler.clj
15:12uvtcAnd the templates are just in a directory I made: myproj/templates/foo.html
15:13uvtcBut I've tried `(render-resource "../templates/foo.html" {...})`
15:13uvtcand `(render-resource "../../templates/foo.html" {...})`
15:13xeqimove it to resources/templates/foo.html
15:13pandeiroi'm trying to debug compojure routes while running jetty via nrepl.el but for some reason (println) doesn't output anything. Any guesses?
15:14xeqipandeiro: anything in the *nrepl-server* buffer?
15:14uvtcxeqi: Thanks for the suggestion, but I get the exact same exception and stack trace.
15:15pandeiroxeqi: yikes, tons of stuff
15:16uvtcxeqi: Wait!
15:16uvtcxeqi: Works. That fixed it.
15:17xeqipandeiro: heh, I think there is a fix in master to make it go to the buffer with the prompt, but you can find it there for now
15:17uvtcxeqi: Thanks so much. :) Why does it insist on having things in a resources directory?
15:17pandeiroxeqi: yes wasn't expecting that, thanks
15:18jeremyheileruvtc: io/resource expects things to be on the classpath, and resources/ is on the classpath by default i think.
15:19uvtcAh. Thanks, jeremyheiler . So, maybe `lein new compojure myproj` should also create a "resources" dir in the project.
15:19jeremyheilerIt's configurable with the :resource-paths options in project.clj
15:20jeremyheilerYeah, maybe.
15:36SgeoI was just looking at #clnoobs and someone was talking about why you shouldn't modify literal objects. I take it that that's a non-issue in Clojure because literal objects aren't modifyable?
15:36SgeoAlthough, I wonder if there might be some that are, such as literal deftype sort of things
15:37mvidany idea why I wouldn't be able to resolve the symbol "catch" in this code? http://dpaste.com/795826/
15:37nDuffSgeo: One still runs into mutable objects when working with Java interop
15:38chouserBut there's no literal format for those, generally, just ctor syntax.
15:43jeremyheilermvid: What's the actual error?
15:43mvidException in thread "main" java.lang.RuntimeException: Unable to resolve symbol: catch in this context, compiling:(credits/foursquare.clj:46)
15:43mvidwhen i run lein test
15:44djanatynTIL about the partial function :)
15:44djanatynhooray for currying!
15:44mvidjeremyheiler: it fails in compilation
15:45djanatynwhen is it appropriate to use partial, and when is it not?
15:46chousermvid: That usually shows up when there are parens missing or in the wrong place, but that doesn't appear to be the case there. You're sure that's the snippet that's failing?
15:46mvidthat is what the output is, but it might be somewhere else. thanks for the tip
15:47mvidis it better to use :require or :use ?
15:48uvtcI like :require, sometimes with :refer.
15:48emezeskemvid: Generally speaking, :require is preferable, as it will never cause problems when e.g. two namespaces contain the same symbol
15:49uvtcmvid: ^^
15:54rbxbxAnyone have thoughts on the `motivate` technique described here (http://bjeanes.com/2012/09/motivate-your-lazy-sequences) ?
15:55rbxbxDoes seem like their should be a built-in for this pattern, or are there reasons you might not want to do this?
15:56hiredman,(doc seque)
15:56clojurebot"([s] [n-or-q s]); Creates a queued seq on another (presumably lazy) seq s. The queued seq will produce a concrete seq in the background, and can get up to n items ahead of the consumer. n-or-q can be an integer n buffer size, or an instance of java.util.concurrent BlockingQueue. Note that reading from a seque can block if the reader gets ahead of the producer."
15:58rbxbxhiredman that's in response to my query?
15:58rbxbxseems to fit the bill.
16:03gfredericksoh man that was my fault
16:10rbxbxhaha, gfredericks you caused a blagging :(
16:10rbxbxthx hiredman :)
16:12rbxbxgfredericks at least it was an opportunity to learn. Built-ins are good for production code, but figuring things out yourself is nice too :)
16:19gfredericksrbxbx: it true
16:25l1xhey
16:25gfredericks~hey
16:25clojurebotwhat's up <from>
16:26l1xhow could i remove an element of a set? this does not work -> (remove "bog" ("bog" "cog" "dog" "fog" "gog"))
16:26gfredericksdisj
16:26gfredericksbut that's a list there
16:26Raynesxeqi: ping
16:26gfredericks,(remove #{"bog"} ("bog" "cog" "dog" "fog" "gog"))
16:26clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>
16:26Raynesxeqi: With my clojail changes, code that used to timeout after 15 seconds runs in 38 milliseconds.
16:26gfredericks,(remove #{"bog"} ["bog" "cog" "dog" "fog" "gog"])
16:26clojurebot("cog" "dog" "fog" "gog")
16:26Raynesxeqi: Was it worth the wait? :D
16:27l1xi see
16:27l1xthanks
16:27gfredericksRaynes: you deleted the Thread/sleep calls?
16:27Raynesgfredericks: Lol, yeah, tots.
16:28gfrederickswe do that every week at work. we're thinking of researching whether or not we could build a script to do it.
16:28RaynesBut for real, clojail just accumulated a lot of cruft. I've rewritten the whole tester implementation now.
16:29gfredericks##(/ 15 0.038) speedup is a lot of cruft
16:29lazybot⇒ 394.7368421052632
16:29xeqiRaynes: always worth the wait for you
16:30xeqiis lazybot updated?
16:31firesofmayCan anyone tell me why is Promise called as "Promise"? What is the context? I understand (a bit) what they do. But I am trying to understand the reason to name it that way.
16:33weavejesterfiresofmay: You're promising to assign it a value at a later date.
16:34firesofmayweavejester, ah okay. and future is like this function call will return its value sometime in future. Am I correct?
16:35gfredericksa future is like a promise where you give it the computation to produce the result at the same time you create the future itself
16:36weavejesterfiresofmay: Yes… but more precisely, what gfredericks said :)
16:36gfrederickspromises decouple that; you create a promise without saying anything about who computes its value or how
16:36weavejesterA future is essentially a promise + a calculation in a background thread that fulfills the promise.
16:36firesofmaygfredericks, ah that clears the difference.
16:36firesofmayweavejester, now I got it :)
16:37dansalmoIs there a function that will remove outer list containers until reaching the innermost list without losing any elements? such as (wtf? '(((xz) yz))) => ((xz) yz) , (wtf? '((xz) yz)) => ((xz) yz)
16:37gfredericksgo and do great things
16:37gfredericksdansalmo: doubt there's a built-in for it
16:37firesofmaygfredericks, someday, someday.. :)
16:37gfredericksbut easy to define yourself
16:38dansalmoSo I must itterate until count > 1?
16:38weavejesterYeah, basically just a reduce
16:38gfredericksweavejester: I'll bet you $.49 you can't reduce that
16:40weavejesterI guess it wouldn't be a reduce, now that I think about it, but now you've said that I want to write it using reduce :)
16:40gfredericksI think the only reasonable thing is loop
16:40gfredericksor iterate
16:40weavejesterYeah...
16:41gfredericks,(first (drop-while #(and (sequential? %) (= 1 (count %))) '(((x z) yz))))
16:41clojurebot((x z) yz)
16:41gfrederickswait that doesn't have iterate in it
16:41gfrederickswhat did I just do
16:42weavejesterYou could clojure.walk it and then find the first element that has a rest
16:42gfredericksoh my input didn't match his; I was wondering how the heck it came out different
16:43gfredericks,(first (drop-while #(and (sequential? %) (= 1 (count %))) (iterate first '((((((xz) yz))))))))
16:43clojurebot((xz) yz)
16:43Raynesxeqi: No.
16:43weavejester,(clojure.walk/prewalk identity '(((xz) yz)))
16:43clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.walk>
16:44gfredericksI always feel icky about making iterates that will crash if you walk them too far
16:44gfredericks&(clojure.walk/prewalk identity '(((xz) yz)))
16:44lazybot⇒ (((xz) yz))
16:44gfredericksweavejester: I doubt there's any natural walk solution either
16:45weavejesterWhat about...
16:45casionis there any other way to stop clojure from promoting types other than littering my code with (unchecked-int )
16:46Raynesxeqi: Could you PM me a bit of code that fails the current sandbox? Preferably one line.
16:46gfrederickscasion: is this about the byte-wrangling?
16:46casiongfredericks: yep
16:46casionstill having issues with clojure constantly promoting signed ints to longs
16:46gfredericksI'm convinced there's got to be something simpler than playing with primitive types
16:46Guest88912guile
16:46gfrederickssigned ints now?
16:47casiongfredericks: I get fed signed or unsigned 2,3,4 byte values in big or little endian :|
16:47casionand I'm tyring to use ByteBuffer to deal with this in a reasonable way
16:47gfrederickscasion: through what kind of interface?
16:47casionbut clojure is constantly promoting negative ints to longs
16:48gfredericksdoes the jvm expose any endiannesses?
16:48casiongfredericks: audio files, via javax.sound.sampled
16:48casiongfredericks: yes, I get that information and store it in a map with other data and the byte stream
16:49weavejesterHm, maybe a loop would be simplest :)
16:49gfredericks~hurray
16:49clojurebot\o/
16:51gfrederickscasion: what's the signature of the method wherein you actually read data? returns a byte?
16:52casiongfredericks: I get 'frames' containing an array of bytes, which I have to split by the number of channels then convert to signed int or float
16:52casionif I was dealing with just 16, 32 and 64bit values. everything would be peachy
16:53casionbut I have to support 8, 12 and 14 as well
16:53gfredericksoh you're talking about endianness regarding the order of bytes within larger words
16:53casionyes
16:53gfredericksI got distracted thinking about the order of bits within bytes
16:53casionI should have been a bit more clear about that, sorry
16:54gfredericksalthough if you have numbers that cross byte boundaries like 12-bit I guess you might have to worry about that anyhow
16:56casionif I could get clojure to just not promote types, ByteBuffer works great
16:57casionI still have to handle a few cases manually, but it's better than writing 20 functions for the strange format combinations
16:58gfrederickscasion: I assume you know about primitive type annotations right?
16:58casionyeah
16:58casionthat's what I just started messing with now
17:01dansalmogfredericks: thanks for the code solution to my question.
17:03gfredericksdansalmo: ##(loop [x '(((((bf) uh))))] (if (and (sequential? x) (= 1 (count x))) (recur (rest x)) x))
17:03lazybot⇒ ()
17:03gfredericksw00ps
17:04l1xis there a way to replace the nth character in a string without using the setCharAt from java?
17:05dnolenl1x: yes but it's less straighforward that setCharAt.
17:05l1xthe only thing i can think of is to deconstruct the string and use the replace-first
17:06l1xand build it up again
17:06gfredericksdansalmo: ##(loop [x '(((((bf) uh))))] (if (and (sequential? x) (= 1 (count x))) (recur (first x)) x))
17:06lazybot⇒ ((bf) uh)
17:06gfredericksyeah that's it
17:07dnolenl1x: Clojure strings are Java strings, what's the problem w/ using setCharAt?
17:07l1xdoes that work when you are running your code on .net clr?
17:08dnolenl1x: I doubt it but that's a problem Clojure hasn't committed to solving.
17:09l1xi see
17:13dnolenl1x: there's been some talk of CL-like conditional compile - upon which platform generic string ops could be built but it's near clear such a lib would even make it into core.
17:13l1xyeah
17:13l1xcool
17:16emezeskel1x: I have a conditional-compile lib called prism, but it doesn't support CLR yet
17:17emezeskel1x: It's pretty much a hack, but it works fine for jvm vs js, and I'm sure it would work fine with CLR with some small changes
17:17l1xnice
17:18emezeskel1x: Basically you'd have to find some way to tell, from a macro, that it's running in the CLR environment
17:18emezeskel1x: that's the hack part :)
17:18l1x:)
17:18emezeskeSadly, there's no standard clojure.core/*platform*, or it would be dead-easy
17:18l1xreminds me of some autconfigure hacks on unix
17:18emezeskeYeah, very similar (unfortunately)
17:23dnolenl1x: http://dev.clojure.org/display/design/Feature+Expressions
17:25l1xi see, thanks
17:25l1xi just would like to rewrite this -> (let [sb (StringBuilder. word)] (for [altc alphabet] (str (doto sb (.setCharAt 1 altc)))))
17:26l1xto a clojure only implementation
17:26l1xi guess it is possible ti recur
17:26hyPiRion$javadoc StringBuilder
17:27lazybothttp://docs.oracle.com/javase/6/docs/api/java/lang/StringBuilder.html
17:27l1xhttps://gist.github.com/3613696
17:27l1xi got this far
17:28hyPiRionWhy would you like to do a (.setCharAt 1 ...) multiple times?
17:28l1xsorry it is just a debug line, in the function it is using an index
17:29hyPiRionokay.
17:29ToxicFrogIs there a recommended library for dealing with character encodings in clojure?
17:29ToxicFrogAutomatically skipping BOMs, for example?
17:29l1xnow the tricky part is to decompose the string to first & rest and recur on the function and return the first + rest where the rest has the first character replaced
17:30dnolenl1x: are you planning on having it run on the JVM & CLR?
17:30l1xwell, i would like to write the way that i dont need to worry about that
17:32dnolenl1x: if you're not going to actually use both platforms then I wouldn't bother. If you are, probably more productive to weigh in on Feature Expressions.
17:34l1xdnolen: i am pretty close, the only problem i dont fully understand recur yet and I am not sure how to build a return []
17:37dnolen,(apply str (assoc (into [] "foo") 2 \r))
17:37clojurebot"for"
17:38dnolenl1x: ^ but grossly inefficient, as well as whatever it sounds like you are working on. Perhaps that doesn't matter for your application. But I as I've already said, I wouldn't bother, use setCharAt
17:38l1xthis is just a learn2code in clojure, i dont care about performance at all. in real project i always use the java calls cause we are working on JVM
17:39dnolenl1x: ah then go for it ;)
17:39l1xhttps://github.com/l1x/euler/blob/master/src/euler/core.clj#L94
17:39casionis there any way to process all-but the last item in a seq with map-indexed withouth using something like butlast?
17:40casionI thought about comparing the index to count inside the map, but that also seems inefficent
17:40dnolencasion: why do you want to avoid butlast?
17:40gfredericksif the collection isn't Counted then I assume anything would be equivalent to butlast
17:41casiondnolen: linear time
17:41dnolencasion: but you're already using map-indexed
17:41casionyes, and I don't want to incur that cost twice
17:41dnolencasion: map-indexed and butlast are both lazy
17:41casionif I can avoid it
17:42gfredericksreducers!
17:42dnolencasion: oops
17:43casionoops?
17:43dnolencasion: I thought butlast was lazy
17:44gfrederickscasion: pulling something off the end of a seq is always going to be linear, if you want better than that you'll have to back up to wherever the seq came from and get something smarter
17:44casiongfredericks: ok
17:45dnolencasion: though still for your purposes map-indexed + butlast is still one traversal.
17:45dnolen(butlast (map-indexed ...))
17:46casionwell, I'm writing this silly byte-array value getter to handle buffer sized 1/2/4/8
17:46casionand I came up with (reduce + (map-indexed #(bit-shift-left (bit-and %2 0xFF) (* % 8)) val)
17:47casionexcept the last value shouldn't be & 0xff
17:47casionso maybe there's another solution I'm missing
17:48gfredericksis %2 supposed to be a byte?
17:48casionyes
17:48casion% index, %2 byte
17:48gfredericks(bit-and %2 0xFF) actually does someothing?
17:49casionyes, it unsigns the value
17:49casionthat above is assuming little-endian btw
17:50casionso if fed a byte-array of [0xd9 0xfe 0xFF], it should output -295
17:50gfrederickswell arrays are counted
17:51casionbut the last value has the sign, so & 0xff blows that… so you just shift that by itself
17:51gfredericksI assume (count some-array) is constant
17:51gfredericks(but it might not be; it just could be)
17:52casionI have something like (reduce + (map-indexed (fn [idx itm] (bit-shift-left (if-not (= idx count) (bit-and itm 0xff) itm) (* idx 8))) val))
17:52casionand that works, but I'm not sure how clojure handles that conditional
17:52gfredericksnot sure how clojure handles it?
17:52gfredericksyou compute count outside the thing right?
17:52casioncorrect
17:53gfredericksso what's ambiguous about that?
17:53casionthat above is slower than butlast it seems :|
17:54gfredericksif you're worried about speed you might just use loop
17:55casionthat seems like it'd be the same?
17:55gfredericksI think it could be faster for less function calls
17:56casionI'd still have to compare every value against the index, or use butlast wouldn't I?
17:56gfredericksyou could keep an index and increment it up to the second-to-last position
17:56casionhmm, I see what you're saying
17:56casionand I get that as well now haha
18:34estebannif you know that a sequence will always be entirely consumed and will be reasonably sized, is it better to fully realize it at the time of creation (rather than producing a lazy sequence)?
18:37estebannor perhaps a better way to state my question, are there any significant penalties associated with lazy realization of sequences in this case?
18:40hyPiRionestebann: It will be slower than eager realization.
18:41estebannhyPiRion: gotcha... thanks
18:41chouserbut realizing a lazy seq early is not necessarily slower than realizing it later.
18:41hyPiRionIt shouldn't be noticably different.
18:41estebannok
18:41chouserusing reducers or something else that avoids building the lazy seq entirely might be faster.
18:41technomancyestebann: clojure chunks certain kinds of sequences for you behind the scenes
18:42technomancyunfortunately it's often a bit unpredictable when happens
18:42estebannis there any benefit to all-at once realization eg doall vs, one at a time?
18:42technomancyonly one way to find out
18:42chouserestebann: I wouldn't assume so without measuring.
18:42estebanntechnomancy: touche
18:42casiongfredericks: It seems that if I make sure I'm using an array, (conj (map f (butlast array) (last array)) is fastest
18:43casiondamn missing parens in there, I need to switch back to erc
18:43technomancyestebann: instead of creating a lazy seq and then forcing the whole thing, it might be marginally more efficient to just mapv straight to a vector instead
18:43technomancybut on no account should you take my word for it without empirical evidence
18:43estebannok.. i'll do a little testing
18:43estebannthanks
18:43hyPiRionBut, well, you know, if speed is an issue, consider going into java and use pure arrays instead.
18:44chouseror staying in clojure and using pure arrays
18:45hyPiRionchouser: That's what I meant - maybe I phrased it bad.
18:45chouserah
19:09gfrederickscasion: that's quite interesting
19:09casionI guess because butlast/last are constant time on arrays?
19:09gfredericksnot butlast at least
19:09casionand that's faster than having any conditionals in a loop
19:10gfredericksit builds up a vector
19:10casionmy guess at least
19:10casiondoes it?
19:10gfredericksyep; eagerly
19:10casionhmm
19:10gfredericksthat's why dnolen retracted his lazy assertion
19:10casionit's almost 2x faster than the map that checks for the last index
19:11casionand about 50% faster than a plain loop
19:11gfredericksI wonder if arrays are chunked
19:11djanatynanyone use nrepl with evil-mode?
19:11amalloydjanatyn: Raynes probably does
19:12djanatynI'm trying to figure out how to have the *nREPL error* buffer always in emacs mode
19:12RaynesSure.
19:12RaynesNo clue.
19:13djanatynI can just do \q but there's probably a better way to do it
19:19djanatynhmm. I'm trying to work with binary trees
19:19djanatynI want to write a function that generates a tree of all possible results from flipping a coin n number of times
19:20djanatynnow that I think about it, I guess I don't even need a tree. I can just have a list of lists
19:27djanatynO_O
19:28djanatyn,(conj '(1 2) 3)
19:28clojurebot(3 1 2)
19:28djanatyn,(conj [1 2] 3)
19:28clojurebot[1 2 3]
19:28gfredericks,(doc conj)
19:28clojurebot"([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."
19:28djanatynI'm trying to read the documentation to understand why this happens
19:29djanatynsorry if this comes up a lot, I can imagine a lot of people running into this issue
19:29gfrederickslists are fast at the front, vectors are fast at the end
19:29djanatynokay, that makes sense
19:29djanatynwhy are vectors fast at the end?
19:30djanatynI understand why linked lists are fast at the front
19:30gfredericksdo you know anything about the impl of vectors?
19:32djanatynI thought that vectors didn't evaluate their elements
19:32gfrederickswell that's a characteristic of vectors-as-source-code
19:32gfredericksbut they are also data structures, distinct from lists
19:33djanatynare they like arrays?
19:33gfredericksthey couldn't easily be arrays because they are persistent/immutable
19:33djanatynokay. is there a good resource to read about clojure data structures?
19:34gfredericksvectors have been described a good bit; there's a nice video or two as well
19:36gfrederickshttp://blip.tv/clojure/daniel-spiewak-extreme-cleverness-functional-data-structures-in-scala-5970151
19:36djanatynalso, how do I add an item to the front of a list? use conj after reversing, and reverse again?
19:37gfredericksconj works for the front of a list; did you meant the front of a vector or the end of a list?
19:37djanatynumm
19:37gfredericks,(conj '(3 5 54) 2844)
19:37clojurebot(2844 3 5 54)
19:38djanatynthe intended behavior I'm looking for is having (function '(foo bar) 'baz) evaluate to '(foo bar baz)
19:38gfredericksah so we're clashing on our definition of "front"
19:38gfredericksthe easiest way is ##((fn [coll x] (concat coll [x])) '(foo bar) 'baz)
19:38lazybot⇒ (foo bar baz)
19:39gfredericksbut keep in mind that's not efficient
19:39SgeoWhat's this ## stuff?
19:39gfredericksthat's how you kick lazybot and make him pay attentien
19:39djanatynokay, thank you gfredericks
19:42SgeoIs there a central repository for Clojurescript?
19:44Frozenlo`gfredericks: either the presenter moves too much, either the camera is too zoomed in.
19:46S11001001djanatyn: if there is a concern about forcing the first argument to conj, cons is better for creating a new list whose head is your arg and tail is your other arg
19:47SgeoIf some Java code uses Math.sin, I can't with-redefs that away, can I?
19:47SgeoTo replace sin with another function
19:56gfredericksnope
20:05djanatyncan you use defn with clojurebot?
20:05gfredericksnot really
20:05xeqi,(defn asdf [x] (+ 1 2))
20:05clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
20:05djanatynis that supposed to say SANDBOX?
20:07djanatynanyway, regardless, I did it!
20:07djanatynhttps://gist.github.com/3615071
20:07djanatyn(list-possible-sequences 2)
20:07djanatyn=> ((heads heads) (heads tails) (tails heads) (tails tails))
20:08djanatynand I can map my other functions over that :)
20:08djanatyn(map count-heads-and-tails (list-possible-sequences 2))
20:09gfredericksdjanatyn: so for this purpose you could have just as well added to the "back" of the list, right?
20:09djanatyn=> ({:heads 2, :tails 0} {:heads 1, :tails 1} {:heads 1, :tails 1} {:heads 0, :tails 2})
20:09djanatyngfredericks: ...hmm
20:09djanatynyes -_-
20:09gfredericksor really you could have been using lists or vectors but not cared which and just used conj
20:09djanatynorder doesn't matter here.
20:09amalloy&((fn flips [n] (lazy-seq (if (zero? n) [[]], (for [flip '[heads tails], more (flips (dec n))] (cons flip more))))) 2)
20:09lazybot⇒ ((heads heads) (heads tails) (tails heads) (tails tails))
20:10djanatynugh, for confuses me
20:10djanatynis it even a macro?
20:10gfredericksit is
20:10amalloyyou should also stop calling the right of a linked list the front. everyone in the world calls it the back
20:11gfredericksor "end"
20:11amalloysure
20:11djanatynokay, sorry. I have trouble labeling the front and back of any one dimensional thing
20:14amalloyanyway, for is worth learning. eagerly building a list of size 2^n seems like a bad idea in general
20:19gfredericks&((fn flips [n] (let [N (bit-shift-left 1 n)] (for [x (range N)] (-> x (+ N) (Long/toString 2) (rest) (->> (map {\0 'heads \1 'tails})))))) 3)
20:19lazybot⇒ ((heads heads heads) (heads heads tails) (heads tails heads) (heads tails tails) (tails heads heads) (tails heads tails) (tails tails heads) (tails tails tails))
20:21amalloyhuh. i would have assigned heads to 1. i wonder if anything interesting lies behind our different choices
20:21gfredericksoh man I totally hadn't even thought about it
20:21gfredericksI don't even remember choosing
20:21gfredericksI just typed
20:22gfredericksI would've done like you said if I had thought about it I'm sure
20:33nvyhello, what does ->> do?
20:33gfredericks,(doc ->>)
20:33clojurebot"([x form] [x form & more]); Threads the expr through the forms. Inserts x as the last item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the last item in second form, etc."
20:34nvythanks
20:34gfredericksso (->> x (foo baz) (bar bajoong)) is (bar bajoong (boo baz x))
20:38cshell_does anyone know of a clojure wrapper around processing? (ie processing.org)?
20:38cshell_or something similar for drawing graphics/animations?
20:39wmealing_i thinkquill
20:39cshell_wmealing_: that's awesome, thanks!
21:07SgeoI have reason to make a mock Math class and force all code to use it. Is this accomplishable?
21:09brehautgreat evil might be possible with classpath munging, but it might be extremely unpredictable
21:10gfredericksprobably easier to decompile the code you care about, switch the calls, and recompile :D
21:11amalloybrehaut: Math is in java.lang, so i think you'd need to recompile all of the jre and put your version on the bootclasspath when you start clojure
21:14SgeoHmm, darn
21:15SgeoI just want to replace those static methods with ones that can accept dual numbers
21:15gfrederickswhat are dual numbers?
21:16stankleygfredericks: http://en.wikipedia.org/wiki/Dual_number
21:16stankley… no idea
21:16Sgeohttp://en.wikipedia.org/wiki/Dual_number#Differentiation the reason I'm interested
21:17SgeoIt's an easy way to calculate derivatives
21:18gfredericksderivatives of polynomials over reals is difficult?
21:21SgeoCan do more than polynomials
21:22gfredericksso what library are you using whose behavior you want to redefine?
21:23Sgeo...well, I sort of wanted to make it work with any function in Java or Clojure that was a mathematical function, and calculate the derivative without changing the function itself
21:24gfredericksso differentiate here means differentiating at a point?
21:25SgeoYes
21:25gfredericksthat is terribly interesting
21:25arohner,(name :foo/bar)
21:25clojurebot"bar"
21:25arohnerthat's irritating
21:26gfredericksarohner: that's what the name function is for
21:26gfredericksit complements the namespace function
21:26Sgeo(Although automatic differentiation doesn't seem to work well when the derivative is undefined. (lambdabot in #haskell has an AD thing loaded)
21:26gfredericksSgeo: so if you wanted to do sin you would need some approximation so that you could compute it for duals?
21:27gfredericksarohner: I don't think it's very common to have a namespaced keyword and to want to convert the whole thing to a string without a colon
21:27Sgeogfredericks, I _think_ you'd just write the sin function that accepts duals to do the sine of the real part and ... the cosine of the coefficient of the dual (I'm not certain though, but I think it would be defined in those terms))
21:28Sgeo,(let [fullname (fn [sym] (str (namespace sym) "/" (name sym)))] (fullname :foo/bar))
21:28clojurebot"foo/bar"
21:29SgeoHmm, I should learn to letfn
21:29SgeoI guess letfn is the equiv. of CL's labels?
21:29Sgeo,(doc letfn)
21:29clojurebot"([fnspecs & body]); fnspec ==> (fname [params*] exprs) or (fname ([params*] exprs)+) Takes a vector of function specs and a body, and generates a set of bindings of functions to their names. All of the names are available in all of the definitions of the functions, as well as the body."
21:29gfredericks,(subs (str :foo/bar) 1)
21:29clojurebot"foo/bar"
21:30Sgeo,(doc subs)
21:30clojurebot"([s start] [s start end]); Returns the substring of s beginning at start inclusive, and ending at end (defaults to length of string), exclusive."
21:30SgeoSymbols are strings now?
21:30SgeoOr act as them for ... stringy purposes?
21:30gfredericksno I called str on them
21:30gfrederickson it*
21:30SgeoOh
21:31Sgeo,(str :foo)
21:31clojurebot":foo"
21:31Sgeo,(namespace :foo)
21:31clojurebotnil
21:36gfredericks,(name '/)
21:36clojurebot"/"
21:36gfredericks&:/
21:36lazybotjava.lang.RuntimeException: Invalid token: :/
21:55qmxrepl-based programming is spoiling me
21:55qmxspecially after getting vimclojure appropriately-setup
21:57spoon16how can I get a multiline string to print at the repl?
21:57spoon16##(pprint "hello\nworld")
21:57lazybotjava.lang.RuntimeException: Unable to resolve symbol: pprint in this context
21:58spoon16(clojure.pprint/pprint "hello\nworld")
21:58gfredericksspoon16: use print or println instead of pprint
21:58spoon16there you go
21:58spoon16nice