2010-03-07
| 01:08 | brandonw | am i doing something wrong if i want to do something like this: |
| 01:08 | brandonw | ,(letfn [(foo [arg1] (* arg1 x))] (let [x 5] (foo 2))) |
| 01:08 | clojurebot | java.lang.Exception: Unable to resolve symbol: x in this context |
| 01:09 | brandonw | how can i get functions i want to define only for the use inside of one method, to use symbols scoped inside of that method without having to use something like partial |
| 01:10 | brandonw | s/method/function |
| 01:10 | brandonw | unless partial is the idiomatic way to do so |
| 01:19 | hiredman | brandonw: put the let outside the letfn |
| 01:20 | brandonw | the functions bound in letfn are available outside the body of the letfn? |
| 01:21 | hiredman | no |
| 01:22 | hiredman | ,(let [x 5] (letfn [(foo [arg1] (* arg1 x))] (foo 2))) |
| 01:22 | clojurebot | 10 |
| 01:22 | brandonw | ah |
| 01:23 | brandonw | okay, thanks |
| 01:23 | brandonw | i have to dissuade myself from assuming i won't need more than one let per function :) |
| 01:45 | timothypratley | Using Compojure I'm expecting :query-string "foo=1" to result in :params {"foo" "1"} or something like that... but I'm seeing an empty :params {} instead |
| 01:46 | timothypratley | any clues what I'm missing? |
| 01:49 | hiredman | where are you seeing that? I think I saw something about middleware not getting the :params values |
| 01:51 | timothypratley | I'm just writing out the request (well I'm doing that because I couldn't find the param :) |
| 01:55 | timothypratley | Hmmm I think I must have stuffed up my routes to cause it. |
| 02:02 | tomoj | anyone seen this error before? |
| 02:03 | tomoj | trying to use penumbra master as a lein dependency |
| 02:03 | tomoj | get that error when running lein swank |
| 02:04 | ned | is there a clojure equivalent of pythons urllib2/BeautifulSoup/lxml ? |
| 02:09 | hiredman | ned: beautifulsoup is, I believe, based on the java lib tagsoup which is very usable from clojure |
| 02:09 | hiredman | you might look at enlive which is a clojure lib |
| 02:09 | ned | hiredman, will take a look. im coming from python (as implied before), and i guess its time to brush up on my java. |
| 02:10 | timothypratley | ah.... I should have read this first: "In 0.3, Compojure provided several magic variables, like "params" and |
| 02:10 | timothypratley | "session". In version 0.4, these will be replaced with a binding form. |
| 02:10 | ned | are there any good docs delineating best practices for interacting with java (other than the stuff on clojure's site)? |
| 02:13 | timothypratley | ned: "Use Klass/staticField, (Klass/staticMethod), (Klass.) and (.method obj) interop styles, with the only exception being in code-generating-code where the older (. obj method) style may be easier to produce." |
| 02:14 | timothypratley | ned: according to "http://www.assembla.com/wiki/show/clojure/Clojure_Library_Coding_Standards" |
| 02:14 | timothypratley | I guess that's not much more - but thought I'd mention it :) |
| 02:17 | ned | timothypratley, hah, its like a mini-PEP8 sort of. thanks for the link :) |
| 02:20 | timothypratley | :) |
| 02:31 | nteon | im having trouble with a pesky macro I'm writing. http://fpaste.org/3cvb/ its almost there, but I'm having problems with autogenerated symbols, specifically state# in the paste |
| 02:31 | nteon | does anyone have any pointers as to where I went wrong? |
| 02:37 | nteon | I know state# shouldn't be quoted on line 15, but I wanted to get it to compile so I could see how the expansion looked |
| 02:37 | _ato | the problem is autogenerated symbols are local to a syntax-quoted form, so the state# in eqns-kv is different to the one on in `(def ~set-name ...) |
| 02:40 | _ato | I guess one way to fix it would be to call gensym explicitly instead of relying on auto gensym |
| 02:43 | nteon | _ato: I don't seem to understand how to explicitly use gensym. I expected to be able to do ~(gensym "state") in place of state#, but that doesn't seem to work |
| 02:43 | _ato | right as that will generate a new symbol each time |
| 02:43 | _ato | you want to use the same one |
| 02:44 | nteon | _ato: no, I understand I need to do it in a let binding. I get 'unable to resolve symbol in this context' when done with a let or spliced in |
| 02:47 | _ato | ,(let [state-sym (gensym "state"), eqns-kv `(blah (+ ~state-sym 2))] `(fn [~state-sym] (let [~@eqns-kv] ...))) |
| 02:47 | clojurebot | (clojure.core/fn [state11379] (clojure.core/let [sandbox/blah (clojure.core/+ state11379 2)] ...)) |
| 02:49 | nteon | _ato: ah, thanks! I had been doing a splicing-unquote instead of a simple unquote, which would explain it |
| 02:56 | bobo_ | hm, is there any built in stuff to transform a list? ie applying a function to all items in a list |
| 02:57 | somnium | bobo_: map? |
| 03:01 | nteon | ,(doc map) |
| 03:01 | clojurebot | "([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments." |
| 03:01 | bobo_ | that sounds right, but cant seem to find any example |
| 03:02 | bobo_ | and there it is :-p |
| 03:02 | nteon | ,(map #(* 2 %) (1 2 3)) |
| 03:02 | clojurebot | java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn |
| 03:02 | nteon | ,(map #(* 2 %) '(1 2 3)) |
| 03:02 | clojurebot | (2 4 6) |
| 03:02 | bobo_ | thank you very much |
| 03:02 | nteon | bobo_: more than welcome |
| 03:03 | nteon | man i am so psyched on clojure |
| 03:03 | bobo_ | :-) |
| 03:04 | bobo_ | ive missed lisp since uni, now i can finally sneak it in everywhere |
| 03:05 | nteon | I've never done lisp before. its a mind-boggling (in a good way) experience |
| 03:15 | jeffmess | is there an issue with lein swank version 1.1.0 ? I have :dev-dependencies [[leiningen/lein-swank "1.1.0"]] in my project file but when I run lein deps i get 1 required artifact is missing. org.apache.maven:super-pom:jar:2.0 |
| 03:23 | _ato | jeffmess: I used it this morning and it worked okay |
| 03:24 | _ato | jeffmess: http://gist.github.com/324243 |
| 03:25 | jeffmess | _ato_: thats almost identical to mine except I have compojure aswell as a :main line |
| 03:26 | _ato | strange |
| 03:27 | jeffmess | I am a clojure newbie though. How does Leiningen handle classpaths? Or is that handles automatically? |
| 03:29 | hiredman | automagicaly |
| 03:49 | Raynes | http://www.assembla.com/wiki/show/clojure/Clojure_Library_Coding_Standards Is huge. |
| 03:49 | Raynes | And intimidating. |
| 03:49 | Raynes | It scares me. |
| 08:00 | dermatthias | hmm, i have a update function for an agent. inside this function i have another batch of agents (i.e. list of agents inside an agent), for which i want to do (dorun (map #(send % up-func) agents))....gets me Agent has error, and I have no idea how to debug it with (agent-errors) or where the error is in the first place |
| 08:01 | dermatthias | any ideas? |
| 08:02 | dermatthias | perhaps it isn't possible to call agents recursively? |
| 08:07 | chouser | it's ok to send from inside an agent action |
| 08:07 | chouser | dermatthias: you're using clojure 1.1? |
| 08:07 | dermatthias | yes |
| 08:08 | chouser | would it be too difficult to put try/catch around the entire contents of all of your action fns? |
| 08:09 | dermatthias | good point, needs some rewrite, but worth a try |
| 08:09 | chouser | clojure 1.2 has some better options |
| 08:10 | chouser | but on 1.1 although there are some things you can try, I generally have found that the quickest route to actually understanding what I'm doing wrong with agent actions is try/catch everywhere. |
| 08:10 | chouser | you have a lot of action fns? |
| 08:11 | dermatthias | ahh, found something |
| 08:11 | dermatthias | Exception java.lang.Exception: Can't await in agent action |
| 08:11 | chouser | ah, yes, there is that. |
| 08:11 | dermatthias | why? :) |
| 08:12 | chouser | to prevent the possibility of deadlocks |
| 08:14 | dermatthias | ok, thanks. then this has to be solved something else...:) |
| 08:14 | dermatthias | different... |
| 08:16 | chouser | sometimes when you've got agent+await you can use future instead |
| 08:22 | vy | Are there anything like assoc/find of CL? I need to get the "second"s in a list of lists: '(("foo" 2) (3 "bar") ...) |
| 08:23 | a_strange_guy | ,(map second '((a 1) (b 2))) ; ? |
| 08:23 | clojurebot | (1 2) |
| 08:24 | a_strange_guy | vy: sry didn't understand |
| 08:24 | a_strange_guy | don't use alists |
| 08:24 | a_strange_guy | we have real maps |
| 08:26 | vy | a_strange_guy: But function arguments appear as lists, not maps. |
| 08:28 | a_strange_guy | ,(second (some #(when (= :elem-to-find (first %)) %) '((:elem-to-find 1) (b "foo"))) |
| 08:28 | clojurebot | EOF while reading |
| 08:29 | a_strange_guy | ,(second (some #(when (= :elem-to-find (first %)) %) '((:elem-to-find 1) (b "foo")))) |
| 08:29 | clojurebot | 1 |
| 08:29 | a_strange_guy | don't know of an easier way |
| 08:40 | vy | (first (filter #(= :elem-to-find (first %)) ...)) is relatively shorter, but I was expecting a find/find-if/assoc, whatever. |
| 08:43 | arbscht | maybe c.c.seq/find-first |
| 08:44 | vy | find-first source code: (first (filter pred coll)). Heh! |
| 08:45 | arbscht | it's exactly what it says on the tin :) |
| 08:47 | djpowell | Just been using clojure-jna. Noticed that if you just use jna-invoke, then when a GC happens, your DLL unloads, which was a bit unexpected. It loads back, but I lost some context then. Is that supposed to happen? |
| 08:48 | djpowell | (programming the screen on my logitech G19 keyboard from clojure) |
| 08:52 | vy | Using SLIME installed by ELPA, C-M-f and C-M-b doesn't work right for [ and ] characters in SLIME REPL buffer. Anybody experiencing same problem? |
| 08:54 | vy | djpowell: May I ask how did you manage to track the load and unload of the DLL during a GC pass? (BTW, I use JNA and had never experienced a similar problem.) |
| 08:58 | djpowell | i put some printfs in my DllMain |
| 08:58 | djpowell | It is fine when I keep a ref to a function, eg, with jna-fn |
| 08:59 | djpowell | I had a problem cause I was using a thread-local in my Dll to hold onto some state, which suddenly disappeared when I created a big ByteBuffer |
| 09:00 | djpowell | cause I was getting a DLL_PROCESS_DETACH |
| 09:01 | vy | Hrm... I see. I always keep a ref to a function, that explains why I never had same gotcha. |
| 09:01 | djpowell | I guess GCing the DLL is a good thing, and making jna-fns is probably better anyway, but maybe it needs a bit of a warning in the readme |
| 09:02 | vy | IMHO, it's not clojure-jna related, is it mentioned in the JNA documentation? |
| 09:42 | dermatthias | I want to use dosync on many expressions and unroll them somehow, because I only know at runtime how many there will be. is there are way to do is? |
| 10:04 | dermatthias | nevermind, think i got a workaround (not involving dosync) |
| 10:50 | powr-toc | Are chunked sequences becoming the default in clojure 1.2? If so |
| 10:50 | powr-toc | *** #how do you specify that you want to consume different sized chunks? |
| 10:51 | StartsWithK | powr-toc, i don't thing you can |
| 10:52 | kotarak | I also think that the chunk size depends on the underlying data structure. |
| 10:52 | kotarak | Or could depend, that is. |
| 10:54 | powr-toc | I guess it's probably not worth worrying about... I was just |
| 10:54 | powr-toc | wondering whether chunks make sense when the cost of generating each |
| 10:54 | powr-toc | element is high |
| 10:54 | powr-toc | ughh... my irc clients breaking lines :-\ what have I changed? |
| 11:01 | powr-toc | Has anyone here read let over lambda? If so how well does it |
| 11:01 | powr-toc | translate to clojure? |
| 11:05 | kotarak | oha |
| 11:07 | scode | Is leiningen expected to work with git versions of clojure/clojure-contrib? |
| 11:07 | scode | I started failing in various ways as soon as I tried upping the dependencies for my project to require newer clojure/clojure-contrib (becuase I wanted to make changes to -contrib). |
| 11:07 | scode | And I'm not sure why, and I'm no maven expert... |
| 11:16 | scode | Oh. Truncated/broken .jar in my ~/.m2/repository. Nevermind. |
| 11:35 | joegg | Can someone please take a look at http://paste.lisp.org/display/96055 ? I'm dying here. I can't for the life of me figure out why this isn't printing things out in order. I've written it in java, and it works fine, but I can't get it working as written. |
| 11:49 | tjg | joegg: I think I might see your problem. comparator() assumes it's getting function which returns truth/falsity values. |
| 11:49 | joegg | tjg: Are you my inner monologue? I'm looking at the documentation for that right now! And I think you are *quite* right. |
| 11:49 | tjg | joegg: The problem is, compare(), which you pass it, returns numbers, not truth/falsity issues. |
| 11:49 | joegg | Yeah. |
| 11:50 | tjg | "issues" -> "values" |
| 11:50 | joegg | Okay, I'm really close, though, then. Before I just thought I was crazy. |
| 11:50 | joegg | Thanks! |
| 11:51 | tjg | No prob, such things drive me mad too... |
| 12:04 | avar | Is there a more up to date guide to getting clojure working with emacs/swank than this one: http://riddell.us/tutorial/slime_swank/slime_swank.html |
| 12:05 | avar | it references stuff in swank-clojure-extra-classpaths that's not there anymore in the latest git versions |
| 12:06 | tjg | avar: Yeah, that's crazy old. I use ELPA, as (I believe)described here: |
| 12:06 | tjg | http://github.com/technomancy/swank-clojure |
| 12:07 | tjg | Though that's kinda hard to read, I think. This is a bit outdated, but a better explanation: http://technomancy.us/126 |
| 12:09 | tjg | Ehh, I should go on the Clojure wiki (if it still exists) and help fix up its entry on Slime; many have complained that all that exists is a bunch of disconnected and questionable blog posts. |
| 12:14 | avar | ELPA will just get me the relevant packages right? I already have clojure.git / swank-clojure.git and slime.git (the version that's frozen to work with clojure). The problem is that I can't figure out how to configure emacs + those parts to work together because I can't find the right elisp to glue it together |
| 12:16 | avar | M-x slime and M-x swank-clojure-project give me "Searching for program: no such file or directory, lisp" which suggest that I'm not setting up the path to the clojure lisp correctly, but I'm too rusty at SLIME to find out what the problem is |
| 12:17 | tjg | avar: I think that swank-clojure-project error means that you need to put things like clojure.jar into the src/ directory. |
| 12:19 | tjg | avar: ELPA is supposed to download the relevant packages. (if i understand your constraints correctly.) it creates an emacs.d/elpa/ dir and puts the necesasry stuff into it. it also modifies your .emacs file to auto-load things. if you wish, it'll also fetch clojure and clojure-contrib via git, IIRC. |
| 12:20 | tjg | (When I say "clojure.jar into the src/ directory", I mean the project-root/src/ directory, whereever that may be.) |
| 12:27 | avar | my clojure-mode from http://github.com/technomancy/clojure-mode tries to require swank-clojure-autoload which is only there in an older version http://github.com/technomancy/swank-clojure/tree/34e6921fb1f89b3f30354539c6b8f9791f7913ed |
| 12:27 | avar | *sigh* |
| 12:30 | tjg | I think (maybe I'm wrong) that ELPA packages both clojure-mode and swank-clojure, so you don't need to manually use the Github versions? |
| 12:31 | avar | Right, maybe I'll bite the bullet and install it via ELPA, I just have a git-based emacs configuration that I try to use instead of elisp I wget over the net: http://github.com/avar/dotemacs http://github.com/avar/elisp |
| 12:32 | somnium | avar: last time I setup slime it was less than 5 minutes to get a clojure env going from a blank .emacs: install ELPA, install clojure-mode, (get leiningen: optional). |
| 12:33 | avar | Right, the issue seems to be that the git HEAD versions of the repositories I pulled down are incompatable |
| 12:45 | LauJensen | I read about some high performant JSON lib for Clojure a while ago - Anybody remember where it is ? :) |
| 12:47 | tjg | Perhaps the benchmarks mentioned here? http://disclojure.org/2010/03/01/this-weekend-in-the-intertweets-feb-28th-ed/ |
| 12:49 | LauJensen | thx |
| 12:50 | StartsWithK | LauJensen, http://bitbucket.org/ksojat/yummy-json/src/ is ~4-7x faster on reads than clojure.contrib.json |
| 12:50 | StartsWithK | and ~2x on writes, reads don't consume stack and it has no (known) parsing errors |
| 12:50 | StartsWithK | like parsing invalid json ala "1" "[1,,2]"... |
| 12:54 | LauJensen | sounds great - why isnt that in contrib ? |
| 12:56 | somnium | hmm, it depends on Jackson, LGPL/AL |
| 12:56 | StartsWithK | yes, jackson rocks |
| 12:57 | StartsWithK | they spent years writing that thing |
| 12:57 | StartsWithK | pure jackson can even compare in speed to procol buffers |
| 13:00 | StartsWithK | http://code.google.com/p/thrift-protobuf-compare/wiki/Benchmarking |
| 13:04 | StartsWithK | and i used http://inkdroid.org/journal/2008/10/24/json-vs-pickle/ for data |
| 13:04 | StartsWithK | it has a nice large json and numbers to compare with |
| 13:06 | kotarak | http://github.com/mmcgrana/clj-json also uses Jackson |
| 13:07 | StartsWithK | thats the only way to go imo |
| 13:09 | StartsWithK | other problem with c.c.json, is that it will accept invalid json |
| 13:10 | StartsWithK | and as i understand that thing will maybe go to core |
| 13:11 | kotarak | StartsWithK: raise your concerns on the dev list. |
| 13:12 | StartsWithK | kotarak, i can't post on -dev |
| 13:12 | kotarak | huh? o.O |
| 13:12 | StartsWithK | no CA, no -dev |
| 13:12 | kotarak | oo.OO really? |
| 13:13 | LauJensen | mmcgrana's looks interesting enough to give a try |
| 13:13 | StartsWithK | i tried to register, just for lurking, and on registration form there was a notice how i should provide .. something CA related |
| 13:13 | StartsWithK | and if he can get his json in core, that would be awesome |
| 13:14 | LauJensen | I think contrib should strive to assimilate superior libs outside of contrib, and by doing so avoid being thought of as irrelevant |
| 13:14 | StartsWithK | i think it already is irrelevant.. don't get me wrong, but i don't even have anything that is using c.c |
| 13:15 | LauJensen | There's a ton of good stuff in there |
| 13:15 | somnium | I use string and seq all the time |
| 13:15 | StartsWithK | and with stuff like logging getting in.. i don't think i care anymore about it |
| 13:16 | somnium | and c.c.monad for the pleasures of suffering |
| 13:17 | LauJensen | monads caused the swine-flu pandemic :( |
| 13:17 | StartsWithK | also, mondas use macrolet and that thing has errors |
| 13:17 | kotarak | macrolet is a big hack. You can write monads without. |
| 13:17 | StartsWithK | you can spot them just by reading the code, no need to even run anything :/ |
| 13:19 | kotarak | Just as quasiquote in CQL was a big hack. |
| 13:20 | StartsWithK | kotarak, but why are 'big hacks' in 'standard/incubator' library |
| 13:25 | kotarak | StartsWithK: dunno, other things (much less hacky) were not included were I would have seen much more use cases. |
| 13:26 | kotarak | But I'll shut up. For me it's not clear where Rich's going with contrib. |
| 13:28 | StartsWithK | i'll shut up.. after the short rant about the log lib :) |
| 13:28 | StartsWithK | there are like two rules.. no external deps and no wrappers, and logging is both |
| 13:29 | StartsWithK | to avoid detection, it wrapps all its code in three giant eval blocks |
| 13:30 | StartsWithK | it dosn't support slf4j (as it is a wrapper itself; and it isnt) and supports commons-loggins (that is a wrapper) |
| 13:30 | StartsWithK | and in the end, from three libs it does support, non of them are maintained anymore, as slf4j is pushim them all aside |
| 13:31 | StartsWithK | and commons-logging has know class loader problems |
| 13:31 | StartsWithK | so.. i can't see the logic in that lib, and how it ended in c.c in the first place |
| 13:33 | somnium | OT, anyone know if its possible to run ClojureCLR on mono? (visual studio is mentioned on the wiki :/) |
| 13:36 | LauJensen | Ehm - I dont see why it shouldnt, but why would you want to ? |
| 13:39 | somnium | Ive been playing with F# and will begrudgingly admit that I rather like it (a kind of practical haskell), but I dont know .NET at all. Clojure has been great for exploring java libs, so - |
| 13:39 | hiredman | StartsWithK: it seems like the main stuff people use contrib for (io) will spin off into clojure.lib which may or may not be distributed with clojure, and then contrib can disapear |
| 13:40 | StartsWithK | hiredman, it would be nice, maybe not to kill contrib, but maybe to present the problem, the vision of solution and the code before the inclusion |
| 13:41 | kotarak | somnium: F# is rather nice as are the other parts of the ML family. I particularly like OCaml. |
| 13:41 | hiredman | StartsWithK: I think it's better to split out anything anyone wants to save to its own library |
| 13:44 | StartsWithK | hiredman, isn't one reason why c.c lives is that all contributors have ca signed and rich can include the code in core |
| 13:44 | StartsWithK | if there is no c.c, how will new code enter the core? |
| 13:45 | hiredman | code doesn't enter core from contrib very often |
| 14:26 | fanatico | clojars is timing out, and it has taken 'lein deps' down with it. Is there a way to force leiningen to use the local repository without looking for updates? |
| 14:42 | rem7 | I was reading that you can only use recur from a tail position. Can it used in a cond? like so: http://paste.lisp.org/display/96061 |
| 14:48 | hiredman | you don't need an extra (loop ...) there |
| 14:49 | rem7 | hiredman: i thought recur and loop had to be used together.. no? |
| 14:50 | kotarak | rem7: recur also works on function boundaries |
| 14:50 | hiredman | recur will jump to the enclosing loop or function |
| 14:51 | rem7 | ah ok, thanks |
| 14:52 | ska2342 | Hi. After my son separated my machine from the current today I need to reopen many windows. And I can't open the Clojure source code in Netbeans now. Am I just too stupid right now or is there a trick (other than removing pom.xml)? I'm trying the 1.1.0 release, downloaded as ZIP. |
| 15:00 | lespea | Hello |
| 15:04 | kotarak | Interesting how two weeks of work suddenly end up a just a few lines of code... |
| 15:06 | ska2342 | nevermind my question. NB somewhere had a reference to that dir and didn't want to open it again. |
| 15:08 | lespea | So I'm new to both functional programming in general as well as clojure. I'm trying to make an infinite pascal's triangle (so you can take 10 to get the first 10 lines) but I'm running into StackOverflowError. I assume that I'm "hanging onto the head" but I can't figure it out. Could anybody give me some pointers? http://pastebin.com/qmNJ19pU |
| 15:12 | derefed | is there a way to get the current classpath clojure is using from the REPL? |
| 15:13 | the-kenny | ,(System/getProperty "java.class.path") |
| 15:13 | clojurebot | java.security.AccessControlException: access denied (java.util.PropertyPermission java.class.path read) |
| 15:15 | derefed | thanks |
| 15:15 | derefed | hmm... it seems to be different than what's in my $CLASSPATH |
| 15:17 | bsteuber | lespea: you don't need to do the iteration on your own |
| 15:17 | bsteuber | ,(doc iterarate) |
| 15:17 | clojurebot | Pardon? |
| 15:17 | the-kenny | ,(doc iterate) |
| 15:17 | clojurebot | "([f x]); Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects" |
| 15:17 | bsteuber | ,(doc iterate) |
| 15:17 | clojurebot | "([f x]); Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects" |
| 15:18 | bsteuber | too late |
| 15:18 | bsteuber | so you can run (iterate mkline [1]) |
| 15:18 | bsteuber | and this don't need the special case for no arguments |
| 15:20 | lespea | Oh okay that makes sense... certainly cleans up my code |
| 15:21 | lespea | I'm still getting stack overflow though: (nth (last (take 1000 (iterate mkline [1]))) 25) |
| 15:24 | kotarak | lespea: I think you put lazy-seq on lazy-seq on lazy-seq ... Try putting a doall in mkline: (mkline [line] (doall (map ...))) |
| 15:26 | Knekk | where can I find a better REPL? command history and all that good stuff. |
| 15:26 | lespea | kotarak: Ah that worked perfectly! Thanks. |
| 15:26 | kotarak | Knekk: rlwrap |
| 15:26 | lespea | kotarak: I see now how that could cause an overflow... all those promises |
| 15:26 | bsteuber | knekk: Most use swank-clojure for emacs |
| 15:27 | kotarak | Knekk: or JLine or VimClojure's buffer Repl similar to SLIME thing, but if you are more into vi. |
| 15:27 | Knekk | I use swank-clojure as well, but sometimes I find it's easier to just fire up a repl for some quick commands |
| 15:28 | bsteuber | then I use M-x slime instead of swank-clojure-project |
| 15:28 | Knekk | so, I am installing clojure/emacs on a brand new machine. Using ELPA I already downloaded clojure-mode/swank-clojure and all that. Using slime is now also downloading clojure itself, does that sound about right? |
| 15:29 | lespea | I'm waiting for VimClojure to be updated for 1.1 compatability |
| 15:29 | kotarak | lespea: VimClojure is 1.1 compatible |
| 15:29 | drocko | is there a guide to the best way to structure a compojure project? |
| 15:30 | drocko | i'm enjoying using it, but i realize i'm just putting code all willy nilly in the projects directory. if my experiments actually turn into something i'm going to need to organize things better... |
| 15:30 | bsteuber | lespea: my code for mkline looks like that |
| 15:31 | bsteuber | ,(vec (concat [1] (map #(apply + %) (partition 2 1 [1 4 6 4 1])) [1])) |
| 15:31 | clojurebot | [1 5 10 10 5 1] |
| 15:31 | mlehman | Any thoughts on the best way to document structmaps? Since defstruct does not currently take a doc-string and the resulting clojure.lang.PersistentStructMap$Def does not implement IObj (for meta). The best I have so far is just doing: |
| 15:31 | mlehman | (def #^{:doc "..."} mystruct (create-struct :name :description)) |
| 15:32 | derefed | I have clojure/emacs set up using ELPA -- how do I change clojure's classpath? (setq swank-clojure-extra-classpaths (list ...)) doesn't do it |
| 15:32 | lespea | bsteuber: I was using apply but I switched it to reduce (don't remember why) -- is there a reason to use one over the other? |
| 15:35 | bsteuber | lespea: personally, I would use reduce for operations where apply doesn't work - so not for just adding two numbers |
| 15:35 | bsteuber | probably not even for adding n numbers, as + already does the call to reduce for me |
| 15:36 | lespea | so, in general, apply is better than reduce? In terms of speed/memory or is it just considered best practice? |
| 15:36 | kotarak | lespea: apply is good for str, because it works internally with StringBuilder |
| 15:37 | bsteuber | for me, reduce feels a bit like loop - it's very powerful, but more complex to understand than other things |
| 15:37 | Knekk | slime failed to download Clojure jars :( |
| 15:37 | kotarak | lespea: but apply and reduce are in general fundamentally different operations. So it doesn't make sense to talk about best practice. |
| 15:37 | bsteuber | so I'd stick to other idioms unless necessary |
| 15:38 | bsteuber | and apply is definitely the simpler operation compared to reduce in general - as reduce is way more powerful |
| 15:38 | bsteuber | so I guess in your code, apply is easier to read |
| 15:39 | lespea | Okay... I just remembered why I switched it... I didn't know if apply was causing my overflow so I switched it and never put it back |
| 15:39 | bsteuber | because when I see a reduce, I start trying to figure out what is combined through something where |
| 15:39 | lespea | makes sense |
| 15:39 | bsteuber | ah, I see |
| 15:40 | kotarak | lespea: apply holds onto the head. I still don't see a point to "compare" apply and reduce. They are completely different operations with a rather limited set of intersection. |
| 15:40 | lespea | bsteuber: Also, why did you cast the map to a vector? |
| 15:41 | bsteuber | to circumvent the stack bloating issue |
| 15:41 | bsteuber | but maybe doall is cleaner |
| 15:41 | bsteuber | dunno |
| 15:42 | bsteuber | I usually cast things I don't want to be lazy to vec, but I have no idea if this is idiomatic |
| 15:42 | bsteuber | probably not :) |
| 15:42 | lespea | haha |
| 15:42 | bsteuber | I guess it just makes stuff slower, so thanks for pointing is out :) |
| 15:42 | drocko | is this a crazy way to deploy and run a website with compojure? http://briancarper.net/blog/deploying-clojure-websites |
| 15:45 | bsteuber | drocko: interesting, thanks for sharing :) |
| 15:46 | drocko | bsteuber: it is interesting! i wonder if it works in production? |
| 15:46 | drocko | like does it scale |
| 15:47 | bsteuber | I don't have any experience using compojure (yet) or any java server stuff - but my feeling would be to use a more "enterprisey" way for production systems |
| 15:48 | bsteuber | like war archives |
| 15:48 | lespea | so, does overloading a function really slow down the algorythm? ex: (defn a ([x] 1)([] 2)) |
| 15:48 | bsteuber | but I like your way |
| 15:48 | bsteuber | lespea: no, this compiles to java overloads which will be resolved during compilation |
| 15:49 | lespea | bsteuber: okay I thought so but just wanted to be sure |
| 15:50 | bsteuber | drocko: I'd be considering google appengine for highly scalable stuff - although you can't fire off your own threads with this |
| 15:51 | bsteuber | but I'd be glad to hear about other approaches |
| 15:51 | drocko | bsteuber: i had been considering GAE too, but it was a bit overcomplicated for me to get started on |
| 15:51 | drocko | i have enough to learn with clojure and compojure |
| 15:51 | drocko | with GAE you have to learn those things plus gae, plus a bunch of java build tools, etc |
| 15:51 | bsteuber | drocko: yeah, I'll probably start exactly like you (so thx again :) ) |
| 15:52 | drocko | clojure is freaking amazing though |
| 15:52 | bsteuber | and then later try to integrate compojure with GAE and swich to there datastore-stuff etc |
| 15:52 | bsteuber | it definitely is :) |
| 15:52 | drocko | i have been reading the "Programming Clojure" book. I think it's probably the 3rd computer book that i'll read cover to cover |
| 15:53 | bmason | yeah Stuart did a great job on that |
| 15:53 | drocko | definitely |
| 15:53 | bmason | you know, it actually touches on Compojure at the end |
| 15:53 | lespea | I agree! |
| 15:53 | bmason | dunno if you're at that point yet :) |
| 15:53 | derefed | I'm reading that now too |
| 15:53 | drocko | bmason: yeah i do know. i skipped ahead and read that stuff... i'm in the concurrency chapter now |
| 15:53 | lespea | I'm reading that + attempting SICP right now (hence pascal's triangle) |
| 15:54 | bsteuber | drocko: did you watch richs talks at clojure.blip.org yet? they even increased my excitedness... |
| 15:54 | derefed | what's sicp? |
| 15:54 | kotarak | It's starts getting outdated, though. |
| 15:54 | drocko | bsteuber: i have seen some... |
| 15:54 | lespea | derefed: http://mitpress.mit.edu/sicp/ |
| 15:54 | bmason | bsteuber: yeah I've evangelized clojure some but really can't do it justice without Rich's explanations :) |
| 15:54 | bsteuber | kotarak: true, I was quite confused about the new sequence stuff at first, for example |
| 15:55 | derefed | oh yeah I've seen this one before |
| 15:55 | derefed | is it worthwhile reading for experienced programmers? |
| 15:55 | kotarak | bsteuber: and the annoying (. obj method args) syntax everyone is now using. :| |
| 15:55 | lespea | This is all in an effort to get smart enough to try and tackle some of Norvig's AI books |
| 15:55 | derefed | I started reading it but stopped cause it was doing beginner stuff |
| 15:56 | drocko | derefed: possibly. i think the sicp puts you in the right mindset |
| 15:56 | drocko | maybe you are there already |
| 15:56 | lespea | derefed: I'm still in the first chapter... I'm completely new to functional programming so it's worth it for me haha |
| 15:56 | derefed | ah okay |
| 15:56 | drocko | lespea: have you read "the little schemer"? |
| 15:56 | derefed | lespea: even after 4 years of CS, norvig's AI is hard |
| 15:56 | lespea | drocko: no, haven't even heard of it :( |
| 15:56 | bsteuber | lespea: do you know about sicpinclojure.com (though not really much there yet)? |
| 15:57 | drocko | lespea: it's pretty cool. it will blow your mind |
| 15:57 | lespea | bsteuber: yeah I looked at it but, as you said, not much there yet haha |
| 15:57 | drocko | well perhaps. it's about recursion |
| 15:57 | lespea | would you say it's better than SICP for being introduced to FP? or is there something even better than both of them? |
| 15:58 | lespea | I've done almost all of my programming in Perl for the last 2 years so this is all a pretty big jump :S |
| 15:58 | lespea | but I like it so far... a lot of Ooooh that's awesome moments |
| 15:59 | kotarak | Rich's 0.02€ on SICP: http://groups.google.com/group/clojure/msg/be43ec191cd69869 |
| 15:59 | bmason | lespea: you have "Programming Clojure" ? |
| 16:01 | bmason | lespea: I think Stuart's book does a good job of actually making FP in Clojure a practical, time saving and elegant practice |
| 16:02 | bmason | I tried to learn Haskell before coming to Clojure, and found Clojure a far more digestible introduction to FP |
| 16:03 | ska2342 | Just for the record: Practical Common Lisp by Peter Seibel is an excellent book, worth reading cover to cover and it will make you go Oooooh when you finally get macros. It doesn't cover Clojure, though. :-) |
| 16:04 | derefed | and it's free! |
| 16:04 | lespea | kotarak: oh that's sad :( I still think it's fun to try and tackle the problems... especially since it forces me to learn the clojure-way vs the scheme way. Though I see that I will run into walls later on :/ Do you have a better suggestion? |
| 16:04 | lespea | bmason: yeah I'm upto the concurency chapter |
| 16:05 | lespea | ska2342: oh sweet, I don't have that book -- maybe I'll have to get it. Can you download it online? (based off of derefed's comment) |
| 16:05 | derefed | yep I'll link you |
| 16:05 | ska2342 | lespea: gigamonkeys.com/book |
| 16:05 | derefed | d'oh |
| 16:05 | derefed | beat me to it |
| 16:07 | ska2342 | I still remember the day when I read "Parsing Binary Files". Do yourself a favor and read the book slowly up to that chapter. Really. |
| 16:08 | drocko | isn't it crazy when you have these revelations? |
| 16:08 | bmason | hmm... thanks for the link, I'll have to check that out too |
| 16:08 | drocko | you read something and then suddenly everything looks different |
| 16:08 | bmason | hah! |
| 16:08 | bmason | the one I loved was the 'select' syntax in clojure |
| 16:08 | bmason | (select predicate set) |
| 16:08 | ska2342 | drocko: isn't that the case with all major constructs? Like, closures, macros, STM :-) |
| 16:09 | drocko | ska2342: yes! |
| 16:09 | drocko | even outside of programming though, 'aha' moments are awesome |
| 16:09 | ska2342 | drocko: what's that "outside of programming"? |
| 16:10 | drocko | ska2342: for instance when i was studying art history and I learned about the history of perspective in paintings |
| 16:10 | bmason | ska2342: I/O |
| 16:10 | ska2342 | :-) |
| 16:10 | drocko | i read this book called 'changing images of pictorial space' |
| 16:10 | drocko | and suddenly every painting i looked at was different |
| 16:10 | drocko | same with when i read a book called 'what painting is' by james elkins |
| 16:11 | ska2342 | like, quantum mechanics. Yes, those were the day at university. Hm, it's been quite a while.... |
| 16:11 | drocko | yeah |
| 16:11 | bmason | The Pleasure of Finding Things Out, by Richard Feynman |
| 16:11 | somnium | when I read an abridged version of flatland... |
| 16:11 | bmason | brilliant series |
| 16:11 | ska2342 | Ah, Feynman. Good, and a good read, too. |
| 16:12 | bmason | http://www.youtube.com/watch?v=srSbAazoOr8 |
| 16:13 | ska2342 | Talking about books... anyone interested in a German Clojure book? |
| 16:14 | derefed | I would be |
| 16:14 | derefed | I've been studying german for a while |
| 16:14 | kotarak | ska2342: me too, but no introductory stuff |
| 16:15 | the-kenny | ska2342: If you seek some german-speaking clojure users, ask in #clojure.de ;) (Just a pointer) |
| 16:16 | ska2342 | So I may as well pick this particular moment to humbly announce it? http://www.dpunkt.de/buecher/3372.html :-) Please excuse the self-plug |
| 16:16 | lespea | wow thanks for the book link guys :D I'll have to get to reading. Man my weekend is disappearing :o |
| 16:18 | derefed | ska2342: hast du dieses buch geschrieben? |
| 16:18 | ska2342 | derefed: I still do. |
| 16:18 | derefed | oh cool |
| 16:18 | hiredman | how do I upgrade swank-clojure? |
| 16:18 | bsteuber | ausgezeichnet :) |
| 16:19 | hiredman | can I change which version of clojure and contrib swank-clojure uses? |
| 16:20 | kotarak | hiredman: converting? |
| 16:20 | bmason | it should just be a matter of your classpaths right? |
| 16:20 | hiredman | kotarak: I've been using emacs locally for a while now |
| 16:21 | bmason | won't lein let you create a swank server with whatever version you want? |
| 16:21 | hiredman | but I don't want a lein project |
| 16:21 | bmason | well :) |
| 16:21 | hiredman | I just want a 1.2 repl, I don't want contrib or anything else |
| 16:21 | bmason | I think you'd have to change your classpath another way then... |
| 16:22 | hiredman | the other issue is the clojure portion of swank-clojure is aot compiled |
| 16:22 | bmason | there's some functions to do that but I don't remember off the top of my head |
| 16:23 | hiredman | so just changing the jars or the classpath to point to newer version of clojure most likely will not be enough because this swank stuff was built with 1.0 so most likely will be binary incompatble |
| 16:23 | the-kenny | hiredman: Try calling C-h v swank-clojure-<TAB> |
| 16:24 | somnium | hiredman: there was a slim version in the repo, though I have a lein project with 1.2 that works with swank-clojure from clojars |
| 16:25 | Knekk | ,(doc apply) |
| 16:25 | clojurebot | "([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq." |
| 16:25 | hiredman | somnium: so I can get the slim version if I do a git checkout? |
| 16:27 | somnium | hiredman: maybe just checkout and jar it? the slim I had was from the ant days |
| 16:32 | derefed | if ELPA sets up my swank-clojure-classpath, how can I change it? it doesn't include the current directory and I need to add it |
| 16:34 | derefed | I threw a (setq swank-clojure-extra-classpaths) into my .emacs, but it didn't do anything |
| 16:34 | derefed | well, along with the paths themselves but I omitted that here |
| 16:36 | schizm | hi there, trying out clojure...java newbie. Following getting started and apparently I am missing some basic info. trying to execute "(. javax.swing.JOptionPane (showMessageDialog nil "Hello World"))" and it just sits there...so I grab jline, put it's jar in the clojure dir..and execute 'java -cp jline-0.9.91.jar:clojure.jar jline.ConsoleRunner clojure.main' and I get it not finding jline/ConsoleRunner. What simple assumption am I missing here? |
| 16:46 | schizm | anyone alive? surely someone is |
| 16:46 | Knekk | kinda |
| 16:46 | schizm | thoughts on my question there? Just want to get started on it :) |
| 16:47 | schizm | basically the first two items in 'getting started' 'fail on me |
| 16:47 | Knekk | sorry, I am not advanced enough to help you with that one |
| 16:48 | the-kenny | ,(System/getProperty "java.class.path") |
| 16:48 | clojurebot | java.security.AccessControlException: access denied (java.util.PropertyPermission java.class.path read) |
| 16:51 | bsteuber | schizm: I think everyone starting with clojure runs into some sort of classpath hazzle - expecially at the very beginning |
| 16:51 | schizm | bsteuber: it's kind of like a skill testing component? If you cannot figure this out, you are not worthy to run clojure? :P |
| 16:52 | Knekk | ok, dumb question. What's the best way to check if \1 is in (\1 \2 \3) ? |
| 16:52 | texodus | ,(#{\1 \2 \3} \1) |
| 16:52 | clojurebot | \1 |
| 16:53 | bsteuber | schizm: no, sorry - that was not my intention. I just wanted to encourage you, but I don't know what's wrong with your setup |
| 16:53 | schizm | I am making the assumption that "." is searched for jars |
| 16:53 | texodus | ,(#{\1 \2 \3} \4) |
| 16:53 | clojurebot | nil |
| 16:53 | schizm | it obviously is for clojure.jar, why would jline not ba found |
| 16:53 | schizm | I am not a java guy, was never drawn to it |
| 16:53 | schizm | so |
| 16:53 | schizm | *shrug* |
| 16:53 | bsteuber | I never used the JLine setup |
| 16:54 | Knekk | texodus: thanks. now to figure out how to do it using every? |
| 16:54 | schizm | bsteub: only reason I was trying was cause the first 'try this line' just sits there doing nothing |
| 16:54 | schizm | :) |
| 16:55 | bsteuber | schizm: so what setup do you usually have? |
| 16:55 | schizm | 'do I usually have' meaning what? |
| 16:55 | schizm | I run on a variety of boxen, this one happens to be a win7x64 box w/ cygwin |
| 16:55 | texodus | ,(doc every?) |
| 16:55 | clojurebot | "([pred coll]); Returns true if (pred x) is logical true for every x in coll, else false." |
| 16:56 | bsteuber | schizm: I meant the way you talked to clojure when trying the example at first |
| 16:57 | schizm | java -cp clojure.jar clojure.main, as per the 'getting started' pag |
| 16:57 | schizm | http://clojure.org/getting_started |
| 16:57 | bsteuber | ok |
| 16:57 | schizm | 2nd line it says to try is: (. javax.swing.JOptionPane (showMessageDialog nil "Hello World")) |
| 16:57 | schizm | I try that, assumption is a pop-up of some sort I imagine? nothing. |
| 16:58 | schizm | oh syntax file for vim, nice, that will make life easier |
| 16:59 | lespea | make sure you turn on rainbow parens :) |
| 16:59 | bsteuber | schizm: I think most use emacs with swank-clojure, some vimclojure, some a netbeans plugin |
| 16:59 | bsteuber | whatever you feel comfortable with |
| 17:00 | schizm | I used to be an emacs guy...once I decided to really learn VIM that changed :) |
| 17:00 | schizm | I used VI back in the early 90s, but never really 'learned' it |
| 17:00 | lespea | I could never get vimclojure to compile :( I'm using slimv (which sorta sucks) |
| 17:00 | lespea | maybe I should try it again... |
| 17:00 | bsteuber | I really love paredit in emacs |
| 17:01 | texodus | ,(not (every? #(not (= \1 %)) [\4 \2 \3])) |
| 17:01 | clojurebot | false |
| 17:01 | texodus | ,(not (every? #(not (#{\1} %)) [\1 \2 \3])) |
| 17:01 | clojurebot | true |
| 17:01 | texodus | thats abusive |
| 17:04 | bsteuber | schizm: but it's very strange you didn't get a window popping up in the first place |
| 17:04 | schizm | bsteuber: I concur :) |
| 17:06 | hiredman | ugh |
| 17:07 | hiredman | that is lame, why instead there an IChunkBuffer |
| 17:08 | itistoday | anyone from japan here? |
| 17:09 | somnium | itistoday: I used to live in yokohama, but I guess thats a no |
| 17:11 | itistoday | somnium: do you know any japanese immigrants that I could ask a few questions? |
| 17:11 | somnium | itistoday: not off hand |
| 17:11 | kotarak | lespea: if you have trouble with VC ask me |
| 17:12 | somnium | itistoday: I guess it would depend on the questions too O_o |
| 17:12 | itistoday | somnium: just related to their reactions to America |
| 17:18 | somnium | itistoday: I heard some varied opinions when I was a translator, but I expect you could get the general spectrum from google. |
| 17:19 | itistoday | somnium: the problem is finding something not written in japanese... |
| 17:19 | defn | "1240255294 foo #xyz http://www.youtube.com/" -- Given a string like this what is the best way to get the last item in that list? |
| 17:19 | defn | the url i mean |
| 17:19 | defn | (last (split-with)) maybe? |
| 17:22 | somnium | itistoday: 'people dont use umbrellas', 'trains are always late', and 'the squirrels are cute' were some of my favorites |
| 17:22 | itistoday | somnium: hehe, all unrelated to american culture though |
| 17:22 | bsteuber | defn: split-with only gives you two collections |
| 17:23 | defn | re-split maybe |
| 17:23 | defn | ah yes |
| 17:23 | defn | there we go |
| 17:26 | defn | now to figure out what i should do with 7000 urls from #clojure |
| 17:28 | bsteuber | ,(re-seq #"[^ ]*" "ab adsdjsk dsd") |
| 17:28 | clojurebot | ("ab" "" "adsdjsk" "" "dsd" "") |
| 17:28 | bsteuber | or did you find anything better? |
| 17:28 | defn | (map #(last (re-split #" " %) urls)) |
| 17:29 | defn | then i convert it to a set to get uniques |
| 17:29 | defn | (set (map #(last (re-split #" " %) urls))) |
| 17:30 | bsteuber | `re-split |
| 17:30 | bsteuber | ,`re-split |
| 17:30 | clojurebot | sandbox/re-split |
| 17:30 | bsteuber | I don't have re-split out of the box |
| 17:31 | defn | it's in str-utils |
| 17:31 | StartsWithK | (seq (.split "string" re-string)) |
| 17:31 | bsteuber | ic |
| 17:32 | bsteuber | I'm just too unexperienced in the Java world I guess |
| 17:32 | defn | bsteuber: i suggest getting a lame java book |
| 17:32 | defn | and then do all the examples with clojure |
| 17:33 | defn | it makes java not suck |
| 17:35 | bsteuber | hmm, maybe I really should :) |
| 17:36 | bsteuber | but I need a book about the libraries, not the concepts |
| 17:37 | somnium | yeah, nothing like studying the visitor pattern and factory factories with a lisp |
| 17:39 | technomancy | I've wanted to write an introduction to JVM I/O for a while. |
| 17:39 | technomancy | that's the hardest JDK stuff to avoid in Clojure |
| 17:39 | nteon | is there a function that returns whether a symbol is defined? |
| 17:40 | defn | technomancy: inputstreamreader and all of that? |
| 17:41 | technomancy | ,(ns-resolve 'clojure.core 'undefined) |
| 17:41 | clojurebot | nil |
| 17:41 | technomancy | nteon: ^^ |
| 17:41 | nteon | technomancy: fabulous! thanks |
| 17:41 | technomancy | nteon: pedantry: symbols are not bound to values, vars are |
| 17:41 | technomancy | but vars are named with symbols |
| 17:41 | technomancy | defn: right |
| 17:41 | defn | yeah that was hard to understand at first |
| 17:41 | defn | very foreign |
| 17:41 | defn | specially coming from ruby |
| 17:42 | technomancy | defn: especially if you're used to a language that treats all strings as (ugh) byte arrays. |
| 17:42 | technomancy | took me a while to realize it really was more complex for a reason. =) |
| 17:42 | nteon | technomancy: so what is the correct way to phrase what I asked? |
| 17:42 | Raynes | Is there a function like Haskell's 'group' which creates a list of lists of duplicate elements in a list? For example: (group "aabbbc") -> ((\a \a) (\b \b \b) (\c)) or something similar. |
| 17:42 | technomancy | nteon: it would be checking whether a var is bound to a value. |
| 17:43 | technomancy | def forms create vars |
| 17:43 | nteon | technomancy: let forms as well, right? |
| 17:44 | bsteuber | ,(find-var `undefined) |
| 17:44 | clojurebot | nil |
| 17:44 | defn | java is an estrogen language |
| 17:44 | arbscht | Raynes: maybe c.c.seq/partition-by |
| 17:44 | technomancy | nteon: no, let forms only create locals |
| 17:44 | defn | http://www.stumbleupon.com/su/1YmbwB/enfranchisedmind.com/blog/posts/what-killed-lisp-could-kill-haskell-as-well//r:t |
| 17:44 | bsteuber | what's the difference between find-var and ns-resolve? |
| 17:44 | technomancy | nteon: so actually ns-resolve might not be what you want if you want it to also look for locals. |
| 17:45 | technomancy | bsteuber: ns-resolve takes the namespace as a separate arg; find-var takes a single namespace-qualified symbol |
| 17:45 | nteon | technomancy: scratch that, I don't need to look for locals |
| 17:45 | bsteuber | technomancy: ic, thanks |
| 17:45 | technomancy | nteon: locals are a bit different since they're totally immutable |
| 17:45 | tomoj | seq-utils was renamed to seq? |
| 17:46 | bsteuber | ,(doc partition-by) |
| 17:46 | defn | is there any refactoring browser for clojure? |
| 17:46 | clojurebot | "([f coll]); Applies f to each value in coll, splitting it each time f returns a new value. Returns a lazy seq of lazy seqs." |
| 17:46 | SynrG | win 23 |
| 17:46 | SynrG | meh |
| 17:46 | tomoj | ,(partition-by identity "aabbbc") |
| 17:46 | clojurebot | ((\a \a) (\b \b \b) (\c)) |
| 17:47 | defn | ^cool |
| 17:47 | tomoj | ,(let [group (partial partition-by identity)] (group "aabbbc")) |
| 17:47 | clojurebot | ((\a \a) (\b \b \b) (\c)) |
| 17:48 | Raynes | Awesome. |
| 17:48 | somnium | they have to be in order though |
| 17:48 | tomoj | yeah, that's what haskell's group does |
| 17:49 | tomoj | if you were looking for a histogram it'd seem strange to me to return seqs of duplicates instead of just a map from values to counts anyway |
| 17:49 | Raynes | Ioke's group does what I want, but doesn't preserve order. :( |
| 18:05 | defn | Anyone here use TDD with clojure? |
| 18:06 | bsteuber | defn: yeah, just started and liked it |
| 18:06 | defn | using clojure's testing tools |
| 18:06 | defn | or outside stuff? |
| 18:06 | bsteuber | default language and clojure-test-mode for emacs |
| 18:06 | bsteuber | is etc |
| 18:06 | defn | cool |
| 18:07 | defn | ive messed with it a bit but i never can get into doing it all the time |
| 18:07 | tomoj | one thing that bothers me about clojure-test-mode is that are doesn't really work |
| 18:07 | defn | i need some discipline! |
| 18:07 | bsteuber | ,(is 42) |
| 18:07 | clojurebot | java.lang.Exception: Unable to resolve symbol: is in this context |
| 18:07 | tomoj | you just see that the entire are template failed, but don't see which parts of it failed |
| 18:07 | defn | ,(use clojure.test) |
| 18:07 | clojurebot | java.lang.ClassNotFoundException: clojure.test |
| 18:07 | defn | ,(use 'clojure.test) |
| 18:07 | clojurebot | nil |
| 18:08 | defn | ,(is 42) |
| 18:08 | clojurebot | DENIED |
| 18:08 | defn | oops nvm |
| 18:08 | bsteuber | tomoj: yeah, I ran into the same issue and therefore started to do one single (is call for each statement |
| 18:08 | bsteuber | withoug generating is from functions or macros |
| 18:08 | bsteuber | that worked pretty well |
| 18:08 | tomoj | it's unfortunate, though |
| 18:08 | defn | ive read rich's thoughts on TDD in clojure, that it is less necessary in a purely functional language |
| 18:09 | tomoj | I wonder if it's feasible to make clojure-test-mode smarter about that stuff |
| 18:09 | defn | which i tend to agree with |
| 18:09 | tomoj | or if it'd require a bunch of patching to clojure.test |
| 18:09 | defn | but there are many situations where tests would be nice |
| 18:09 | tomoj | I'm fine with clojure.test, where I am unhappy is with integration testing |
| 18:10 | technomancy | tomoj: I actually never really got into the are clause |
| 18:10 | tomoj | to the point that I will probably not write those tests in clojure |
| 18:10 | technomancy | clojure-test-mode was only designed to work with "is" |
| 18:10 | technomancy | patches welcome. =) |
| 18:10 | tomoj | yeah, I just suspect it'd be very painful to make it work with "are" :( |
| 18:10 | technomancy | possibly |
| 18:13 | defn | tomoj: it's only painful until it isn't! |
| 18:13 | defn | :) |
| 18:15 | bsteuber | maybe one could define a custom version of are which the source of all test data there |
| 18:15 | bsteuber | there's a "tracks" missing |
| 18:15 | defn | bsteuber: have any simple examples of your work with clojure-test-mode? |
| 18:15 | defn | simple code i mean |
| 18:15 | bsteuber | defn: http://github.com/bsteuber/clj-go/blob/master/test/clj_go_test.clj |
| 18:16 | defn | awesome |
| 18:16 | defn | thanks :) |
| 18:17 | bsteuber | (though my lib itself is just at commit 3 at the moment, so don't expect anything non-trivial^^) |
| 18:17 | defn | nono that's good |
| 18:17 | tomoj | so it looks like clojure-test-mode just jumps two spaces up the stack and grabs the line number from there |
| 18:17 | defn | im just curious to see how people are using it in practice |
| 18:18 | bsteuber | the tests don't look lispy or DRY at all, but for the moment I'm fine with that |
| 18:18 | tomoj | maybe line numbers for macroexpanded code is bad? |
| 18:20 | bsteuber | actually the only repetition is (is (foo.. , so it's not that bad |
| 18:20 | bsteuber | hey, I also do Java projects ;) |
| 18:22 | bsteuber | defn: there are some more examples at http://github.com/bsteuber/clj-go/blob/master/test/clj_go/board_test.clj |
| 18:27 | defn | bsteuber: thanks |
| 18:49 | Scriptor | bsteuber: does it support rule of Ko? |
| 18:50 | Scriptor | at least, that's what I think it's called, been a while |
| 18:50 | Raynes | Ko? Is somebody writing Go? |
| 18:50 | Raynes | Oh, should have read up. |
| 19:01 | bsteuber | scriptor: I just started the project, so it doesn't even support capture yet |
| 19:01 | Scriptor | ah |
| 19:02 | Raynes | bsteuber: I've wanted to this for a long time, but I'm too stupid. |
| 19:02 | Raynes | :| |
| 19:02 | Raynes | Maybe I can contribute somewhere down the line. |
| 19:03 | bsteuber | raynes: that'd be great |
| 19:03 | bsteuber | but as a clojure programmer I hardly believe you're too stupid :) |
| 19:04 | bsteuber | it just takes time to get all of that crazy stuff |
| 19:04 | Raynes | Oh, I'm sure I could Get It Done(TM), but it would be an ugly mess. |
| 19:05 | bsteuber | I think I've got you wrong - so your problem is writing go algorithms, not playing go |
| 19:06 | Raynes | Well I suck at the game as well, but that's a different story. |
| 19:06 | bsteuber | I guess mine might become elegant but slow as hell :) |
| 19:06 | Raynes | ;) |
| 19:06 | bsteuber | but I don't plan to use it for AI at this point, so it doesn't matter |
| 19:07 | bsteuber | I'd rather roll my own Go problem website one day |
| 19:11 | thearthur | how do I do this: (def [a b] [(first foo) (second foo)]) |
| 19:11 | thearthur | bind two names with one def |
| 19:16 | _ato | thearthur: def doesn't work that way, you'd need to do: (def a (first foo)) (def b (second foo)) |
| 19:16 | Scriptor | would it be possible to do that with a macro? |
| 19:17 | _ato | yes, you could write a macro to do it |
| 19:22 | rem7 | how come you can do (first '(items in list)) and items (not a string,,, what is it?) but you can't do (= (first '(items in list)) items) --> Unable to resolve symbol |
| 19:23 | rem7 | is that because the sequence is lazy and hasn't evaluated the elements inside? |
| 19:23 | somnium | ,(= (first '(items in list)) 'items) |
| 19:23 | clojurebot | true |
| 19:24 | rem7 | huh... need to put the quote first |
| 19:25 | hiredman | rem7: http://en.wikipedia.org/wiki/Lisp_%28programming_language%29#Self-evaluating_forms_and_quoting |
| 19:25 | bmason | Raynes: awesome, I was thinking about writing a clojure Go board myself |
| 19:25 | rem7 | hiredman: thanks |
| 19:26 | bmason | er I guess that's bsteuber's :) |
| 19:31 | bmason | so I'm making a web service in compojure, and I'd like to differentiate between web browsers and other clients, and give browsers a friendly HTML version |
| 19:32 | bmason | not sure how to determine the type of client though |
| 19:35 | bmason | hmm ok, looks like I should be able to grab the User-Agent string from the HTTP headers |
| 19:52 | Raynes | bmason: Yes, that's definite bsteuber's :p |
| 19:52 | bmason | i r bad reader |
| 20:02 | drocko | hm |
| 20:03 | drocko | maybe i am just not getting this. how do i layout my project so i can use swank-clojure-project? |
| 20:03 | drocko | dependency jars go in project_root/lib |
| 20:03 | drocko | i got that |
| 20:03 | drocko | and there is a src and a classes directory |
| 20:03 | drocko | what goes in those? |
| 20:10 | bmason | src = your clojure source, classes = compiled classes I think... |
| 20:10 | bmason | lemme check |
| 20:11 | bmason | I don't have anything in my classes directory... so not sure |
| 20:11 | drocko | i see |
| 20:11 | drocko | ok |
| 20:11 | bmason | do you use lein? |
| 20:12 | bmason | "lein new myprojectname" will create the appropriate structure |
| 20:14 | drocko | ah |
| 20:14 | drocko | ok |
| 20:15 | bmason | I'm really not sure where swank-clojure-project fits in... I didn't see much use for it once I figured out lein |
| 20:15 | bmason | I don't know if it's deprecated or just an alternate method of creating a swank server around a project |
| 20:17 | hiredman | what does .dropFirst on a chunk do? |
| 20:23 | rhickey | hiredman: returns a chunk without the first element |
| 20:29 | technomancy | bmason: it's just an alt. (pure-elisp) method of starting a swank-server |
| 20:29 | technomancy | "lein swank" is a clj implementation of the same thing. |
| 20:30 | bmason | ok, so the net result is the same? |
| 20:30 | technomancy | yup |
| 20:30 | bmason | makes sense now, thanks :) |
| 20:53 | hiredman | implementing all the interfaces you need to do a clojure datastructure with reify is crazy |
| 20:59 | rhickey_ | hiredman: vs waht? |
| 20:59 | rhickey_ | what? |
| 20:59 | clojurebot | what is short for ,(doc ...) |
| 21:01 | hiredman | crazy like oh my god there are a lot of them |
| 21:01 | rhickey_ | hiredman: yeah |
| 21:01 | rhickey_ | I'm working on macro-like mixins for reify and deftype |
| 21:01 | hiredman | mmm |
| 21:03 | hiredman | are transients to be superceded by cells? or will the transient interface stick around, implemented with cells? |
| 21:05 | rhickey_ | there are two aspects to transients - the symbiotic relationship to a particular persistent data structure, which is what enables the O(1) to/from capability, and the single-threaded policy bit. The policy stuff may move to cells |
| 21:05 | hiredman | hmmm, I guess I was only thinking of vectors |
| 21:11 | Raynes | http://www.dreamincode.net/forums/index.php?showtopic=160236&view=findpost&p=951227 |
| 21:17 | tomoj | hah |
| 21:17 | tomoj | "Programming Theoretician" |
| 21:17 | fanatico | Raynes: I'm not sure you want to mess with that guy. He's an *expert* in 11 languages. |
| 21:18 | Raynes | fanatico: 'Expert' is just a badge on the site you get for helping people significantly. |
| 21:19 | fanatico | I was being facetious. |
| 21:20 | tomoj | I wonder what he wants to replace the doseq with |
| 21:20 | tomoj | uh, "I use my vast experience in a plethora of programming languages to help those who seemingly can't be helped" |
| 21:21 | tomoj | he's also managed to run the gambit |
| 21:23 | schizm | I've never run a gambit :P |
| 21:23 | somnium | maybe its a clever scheme pun |
| 21:24 | nteon | anyone know why "extern? #(resolve '%)" works in a let statement, but "extern? #(not (resolve '%))" gives me: |
| 21:24 | nteon | java.lang.IllegalArgumentException: No matching method found: intern |
| 21:24 | nteon | I'm plain old stumped. |
| 21:26 | hiredman | erm |
| 21:26 | hiredman | why are you quoting %? |
| 21:29 | tomoj | ,(#(identity '%) 3) |
| 21:29 | clojurebot | p1__11550 |
| 21:29 | tomoj | huh |
| 21:30 | tomoj | oh, I see why that happens |
| 21:30 | tomoj | crazy |
| 21:30 | nteon | hiredman: I shouldn't be, thats the problem. |
| 21:35 | nteon | tomoj: would you mind explaining? I understand the problem is with me trying to resolve a local, but don't get whats actually happening that gives an intern method not found |
| 21:35 | tomoj | sorry, I didn't understand your problem |
| 21:35 | hiredman | do you know what #() is? |
| 21:35 | tomoj | just why (#(identity '%) 3) gives results like that |
| 21:36 | nteon | sure, its an anonymous function |
| 21:36 | hiredman | ,(macroexpand-1 '#(identity '%)) |
| 21:36 | clojurebot | (fn* [p1__11560] (identity (quote p1__11560))) |
| 21:36 | hiredman | ,(macroexpand-1 '#(identity %)) |
| 21:36 | clojurebot | (fn* [p1__11572] (identity p1__11572)) |
| 21:37 | tomoj | ,(#(get % '%) '{p1__11606 42}) |
| 21:37 | clojurebot | 42 |
| 21:40 | hiredman | ,((pl λx'x) 1) |
| 21:40 | clojurebot | x |
| 21:41 | tomoj | ,(doc pl) |
| 21:41 | clojurebot | "([& forms]); replaces a $ b with (a b) walking right to left replaces a · b with (comp a b) left to right ⌽a with (uncurry a) left to right ↕a with (flip a) left to right" |
| 21:41 | hiredman | ,(macroexpand '(pl λx x)) |
| 21:41 | clojurebot | (do (fn [x] x)) |
| 21:42 | tomoj | ,['a'b'c] |
| 21:42 | clojurebot | [a b c] |
| 21:42 | tomoj | weird |
| 21:43 | hiredman | ,(prn 'a' 1) |
| 21:43 | clojurebot | a 1 |
| 21:44 | tomoj | tricky |
| 21:44 | tomoj | I envision a set of clojure koans |
| 21:45 | Raynes | You know, that that I linked is actually one of the few really negative reviews I've seen for Clojure. Usually people just whine about the parentheses. |
| 21:46 | tomoj | well.. |
| 21:46 | tomoj | I think that's really what was happening there |
| 21:46 | tomoj | "readability" |
| 21:47 | hiredman | I installed emacs starter kit for a setup I needed really fast last week, by default it sets some weird colors for the parens that aren't visible on a dark background |
| 21:48 | hiredman | not having my parens freaked me out |
| 21:48 | tomoj | I think the default is meant to be barely visible in a normal emacs |
| 21:49 | hiredman | :( |
| 21:51 | tomoj | parentheses seem to be the main complaint I've heard from people as well |
| 21:51 | tomoj | other than "java? ick" |
| 21:52 | tomoj | I'm not even sure I can tell whether I like the way parentheses look |
| 21:52 | tomoj | or if I've just brainwashed myself into loving them |
| 22:05 | technomancy | hiredman: yeah, unfortunately emacs in a screen session is usually limited to 8 colors |
| 22:05 | technomancy | which is really lame. =\ |
| 22:05 | technomancy | hiredman: M-x customize-face esk-paren-face will fix it |
| 22:07 | technomancy | or rather will allow you to fix it |
| 22:08 | hiredman | technomancy: oh, I just dug through some elisp file and ripped it out |
| 22:08 | technomancy | that also work |
| 22:08 | hiredman | (ironically editing it with vim) |
| 22:08 | technomancy | I should probably wrap that in a (when window-system) |
| 22:09 | technomancy | though you can still launch in a window system and connect to that instance from the terminal. |
| 22:09 | hiredman | starter kit is pretty nice though |
| 22:09 | hiredman | I wish I had started with it for my actual ~/.emacs |
| 22:09 | hiredman | .emacs.d |
| 22:09 | technomancy | it's ok... I want to get rid of it though. =) |
| 22:10 | technomancy | actually I want to get package.el included in Emacs and then break it up into a number of smaller packages. |
| 22:10 | hiredman | right, get rid of everything |
| 22:10 | defn | i used starter kit as sort of my frankenstein kit |
| 22:11 | defn | left it off to the side and grabbed pieces i agreed with |
| 22:11 | technomancy | defn: in a sense that's even better |
| 22:11 | technomancy | since you know what you're getting into |
| 22:11 | defn | yeah i think that worked better |
| 22:11 | technomancy | you probably understand it better than most people who just take it wholesale |
| 22:11 | defn | i wanted to understand what i was using, how to use it |
| 22:12 | defn | i renamed it all defn-*.el to make it my own :) |
| 22:12 | technomancy | as long as you didn't miss ido-imenu. that's one of my favourites. |
| 22:12 | technomancy | (though not as necessary if you have slime actually) |
| 22:12 | defn | yeah that's great -- i definitely use that |
| 22:13 | defn | i would have lost my mind with emacs if it weren't for the custom.el and the custom auto-save stuff |
| 22:13 | defn | i go between two computers with this config so having custom.el was really nice |
| 22:14 | defn | not to mention your loaddefs stuff, and then your elpa-to-submit had all sorts of fun things i have learned to love |
| 22:15 | defn | gist.el, textmate.el, etc. etc. |
| 22:15 | technomancy | It looks like package.el will be included in Emacs soon. |
| 22:15 | defn | all in all it gave me more of a framework for building my own emacs config -- which i think is the most important thing |
| 22:15 | technomancy | yep, teach a man to fish, etc. =) |
| 22:15 | defn | now if i find myself adding a bunch of customization for, for instance, markdown |
| 22:15 | defn | i create a defn-markdown.el and am able to split it off in a coherent way that makes sense to me |
| 22:16 | defn | the starter kit is great though, in that i wasn't intimidated by it |
| 22:16 | defn | i think just by virtue of the fact that it's named "starter kit" -- i felt more at ease with it |
| 22:17 | defn | if it was "phil's epic emacs config" |
| 22:17 | defn | i would have probably have just stared at it...scared |
| 22:18 | nteon | ,((fn [i j] (for [k (range (count i))] `(~(i k) ~(j k)))) '[a b c] '[x y z]) |
| 22:18 | clojurebot | ((a x) (b y) (c z)) |
| 22:18 | defn | if you tell someone something is "basic" "simple" etc. I think they're more likely to dig into it after awhile |
| 22:18 | nteon | does anyone know how to make that less awful? |
| 22:19 | defn | ,(interleave [a b c] [x y z]) |
| 22:19 | clojurebot | java.lang.Exception: Unable to resolve symbol: a in this context |
| 22:20 | defn | ,(interleave [:a :b :c] [:x :y :z]) |
| 22:20 | clojurebot | (:a :x :b :y :c :z) |
| 22:20 | defn | some variation on that maybe? |
| 22:20 | nteon | defn: close, but I need them to be paired |
| 22:20 | defn | ,(partition 2 (interleave [:a :b :c] [:x :y :z])) |
| 22:20 | clojurebot | ((:a :x) (:b :y) (:c :z)) |
| 22:20 | defn | :) |
| 22:20 | technomancy | defn: yeah, I've had my dotfiles in public version control for years, but when I made the Emacs PeepCode I tidied them up and made it more fit for human consumption... and now it's on the top 10 forked projects on github. |
| 22:20 | nteon | ah, partition! |
| 22:21 | nteon | defn: thanks :) |
| 22:21 | defn | np |
| 22:21 | technomancy | so folks must be really finding it useful |
| 22:21 | defn | technomancy: i am somewhat embaressed to admit that i tried to learn emacs probably 4-5 times before i got the starter kit and aliased vi/vim='emacs -nw' |
| 22:22 | defn | your kit got me over the hump |
| 22:22 | fanatico | ,(map vector [1 2 3] [4 5 6]) |
| 22:22 | clojurebot | ([1 4] [2 5] [3 6]) |
| 22:22 | defn | fanatico: nice |
| 22:24 | defn | technomancy: it was sort of a running joke with my friends that i had kept trying to learn emacs. many of them have switched now as a result of your dotfiles as well. |
| 22:25 | defn | technomancy: like you said, the "teach a man to fish" aspect is very important. if you can show someone how to do some basic emacs configuration, most will discover what i did: it's not about bending to emacs' will -- it's about bending emacs to your own will |
| 22:25 | defn | which is what is so fun and cool about emacs IMHO |
| 22:25 | defn | you can do the same sorts of customization in vi of course, just not to the same extent |
| 22:25 | defn | macros FTW |
| 22:26 | defn | learning clojure + emacs has been a great experience for me as a programmer -- you get to see the evolution |
| 22:27 | defn | </rant> |
| 22:29 | fanatico | technomancy: so we'll see package.el in 23.2? awesome. |
| 22:29 | defn | yeah that's awesome news |
| 22:30 | defn | nteon: as fanatico said you can also do: |
| 22:31 | defn | ,(map list [1 2 3] [4 5 6]) |
| 22:31 | clojurebot | ((1 4) (2 5) (3 6)) |
| 22:31 | defn | which is even sexier |
| 22:31 | TheBusby | sorry to ask an IRC related question here, but any idea why I can only see "/me" text? |
| 22:32 | defn | TheBusby: what do you mean by /me text? |
| 22:32 | defn | your /me output shows up just fine |
| 22:32 | technomancy | fanatico: actually it's too late for 23.2, so it will need to wait for 24.1 |
| 22:32 | nteon | defn, fanatico: oh that is sexy |
| 22:33 | technomancy | by "included in Emacs soon" I meant "included in Emacs source tree" rather than a release. |
| 22:33 | defn | how big of a part does RMS play in emacs these days? |
| 22:33 | technomancy | defn: he's kind of like the Queen of England I guess. |
| 22:33 | technomancy | me mostly just meets with foreign dignitaries. |
| 22:34 | defn | to discuss their surrender? |
| 22:34 | defn | ;) |
| 22:34 | technomancy | hehe |
| 22:35 | defn | I'm curious to see what happens with TextMate on this next release |
| 22:35 | defn | TM is very emacs-ish in a lot of ways |
| 22:35 | defn | not enough customization for my taste, but still a very nice editor in many respects |
| 22:36 | defn | the author has taken a lot of cues from emacs |
| 22:37 | technomancy | well, you don't customize it using the same tools that the author uses to write it... so it kind of misses the biggest point. |
| 22:37 | defn | technomancy: yeah exactly |
| 22:37 | fanatico | TM2 has a bad case of second-system syndrome. It'll be interest what, if anything, ever comes out of that. |
| 22:37 | defn | i like the idea of bundles -- it's sort of like packages in emacs in certain respects |
| 22:38 | defn | but again technomancy -- you are correct in that you can only take that abstraction so far before you need to get under the hood |
| 22:40 | defn | fanatico: yeah im not sure what he's doing with it these days.. i was a long time TM user but i was absolutely annoyed when i couldnt use it on linux at work. i mean, i knew what iw as getting into, but it underlined the biggest problem with the editor IMO |
| 22:40 | defn | it's all Mac, all GUI, and everything i learn to do inside of it is relegated to a very specific context |
| 22:40 | defn | that sucks. |
| 22:40 | fanatico | What TM did implement, it did it fairly well. Very good case for "worse is better". And it makes for an amazing demo. |
| 22:41 | defn | i would kill to have an emacs that managed projects in the way TM does |
| 22:42 | defn | you can get the same functionality in emacs, but it is clunky |
| 22:42 | defn | i might just be doing it wrong. but it has never felt as smooth as project management did with TM |
| 22:43 | fanatico | technomancy: luckily we've got maintainers who'll release faster than once every six years. |
| 22:45 | technomancy | well, the biggest part is you can't fix it yourself or help out with the release of version 2 |
| 22:46 | fanatico | hah, I was referring to Stallman and Emacs from 2001 - 2007, but TM fits as well. |
| 22:47 | fanatico | Monnier and Yidong seem to have their act together. |
| 22:48 | defn | nteon: i should say that it has been my constant experience with clojure that you go from writing a macro to realizing what you want to do is built into the language in some other simple way |
| 22:49 | defn | nteon: luckily refactoring in clojure isn't as painful as other languages (see java) |
| 22:50 | nteon | defn: heh, I'm pretty new to it but that doesn't sound too off the mark. Anything in particular you were referring to? |
| 22:51 | defn | nteon: nah not really, just seeing your original question and watching me go : oh interleave + partition, and then someone else weighing in saying (map list [1 2 3] [4 5 6]) |
| 22:52 | defn | that is typical and not something to obsess over, but i like to flag stuff i write and then come back and say "okay, i know this is easier, just needs more study on my part" |
| 22:52 | technomancy | fanatico: right, but I was using Emacs 22 well before it was released in '07; no such luck with the secret development of TM. |
| 22:53 | defn | if you ever find something you think is "ugly", with rare exception there is probably a better way of doing it, that has been my experience |
| 22:53 | defn | just saying... |
| 22:53 | defn | technomancy: yeah it's highly annoying on that front |
| 22:54 | defn | RedCar is a cool piece of hackery. Dan Lucraft has worked some magic with that |
| 22:54 | nteon | defn: yea! I was just showing my friend how much shorter and simpler all of your solutions were |
| 22:55 | defn | nteon: it's fun to see how much you can express in a single function i think |
| 22:56 | defn | nteon: im used to just strining method calls along, so seeing some of these really elegant functions has been a revelation |
| 22:56 | defn | stringing |
| 22:57 | defn | anyway, im heading to bed after a 20oz steak and a few glasses of wine :) |
| 22:57 | defn | good night all |
| 22:57 | nteon | defn: hah, night |
| 22:57 | hiredman | braggart |
| 22:58 | defn | :) honestly i feel somewhat sick due to food overload |
| 22:58 | defn | i wouldn't be jealous if i were you :) |
| 22:58 | defn | haha good night |
| 22:59 | tomoj | defn gives me an idea |
| 22:59 | Knekk | hmm, what's the easiest way to obtain the X number of digits after the decimal point of an irrational number? |
| 23:00 | tomoj | I think that question has no good answer |
| 23:01 | tomoj | the easiest way to obtain the digits of pi is likely not the easiest way to obtain the digits of other irrationals |
| 23:01 | Knekk | right, I am not concerned about pi specifically. |
| 23:01 | tomoj | well, you must have some specific concern, no? |
| 23:02 | tomoj | otherwise I don't see how you could possibly make any progress |
| 23:02 | Knekk | playing around with project euler. I need to find an irrational number with specific properties. |
| 23:02 | Knekk | this one specifically http://projecteuler.net/index.php?section=problems&id=26 |
| 23:02 | tomoj | ok, but how are you going to tell the computer which irrational number you're talking about? |
| 23:03 | Knekk | 1/d for 0 < d < 1000 |
| 23:03 | tomoj | hmm |
| 23:03 | tomoj | those look like rational numbers to me |
| 23:04 | Knekk | yes sorry, I misspoke |
| 23:04 | tomoj | well |
| 23:04 | Knekk | I meant unending decimal fraction parts |
| 23:04 | tomoj | I think you'll be better off in #math |
| 23:04 | hiredman | that is going to be a problem, how are you getting the decimal representation of the numbers? |
| 23:05 | tomoj | the floating point types available don't have enough precision, I think |
| 23:05 | Knekk | right, my thinking is to first find the decimal representation and put it into a seq, then do a pattern match |
| 23:05 | Knekk | put the digits into a seq I meant |
| 23:05 | Knekk | sorry, my brain's fried. Long day |
| 23:06 | tomoj | well, are you looking for something easier than long division, or..? |
| 23:06 | Knekk | something that works... |
| 23:06 | Knekk | clojure converts to bignum automatically, but I can't get a good representation |
| 23:09 | hiredman | http://www.cimt.plymouth.ac.uk/resources/res1/decimals.htm might be a good place to start |
| 23:11 | hiredman | hmmm |
| 23:12 | hiredman | that might be problematic to solve for the exponents because java's log stuff is double based |
| 23:13 | Knekk | I've been looking at those approaches and keep thinking there must be an easier way. |
| 23:13 | hiredman | that would be #math |
| 23:13 | Knekk | yeah |
| 23:14 | Knekk | thanks |
| 23:18 | fanatico | Knekk: I may be talking out of my ass, but couldn't you use a taylor series to find 1/x to some arbitrary number of decimal places? |
| 23:18 | hiredman | ,(* (Math/pow 10 6) 1/7) |
| 23:18 | clojurebot | 142857.1428571429 |
| 23:18 | tomoj | that sounds strange to me |
| 23:19 | Knekk | ,(* (Math/pow 10 12) 1/7) |
| 23:19 | clojurebot | 1.428571428571429E11 |
| 23:19 | Knekk | ,(format "%100d" (* (Math/pow 10 12) 1/7)) |
| 23:19 | clojurebot | java.util.IllegalFormatConversionException: d != java.lang.Double |
| 23:20 | Knekk | ,(format "%100f" (* (Math/pow 10 12) 1/7)) |
| 23:20 | clojurebot | " 142857142857.142900" |
| 23:20 | hiredman | ,(map #(* (Math/pow 10 %) 1/7) (range 10)) |
| 23:20 | clojurebot | (0.1428571428571429 1.428571428571429 14.28571428571429 142.85714285714292 1428.5714285714291 14285.71428571429 142857.1428571429 1428571.428571429 1.4285714285714291E7 1.428571428571429E8) |
| 23:21 | Knekk | ,(format "%100f" (* (Math/pow 10 16) 1/7)) |
| 23:21 | clojurebot | " 1428571428571429.000000" |
| 23:21 | Knekk | ,(format "%100f" (* (Math/pow 10 20) 1/7)) |
| 23:21 | clojurebot | " 14285714285714290000.000000" |
| 23:29 | tomoj | https://gist.github.com/2a98cc0267c47629b3f5 spoilers |
| 23:29 | tomoj | that's ugly, I'm sure it can be prettier |
| 23:32 | tomoj | I almost like this better https://gist.github.com/015a51c3058c7e9d1f40 |
| 23:38 | _ato | ,(bigint 10000000000000000000000000000000/3) |
| 23:38 | clojurebot | 9223372036854775807 |
| 23:39 | Raynes | That's a really bigint. |
| 23:39 | clojurebot | namespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it |
| 23:39 | _ato | weird |
| 23:40 | _ato | ,10000000000000000000000000000000/3 |
| 23:40 | clojurebot | 10000000000000000000000000000000/3 |
| 23:40 | _ato | ,(bigint 1000000000000/3) |
| 23:40 | clojurebot | 333333333333 |
| 23:40 | _ato | seems like there's a bug there |
| 23:42 | hiredman | ,(bigdec 00000000000000/3 |
| 23:42 | clojurebot | EOF while reading |
| 23:42 | hiredman | er |
| 23:42 | hiredman | ,(bigdec 100000000000000/3) |
| 23:42 | clojurebot | java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result. |
| 23:42 | hiredman | :P |
| 23:42 | _ato | ,(.decimalValue 100000000000000/3) |
| 23:42 | clojurebot | java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result. |
| 23:43 | tomoj | _ato: what's the bug? |
| 23:43 | _ato | ,(bigint 10000000000000000000000000000000/3) |
| 23:43 | clojurebot | 9223372036854775807 |
| 23:44 | _ato | ^ that aint the right answer |
| 23:44 | _ato | it should be a whole bunch of 3s |
| 23:44 | _ato | and Clojure's not supposed to silently truncate numbers |
| 23:45 | tomoj | oh, I see |
| 23:46 | tomoj | hmm |
| 23:46 | tomoj | look at the source of bigint |
| 23:46 | tomoj | if it's a number, it coerces to long before passing to BigInteger/valueOf |
| 23:46 | tomoj | ,(long 10000000000000000000000000000000/3) |
| 23:46 | clojurebot | 9223372036854775807 |
| 23:47 | tomoj | ,(long 10000000000000000000) |
| 23:47 | clojurebot | java.lang.ExceptionInInitializerError |
| 23:47 | tomoj | er, well, I get -8446744073709551616 |
| 23:48 | tomoj | ,(long 1000000000000000000000) |
| 23:48 | clojurebot | java.lang.ExceptionInInitializerError |
| 23:48 | tomoj | weird |
| 23:49 | _ato | ,(.divide (java.math.BigDecimal. 1000000000000000000000) (java.math.BigDecimal. 3)) |
| 23:49 | clojurebot | java.lang.ExceptionInInitializerError |
| 23:49 | _ato | ,(.divide (java.math.BigDecimal. 1000000000000000000000M) (java.math.BigDecimal. 3)) |
| 23:49 | clojurebot | java.lang.IllegalArgumentException: No matching ctor found for class java.math.BigDecimal |
| 23:50 | _ato | ,(.divide 1000000000000000000000M (java.math.BigDecimal. 3)) |
| 23:50 | clojurebot | java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result. |
| 23:51 | hiredman | ,(let [m 10000000000000000000000000000000/3] (.divide (.numerator m) (.denominator m))) |
| 23:51 | clojurebot | 3333333333333333333333333333333 |
| 23:53 | hiredman | bigdec has a check for ratios |
| 23:53 | hiredman | hmmm |
| 23:54 | _ato | I guess bigint should have one as well |
| 23:54 | hiredman | ,(let [m 10000000000000000000000000000000/3] (/ (BigDecimal. (.numerator m)) (.denominator m))) |
| 23:54 | clojurebot | java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result. |
| 23:55 | hiredman | ,(let [m 10000000000000000000000000000000/3] (/ (.numerator m) (.denominator m))) |
| 23:55 | clojurebot | 10000000000000000000000000000000/3 |