#clojure logs

2011-08-23

00:01iceythanks ibdknox, technomancy, jli :) this gives me a good starting point
00:02ibdknoxjli, icey: yeah, split the html into two parts, the "layout" and then the content
00:02ibdknoxyou share code between pages
00:02ibdknoxit ends up much cleaner
00:02ibdknoxsmaller
00:05pdk``jli take a look at graham's lisp book and practical common lisp
00:06pdk``they always have an example chapter stuffed in the back talking about writing a mini language to produce html from s expressions as a handful of macros
00:06iceyibdknox, jli: good feedback - i started using layouts recently once i transitioned to noir (although i am still making many of the mistakes mentioned here in my newer code - this code is from a few weeks ago)
00:07jlipdk``: hm?
00:07pdk``http://www.gigamonkeys.com/book/practical-an-html-generation-library-the-interpreter.html for example
00:07pdk``talks about writing a set of macros so you can write your page code in a lispy structure and have it spit out html from that
00:07jlihe's already using hiccup (I think?) - it's just that the layout stuff is together with code for getting data
00:07scottjDoes every loop/recur involve a function invoke?
00:08scottjis each recur a function invoke?
00:08pdk``you can use recur just to restart the loop it's in iirc
00:10ibdknoxicey: if you're using noir, you should basically never return a map
00:11dnolenscottj: loop/recur is efficient, no more overhead than a for loop in Java.
00:13iceyibdknox: i'm a little better now (although I'm still not using :only here) - this is how i'm using noir: https://gist.github.com/1164329
00:14icey(ignore the extra includes ;))
00:14ibdknoxicey: the only thing I'd do is put all those links into collection
00:15ibdknoxicey: and then map over them
00:16ibdknoxbasically anytime you're doing a list with similar items, you should split that out into a partial and map the partial over the collection :)
00:16iceyibdknox: hm okay. you have an example of that on one of the noir webpages actually
00:35scottjdnolen: ok I'd heard that. I copied the scala version of that stupid josephus benchmark but was still about 5x of it and almost all the time was in my main function's invoke, and I had 2 loop w/ recurs in it so I thought maybe that was it
00:36sridnope, a fix is available at http://stackoverflow.com/questions/6182626
00:37replacadnolen: loved your ClojureNYC talk (oddly it got me thinking about core.logic more than match, but hey)
00:38replacadnolen: did you propose a conj talk?
00:38dnolenscottj: that's the most pointless benchmark ever IMO. the requirement to have a growable array is easily done by just writing a C++ vector like abstraction over Java primitive arrays.
00:39dnolenreplaca: interesting that the talk made you think of core.logic more.
00:39dnolenreplaca: yes, I pitched a talk on core.logic and on predicate dispatch.
00:40replacadnolen: well, I just began to think of cases where relationships between elements matter in a way that seemed to be beyond match but in the wheelhouse of logic techniques
00:41replacadnolen: mostly around producing explanations of how certain things change over time
00:41replacawhich gets really ugly in normal code
00:42dnolenreplaca: definitely. where predicate dispatch ends core.logic begins. and vice versa.
00:42replacadnolen: yeah, it's like a numeric stack of logic
00:43replacabut I haven't done any logic programming since college, so I'm having to rekearn a lot
00:43replaca*relearn
00:44replacaif I really get something interesting, maybe I'll do a lightening talk about it
00:44dnolenI actually started up the predicate dispatch stuff because I wanted a pattern matcher to write the nominal logic version of miniKanren :)
00:44dnolenof course I got carried away.
00:44jlireplaca: where you at clojurenyc?
00:45replacajli: no, I watched it on TV :) (also known as vimeo)
00:45replacaI'm in SF
00:45scottjdnolen: I wonder if the benchmark is really only measuring function invoke time. the main function only runs for 0.0067 millis each iteration
00:46dnolenscottj: the benchmarks measures array operations. that's about it as far as I can tell.
00:47dnolenscottj: all the other langs benchmarked have mutable arrays. the OP had the audacity to post Clojure solutions that converted to seqs. I was going to respond but I lost interest, what's the point when the benchmark is that idiotic ?
00:52jlido you get an ack from rich when he gets your contributor agreement?
00:52dnolenjli: I think Clojure/core handles it now, and your name just appears on the list.
00:53jliokay, cool
00:54dnolenscottj: if you're doing it just for self education. Write a deftype over Java arrays that implements a push / pop interface that grows at the boundaries with System/arraycopy
00:54dnolenit's will be absurdly fast.
00:57scottjdnolen: see I don't think it's the datastructure that matters bc scala version uses ArrayBuffer w/o primitives I think and even a java version using ArrayList is like 10x my clojure version that uses ArrayList
00:59dnolenscottj: what does your implementation look like? and what version of Clojure? *unchecked-math* etc.
01:07scottjdnolen: https://gist.github.com/1164383 clojure 1.3.0-beta1, just turned on *unchecked-math* it made very little diff
01:07scottjno reflection warnings
01:08scottj-server makes very little diff on this benchmark
01:08dnolenscottj: how long does it take on your machine?
01:09scottjtimings at bottom, 8 seconds for a million iterations
01:09scottjin clojure, 0.8 for java
01:11sridis it not possible to get compojure automatically convert types of route arguments? example -- in ` (GET ["/:site/:tag/:n", ...` I want the `n` to be of integer type.
01:11sridelse, I have to manually Interger.parseInt it in all the route mappings.
01:12dnolenscottj: your using vectors for no reason
01:13scottjdnolen: the destructing part? yeah just noticed that when profiling
01:13dnolenvector instantiation, destructuring
01:13dnolenyou're paying for instantiations too
01:14scottjI'll try getting rid of it but I found in another version I have that's faster tha nthis that that amount of destructuring doesn't impact total time much
01:15dnolenscottj: you can't put primitives in vectors
01:15dnolenso you've got boxing
01:15dnolenyou've got boxing so JVM can't inline
01:17replacadnolen: has core.logic been pushed anywhere or do I have to build from source?
01:17dnolenreplaca: hudson
01:17dnolenorg.clojure/core.logic "0.6.3" I think.
01:17replacawhat's the latest version?
01:17michaelr525hey!
01:17scottjdnolen: I've got ArrayLists, isn't that itself going to prevent inlining?
01:18replacacool, thanks!
01:19dnolenscottj: Just by glancing at your code I can see it's not going to be very fast.
01:21dnolenscottj: there's no arithmetic on the contents of ArrayList so boxing is irrelevant there.
01:35dnolenscottj: where's the Java ArrayList version?
01:37scottjdnolen: in that gist, second file
01:39khaliGI start lein swank from a screen session, and sometimes when something goes wrong i'll take a look at the terminal but i can't scroll up to see a complete stacktrace. Is there a fix for this annoying problem? :)
01:40scottjkhaliG: screen has scrolling, C-a [ then pageup
01:40patchworkhey all, trying to get the whole swank-clj setup going and running into a problem with the package manager, marmalade?
01:41patchworkI installed all of the slime and swank packages from M-x package-list-packages
01:41patchworkbut when I do slime-connect I get:
01:41patchworkSymbol's value as variable is void: slime-clj
01:41khaliGscottj, thank you, i'll store that note somewhere handy for next time
01:42patchworkslime-clj-1.6.0 is in my elpa directory
01:42patchworkand it finds the other packages fine that are in there
01:42patchworkbut this one fails for some reason?
01:42patchworkanyone have any idea where to start?
01:43patchworkI was under the impression that because it is a package manager I don't need to require anything from my .emacs
01:43patchwork(besides the package.el of course)
01:44hiredmanpatchwork: you want swank-clojure
01:45hiredman~swank-clojure
01:45clojurebotsee swank
01:45hiredman~swank
01:45clojurebotswank is try the readme. seriously.
01:45hiredmanugh
01:45hiredman~google swank-clojure
01:45clojurebotFirst, out of 1030 results is:
01:45clojurebottechnomancy/swank-clojure - GitHub
01:45clojurebothttps://github.com/technomancy/swank-clojure
01:45hiredman^- forget swank-clj
01:45hiredmanif you follow the instructions in the readme there you will be all set
01:46hiredman~blog posts
01:46clojurebotmake a note of http://scienceblogs.com/goodmath/2006/11/the_c_is_efficient_language_fa.php it is yet another article about picking c or c++ for performance being naive
01:46hiredman~blogs
01:46clojurebotmake a note of http://scienceblogs.com/goodmath/2006/11/the_c_is_efficient_language_fa.php it is yet another article about picking c or c++ for performance being naive
01:46hiredmanbleh
01:47replacadnolen: ever seen "IllegalArgumentException No value supplied for key: true clojure.lang.PersistentHashMap.createWithCheck (PersistentHashMap.java:89)" when loading c.c.l.prelude?
01:47patchworkhiredman: interesting, those are the instructions I was trying to follow!
01:47replacait works for me from the slime repl, but I can't load from the ns directive in my file
01:47patchworkhiredman: possibly, I don't need to install the slime stuff, only clojure-mode?
01:48hiredmanpatchwork: right, swank-clj is not swank-clojure
01:48dnolenreplaca: Clojure version?
01:48replaca1.3 beta1
01:48hiredmanpatchwork: you obviously did not follow the readme
01:48patchworkhiredman: gotcha, strange
01:48hiredmanunder "usage" there are three lines, nothing that mentions slime
01:49patchworkhiredman: I installed marmalade, then tried to install all the packages from there. I thought they were the same thing
01:49patchworkhiredman: I will try your suggestion
01:49dnolenreplaca: no, sounds really weird. can you open a ticket?
01:50replacadnolen: I think it was pilot error with my :use
01:50dnolenreplaca: ok
01:50replacadnolen: when I break it up differently, it works fine
01:51replacadnolen: the problem of looking at something new, is you never know where you're config problems are
01:53patchworkhiredman: okay, followed the readme precisely
01:54patchworkM-x clojure-jack-in now returns:
01:54patchworkProcess swank exited abnormally with code 127
01:54patchwork/bin/bash: lein: command not found
01:54patchwork
01:54patchworkI have lein installed however
01:54patchworkwhat path is it using?
01:54hiredmanbecause you are on osx and osx doesn't source dot files so emacs doesn't have the PATH setup
01:55patchworkso...
01:55patchworkget a new computer?
01:55hiredmanyou can use setenv to set your PATH in your emacs dot files
01:55patchworkhiredman: aha nice, never had to do that before
01:55hiredman(setenv "PATH" "/sbin:/Users/hiredman/bin:/usr/local/bin:/usr/local/sbin/:/Users/hiredman/apache-maven/bin:/usr/bin:/bin:/usr/sbin:/usr/local/git/bin:/usr/X11/bin:/usr/games")
01:58dnolenscottj: here's a version that runs in 2.8s on my Machine, the Java takes 1s, about to post some really ugly Clojure in a second which should be identical.
01:58dnolenhttps://gist.github.com/1164447
01:59patchworkhiredman: PATH is set, now I get:
01:59patchworkerror in process filter: Symbol's variable is void: Process
01:59patchwork(after all kinds of things happen in *swank*)
01:59hiredmanwhat version of emacs?
01:59patchwork23
01:59hiredmanhmmm
02:00patchworkthe gnu version
02:02hiredmanhave you tried restarting emacs?
02:03replacab
02:08dnolenas promised Josephus in Clojure with identical Java performance, https://gist.github.com/1164458
02:09dnolenscottj: ^
02:53michaelr525yo!
02:55michaelr525so, I've used compojure once. should I use anything else for a web framework?
02:55michaelr525what would you recommend?
03:12scottjkhaliG: I had this screen stuck on scroll since I answered your question and I've been wondering why no one's said anything :)
03:13khaliGscottj, haha :)
05:11slilo>/part
05:16agzhey guys, http,agent is not working for me:
05:16agz(http/string (http/http-agent "http://www.google.com"))
05:17agzis not responding, the agent never finishes
05:17agz(http/done? (http/http-agent "http://www.google.com")) is always false
05:18agzanyone?
05:18clojurebotPlease do not ask if anyone uses, knows, is good with, can help you with <some program or library>. Instead, ask your real question and someone will answer if they can help.
05:21michaelr525agz: i'm not familiar with http-agent, but
05:21michaelr525I'm using fetcher to fetch some html pages
05:21michaelr525And it's greate
05:21michaelr525greate
05:21michaelr525great
05:23agzthx, goin try it
05:26agzin project.clj I added [fetcher "0.0.5-SNAPSHOT"] - and got error
05:26agzCaused by: Unable to resolve artifact: Missing:
05:26agz----------
05:26agz1) fetcher:fetcher:jar:0.0.5-SNAPSHOT
05:28michaelr525agz: go to github, get this project and run "lein install", it will print errors for all dependencies it needs, go to github and get them all and run "lein install" in each one of them, then go back to fetcher and run "lein install"
05:29agz:michaelr525: you mean download the source, and run lein install in the library?
05:29agzin the directory mean
05:33michaelr525yep
05:33michaelr525agz: you have the download button at the top right
05:34michaelr525or of course you could use git :)
05:45agzyeah I'm noobie :), I got progress, but:
05:46agzgetwoven-plumbing needs clj-json-0.3.2
05:47agzI installed that but plumbing still doesn't see it
05:48michaelr525hmm
05:49agzI copied the compiled clj-json jar to the /lib of the plumbing
05:49agznot work - that should work?
05:50michaelr525are you sure that "lein install" installs the jar into your repository?
05:50michaelr525the clj-json jar
05:51michaelr525what is the error message when you try to install plumbing?
05:51agzate@mate-laptop:~/Desktop/downloads/firefox/mmcgrana-clj-json-6ac05dc$ lein install
05:51agzCompiling 1 source file to /home/mate/Desktop/downloads/firefox/mmcgrana-clj-json-6ac05dc/classes
05:51agzCopying 3 files to /home/mate/Desktop/downloads/firefox/mmcgrana-clj-json-6ac05dc/lib
05:51agzCopying 4 files to /home/mate/Desktop/downloads/firefox/mmcgrana-clj-json-6ac05dc/lib/dev
05:51agzCreated /home/mate/Desktop/downloads/firefox/mmcgrana-clj-json-6ac05dc/clj-json-0.3.2.jar
05:51agzWrote pom.xml
05:51agz[INFO] Installing /home/mate/Desktop/downloads/firefox/mmcgrana-clj-json-6ac05dc/clj-json-0.3.2.jar to /home/mate/.m2/repository/clj-json/clj-json/0.3.2/clj-json-0.3.2.jar
05:51agzthis is install
05:51agz.
05:51agz.
05:51agz.I mean the clj-json
05:52agzException in thread "main" Unable to resolve artifact: Missing:
05:52agz----------
05:52agz1) woven:clj-json:jar:0.3.2-SNAPSHOT
05:52agz Try downloading the file manually from the project website.
05:52agz Then, install it using the command:
05:52agz mvn install:install-file -DgroupId=woven -DartifactId=clj-json -Dversion=0.3.2-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file
05:52agzthis is the error of the plumbing lib
05:52agzokay
05:52agzsry
05:53michaelr525seems like it looks for -SNAPSHOT version
05:54michaelr525check github, maybe it's there
05:54agzhttp://pastebin.com/bG6hRB2S
05:54agzohh
05:55agzthe snapshot is already 0.4.0
05:55michaelr525take everything from here: https://github.com/getwoven
05:57agzbtw how can I check out the snapshot with git??
05:57lazybotagz: Uh, no. Why would you even ask?
05:57agzyes :)
06:25agzuhm I managed to lein install a clj-json.4.0.0 but plumber needs 0.3.2-SNAPSHOT
06:26agzI tried to change it in the plumbers/project.clj to 4.0.0 from 3.2 but it had no effect
06:29agzokay, maybe wrote wrong version number - it works now
06:57opqdonut_never_ make a record with a field named size
06:58opqdonut(and then try to access it with (.size thing))
07:11michaelr525opqdonut: why not?
07:15opqdonutmichaelr525: go ahead, try it :)
07:16michaelr525:)
07:36michaelr525anyone knows of a jquery autocomplete plugin that mimicks as much of google instant?
07:41ScorchinWhat's the generic way to find out what kind of data structure you have? Looking for something similar to "map?" or "list?"
07:41joegallohttp://docs.jquery.com/UI/Autocomplete
07:46michaelr525joegallo: not similar enough :)
07:47michaelr525actually i don't mind if it's not jquery
08:01mbacwhat's the authoritative zero-to-working-with-clojure-in-emacs howto?
08:01mbacgoogle betrays
08:01PiskettiI'd like to know that as well ;)
08:01thorwilScorchin: type
08:02Scorchinthorwil: thanks
08:03mbacclues indicate that this involves lein
08:04Scorchinanother question, why does my "type" change from a vector to a named type when I wrap it in a (defn easy-name [PersistentVector in here]) ? Is there a more idiomatic way to do this?
08:17ScorchinIf you have a vector of maps, how do you "remove" keys from the maps that the vector stores?
08:19cemerickScorchin: You could use a zipper if appropriate, or there's a dissoc-in fn in old-contrib you can swipe: https://github.com/clojure/clojure-contrib/blob/b8d2743d3a89e13fc9deb2844ca2167b34aaa9b6/src/main/clojure/clojure/contrib/core.clj#L57
08:20opqdonutI'd just do (vec (map #(dissoc % :key) vector-of-maps))
08:20chouserouch
08:20opqdonutoh okay, if you want to edit just one of the maps dissoc-in is pretty much the right thing
08:21cemerickopqdonut: good luck with that ;-)
08:22opqdonuthmm?
08:23cemerickI was commenting on the (vec (map …)) suggestion. That approach will hurt bad if the vector is large.
08:23opqdonutwould (into [] ...) be faster?
08:23cemerickOr, even if it's small, and modified a bunch.
08:24cemerickNo. It's a full copy in any case.
08:24opqdonutwell if he wants to update every map in the vector...
08:24opqdonutthen that's inevitable
08:24Scorchinopqdonut: actually, that's pretty much what I wanted. Thanks!
08:24ScorchinWhat's the counter to that, where you just want to get a single key from each?
08:25opqdonutI'll leave that as an exercise
08:25opqdonuthint: use map
08:25Scorchinokay, thanks
08:28Scorchinis it just (vec (map #(get % :age) vector-of-maps)) ?
08:28Scorchinor is there a better way to do it?
08:28cemerickopqdonut: Yeah, in that case, if thing just absolutely have to be in a vector, then there's no choice. Most of the time, vectors are just not necessary tho.
08:28opqdonutthat's it
08:29opqdonutcemerick: agreed
08:29cemerickScorchin: (map :age vector-of-maps) is sufficient
08:31Scorchincemerick: thanks, that's much cleaner
08:32chousercemerick: ^{:line 42 :k :v} (quote (foo))
08:33cemerickchouser: Some of Rich may have rubbed off on you, 'lo these many years. ;-)
08:34cemerick(meta ^{:line 42 :k :v} (quote (foo))) => {:line 1}, which is (thankfully) consistent with the third example in the email
08:35ScorchinSo lets say that I've now trimmed my crazy vector-of-maps into something easier to work with. I know what unique values exist with (distinct trimmed-vector-of-maps) however I now want to count how many times each one of those occurs to a map. Where's the best place to look at in the docs for that kind of operation?
08:35ScorchinIf I was doing it in python, I'd just use a for loop and increment a counter within a dict, not so sure with clojure
08:36chousercemerick: heh, sorry. '(foo) is read as (quote (foo)), so it's that outer list that's getting your metadata
08:36opqdonutScorchin: have a look at group
08:36opqdonutsorry, group-by
08:37cemerick!! :-(
08:37cemerick(meta (quote ^{:line 42 :k :v} (foo))) => {:k :v, :line 1}
08:37cemerickchouser: thanks.
08:39Scorchinopqdonut: I've currently got a list of ages, which I want to make a normal distribution out of. (group-by (distinct ages) ages) doesn't seem to work
08:39ScorchinIs this because I need to make keys out of the distinct ages?
08:41Scorchinactually, looks like incanter might do what I need, will have a look in there :)
08:44raekScorchin: you can use the 'frequencies' function to count how many times each element occurs in a sequence
08:44opqdonutScorchin: group-by takes a function as its first argument, you might want to use = or something like #(* 10 (Math/floor (/ % 10)))
08:44opqdonut(the latter gives you bins of size 10)
08:46Scorchinoh, that's slick, I think I love clojure
08:46Scorchinugh, but now I need to learn all these helper functions :/
08:46opqdonutbut incanter probably offers lots of stuff like this
08:49chouserScorchin: you don't have to learn them cold. You can do like the rest of us did and write the ones you need.
08:49chouserJust don't forget to ask "is there something like this already" so someone can point out its name. :-)
08:49Scorchin:D
08:49Scorchinyeah, I get that
08:50Scorchinit's just a shame that the repl isn't more playful like node or python
08:50chouserI think frequencies in particular I wrote several times before it was added to core
08:50chouseras did many others
08:53cemerickScorchin: "playful"?
08:54Scorchinyeah, like the ability to just prod things to find out more
08:54Scorchinlike in node how you can do var. (hit tab) and then see what you could do
08:55cemerickClojure doesn't bind functions up with objects or values. That's integral to composability.
08:56cemerickBeyond that, there's tonnes of ways to introspect the environment and see what's available.
08:57joly,(apropos "count")
08:57clojurebot(*initial-report-counters* *report-counters* inc-report-counter ref-history-count counted? ...)
08:57theignoratiis there a better way of doing this: (list (.getCommand m) (.getChannel m) (.getData1 m) (.getData2 m))?
08:57TimMc,(apropos "^count")
08:57clojurebot()
08:57TimMchrmf
08:58cemerick,(apropos #"^count")
08:58clojurebot(counted? count)
08:58TimMcyay
08:58jolyI like find-doc as well
08:59cemerickQuite the anachronism.
08:59chousertheignorati: hm, maybe (map (bean m) [:command :channel :data1 :data2])
09:02theignoratinope
09:03vijaykirantheignorati: you can use juxt ?
09:04vijaykiran,(doc juxt)
09:04clojurebot"([f] [f g] [f g h] [f g h & fs]); Alpha - name subject to change. Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, and returns a vector containing the result of applying each fn to the args (left-to-right). ((juxt a b c) x) => [(a x) (b x) (c x)]"
09:04chouserI don't think juxt will work because those are methods not functions
09:04chousertheignorati: bean doesn't work on that object?
09:04theignoratino
09:05chousertheignorati: Then I think you're done. A macro might help, but I don't think there's any in core that will help.
09:06chousertheignorati: and even if you wrote one yourself it wouldn't be any more efficient than what you have, and hardly any more succinct.
09:08theignoratiok
09:08theignoratithanks
09:10ScorchinI currently have a sequence of strings: ("1" "3" "4" "s"). How do I strip out the non-integers and convert the actual integers into ints?
09:11TimMctheignorati: What you have currently is also pretty readable.
09:15chouserScorchin: (->> ["1" "3" "4" "s"] (filter #(re-matches #"\d+" %)) (map #(Integer/parseInt %)))
09:15agzSchorchin: (map load-string (filter #(re-find #"[0-9]+" %) ["1" "2" "3" "s" "S"]))
09:15agzpff :)
09:15chouser:-)
09:16chouseryours is shorter!
09:16agzyours more efficient! :)
09:16Scorchin:0
09:16chouserread-string would be a bit better than load-string
09:17agzchouser: yep, I though there is a better one :)
09:18chouser,(re-find #"[0-9]+" "123xyz")
09:18clojurebot"123"
09:18chouser,(read-string "123xyz")
09:18clojurebot#<NumberFormatException java.lang.NumberFormatException: Invalid number: 123xyz>
09:18chouser,(Integer/parseInt "123xyz")
09:18clojurebot#<NumberFormatException java.lang.NumberFormatException: For input string: "123xyz">
09:19chouser,(read-string "#=(java.lang.System/exit)")
09:19clojurebot#<RuntimeException java.lang.RuntimeException: EvalReader not allowed when *read-eval* is false.>
09:20cemerick"The sandboxes turn it off; it's not so hard for everyone else to as well!" </snark>
09:25babilenHow would I find numbers in other scripts? E.g. -- (re-find #"????" "123xyz二四五") → "123二四五" ?
09:25Scorchinchouser, agz: that was really helpful, thanks. Although I'm now trying to work out how it works :/
09:26michaelr525how do you people work with git from emacs?
09:27mprenticemichaelr525: magit
09:28michaelr525thanks, will check
09:28raekbabilen: see \p in http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html
09:29michaelr525and what about an integrated "shell" when working with emacs on windows?
09:29mprenticemichaelr525: i have magit-status as "C-c g"
09:30michaelr525mprentice: hmm?
09:30mprenticemichaelr525: that was in reference to magit, not your shell question
09:31babilenraek: Anything in particular you are thinking about? \p{Digit} is (as stated) us-ascii only
09:31mprenticemichaelr525: on mine, M-x shell brings up an interface to Windows Powershell, but i don't use it that way so i can't help you much
09:31raekbabilen: sorry, I was thinking about the unicode category feature (which also uses \p)
09:32babilenraek: No problem. :)
09:32michaelr525mprentice: ok thanks. why did you map C-c g to magit-status?
09:33mprenticemichaelr525: magit works in a buffer brought up with magit-status. it's not an interface to the emacs version stuff.
09:33michaelr525ah, I see!
09:33michaelr525will have to try that
09:34mprenticemichaelr525: when i tried it git-vcs or whatever it was called didn't work out of the box, and i didn't have the patience to set it up :P
09:35raekbabilen: it looks like 二 has the unicode category "OTHER_LETTER" and is not considered a digit...
09:37raekI was expecting that the Nd (decimal digit number) category would work for CJK numerals too
09:39raekbabilen: see the last table: http://www.fileformat.info/info/unicode/char/4e8c/index.htm
09:41raek,(re-find #"\p{Nd}+" "123١٢٣一二三")
09:41clojurebot"123١٢٣"
09:41babilenraek: I have to confess that I am mildly surprised
09:42babilenraek: I know that this is far from being a Clojure issue and thank you for giving an example with other scripts, but seriously: wtf! :)
09:43pjstadigthe goal of Unicode is to have a way of encoding glyphs, it's goals do not include encoding semantic meaning
09:43pjstadigexcept where it's necessary for backwards compatibility with existing encodings
09:45babilenpjstadig: Yes - but that means that if you want to find all numbers in a text you *have* to hardcode all characters that denote numerals for every single script.
09:47michaelr525mprentice: i've staged some files but hitting c in the staging buffer asks me Nothing changed. Commit all unstaged changes?
09:47michaelr525wtf?
09:49raekalso, different cultures have different rules for what a letter is. maybe there isn't much disagreement on what is a numeral, but in that case this would be one of few things in unicode whose rules everyone agree upon
09:51michaelr525mprentice: Sorry, it says: Nothing staged. Commit all unstaged changes?
09:52michaelr525but i have 4 staged files right here in the buffer
10:00mprenticemichaelr525: strange. i'm not familiar enough to know why it would do that :/
10:03babilenraek, pjstadig: Well, I have to dive deeper into this -- Seems to be either a bug in the unihan database or java's regex implementation. (IMHO "(?u)\d" *should* match "三") -- I'll take it to #unicode and #java. Thanks so far :)
10:05cemerickbabilen: \d is equivalent to [0-9], and the 'u' flag only impacts case-insensitivity. Not sure why \d would match cn characters in any case.
10:08babilencemerick: Forgive me -- I am from a Python background and (?u) behaves differently there -- All I meant was "There should be a character class (i.e. Digit) that matches 三
10:08babilen"
10:10cemerickbabilen: Except that there isn't. :-)
10:11cemerickThere are multiple "number systems" in CJK AFAIK. There's 一, but there's also…
10:11cemerick壹 (had to hit wikipedia for that one)
10:12cemerickbabilen: Why not just use your own character class? [一二三…]
10:12babilenYes, I know -- but all of them have kPrimaryNumeric set -- It seems to be specific to unihan -- Note http://www.unicode.org/reports/tr44/#Numeric_Value and http://www.unicode.org/reports/tr44/#Numeric_Type_Han
10:13babilencemerick: I was hoping to find a solution for *all* scripts as hardcoding these will mean a lot of work for me.
10:14raekbabilen: maybe ICU4J is useful for you: http://site.icu-project.org/
10:14chouserbabilen: you only want to match numbers, or also get their values?
10:14raek(in case Java misses some features)
10:15babilenchouser: Right now I only want to match them, converting them to their kPrimaryValue would be nice to have, but is not necessary right now.
10:15babilenraek: I'll take a look.
10:15babilenI'm working in cross-lingual natural language processing and *have* to deal with different scripts/languages
10:25michaelr525heya!
11:06NetpilgrimHi. Could someone be so kind to critique my code at https://gist.github.com/1165353? It's working, am just wondering if it could be made more idiomatic.
11:09NetpilgrimAlso coming from Java I'm still not too comfortable without types. Is there a way to at least make sure that a function parameter is e.g. a two-dimensional array/seq?
11:09raekNetpilgrim: use hyphens instead of underscores in names. #(length-counts %) --> length-counts. (map (fn [x] ...) coll) --> (for [x coll] ...)
11:10raekdon't use ==, use =
11:10NetpilgrimOK. Thanks.
11:11Netpilgrimraek: I thought == would be more effizient with numbers.
11:11Netpilgrims/effizient/efficient/
11:11lazybot<Netpilgrim> raek: I thought == would be more efficient with numbers.
11:12raekNetpilgrim: also, find-paths can probably be implemented by passing the "state" (paths) as a parameter instead of mutating the atom
11:12raekit's not very ideomatic to use mutation for computations in clojure
11:13arohnerNetpilgrim: == is more efficient for numbers. it should be used when you know you're dealing with numbers, and performance is important. (I have no idea whether that applies to your case)
11:13Netpilgrimraek: OK, this is probably a big one. I'll try to rewrite the function.
11:14Netpilgrimraek: Can for always be used instead of map? What are the advantages?
11:15raekyou cannot use for if you want to take from multiple collections in lock step
11:15raekfor just one coll, you can always use 'for'
11:16raekI prefer it since it indents much prettier with bigger expressions
11:17Netpilgrimraek: I wasn't too sure about for, map just seemed made for this purpose.
11:19NetpilgrimIs ((set xs) x) the correct way to test if an element part of a seq?
11:19raekyes. if you are going to test many times, store (set xs) instead of xs
11:20Netpilgrimraek: Ok
11:21raekNetpilgrim: yeah, 'map' is the more simple form, and 'for' is syntactic sugar for certain common tasks
11:22NetpilgrimBut I should be OK if I always use for except when working on multiple collections in parallel?
11:23raekyes. but 'map' is probably shorter if you have an existing function instead of an anonymous function
11:24NetpilgrimHm, so it just comes back to “it depends”. :)
11:24raekyeah :)
11:24raekif you need to write the map expression on more than one line, maybe for looks better
11:26Netpilgrimraek: I've just rewritten am_to_al with for and it looks better. I think the fact that the name of the collection comes to the front of the expression improves the readability.
11:28Netpilgrimraek: Hyphens in symbol names look really odd to me but I guess I better keep to the established style.
11:29raekNetpilgrim: you could probably implement the adjacency lists as a set of [from to] pairs
11:30dnolenrefining the pattern match api for arrays and bits, Object Oriented Macros, http://dosync.posterous.com/object-oriented-macros, upvote on HN por favor
11:31Netpilgrimraek: But then I couldn't get all children with (adj-lists parent).
11:35Netpilgrimraek: To come back to == and =. What exactly is the difference? == Seems to be only defined for numbers, so I thought it might be more efficient there.
11:37ambrosebsI'm having some trouble combining dynamic binding with macros. I don't understand why the last form returns false https://gist.github.com/1165470
11:40Chousukeambrosebs: macro expansion is done at compile time, while the binding happens at runtime
11:41ambrosebsChousuke: cheers, that makes sense.
11:42Chousukeif the macro returned the symbol *test1* instead then that would work
11:44khaliGhm, using set! i'm getting the error "Can't change/establish root binding of: *foo* with set"
11:45ambrosebsChousuke: the problem I'm trying to solve is wrapping a macro in a `binding` form, which triggers behaviour during macro expansion
11:45ambrosebsimpossible?
11:47Chousukeambrosebs: yeah, that's not really possible
11:48Chousukeyou could use eval to make something that "works" but I think then you have more problems than you solve :P
11:48ambrosebs:)
11:48ambrosebsI can work around it, but did cause some headaches
11:49Chousukeyou can use a global bindable variable and set! it though
11:49ambrosebslooks like that's the best way
11:49Chousukecompilation and execution happens sequentially so if you set! something in a global it will affect macroexpansions later in the code. It's still somewhat hackish though :P
11:50ambrosebsthe variable activates trace printing and debugging, so it's not that crucial to be fine grained
11:51ambrosebsalthough it was a nice-to-have
11:51ambrosebspossibly :)
11:51Netpilgrimraek: I have to leave now. Thanks for your help.
11:52Chousukeambrosebs: yeah, that sounds like something you can just have as a global variable
11:56raekNetpilgrim: https://gist.github.com/1165579
11:56raek(find-paths without mutation)
11:58raekNetpilgrim: yes the adj.list suggestion was not a very good idea :)
11:59khaliGam i missing something in using set!? :/
11:59babilenAnd for example: (Python) re.findall(r'(?u)\d+', "123xyz١٢٣二四五") → ['123', '١٢٣'] (Clojure/java) (re-find #"\p{Nd}+" "123١٢٣一二三") → "123١٢٣"
11:59babilenAnd for example: (Python) re.findall(r'(?u)\d+', "123xyz١٢٣二四五") → ['123', '١٢٣'] (Clojure/java) (re-find #"\p{Nd}+" "123١٢٣一二三") → "123١٢٣"
11:59babilen(disregard that ECHAN, sorry)
12:01raekNetpilgrim: honestly, I don't really know. = works for everything and I haven't used == myself yet. perhaps it works as java's ==, but only for numbers.
12:01raekbabilen: so does python have the same problem?
12:02raek(also, the clojure version of re.findall would be re-seq)
12:03Netpilgrimraek: Thanks for the code. Honestly I don't know why I thought I'd need the atom.
12:04babilenraek: hehe, thanks -- Python's "二".isnumeric() → True -- Haven't found a good aequivalent in Java/Clojure yet -- Also Python's regex module is supposed to work better. Am still investigating -- I'll let you know when I'm done.
12:07pjstadigbabilen: wouldn't something like Character/isDigit be the Java equivalent?
12:07pjstadigassuming it wasn't brojen
12:07pjstadiger broken
12:08raek,(Character/isDigit \二)
12:08clojurebotfalse
12:08pjstadigor you're looking for a way to take a string and say "is this a number (assuming I parsed it")
12:08babilenyes ^^^ that is exactly the problem
12:08babilenpjstadig: That is what I am looking for
12:09pjstadigi've never really liked Java for string processing
12:09raekat least string are sequences of characters and not bytes :-)
12:09pjstadighehe
12:10pjstadigi was going to say python and ruby are better for that, but ruby...hmm
12:10babilenSo, this is a bug in Java?
12:10raekbabilen: I think the isDigit property is specified in the unicode standard
12:10babilenWell, it looks as if I have to use Python or Perl in that case
12:10raekpython 3, I hope...
12:10babilensure
12:14babilenwell, isdigit and isnumeric are different .. http://www.unicode.org/reports/tr44/#Numeric_Value and indeed in Python: "二".isdigit() → False -- I am looking for a isnumeric function/method which seems to be missing in Java -- Recipes include Integer.parseInt + catching an exception.
12:15cemerickLooks like this Numeric_Value stuff came out in Unicode 5.2.0. (circa 9/2009). Wouldn't say that lack of support for it is a bug.
12:16raekbabilen: maybe ICU4J provides it
12:16raekit is built for these kind of things
12:17raekhttp://www.unicode.org/Public/UNIDATA/UnicodeData.txt the unicode spec says 二 is of type "So", Other Symbol
12:17raek(entry for 4E8C)
12:18babilenraek: Yes, I still try to understand why 二 is not considered to be a number or Nl (Number/Letter) or whatever ...
12:21cemerickbabilen: Surely python's .isnumeric isn't what you want. It apparently returns true for 2155 (⅕).
12:23eyeriscemerick: why do you consider 1/5 non-numeric?
12:24babilencemerick: I know that I don't understand this as good as I should. But 2155 (⅕) most likely has Numeric_Type=Numeric in http://unicode.org/Public/UNIDATA/UnicodeData.txt with a value of 1/5 and in Python you get "unicodedata.numeric('⅕')" → 0.2
12:24cemerickeyeris: babilen was talking about finding digits and integers within strings. I wouldn't think that that would include glyphs that represent one-fifth.
12:25diogoHi. I want to develop in lisp/clojure using vim. I heard about slimv, but I'm unable to install it in my debian.
12:25babilencemerick: I would settle for that -- It just means that I need additional tests (i.e. kPrimaryNumeric is an integer or so)
12:25diogoAnyone has an how-to install slimv on debian/linux
12:25diogoor any kind of troubleshooting for slimv?
12:26eyerisdiogo: I don't know anything about slimv, but there is a VimClojure plugin on vim.sf.net
12:27sjldiogo: Slimv seems to work great with Pathogen on OS X -- there shouldn't be any problems on Debian.
12:28babilendiogo: I would recommend vimclojure -- I use slimv only for paredit -- you can see my vimrc on https://github.com/babilen/dotfiles/blob/master/vim/vimrc -- I can walk you through the installation later, but you will most likely want to use http://clojars.org/org.clojars.oskarkv/lein-vimclojure (leiningen plugin) to start the server. See https://bitbucket.org/kotarak/vimclojure for further information on vimclojure
12:28cemerickbabilen: It seems like you really need to determine *what you want*, instead of looking/hoping for someone else's categorization to suit your requirements. In the end, you may just find it easier to slurp UnicodeData.txt, do a rough filter on it based on some coarse-grained criteria, and then curate that to yield the set that you want to define as numeric.
12:29sjldiogo: babilen: I actually do the opposite -- I use Slimv with two files from VimClojure :)
12:29babilendiogo: If you are on Debian you can easily install leiningen and clojure from the Debian packages. Give me 30 minutes and I walk you through this, OK?
12:29babilensjl: I would love to learn about your setup :)
12:30babilencemerick: Yes, that is very true. I want to find all digits in a text and am surprised that 二 is not considered a digit in Unicode.
12:30sjlbabilen: It's basically Slimv with VC's indent and syntax files. I like Slimv's repl and keybindings (especially since they're the same when I do lisp or clojure) but VC's indentation and syntax are way better
12:31sjlbabilen: I made a fork of Slimv where I replaced the files, and I try to keep it updated: https://bitbucket.org/sjl/slimv
12:31babilensjl: thanks -- I'll take a look
12:32babilendiogo: Which branch of Debian are you tracking?
12:32sjlOh awesome, Slimv fixed the cw/whitespace problem. https://bitbucket.org/kovisoft/slimv/changeset/75c81a22a1a6
12:38babilendiogo: Install leiningen + clojure according to http://groups.google.com/group/clojure/browse_thread/thread/686569edb1c76df1 -- then configure vim to use vimclojure+slimv -- you also have to install the nailgun client and the leiningen plugin. The former is explained on https://bitbucket.org/kotarak/vimclojure and the latter is done with 'lein plugin install org.clojars.oskarkv/lein-vimclojure "1.0.0-SNAPSHOT"'
12:38babilen(this should be easier)
12:51chewbrancadiogo: I got slimv working with pathogen and https://github.com/vim-scripts/slimv.vim, and just installing the swank clojure plugin: https://github.com/technomancy/swank-clojure
12:51chewbrancadiogo: working config here: https://github.com/chewbranca/rc_files/tree/master/vim
12:54babilendiogo: I recommend vundle instead of pathogen though
13:00chewbrancababilen: vundle seems overly complicated, I like that pathogen keeps the logic and process of fetching git repos in the hands of git
13:01chewbrancababilen: just two different approaches to the same problem though, either way is much much better than just dumping everything manually into ~/.vim
13:01babilenchewbranca: As does vundle -- you don't have to use its ":BundleInstall" but it makes it easier. (OT though → #vim)
13:03sridicey: speaking of refactoring clojure code, checkout http://blog.darevay.com/2011/08/briefly-the-arity-reduce-pattern-in-clojure/
13:04iceysrid: cool, thanks man - i'm actually doing all the refactoring we talked about last night right now :)
13:04sridicey: in an oss project on github? (just wondering if i can take a look at the commits)
13:05iceysrid: just using gists at the moment https://gist.github.com/1164329
13:09iceysrid: i got more feedback on this other file, but i'm still working on it... it's in a proper git repo though: https://github.com/pmn/peeranoia/blob/master/src/peeranoia/core.clj
13:11diogothank you
13:16ScorchinIf I have a sequences of strings (words), how do I track the frequencies? Do I need to create keys for each word in a new map?
13:30sridScorchin: yes, why not? recur on (assoc freq word (inc (or (freq word) 0)))?
13:31Scorchinsrid: Thanks, I figured it out. Needed to convert the strings into keys :)
13:38scottjsrid: another way to write that fyi: (update-in freq [word] (fnil inc 0))
13:41sridscottj: good to know, thx!
13:42ScorchinIs there a limit on the size of a data structure that slime/swank can handle? Is there any way to increase this?
13:42amalloy&(doc frequencies)
13:42lazybot⇒ "([coll]); Returns a map from distinct items in coll to the number of times they appear."
13:42amalloyScorchin: if your data is strings, converting them to keywords is generally pointless
13:45Scorchinamalloy: mapping them to lowercase strings and then running "frequencies" against on the produced lazy list seemed to do the job
13:53ScorchinI think I might be loading too much data for clojure/emacs to handle :/
13:53Scorchin"variable binding depth exceeds max-specpdl-size"
13:54Scorchinthe odd thing is that it's only a 2mb json file that I'm playing with
13:58srid4clojure throws java.util.concurrent.RejectedExecutionException despite having a ~/.java.policy file as described; any clues? the exception doesn't tell which point in the 4clojure source it arises.
14:01amalloysrid: sounds more like a lein problem
14:02amalloythere were a couple versions of lein released that did this for any app that spins up agents or futures (and we use an agent)
14:45AWizzArdAnyone here who knows Nexus, Archiva, Artifactory or any such tool? What I want is a server that can serve me jars in my internal network. The jars I want to put in there manually, and it can not access clojars or any maven repo. But for Leiningen I want it to look like a valid source.
14:46hiredmanAWizzArd: you just need a webserver that understands put / get
14:47hiredmanthe smarts are all actually in mvn, not in the repo
14:49cemerickAWizzArd: What hiredman said; though I happen to use Nexus. It works, and has a lot of nice extras.
14:50cemerickI've also started using S3 as a public maven repo, which is really nice for separate public-facing stuff.
14:50SomelauwEmacs keeps changing fn into a curly f. And I can't figure out why.
14:50AWizzArdcemerick: so, Nexus could be installed on a local machine, and then I can dump some jars in some dir and have maven/leiningen/cake use the Repo it provides?
14:50danlarkinchas has an inexplicable affinity for software labeled "enterprise"
14:51cemerickAWizzArd: Yes, though if you're doing something that simple, just use apache or nginx or whatever.
14:51amalloySomelauw: someone clever included that in some starter package
14:51cemerickI'm pretty sure I've never used anything labelled "enterprise".
14:52AWizzArdah oki
14:52cemerickShibboleths, they come and go.
14:52amalloyi think it also changes #(...) into λ(...)
14:52Somelauwamalloy: It seems confusing to me, but after some tests I figured out it was treated as fn.
14:53amalloySomelauw: yes, i don't think i'd like it, but it's just a visual change
14:53Somelauwamalloy: It doesn't do that lambda trick but my version might be old.
14:53cemerickdanlarkin: I thought the knock on me was that I've never met an XML element I didn't like, etc? :-P
14:54danlarkinwell that too
14:54danlarkinbut maven's got it all
14:55hiredmanall that ecosystem
14:56pjstadigbut...but...you can specify the developers who are involved, and what their roles are
14:58cemerickReminds me of Annie Hall, where Alvy recalls the Marx quote… "wouldn't want to be in any club that would have someone like me as a member"
14:58AWizzArdThat seems to be a funny and *very* lightweight server *lol* http://www.jibble.org/miniwebserver/
14:58amalloySomelauw: looks like it's in emacs starter kit: https://github.com/technomancy/emacs-starter-kit/blob/master/starter-kit-lisp.el#L59
15:01amalloyso if you don't like it, that's where you'd turn it off
15:01SomelauwI still need to watch Annie Hall.
15:02arohnerSomelauw: yes. though don't do it if you're getting over a sad/bitter break-up
15:03arohnerdoes 'case' not work with constant expressions?
15:03arohner(int \newline) is failing me
15:04arohnerbut 10 works
15:04amalloyarohner: no, it doesn't do that
15:04arohner:-(
15:04amalloy(int \newline) will succeed if you pass in '(int \newline)
15:05amalloyjust use condp =?
15:05arohnerI'm trying to build a fast parser
15:05arohner'(int \newline) isn't matching for me
15:05amalloyarohner: no, i mean, if your case clause is (int \newline), and the data you test it against is '(int \newline)
15:06arohneramalloy: ah, I get it. thanks
15:06amalloythough that might not be true. seems like it should be
15:07arohnerI'm reading a char out of a reader, so I need to handle -1, plus a few chars like \newline. I can't put \newline in the case, because .read returns an int.
15:07arohnerand (char -1) fails
15:11danlarkinarohner: (char -1) fails because now casts check validate their inputs
15:11arohnerdanlarkin: that's fine. I'd be happy if case accepted constant expressions to match against. i.e. (int \newline)
15:12aaelonyhi, with-query-results from clojure.contrib.sql will give me a vector of maps. Has someone written a function via Hiccup to mark this up into an HTML table ?
15:12danlarkinhow do you determine what's constant and what's not?
15:12amalloyarohner: you can write a macro that expands to 10 instead of (int \newline), or you can hardcode 10 and put in a comment
15:12arohnerdanlarkin: assume intelligence on part of the developer. "whatever you return the first time we call expr is what we match against"
15:13arohneramalloy: yeah, I'll probably do that
15:13hiredmanor you can (case (char c) \newline ...)
15:13amalloyhiredman: but that fails for -1, which i think was his point
15:14hiredmanamalloy: which is why you put an if (pos? ...) around it
15:14hiredmanarohner: not possible in the compiler
15:14arohnerhiredman: yeah, but that's ugly because you split up your cond. I'll make a macro
15:15hiredmancase has to know the hashcodes of the values at compile time
15:15arohnerhiredman: yeah? a macro can do the job, so the compiler should be able to
15:15amalloyhiredman: i thought i understood (case), but (case '(a) (a) 1) fails, while (case 'a a 1) succeeds. what am i missing?
15:16cemerickamalloy: Lists are for grouping multiple test expressions. (case '(a) ((a)) 1) works.
15:16amalloyoh
15:17hiredman,(case '(a) [a] 1)
15:17clojurebot1
15:17hiredman,(case 'a (a b) 1)
15:17clojurebot1
15:17hiredman,(case 'b (a b) 1)
15:17clojurebot1
15:17amalloyokay. the world is back to sanity; thanks guys
15:17hiredmanwild
15:17amalloyi didn't even know that was a feature that existed
15:20amalloy&(doc case)
15:20lazybot⇒ "Macro ([e & clauses]); Takes an expression, and a set of clauses. Each clause can take the form of either: test-constant result-expr (test-constant1 ... test-constantN) result-expr The test-constants are not evaluated. They must be compile-time literals, and need n... http://gist.github.com/1166207
15:22cemerickcase has some easter eggs in it. Like, falling back to equality upon hash collisions (thanks to ataggart).
15:22amalloyyeah, i remember that one
15:25hiredmanisn't equality the 4th hard thing in computer science?
15:29cemerickhiredman: what's #3?
15:29jolynaming, caching, ______, and equality?
15:29manutter#3 is "coding in the absence of caffeine"
15:29dpritchettDoes MVC exist in clojureland? I've been trying to figure out the point behind the Railsy "Fat Controllers, Skinny Models" mantra and how it might apply to my Django project. I haven't really figured it out yet but it occurred to me that some #clojure minds might have more experience than I do.
15:30SomelauwHi, I have the feeling that reduce is often a bit unreadable or is it just me?
15:30danlarkinit's you
15:30cemerickdpritchett: Not a lot, no…unless you consider simple functions to be controllers.
15:30dEPyFat controllers and skinny models?
15:30arohnercemerick: you forgot off-by-one errors
15:30dEPyIsn't it the way around...
15:30dEPy?
15:30arohnerthe two hardest things in CS are naming, cache-invalidation and off-by-one errors
15:30amalloywell, maybe you'll get lucky and never have to write code that knows about more than one element of a seq at a time, Somelauw
15:31mabesSomelauw: once you have used the concept/pattern a lot reduce looks quite natural. if you've never used a function like that in another language it may be confusing at first
15:32Somelauwamalloy, mabes: Here is some code that I think looks complicated http://ideone.com/FS3RI
15:32hiredmancemerick: off by one errors
15:32dpritchettyou're right dEPy the models are supposed to be fat
15:32SomelauwAnd case is a valid macro nowadays. ideone is just old.
15:32dpritchettMy current django project has 3.5x more LoC in the controller than the models, I was wondering if I am doing this wrong ;)
15:33SomelauwCode should work.
15:33amalloySomelauw: reduce with destructuring over the accumulator can look confusing if you're not used to it
15:34mabesSomelauw: FWIW, that doesn't seem confusing to me
15:34amalloyreduce takes only one accumulator, so he's reducing over a vector of [mapping, stack] pairs, and each iteration he's pulling it apart and reconstituting it
15:35SomelauwIf I didn't write it myself, I probably wouldn't be able to guess what it does.
15:35amalloyoh, you wrote it yourself? then the fact that i was able to explain it to you should reassure you that it's not confusing
15:36SomelauwYes. I was just wondering if anybody except me would understand it.
15:37amalloySomelauw: fwiw, i'd use count instead of .length; probably (let) the result of (peek stack); and maybe use assoc instead of conj
15:40SomelauwStill your explanation of the codeis not really complete.
15:40Somelauwamalloy: I agree on those points.
15:41SomelauwYou didn't describe what it does return.
15:44SomelauwThis might spoiler it, but it returns a map with the positions of brackets associated to the matching bracket.
15:44amalloySomelauw: well, the most-recent positions of brackets, right? you're conjing onto a map, not a seq
15:45greghjoly: there are two things: naming, caching, and off-by-one errors.
15:45amalloy&(conj {} {\[ 2, 2 \[}, {\[ 5, 5 \[})
15:45lazybot⇒ {5 \[, 2 \[, \[ 5}
15:45amalloynote that [ maps only to 5; you've lost the 2, if you intended to keep it
15:47jolyjust passed that one around the office :)
15:48manutterjoly (and arohner): that is a good one.
15:55Somelauwamalloy: Nothing should get overwritten in the map.
15:56amalloySomelauw: oh right, x is the index, not the character
15:56Somelauwamalloy: Right.
15:56amalloythat's the part i found hardest to keep in my head :P
15:56SomelauwThe alternative is to make the reduce iterate through 3 lists because I need the positions.
15:57amalloySomelauw: code is what, a vector?
15:58SomelauwA string containing [ and ] and other chars.
15:59SomelauwAlthough a vector of chars and a string are almost the same.
15:59amalloyyou can reduce over a list of pairs, which seems more self-documenting to me: (reduce (fn [[mapping stack] [c idx]] ...) [{} ()] (map (juxt identity #(get code %)) (range (count code))))
15:59amalloyor at least use a name that implies an integer count, like i or n; x is very confusing there
16:00amalloy(and i guess that should be [idx c], if it's going to match up with my juxt)
16:00jkkramer,(map-indexed vector "abc")
16:00clojurebot([0 \a] [1 \b] [2 \c])
16:05amalloyah, that's nicer, of course
16:14SomelauwI think it is getting readable.
16:15Somelauwhttp://ideone.com/mFEtf
16:16SomelauwSorry, I pasted the old one again
16:16ldhI'm calling 'map' on a collection, but ultimately i want the results put into a set instead of a lazy-seq. is there a better way than (apply hash-set (map f coll))?
16:17SomelauwThis is what it looks now: http://ideone.com/YENwp
16:19hiredman,(doc set)
16:19clojurebot"([coll]); Returns a set of the distinct elements of coll."
16:19SomelauwThanks guys.
16:21ldhhiredman: ah, of course. (set (map f coll)). That's better.
16:26arohnerdnolen: (match foo [foo & rest :foo]) just made my day!
16:27dnolenarohner: nice! :)
16:27dnolensomeone's trying to red-black trees, but that needs to wait for vectors patterns.
16:27arohnerdnolen: one of those "I wonder if this will work..." moments, where it goes your way :-)
16:28dnolenarohner: it had better work! there are tests in there man!
17:52patchworkhey all, trying to use swank-clojure with emacs https://github.com/technomancy/swank-clojure
17:52patchworkI keep getting a connection refused error when running M-x clojure-jack-in
17:52patchworkany clues where to start here?
17:53patchworkemacs 23 on macosx
17:53patchworkclojure-mode works fine otherwise
17:54chewbrancapatchwork: you did the lein plugin install swank-clojure I take it?
17:54patchworkchewbranca: yep
17:55chewbrancapatchwork: hrmm... maybe try jumping into your project with the command line and run lein swank to see if there is any errors; other than that, not sure
17:55patchworkthe actual error: "error in process filter: make client process failed: connection refused, :name, SLIME Lisp, :buffer, nil, :host, localhost, :service, 63232"
17:55patchworklein swank works fine
17:56patchwork"Connection opened on port 4005"
17:56patchworkwhile that is running if I do slime-connect I get the same error
17:57hiredmancan you ping localhost?
17:58patchworkis it an issue with emacs then?
17:58patchworkYeah, pinging localhost works fine
17:58hiredmancan you telnet to localhost 4005 ?
17:59chewbrancathat error message looks like its trying to connect on port 63232, rather than 4005, I'm not familiar with the emacs side of things, but could that be the issue?
17:59patchworkWhen I do slime-connect it tries 4005
18:00patchworkclojure-jack-in starts its own process, so I assume that is where it gets the port from
18:00hiredmanclojure-jack-in uses a a random port
18:00patchworktelnet localhost 4005 fails
18:00patchworkconnection refused?
18:00hiredmanmaybe a firewall issue
18:00patchworkweird
18:01patchworkfirewall, between me and my own computer?
18:01patchworkhow did that happen?
18:01amalloypatchwork: windows does that
18:01hiredmandunno
18:01patchworkI'm on macosx
18:01patchworkstrange
18:02patchworkany idea how to troubleshoot? I guess this is beyond the scope of #clojure now
18:02hiredmanosx will sometimes popup a window asking if I want to let java connect to the internet
18:03patchworknot too familiar with local network settings
18:15kencauseyI'm finally getting around to dnolen's NYC meetup talk (good stuff!) and I'm wondering if the slides have been posted somewhere yet.
18:15amalloykencausey: on scribd, i think
18:16dnolendirect download from github here, https://github.com/downloads/swannodette/match/patterns.zip
18:16AWizzArdA friend yesterday told me how easy it was for him to use Match to optimize terms (:
18:17dnolenAWizzArd: cool!
18:17kencauseydnolen: thanks, I think I just found it on scribd, but that's probably better
18:19RaynesOfftopic: I've got Spotify invites. If anybody in the USA wants one, PM me an email address.
18:22patchworkinteresting, here is my netcat line for lein swank:
18:22patchworktcp4 0 0 10.0.1.120.4005 *.* LISTEN
18:22patchworkand I can telnet 10.0.1.120 4005
18:22patchworkjust not telnet 127.0.0.1 4005?
18:22patchwork(10.0.1.120 is my local network ip)
18:22patchworkhow is that possible?
18:22patchwork*netstat
18:25amalloypatchwork: if it's only listening on the remote interface, then telnetting over the remote interface won't work
18:26patchworkYeah, all I did was type "lein swank"
18:26patchworkit set up the port etc
18:26patchworknot sure how to tell it to listen on localhost rather than my local ip?
18:26amalloy*shrug* i'm just pointing out that it's entirely possible from the netstat point of view
18:27patchworkYeah so it is expecting a remote connection then?
18:27gtrakhow would I say... test a function just by defining a bunch of inputs and the corresponding outputs?
18:28patchworkis it some kind of lein setting I need to put somewhere?
18:28amalloygtrak: in clojure.test? you probably want to use (are...)
18:29gtrakamalloy, I can't really define them outside the macro and pull it in, right? I'd need like a compile-time apply for that
18:30gtrakah, I see there is apply-macro
18:30amalloygtrak: god no. don't use that
18:30gtrakhaha, ok
18:30amalloyyou haven't made clear why you want to define them outside of the are clause
18:31gtrakI guess it doesn't really matter, it just seems like I should be able to do that
18:34tomojdefine what?
18:34gtraktest-data outside of an is macro... then do something like... for the corresponding inputs and outputs, run this function on them
18:35gtrakdo a proper error when something fails
18:37gtrakmakes sense for say, the mathematical definition of a function, something that maps from inputs to outputs
18:47Netpilgrimgtrak: I'm a noob around Clojure, and perhaps I don't understand you correctly. But why don't you just put your test input and output in a map and do something like (doseq [input (keys testdata)] (assert (= (f input) (testdata input))))?
18:48gtrakyea, that's exactly what I'm about to do
18:49gtrakassert-predicate looks like the right thing to use
18:51patchworkI figured it out
18:51patchworklein swank 4005 0.0.0.0
18:51patchworkit was defaulting to the wrong interface
18:51patchworkis that a lein swank bug?
18:52hiredman0.0.0.0 is every interface, which is a security risk, so lein defaults to 127.0.0.1 I believe
18:52patchworkExcept that in my case it defaults to 10.0.1.120
18:53hiredmanthat may be a bug in the way it figures out the ip for lo
18:53patchworkThat is what I am wondering
18:55hiredmandoes localhost actually resolve to 127.0.0.1 for you?
18:56hiredmanswank-clojure uses (InetAddress/getByName host) and host defaults to "localhost"
19:01patchworklocalhost resolves to 127.0.0.1
19:02patchworkPING localhost (127.0.0.1)
19:51dnolenchouser: what are quoting in your tweet?
21:26hiredmanhuh
21:26hiredmanthe release notes for 1.3 isssue in jira has been closed
21:26hiredmanhttp://dev.clojure.org/jira/browse/CLJ-777
21:39jliif I have a bunch of tiny web apps, is there a nice way to host them all in one place? say, have root.com/app1/whatever do the same thing as app1site.com/whatever ?
21:40jliI guess if each project exposed their handler, you could have a router site that used the first bit of the URI to route to the right sub-app, and strip the first part off in the process?
21:41amalloyjli: i use nginx to do that
21:42jliamalloy: cool, I'll look into it. thanks
21:43amalloyand i think that's basically jetty's default behavior, if you can figure out how to use it; i cna't
21:47amalloyfwiw, jli, subdomains are a "safer" way to do this than url prefixes. app1.root.com/whatever will work better, because app1 may include hrefs like /foo
21:49hiredmanhuh, there is a whole "clojure 1.3" dashboard in jira
21:54jliamalloy: yeah, that sounds nicer
21:56jliand I guess with wildcards in DNS, there's no extra administrative stuff to do, right?
21:57amalloyheh, i dunno. i'm not much of a server admin
21:57jliokay. I think it'd work :)
22:13sleepynateok darevay, i know you're around here somewhere
23:14ivan__hi all, im trying to add a plugin written in clojure to an existing java project, but am having problems with either the classpath or how im using clojure. I'm extending a class which works fine, but then if i try and call outside clj code, the clj compiler gives me erorrs. Am I missing somthing? (more details to follow)
23:15ivan__ant output https://gist.github.com/b66ff83787d58ddf81c3
23:15ivan__my plugin https://github.com/hadashi/play-clojure/blob/master/src/play/modules/clojure/clojureplugin.clj, and the code it tries to call https://github.com/hadashi/play-clojure/blob/master/src/play/modules/clojure/util.clj
23:43jjddbhello
23:43jjddbmight anyone be familiar with http.async.client?
23:44jjddbI am trying to figure out how to download a non-string file, like an mpr
23:44jjddbmp3
23:46jjddbThe closest I've gotten is this:
23:47jjddb(spit "ex.mp3" (with-open [cl (c/create-client)] (-> (c/GET cl "http://www.example.com/ex.mp3&quot;) (c/await) (c/string))))
23:48amalloyjjddb: since you apparently don't care about asynchronicity, why not just use slurp?
23:48jjddbamalloy: hmm... let me try that
23:49jjddbyea, all I want is a simple get
23:49amalloyslurp might have a binary/text toggle, you'll want to check the docs
23:59sridi don't think so
23:59sridi had to use java.net.URL
23:59sridand then slurp the resulting stream