#clojure logs

2011-02-18

00:03simardtechnomancy: how/where do you start swank-clojure ? also when using slime with swank-clojure, is there a way to see the output of the stdout ? (all I see is #<ServerSocket ServerSocket[addr=localhost/127.0.0.1,port=0,localport=4005]>)
00:03simardof course I see the returned values, and slime-events, but no stdout ie: (println ..)
00:03pdk(doc take)
00:03technomancysimard: if I'm working on a project: lein swank. if I'm just screwing around standalone, I use the swank-clojure server
00:03clojurebot"([n coll]); Returns a lazy sequence of the first n items in coll, or all items if there are fewer than n."
00:04technomancy*swank-clojure shell script
00:04technomancysimard: you can rebind *out* to System/out to write to the stdout in the shell
00:06simardhum I might have a problem with my installation then because "lein swank" only returns "That's not a task", as I said before
00:07simardmaybe I missed a reply of someone about that
00:07technomancysimard: it's in the readme; lein plugin install swank-clojure 1.3.0-SNAPSHOT
00:08simardthen there's an error in the readme :)
00:08simard'plugin' is not in the line
00:09simardit reads: lein install swank-clojure 1.3.0-SNAPSHOT
00:09technomancyoops; you're right. that only installs the shell script
00:09technomancybut you can put it in project.clj as well
00:10simardnow I do have the lein swank option
00:10simardso that was why
00:10simard:)
00:10simardyay
00:10simard'Note that the lein-swank plugin now comes with Swank Clojure; it does not need to be specified as a separate dependency any more.'
00:14pdk,(cons 1 ())
00:14clojurebot(1)
00:14pdk(doc cons)
00:14clojurebot"([x seq]); Returns a new seq where x is the first element and seq is the rest."
00:14jnymo_emacs in the browser: http://www.ymacs.org/demo/
00:14simardtechnomancy: thanks for you help, it's working fine now
00:19pdk,(cons 1 nil)
00:19clojurebot(1)
00:25amalloyjnymo_: neat, and surprisingly functional, but it seems to be reading all my keystrokes twice
00:25jnymo_hmm. Works in chrome here
00:25amalloyon keydown and on keyup
00:25amalloyso if i hold a key, it works fine in between
00:26amalloyi think linux sends different key events
00:26amalloywhat OS are you using to test?
00:42simardhow do I get to see the :doc string from the metadata ? C-c C-d C-d doesn't see to work, although M-. gets me at the function in the source (ie.: clojure.contrib.math/expt)
00:42simardseem
01:20kilo_hi, am just starting off with clojure - is it possible to build clojure and clojure-contrib using lein ? or do I specifically need maven ? (clojure-contrib doesn't have a build.xml)
01:34kilo_o-kay.maven it is
01:35amalloykilo_: you don't need to build them at all
01:36kilo_oh. hi
01:36amalloyjust make sure you have lein installed (lein self-install), then lein new my-project-name
01:37amalloywill create a project directory; the project.clj file there will cause maven to download prebuilt copies of clojure and clojure-contrib
01:37kilo_aha
01:38kilo_is maven downloaded as part of lein self-install ?
01:38amalloykilo_: i believe so, but it's been a while
01:38amalloyi built them twice: once when i was confused and in your position, and once a month ago when i wanted to submit a compiler patch. but you don't need to
01:40kilo_i just ran lein self-install - it said "leiningen-1.4.2-standalone.jar" already exists. Delete and retry" so what i did yesterday must've been correct.
01:40amalloyyep, sounds good to me
01:40amalloyjust checked that jar file myself, btw, and it includes maven
01:41kilo_cool. if i want to depend on an existing library, i put it in my project.clj, right ? and lein deps will take care of it ...
01:41amalloyyep
01:41kilo_neat
01:41kilo_saved me a download : D
01:41amalloykilo_: you're just lucky jeopardy ended before you'd gone and installed maven again :)
01:42kilo_heh heh
01:42kilo_is this the ken jennings /watson one ?
01:42amalloyyeah
01:42kilo_keeps popping up on reddit
01:42amalloyi was really excited about watson last year when it was still a research project; i can't believe i didn't find out it was airing until today
01:44kilo_oho. not a reddit reader i presume. the jokes and photoshopped images start on reddit almost immediately after any new event...
01:44kilo_say, what's watson programmed in ?
01:44amalloyno, not big on those social-media things
01:44amalloydespite working for one of them :P
01:45kilo_hmm.
01:48kilo_say, who was winning
01:48amalloykilo_: what, on jeopardy?
01:49kilo_yes
01:49kilo_amalloy: it's all nlp ,right ?
01:50amalloykilo_: yeah, although i was disappointed to see that they scrapped the idea of having watson have to listen to clues and/or read them from the screen. giving him a text file makes things so much easier
01:52kilo_wikipedia says there were instances where watson gave the same/reworded answer as ken jennings, and this was because he(watson) was deaf...
01:52kilo_anyways , today jeopardy, tomorrow skynet
01:52kilo_clojure hackers will form the resistance
01:52amalloyyeah. and if you want help with actual clojure, i'm still here :P
01:52kilo_:)
01:53kilo_right. am off to read some more. thanks !
03:09khaliGhm im trying to run the uberjar app and it comes back with "Could not find the main class: foo.core Program will exit."
03:09khaliGlein run works fine though
03:10brehautyou need to set your foo.core namespace to be gen-class'd
03:10brehautand provide a -main function
03:10khaliGi did both things, since it was generated using lein new
03:10khaliGalso, why would lein run work then if it wasnt the case?
03:11brehautlein run just runs interactively doesnt it?
03:11brehauti dunno, im out of my depth sorry
03:11khaliGno idea
03:11khaliGim guessing it just calls the main- method
03:11brehauthave you got a :main foo.core in project.clj ?
03:11khaliGyep
03:12khaliGso the stack trace actually starts with
03:12brehautits -main rather than main- ?
03:12khaliGCaused by: java.lang.ClassNotFoundException: org.joda.time.DateTime
03:12khaliG at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
03:12khaliGlets see
03:12khaliGyea -main
03:13brehautyeah im completely out of ideas now sorry
03:14khaliGno problem
03:14khaliGstupid lein :/
03:15khaliGhi KirinDave
03:19khaliGhm interesting, i dont think it packaged up joda-time.jar
03:22khaliGbrehaut, yep that was the problem, clj-time uses jodatime but the jodatime jar wasn't being included for some reason
03:22brehauthuh curious
03:53jkruegerdoes anybody know if more of clojure's core interfaces, like IFn are slated to become protocols in the future ?
05:47fliebel&(map #(Integer/parseInt (str %)) (Integer/toString 23 2))
05:47sexpbot⟹ (1 0 1 1 1)
05:49fliebelI'm not yet sure why that is useful, but I like it. ^
05:50ejacksonand here I thought you wanted: (map #(Integer/parseInt (Integer/toString %)) [23 2])
05:50__name__&(Integer/toString 23 2)
05:50sexpbot⟹ "10111"
05:51__name__&(Integer/toString 23)
05:51sexpbot⟹ "23"
05:51__name__Nifty.
05:51__name__&(Integer/toString 23 25)
05:51sexpbot⟹ "n"
05:51__name__&(Integer/toString 999 1000)
05:51sexpbot⟹ "999"
05:51__name__okay?
05:52fliebelI wanted to have a number as a list of bits
05:54__name__why does 999 1000 return "999" and not raise an error?
05:56fliebel__name__: I don;t know :( ##(Integer/toString 999 36)
05:56sexpbot⟹ "rr"
05:56__name__i blame oracle.
05:57__name__:_)
05:57__name__*:-)
05:57fliebelI blame you, because of quantum theory, the bug did not exist before you observed it.
05:58__name__I'm sorry.
05:59_mst__name__ actually went as far as to document the bug here: http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Integer.html#toString(int, int). The nerve!
06:00__name__I never said it were a bug
06:00__name__It's just odd behaviour imo.
06:01__name__I'd prefer if it just failed.
06:01_mstyeah, agreed :)
06:02__name__I dissaprove of any function that just defaults to some arbitrary behaviour on error case
06:02__name__*disapprove
06:03Chousukesometimes that's the only option if you want performance, though.
06:03Chousukeand it's the caller's fault if they misuse a function anyway :P
06:03__name__Chousuke: Blaming the caller for a bad API design is wrong imo.
06:03__name__A good API makes it less likely that it is used incorrectly.
06:04Chousukesure, but you can't always do that.
06:04__name__How does it make performance better in this case?
06:04__name__Doyou
06:04ChousukeI was speaking in general
06:04__name__*Do you think an if condition that raises an error would be too slow in that case?
06:05__name__Chousuke: I agree, but in most cases it's avoidable.
06:09fliebelWhat is the minimum number of math and logic operators you need to implement all the others?
06:10ejacksonxor
06:10ejacksonor nand, i think
06:11fliebelejackson: And what about math? or can you define addition using nand?
06:12ejacksonyes, you can do a full adder using only nands
06:12mrSpecfliebel: http://en.wikipedia.org/wiki/Negated_AND_gate
06:12mrSpechttp://en.wikipedia.org/wiki/File:NandFullAdder.png
06:12mrSpecfliebel: you can ;)
06:15fliebelwhat is the carry?
06:17fliebelAh, I see
06:19fliebelIt's like adding 2 large number on paper where you 'remember' numbers...
06:23shanmuI'm using the following modules: erc-track-mode, erc-track-minor-mode, erc-stamp-mode, erc-ring-mode, erc-readonly-mode, erc-pcomplete-mode, erc-noncommands-mode, erc-networks-mode, erc-netsplit-mode, erc-move-to-prompt-mode, erc-message-english-flood-strict-mode, erc-menu-mode, erc-match-mode, erc-list-mode, erc-irccontrols-mode, erc-fill-mode, erc-button-mode, erc-autojoin-mode!
06:29shanmuis there an example on workflow for tdd with clojure
06:31AWizzArdshanmu: there is a nice video from the author of Midje: https://github.com/marick/Midje/
06:32AWizzArdshanmu: this is a 40 min video, showing you TDD with Top-Down-Testing: http://www.vimeo.com/19404746
06:33shanmuAWizzArd: Thanks! this is good...
06:42bobomidje is awesome
06:44shanmubobo: this is the first I have heard of it... looks good though and as the author says, there is a smooth upgrade path from clojure.test :)
06:44fliebelejackson, mrSpec: Is there a way I can define a full adder in Clojure without converting a number to a list first? ##(map #(Integer/parseInt (str %)) (Integer/toString 50 2))
06:44sexpbot⟹ (1 1 0 0 1 0)
06:45ejackson+
06:45boboshanmu: yeh, but the biggest beenfit comes when you use it with tdd, your functions are almost forced to be smal, and nice in so many ways
06:45fliebelejackson: meh, to easy...
06:46mrSpecso convert a number to a list :D
06:46mrSpecit will be harder ;)
06:47fliebelhm, maybe there is something fancy with rem that can get me separate bits :)
07:35raek&((fn [n] (loop [i n, bits ()] (if (zero? i) bits (recur (bit-shift-right i 1) (conj bits (bit-and i 1)))))) 52)
07:35sexpbot⟹ (1 1 0 1 0 0)
07:40AWizzArdraek: is that a demonstration of something or just a fast try cause you have no repl?
07:43raeknothing in particular
08:23raekhow would you implement the following function? (f [0 1 2 3 7 8 9 20 21 22 23]) => ([0 3] [7 9] [10 23])
08:24raektype of collection (vectors or lists) and whether the range is inclusive or exclusive are not important
08:50pdk,(apply list {} {} nil)
08:50clojurebot({} {})
08:50AWizzArdIs there a .zip download for Clojure Contrib that contains all Contrib .jars in one folder?
08:51__name__,(list nil nil)
08:51clojurebot(nil nil)
08:51__name__,(list 1 nil nil)
08:51clojurebot(1 nil nil)
08:57pdkcontrib has always been packaged all together into one jar
08:57pdkor do you want a zip of every release of it
08:59AWizzArdpdk: Contrib has so far been one big .jar file. But since 6-12 months every single NS from contrib is available as a single .jar file.
09:00AWizzArdThis allows people to include deps in a more granular way, i.e. your own product.jar will not automatically get much bigger cause you want to use just one contrib module.
09:00AWizzArdpdk: I am downloading fresh Contribs from build.clojure.org
09:01AWizzArdstuartsierra: is there a .zip file containing all .jars from Contrib in one plain folder?
09:01stuartsierranot at present
09:01stuartsierracould be done
09:01AWizzArdThat would be very helpful
09:01stuartsierraBut most of my attention is focused on "new" contrib.
09:01AWizzArdWhat is "new contrib"?
09:02pdk1.3 i imagine
09:02AWizzArdI just browsed build.clojure.org and downloaded a fresh Clojure. But by clicking through several links I see no way to download Contribs jars
09:02stuartsierra"new contrib" is github.com/clojure
09:03stuartsierraSo far it includes Unify and NRepl
09:03AWizzArdvs. build.clojure.org?
09:03stuartsierraNo, build.clojure.org continues.
09:03stuartsierraBut github.com/clojure/clojure-contrib is "old" contrib and will be discontinued after 1.3.
09:03AWizzArdAh, good info.
09:04stuartsierraSee http://dev.clojure.org/display/design/Common+Contrib+Build
09:04AWizzArdMost helpful would be: one zip containing the, say, 19 Contrib .jars in one folder. Also helpful would be a zip containing the 19 jars in some kind of folder structure. I could write a script that flattens it.
09:04stuartsierraMaven can do that. But again, "new" contrib takes priority.
09:06AWizzArdCurrently I see no way to get the freshest build of contrib as it seems that not even the single .jar files can be downloaded manually.
09:06AWizzArdAt least I did not find it while clicking through the hudson links.
09:06AWizzArdThe only download I can find is something that is several months old, on github I saw it I think.
09:07pdk(doc insert-right)
09:07clojurebotNo entiendo
09:07AWizzArdI remember there were some "secret" hudson links to build.clojure.org that can't be reached by visiting the initial domain
09:09stuartsierraThere's a maven repository at build.clojure.org/snapshots
09:09stuartsierrait should have the latest builds
09:09AWizzArdah yes, that was this "secret link"
09:10AWizzArdThough the time stamps are pointing to Nov. 2010
09:10stuartsierra"old" contrib is not under much active development, that may be the latest
09:10@chouserI'll be pushing some lazy-xml changes to old contrib sometime in the next few days
09:11@chouserI miss lazytest
09:11stuartsierrachouser: Did you get an answer on external depenencies?
09:12chouserstuartsierra: nothing since I said I was going ahead anyway
09:12chousereasier to ask forgivenes than permission, etc.
09:31pdk,(apply list [] '() [])
09:31clojurebot([] ())
09:33stuartsierrachouser: Did your ears burn a minute ago?
09:35chouserstuartsierra: heh, nope. Got some news for me?
09:36pdk,(concat [] [] [])
09:36clojurebot()
09:36pdk,(concat [[]] [[]] [[]])
09:36clojurebot([] [] [])
09:36pdk,(cons [] (cons [] [[]]))
09:36clojurebot([] [] [])
09:36chouserpdk?
09:36pdkchouser!
09:36pdkit's [] night
09:36stuartsierrachouser: We discussed external dependencies and lazy-xml.
09:36chouserstuartsierra: cool. and?
09:38stuartsierra2ah crud, 'net troubles
09:38stuartsierra2So, short summary:
09:39stuartsierra2To introduce a new dependency, we want to know 1) what it is, 2) why it's needed, and 3) what is its license.
09:41abedrastuartsierra2, are you cloning yourself?
09:41abedrai'm starting to become concerned
09:41stuartsierra2Crappy network cable keeps popping out and Adium clones me.
09:41chouserstuartsierra2: I would be equally content yanking the lazy-xml-pull code out of contrib entirely, but since it was previously donated to the clojure project I'm not sure I'm allowed to.
09:42abedraI for one welcome our new stuartsierra overlords
09:43stuartsierra2chouser: Rich isn't totally against dependencies, just cautious
09:43stuartsierra2Personally, if it's an integration point for people who want to use the external library, I think it's a good idea.
10:02stuartsierra2The BDFL was also adamant that no new development happen on "old" clojure-contrib.
10:07AWizzArd$seen rhickey
10:07sexpbotrhickey was last seen quitting 1 week and 3 days ago.
10:11Scriptorbusy guy, I guess
10:11fogus_You think?
10:13stuartsierra2He was at Clojure NYC Wednesday night.
10:15Scriptoryep, he stayed for a whiles too
10:18chouserstuartsierra2: wait, no new development? So my bug fixes and updates should be... what?
10:19chouserdelayed until someone creates new contrib projects for them?
10:19stuartsierra2chouser: In a "new" contrib project with its own repo.
10:19chouserok, but I can't do that
10:20chouserstuartsierra2: and you have better things to do. :-P
10:20stuartsierra2Right. We need a new process for proposing and vetting "new" contrib libs.
10:22chouserwell, I didn't really want to do that work anyway. ...was just trying to be responsible. :-P
10:22mprenticehappy friday folks
10:24stuartsierra2chouser: Thanks. We do appreciate it, honest. :)
10:24chouser:-)
10:46jweiss leiningen question - i currently have a (comment (do (...) ) in project.clj that after i start swank, I execute in emacs with C-x C-e to initialize my app to the state where it's ready to interact at the repl. but i'd like a lein command that does this - starts swank + init code.
10:47jweisscouldn't find any example of defining a new task on top of swank
11:11raekjweiss: would that code run in the project clojure instance or in the leiningen clojure instance
11:11raek?
11:12raekjweiss: you might find this interesting: http://groups.google.com/group/clojure/browse_thread/thread/4d8a1fc669a5a2df#
11:12jweissraek: the project clojure instance
11:13jweisswell, actually i am not sure - i assume the swank server is not the same jvm as leiningen
11:13jweissi would want it running in the swank server
11:15raekthe swank server is running in the project clojure instance
11:16raekI think it would be possible to add a hook to lein swank that does something like eval-in-project with (require 'my-proj.main) (my-proj.main/init)
11:17raekI usually just C-c C-k my main namespace and run a main function from the repl
11:18jweissraek: yeah, that's sorta what i do now, to be honest what i'm asking for doesn't save that much effort, but i thought it might be implemented already
11:25stuartsierra2You could also implement something like that in Emacs directly.
11:27raekjweiss: you should be able to do something like (ns leiningen.myinit (:use [leiningen.compile :only [eval-in-project]]) (:require leiningen.swank)) (defn myinit [project & args] (apply leiningen.swank/swank project args) (println "starting custom stuff") (eval-in-project project '(do (require my-proj.main) (my-proj.main/init))))
11:27raekbeware: I haven't tested this
11:27raekif it works, you should be able to run it with "lein myinit"
11:31AWizzArdIf I want (1.3) to make a def private I can say (def ^:private foo :bar) When I want to make it private AND add a docstring, should I then go by ^{:private true :doc "xyz"} ?
11:33TimMcAWizzArd: Looks right.
11:33fogus_AWizzard: I think multiple ^:blahs fold
11:34fogus_Hmmm, maybe not
11:34AWizzArd,*clojure-version*
11:34clojurebot{:major 1, :minor 2, :incremental 0, :qualifier ""}
11:34AWizzArd$*clojure-version*
11:34stuartsierra2fogus_: They fold in 1.3
11:35AWizzArdfogus_: so the idea is that (def ^:private :doc "xyz" foo :bar) could work?
11:35AWizzArd^:doc
11:35fogus_stuartsierra2: Whew. Thanks
11:36stuartsierra2AWizzArd: it only works with bare keywords, not key-value pairs like :doc
11:36AWizzArdoki
11:38fogus_But this should work no? (def ^:private ^:estimate ^{:doc "foo"} pi 3.14)
11:40jweissraek: thanks will try that
11:42fogus_Yes, that does work
11:43fogus_(meta (var pi)) => {:estimate true, :ns #<Namespace user>, :name pi, :private true, :doc "foo" ...}
11:43AWizzArdHmm strange, I now get a reflection warning for (Exception. (format "foo")). Is the return type of format no longer type hinted as ^String ?
11:43fogus_Symbols too
11:44fogus_(def ^:private ^:estimate ^Float ^{:doc "foo"} pi 3.14) => {.... :tag java.lang.Float}
11:45AWizzArdHmm, seems that more type hints are no longer working in a very recent 1.3 from build.clojure.org
11:46AWizzArd(when-let [c (class %)] (.isArray c)) ==> doesn't know the type of c
11:53fogus_AWizzard: Now it does. ;-) (when-let [^Class c (class %)] (.isArray c))
12:00AWizzArdfogus_: what do you mean by "now"?
12:01chouser,(meta #'class)
12:01clojurebot{:ns #<Namespace clojure.core>, :name class, :file "clojure/core.clj", :line 2651, :arglists ([x]), :added "1.0", :doc "Returns the Class of x", :tag java.lang.Class}
12:04AWizzArdchouser: This is the output on my system: {:ns #<Namespace clojure.core>, :name class, :arglists ([x]), :added "1.0", :static true, :doc "Returns the Class of x", :line 2962, :file "clojure/core.clj"}
12:06dnolenAWizzArd: seems like a legitimate but to me, return type-hints on fns don't seem to work anymore on 1.3.0-alpha5
12:06dnolens/but/bug
12:06sexpbot<dnolen> AWizzArd: seems like a legitimate bug to me, return type-hints on fns don't seem to work anymore on 1.3.0-alpha5
12:07AWizzArdSeems so.
12:12AWizzArdAlthough this is not a general issue. 'str' has a :tag in its meta, so (let [c (str "hi")] (.length c)) works fine.
12:24Cozeycan I put defmulti/defmethod to different namespaces? how should I use/require those namespace from one another?
12:27stuartsierraCozey: (ns a) (defmulti foo …) … (ns b (:use [a :only (foo)]) (defmethod foo …)
12:28Cozeytnaks!
12:28Cozeyif I would like to have access to all the methods using (:use a)
12:28Cozeywill it work?
12:28Cozey(use a) from other code
13:00bhenryhow can i parse a date that may or may not include the time?
13:01bhenryi want null if unparsable and the date object if parsable
13:01amalloybhenry: isn't that basically what java.text.[Simple]DateFormat does?
13:02bhenryit errors if there is no time.
13:03amalloydid you set it to lenient?
13:04bhenryi was toying with it, but since i don't know java i wasn't quite sure where to put it.
13:06amalloy&(-> (doto (java.text.SimpleDateFormat. "yyyy/MM/dd HH:mm") (.setLenient true)) (.parse "2011/02/18"))
13:06sexpbotjava.lang.IllegalArgumentException: Malformed member expression
13:06amalloy,(-> (doto (java.text.SimpleDateFormat. "yyyy/MM/dd HH:mm") (.setLenient true)) (.parse "2011/02/18"))
13:06clojurebotjava.text.ParseException: Unparseable date: "2011/02/18"
13:06edoloughlinI have a sequence of maps, which may themselves contain sequences of maps etc. I'm wondering what's the best way to traverse this to transform its structure (I want vectors containing vectors so I can use prxml). I looked at the pprint source but I'm concerned that using multimethods for this is overcomplicating things. Is the best approach to use (for) and recursion? Or a zipper? I'm worried that I'm just not grokking the Clojure way...
13:07amalloy,(-> (doto (java.text.SimpleDateFormat. "yyyy/MM/dd HH:mm") (.setLenient true)) (.parse "2011/02/18 10:01"))
13:07clojurebot#<Date Fri Feb 18 10:01:00 PST 2011>
13:07amalloyhm, guess lenient's not the way to go :P
13:07amalloyedoloughlin: have you looked at clojure.walk?
13:08edoloughlinNope. Haven't seen that before!
13:08amalloypostwalk is probably good enough for you, but if you need more flexibility you can roll your own with walk
13:09edoloughlinamalloy: Looks interesting. Will check it out. Thanks
13:12edoloughlinamalloy: Having trouble seeing how you'd know your context when walking. E.g., you might want to treat a node differently depending on its parent...
13:13TimMcI've written this function: (fn interp [binop vals] (map bi (drop-last 1 vals) (drop 1 vals)))
13:13TimMcand now I'm wondering if there's a name for that in functional programming.
13:13stuartsierraedoloughlin: also consider clojure.zip
13:13TimMc(I wrote it for linear interpolation in a graphics program, BTW.)
13:16ChousukeTimMc: you could probably get the same result with somthing like (for [[a b] (partition 2 1 vals)]] (binop a b))
13:17TimMcYup, that should work too.
13:17amalloyedoloughlin: if you want to treat a node differently depending on its parent you probably aren't doing it right :P
13:18ChousukeTimMc: I don't think there's a specific name for it though.
13:18amalloyi've actually used multimethods to do this task pretty cleanly, edoloughlin. let me find you a link
13:20edoloughlinamalloy: Perhaps! But if I ultimately want to output something like "<container><element>1</element><element>2</element></container>" then I might need to know something about container when I'm processing element… Maybe.
13:21amalloyedoloughlin: https://github.com/ninjudd/cake/blob/master/src/cake/tasks/deps.clj#L85
13:22amalloyit starts with some unrelated stuff about camelCase conversion, but i pointed the link there so the functions don't look confusing later
13:22edoloughlinamalloy: Thanks! My first foray into multimethods.
13:24amalloyheh. mine too, almost
13:31amalloyedoloughlin: you can see a sample of this code in action if you run $ cake deps from within a cake project - it generates the pom.xml file from project.clj
13:40edoloughlinamalloy: Thanks. Will do.
13:50khaliGugh, what timezone is clj-time using
13:50khaliG:/
13:53semperoskhaliG: pretty sure it defaults to UTC
13:53khaliGthat's what the README says
13:54semperoswhat are you experiencing? code exmaples?
13:56khaliGsemperos, i guess i just need to convert to my timezone to get meaningful numbers out, no problem
13:56khaliGi like how sun's Calendar just uses the local one
13:58semperoskhaliG: you can apply a timezone to the datetime itself
13:58semperosor just to the formatter used to print it
13:58semperosthe formatters use UTC by default as well
13:58semperostry (with-zone)
13:58mabesdid something like fogus_'s seq1 (de-chunkifying seqs) ever make it into core or contrib? (seq1 post: http://blog.fogus.me/2010/01/22/de-chunkifying-sequences-in-clojure/)
13:59khaliGi dont want to hardcode a TZ in though, semperos, in case someone else uses the app on a difefrent machine
14:04semperoskhaliG: you can use DateTimeZone/getDefault
14:04semperoson my system, for example, it defaults to "America/New_York"
14:05semperosit's the org.joda.time.DateTimeZone class, a static method
14:06khaliGoh yea, (clj-time.core/default-time-zone)
14:07semperospoints to khaliG for looking at the clojure source instead of the javadoc :)
14:07khaliG:)
14:11khaliGgood night, and thanks for the help semperos
14:14semperoskhaliG: no problem
14:43anonymouse89is there a way to exclude functions from clojure.core?
14:44anonymouse89i'm using clojure.contrib.generic.arithmetic and there are conflicts with +/-/*/etc
14:45brehautanonymouse89: i think you are looking for refer-clojure
14:46amalloyyeah, that's the ticket. (ns myns (:refer-clojure :exclude [+ - * /])), i think
14:47anonymouse89brehaut, amalloy : thanks!
14:47amalloyif you need access to both versions, you can (:require [clojure.core :as c :only [+ - * /]]) (c/- 10 2)
14:47bmhany incanter devs/users around? I'd like to add sampling from the conditional mvn distribution, and would like to chat about interface
14:57stuartsierrameow
15:21mattmitchellis there a built-in function that will convert a list of strings and keywords, to strings? for example (to-kw "one_" :two "_three") => :one_two_three
15:22mattmitchellsorry, i mean convert to keywords?
15:22brehaut(keyword "hello")
15:22brehaut,(keyword "foo")
15:22clojurebot:foo
15:22brehaut,(keyword :foo)
15:22clojurebot:foo
15:23brehaut,(name :foo)
15:23clojurebot"foo"
15:23brehaut,(keyword (apply (str (map name ["one_" :two "_three"]))))
15:23clojurebotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$apply
15:24brehautits apparently way to early
15:24brehaut(keyword (apply str (map name ["one_" :two "_three"])))
15:24brehaut,(keyword (apply str (map name ["one_" :two "_three"])))
15:24clojurebot:one_two_three
15:26brehautmattmitchell: i dont think there is a builtin though; apropos only returns (keyword? keyword) for fns with keyword in the name
15:26jamesswifthi all. looking for a quick example of dynamic fetching a page and selectively removing elements and/or attributes and re-emitting the page with enlive. I'm familiar with deftemplate and defsnippet and so on using a static file as the template but unfamiliar with doing this dynamically.
15:26mattmitchellbrehaut: great thanks for those examples. kinda what i had going, but yours is more concise.
15:27brehautjamesswift: have you seen david nolen's tutorials ?
15:27jamesswiftmaybe not.
15:27jamesswiftlink?
15:27clojurebotyour link is dead
15:27brehautmattmitchell: sorry about the messy thinking there
15:28jamesswiftoh yeah seen those
15:28mattmitchellbrehaut: oh no problem. it helps me see how i might figure things out on my own.
15:29jamesswiftmaybe i misunderstand how it's working. will look over it again. thanks brehaut.
15:30brehaut$findfn ["one_" :two "_three"] :one_two_three
15:30sexpbot[]
15:30brehautyeah nothing built in
15:31brehautshould have done that first
15:31brehautjamesswift: a lot of my issues learning enlive was realising that its actually a lot more general and reusable than i i first though
15:33mattmitchellbrehaut: what is $findfn ?
15:34brehautmattmitchell: part of sexpbot; it takes as arguments n forms; 1 to n-1 are arguments and n is the return
15:34mattmitchellbrehaut: and then if finds a function that matches the arg sig and return value?
15:34brehautand it runs through all of clojure.core trying to see if anything returns what you want based on the args you provide
15:34brehautyeah
15:34jamesswiftbrehaut: i've built some relatively complicated stuff using defsnippet and deftemplate but they generate functions where the source is static. i'd like to take a live source, select some parts of it and replace or change them. i bet i probably need an example for the transform function
15:34mattmitchellbrehaut: wow, that's awesome
15:34brehaut$findfn 1 2
15:34sexpbot[clojure.core/unchecked-inc clojure.core/inc]
15:34mattmitchelldamn
15:35mattmitchell$findfn "t" "T"
15:35sexpbot[clojure.string/upper-case clojure.string/capitalize clojure.contrib.string/swap-case clojure.contrib.string/upper-case clojure.contrib.string/capitalize]
15:35brehautif you are going to do a bunch of $findfn'ing you are probably best to private message sexpbot
15:36mattmitchellbrehaut: yeah good advice
15:38brehautjamesswift: have a look at https://github.com/cgrand/enlive/blob/master/src/net/cgrand/enlive_html.clj#L568-571
15:40jamesswiftbrehaut: i get lost in the macros :)
15:40brehautjamesswift: oh and template right below that selection; you can see that a template is just a snippet that is composed with emit*
15:41brehautjamesswift: ok lets look at the important parts
15:41brehauteverything inside the `(…) is the templatef form the ~ and ~@ reader stuff just tells the reader how to interpolate the values those symbols represent into the form
15:42brehaut~ just interpolates it verbatim, ~@ takes the seq and splices it into the parent seq
15:42clojurebotamac: So it's a seq of connections? And what do you do with them? I understand what disjoined sets look like, but the representation and iteration is where I run into trouble.
15:43brehauteg if foo is [1 2 3] then `(bar ~foo) becomes (bar [1 2 3]) and `(bar ~@foo) becomes (bar 1 2 3)
15:43brehautjamesswift: following?
15:44brehautjamesswift: dont forget that if you evaluate say (macroexpand-1 '(snippet "foo.html" {"a" "b"} [z y x] whatever)) in your repl, you will see the expansion
15:46jamesswiftbrehaut: thanks :)
15:46jamesswiftbrehaut: I have an example here that works now
15:46brehautjamesswift: cool :)
15:47jamesswiftbrehaut: eg (enlive/transform (fetch-url url) [:td] (enlive/remove-attr :colspan))
15:47jamesswiftif someone would write a small enlive cookbook i'd buy it ;)
15:47brehautcgrand needs to make a 1.0.0 non-snapshot version first ;)
15:48jamesswiftheh heh true. it's good enough imho.
15:48brehautits great!
15:48brehautbut -SNAPSHOT doesnt scream 'release' ;)
15:48jamesswiftin fact i think it's great. best templating mechanism i've even seen
15:48jamesswifttrue
15:49boboit also doesnt look that great that last commit was almost a year ago. Not that it realy needs any commits
15:50brehauthuh, it depends on clojure 1.1.0 or greater too
15:50brehautstill, its fantastic and i wish i had it for my day job
15:56jamesswiftyeah, if i could ask for one change it would be to change the dependancy to 1.2
15:57brehautreally?
15:57brehautits [1.1.0,)
15:57brehautso if you are using 1.2 it should usethat
15:58stuartsierraYou can override dependencies in Lein or Maven.
15:58jamesswiftthanks for the tip stuart
16:10amalloybrehaut: how do you specify whether you want version v, or version >= v?
16:10brehautin lein?
16:10@rhickeycemerick: nice - https://github.com/cemerick/bandalore
16:11cemerickrhickey: thanks :-)
16:11cemerickrhickey: I've been making good use of a (slightly updated) rev of your sdb library from a while back. It seemed like sqs needed some love, too.
16:12@rhickeycemerick: I presume deleting-consumer doesn't on exception?
16:12cemerickrhickey: right
16:14brehautamalloy: http://maven.apache.org/plugins/maven-enforcer-plugin/rules/versionRanges.html
16:14cemerickMy instinct was actually that I'd like the return value of the msg-processing fn drive whether the message should get deleted or not. That makes simple stuff like dumping messages to stdout a PITA though.
16:15@rhickeycemerick: any help for idempotency? (not a word)
16:16amalloybrehaut: oh neat. i didn't realize you could do that
16:17cemerickrhickey: Idempotence of what, the fn you pass into deleting-consumer?
16:17brehautamalloy: building on maven has its advantages :)
16:17@rhickeyI guess that's hard to library-ize
16:17@rhickeycemerick: yeah, duplicate msg handling
16:17cemerickrhickey: I wasn't thinking along those lines, really -- there just happen to be circumstances where you'll receive a message, but only conditionally delete it from the q.
16:18cemerickThat's enough of a 10% case that people can call delete on their own, I guess.
16:18@rhickeycemerick: yes, but also at least once semantics when that's not the case
16:19cemerickoh, I see
16:19@rhickeythat's the trickiest bit of SQS, imo
16:19@rhickeyunderstandable, but tricky
16:20cemerickRight; in my case, it doesn't *really* matter. If we run an extraction process on a document twice or four times instead of once every now and then, oh well.
16:20cemerickWithout understanding the use case, I wouldn't want to go tossing helpers around.
16:21@rhickeyunderstood, it can always be an application problem (or not), and can't do much in a lib except in narrow circumstances (single consumer)
16:22cemerickIt seems like if you're using SQS you're going to be in a load a pain if you think you can enforce things like just-once at the app level.
16:23@rhickeybut you could make a version of deleting consumer that tracked recently-handled messages
16:23cemerickonly within a single VM though
16:23@rhickeyyes, single consumer
16:23cemerick*shrug*
16:23@rhickeynot important, just wondering
16:23cemerickSure. :-)
16:24cemerickrhickey: it's the "recently" part of that description that gets tricky
16:25@rhickeycemerick: could just be a knob
16:25cemerickhorizon of N msgs?
16:25@rhickeyI'm not advocating for it, I understand SQS and the tradeoffs
16:26amalloywould there be any support for adding (defn invoke [f & args] (apply f args)) to core or someplace similar? ie, a version of apply that doesn't expand the last arg. then you could write (map invoke [+ -] [10 20] [4 7]) instead of ##(map #(%1 %2 %3) [+ -] [10 20] [4 6])
16:26sexpbot⟹ (14 14)
16:26@rhickeycemerick: yes, N, or time
16:26cemerickrhickey: I'm open to most things at the moment. Have only been using SQS for ~2 days at this point. :-)
16:26amalloyi've seen #(%1 %2) written too many times :P
16:26@rhickeycemerick: well, looks nice, I'll be sure to try it next time I'm fiddling with SQS
16:27cemerickthanks
16:27@rhickeySQS rocks (as does most of AWS)
16:27cemerickindeed
16:28cemerickBeanstalk really blew it open for me.
16:28@rhickeyyeah
16:28@rhickeygreat for Clojure
16:28opqdonutinvoke would be nice
16:28cemerickfinally, finally, a vertically-integrated option :-D
16:30jamesswiftbrehaut: oops missed the obvious and more useful form 'at' which can handle multiple transformations(enlive/at (fetch-url url) [:td] (enlive/remove-attr :colspan))
16:39jcromartieis there a way to make macros do checking on their arguments so that they fake a "compile time" check?
16:40jcromartieI know that question might not make much sense...
16:40cemerickjcromartie: any conditional that would result in an error at compile time in a macro is a compile time check. ;-)
16:41jcromartielike, what if you wanted to design a layer of the system to be used by n00bs so that they can't screw things up
16:42jcromartienever mind, I'm ahead of myself
16:44cemerickjcromartie: it's a reasonable thought, but not a simple thing in practice. There be dragons.
16:44jcromartieI saw a really cool presentation from Naughty Dog (video game devs, Crash Bandicoot, Uncharted series) about their new Scheme scripting engine
16:44jcromartiethey basically expose a mini-language to their designers
16:45jcromartieit made me think that a similar approach might be good for certain kinds of apps where you want to let people write scripts
16:45jcromartiebut then, if you're on the JVM you might as well just use Rhino and let them write JS
16:50ev4ljcromartie: which Naughty Dog presentation you watched? i'm asking it because i saw some slides a couple of years ago, but never managed to find the talk
16:51jcromartieState Scripting
16:51jcromartiein Uncharted 2
16:51jcromartieit was from GDC09
16:52ev4lhmm
16:57rata_hi
17:07jcromartieif ev4l here's the PDF http://dl.dropbox.com/u/5844871/gdc09-statescripting-uncharted2.pdf
17:08ev4ljcromartie: thx! lemme see
17:09jcromartieit's cool to see that a major part of one of the greatest games ever runs on Lisp
17:10ev4ljcromartie: Naughy Dog have a very interesting lisp history. Jak and Dexter series was coded in a dialect of lisp Naughy dog Developed
17:12jcromartiethey were using Lisp from the earliest games
17:12jcromartieCrash Bandicoot
17:12jcromartiethere was a hiatus when they were taken under Sony's wing to become 2nd-party devs
17:12jcromartiebut they are back with Scheme in Uncharted and Uncharted 2
17:14ev4ljcromartie: yup, sony greenspuned lots of their stuff :)
17:14ev4ljcromartie: that's cool to see!
17:15ev4ljcromartie: (i saw another presentation of them. this one is new to me)
17:15jcromartiewhat does "greenspunned" mean?
17:19ev4ljcromartie: http://en.wikipedia.org/wiki/Greenspun's_Tenth_Rule
17:19ev4ljcromartie: When they were acquired by sony, most of their lisp based tools were dropped
17:20jcromartiehah I see
17:21jamesswiftanother enlive question. i can't tell from the syntax spec if it's possible to define a selector that can select on the text value of an attribute. anyone know if is this possible?
17:32khaliGclj-time is really nice!!
17:41semperosjamesswift: what do you mean by "text value" of an attribute?
17:42semperosyou have an example of what you're trying to select on?
17:44semperosthere are the functions attr=, attr-has, attr-starts, attr-ends, attr-contains
17:44semperoswhich you can use to check against attribute values
17:44semperosin your selectors
17:44semperosit's outline here: http://enlive.cgrand.net/syntax.html
17:46jamesswiftsemperos: i really need to stop drinking beer while coding. thanks!
17:51semperosjamesswift: :) no problem
18:20ev4lanyone here experienced the following runtime error: "Could not locate clojure/java/io__init.class or clojure/java/io.clj on classpath" ?
18:20ev4li'm attempting to bootstrap a compojure app , and this error pops out when i try to start the ring server
18:21ev4li think it's a problem with my clojure installation/version
18:23raekev4l: sounds like you have a clojure version prior to 1.2, but that your code needs 1.2.
18:23ev4lraek: good!
18:24ev4lraek: my current version is 1.1
18:24ev4li'll update it, thx :)
18:24raekare you managing dependencies and the classpath manually? if so, why?
18:24ev4lraek: nope, i'm using leiningen
18:25raekah, and you had 1.1. declared in your project.clj file?
18:26ev4lraek: yup! both clojure and clojure contrib @ 1.1 version
18:27raekgood. :-)
18:27ev4li'll fix it now
18:56Guest8150ww
19:19ev4lraek: thx! it worked. Shiny jetty server up
19:56markskilbeckIs this correct for projecteuler #20 (http://projecteuler.net/index.php?section=problems&amp;id=20)?
19:56markskilbeck,(reduce * (range 1 100))
19:56clojurebot933262154439441526816992388562667004907159682643816214685929638952175999932299156089414639761565182862536979208272237582511852109168640000000000000000000000
19:59markskilbeckOh, I see. There's more to it.
20:12Guest37502can someone please tell me why i see nothing print when i run this last line in the repl? http://pastebin.com/0Mvdv31s
20:28DespiteItAllif you're using an IDE connected to a separate REPL, that probably prints to the console that's actually running the REPL. t
20:28Guest37502doh! i saw that just now before returning here
20:29DespiteItAllyou can use binding to fix it
20:29Guest37502that's exactly what is happening
20:29Guest37502thank you DespiteItAll
20:29DespiteItAllyou're welcome
21:46rata_$source not-any?
21:46sexpbotnot-any? is http://is.gd/y0oEz0
21:48pdknone? is a more concise name
22:08amalloypdk: and less explicit
22:08amalloynone? could be interpreted to mean empty?, whereas not-any? seems clearer to me
22:53rata_does anyone see how to make this code run faster? https://gist.github.com/834802
22:55scottjprofile it and see what is slow?
22:57rata_I'm trying to calculate what's the probability of n people to not have the same lastname (we commonly have two lastnames, even when then "last" don't make sense)
22:59rata_scottj: the profiler (visualvm) says that c.l.Cons.first takes most of the time, but it's just ~13%
23:02rata_(I've just edited the gist to write a sample use case)
23:06amalloyrata_: your weird logic about [_ _ p m] looks a lot like (drop 2 (...))
23:06DespiteItAllcombinations can eat up cycles quick
23:06amalloyyeah, and distinct is gonna be pretty slow too
23:06amalloyin fact most of ningun-apellido's let-block looks like (frequencies as)
23:08rata_amalloy: that seq can have more than 4 elements, so it's not the same as (drop 2 ...)
23:09amalloy(take 2 (drop 2)), then
23:10rata_but m could be an empty string, not just nil, and I want to filter that out too
23:12amalloy(filter seq (take 2 (drop 2 whatever))) - my point is it's not really necessary to put this into a destructuring-let with if statements attached
23:12rata_is if slow?
23:13amalloyno, but destructuring might be. tbh i'm more interested in the program seeming well-written than running fast, so you can ignore my advice if you don't like it
23:13amalloy&(filter seq (take 2 (drop 2 ["useless" "garbage" "apellido" ""])))
23:13sexpbot⟹ ("apellido")
23:20rata_and the problem with (frequencies (apply concat as)) is that if the first surname of one person is the same as the second surname, I'd count that surname twice and that's wrong
23:20rata_$source frequencies
23:20sexpbotfrequencies is http://is.gd/oSsjjJ
23:21amalloy&(distinct (filter seq (take 2 (drop 2 ["marco" "explorer" "polo" "polo"]))))
23:21sexpbot⟹ ("polo")
23:22rata_that's probably better than what I have
23:22rata_thanks =)
23:32amalloyrata_: conteo could be written as (count (filter (partial apply pred tol) as))
23:32amalloyor i see, i guess you're trying to get a ratio
23:32rata_yes
23:33rata_you mean conteo in prob-n or ningun-...?
23:33amalloyi meant prob-n
23:33rata_ok
23:34rata_yes, I do it so to then compute the ratio between the pairs of people (in case n=2) that doesn't have the same lastname vs all the pairs
23:40amalloyhm. it sounds like this could be made faster by doing some math ahead of time, then
23:40amalloylike, with K people, you already know that the number of unique subsets of size N will be (/ (! K) (! N) (! (- K N)))
23:40amalloyso you don't need to construct them all and then count them
23:41rata_yeah, that's right
23:42rata_but I still have to make the pairs with c/combinations
23:45amalloylikewise if there are ten people named francisco, you know how many groups of four franciscos there will be, so rather than doing all the permutations you can just compute the frequencies and do appropriate multiplications
23:45amalloyrata_: ^
23:46rata_so instead of counting up should I count down?
23:47rata_amalloy: ^
23:53amalloyrata_: what? why?
23:53amalloyrata_: you can count the number of times each name appears
23:54amalloysay there are four guys whose last name is de Seville or whatever
23:55amalloyyou don't need to split them into ten pairs, or two triples, or 24 ordered-quadruples, to know that there are ten groups with that last name
23:56rata_yes, you're rigth... the only thing that remains unclear to me is what happen when I have four X and four Y, but some of those Xs are the same people as some of the Ys, as people have two lastnames
23:56rata_amalloy: ^
23:58rata_amalloy: I know almost nothing about combinatorics
23:58amalloyrata_: that's up to you, i guess
23:58rata_and hate not knowing about that
23:58rata_it seems so useful sometimes
23:59amalloyyeah, i never went past number theory and discrete math, but counting was my favorite part of the non-calculus stuff