2011-02-18
| 00:03 | simard | technomancy: 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:03 | simard | of course I see the returned values, and slime-events, but no stdout ie: (println ..) |
| 00:03 | pdk | (doc take) |
| 00:03 | technomancy | simard: if I'm working on a project: lein swank. if I'm just screwing around standalone, I use the swank-clojure server |
| 00:03 | clojurebot | "([n coll]); Returns a lazy sequence of the first n items in coll, or all items if there are fewer than n." |
| 00:04 | technomancy | *swank-clojure shell script |
| 00:04 | technomancy | simard: you can rebind *out* to System/out to write to the stdout in the shell |
| 00:06 | simard | hum I might have a problem with my installation then because "lein swank" only returns "That's not a task", as I said before |
| 00:07 | simard | maybe I missed a reply of someone about that |
| 00:07 | technomancy | simard: it's in the readme; lein plugin install swank-clojure 1.3.0-SNAPSHOT |
| 00:08 | simard | then there's an error in the readme :) |
| 00:08 | simard | 'plugin' is not in the line |
| 00:09 | simard | it reads: lein install swank-clojure 1.3.0-SNAPSHOT |
| 00:09 | technomancy | oops; you're right. that only installs the shell script |
| 00:09 | technomancy | but you can put it in project.clj as well |
| 00:10 | simard | now I do have the lein swank option |
| 00:10 | simard | so that was why |
| 00:10 | simard | :) |
| 00:10 | simard | yay |
| 00:10 | simard | '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:14 | pdk | ,(cons 1 ()) |
| 00:14 | clojurebot | (1) |
| 00:14 | pdk | (doc cons) |
| 00:14 | clojurebot | "([x seq]); Returns a new seq where x is the first element and seq is the rest." |
| 00:14 | jnymo_ | emacs in the browser: http://www.ymacs.org/demo/ |
| 00:14 | simard | technomancy: thanks for you help, it's working fine now |
| 00:19 | pdk | ,(cons 1 nil) |
| 00:19 | clojurebot | (1) |
| 00:25 | amalloy | jnymo_: neat, and surprisingly functional, but it seems to be reading all my keystrokes twice |
| 00:25 | jnymo_ | hmm. Works in chrome here |
| 00:25 | amalloy | on keydown and on keyup |
| 00:25 | amalloy | so if i hold a key, it works fine in between |
| 00:26 | amalloy | i think linux sends different key events |
| 00:26 | amalloy | what OS are you using to test? |
| 00:42 | simard | how 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:42 | simard | seem |
| 01:20 | kilo_ | 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:34 | kilo_ | o-kay.maven it is |
| 01:35 | amalloy | kilo_: you don't need to build them at all |
| 01:36 | kilo_ | oh. hi |
| 01:36 | amalloy | just make sure you have lein installed (lein self-install), then lein new my-project-name |
| 01:37 | amalloy | will create a project directory; the project.clj file there will cause maven to download prebuilt copies of clojure and clojure-contrib |
| 01:37 | kilo_ | aha |
| 01:38 | kilo_ | is maven downloaded as part of lein self-install ? |
| 01:38 | amalloy | kilo_: i believe so, but it's been a while |
| 01:38 | amalloy | i 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:40 | kilo_ | 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:40 | amalloy | yep, sounds good to me |
| 01:40 | amalloy | just checked that jar file myself, btw, and it includes maven |
| 01:41 | kilo_ | 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:41 | amalloy | yep |
| 01:41 | kilo_ | neat |
| 01:41 | kilo_ | saved me a download : D |
| 01:41 | amalloy | kilo_: you're just lucky jeopardy ended before you'd gone and installed maven again :) |
| 01:42 | kilo_ | heh heh |
| 01:42 | kilo_ | is this the ken jennings /watson one ? |
| 01:42 | amalloy | yeah |
| 01:42 | kilo_ | keeps popping up on reddit |
| 01:42 | amalloy | i 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:44 | kilo_ | oho. not a reddit reader i presume. the jokes and photoshopped images start on reddit almost immediately after any new event... |
| 01:44 | kilo_ | say, what's watson programmed in ? |
| 01:44 | amalloy | no, not big on those social-media things |
| 01:44 | amalloy | despite working for one of them :P |
| 01:45 | kilo_ | hmm. |
| 01:48 | kilo_ | say, who was winning |
| 01:48 | amalloy | kilo_: what, on jeopardy? |
| 01:49 | kilo_ | yes |
| 01:49 | kilo_ | amalloy: it's all nlp ,right ? |
| 01:50 | amalloy | kilo_: 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:52 | kilo_ | wikipedia says there were instances where watson gave the same/reworded answer as ken jennings, and this was because he(watson) was deaf... |
| 01:52 | kilo_ | anyways , today jeopardy, tomorrow skynet |
| 01:52 | kilo_ | clojure hackers will form the resistance |
| 01:52 | amalloy | yeah. and if you want help with actual clojure, i'm still here :P |
| 01:52 | kilo_ | :) |
| 01:53 | kilo_ | right. am off to read some more. thanks ! |
| 03:09 | khaliG | hm im trying to run the uberjar app and it comes back with "Could not find the main class: foo.core Program will exit." |
| 03:09 | khaliG | lein run works fine though |
| 03:10 | brehaut | you need to set your foo.core namespace to be gen-class'd |
| 03:10 | brehaut | and provide a -main function |
| 03:10 | khaliG | i did both things, since it was generated using lein new |
| 03:10 | khaliG | also, why would lein run work then if it wasnt the case? |
| 03:11 | brehaut | lein run just runs interactively doesnt it? |
| 03:11 | brehaut | i dunno, im out of my depth sorry |
| 03:11 | khaliG | no idea |
| 03:11 | khaliG | im guessing it just calls the main- method |
| 03:11 | brehaut | have you got a :main foo.core in project.clj ? |
| 03:11 | khaliG | yep |
| 03:12 | khaliG | so the stack trace actually starts with |
| 03:12 | brehaut | its -main rather than main- ? |
| 03:12 | khaliG | Caused by: java.lang.ClassNotFoundException: org.joda.time.DateTime |
| 03:12 | khaliG | at java.net.URLClassLoader$1.run(URLClassLoader.java:217) |
| 03:12 | khaliG | lets see |
| 03:12 | khaliG | yea -main |
| 03:13 | brehaut | yeah im completely out of ideas now sorry |
| 03:14 | khaliG | no problem |
| 03:14 | khaliG | stupid lein :/ |
| 03:15 | khaliG | hi KirinDave |
| 03:19 | khaliG | hm interesting, i dont think it packaged up joda-time.jar |
| 03:22 | khaliG | brehaut, yep that was the problem, clj-time uses jodatime but the jodatime jar wasn't being included for some reason |
| 03:22 | brehaut | huh curious |
| 03:53 | jkrueger | does anybody know if more of clojure's core interfaces, like IFn are slated to become protocols in the future ? |
| 05:47 | fliebel | &(map #(Integer/parseInt (str %)) (Integer/toString 23 2)) |
| 05:47 | sexpbot | ⟹ (1 0 1 1 1) |
| 05:49 | fliebel | I'm not yet sure why that is useful, but I like it. ^ |
| 05:50 | ejackson | and here I thought you wanted: (map #(Integer/parseInt (Integer/toString %)) [23 2]) |
| 05:50 | __name__ | &(Integer/toString 23 2) |
| 05:50 | sexpbot | ⟹ "10111" |
| 05:51 | __name__ | &(Integer/toString 23) |
| 05:51 | sexpbot | ⟹ "23" |
| 05:51 | __name__ | Nifty. |
| 05:51 | __name__ | &(Integer/toString 23 25) |
| 05:51 | sexpbot | ⟹ "n" |
| 05:51 | __name__ | &(Integer/toString 999 1000) |
| 05:51 | sexpbot | ⟹ "999" |
| 05:51 | __name__ | okay? |
| 05:52 | fliebel | I 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:56 | fliebel | __name__: I don;t know :( ##(Integer/toString 999 36) |
| 05:56 | sexpbot | ⟹ "rr" |
| 05:56 | __name__ | i blame oracle. |
| 05:57 | __name__ | :_) |
| 05:57 | __name__ | *:-) |
| 05:57 | fliebel | I 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 | _mst | yeah, agreed :) |
| 06:02 | __name__ | I dissaprove of any function that just defaults to some arbitrary behaviour on error case |
| 06:02 | __name__ | *disapprove |
| 06:03 | Chousuke | sometimes that's the only option if you want performance, though. |
| 06:03 | Chousuke | and 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:04 | Chousuke | sure, but you can't always do that. |
| 06:04 | __name__ | How does it make performance better in this case? |
| 06:04 | __name__ | Doyou |
| 06:04 | Chousuke | I 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:09 | fliebel | What is the minimum number of math and logic operators you need to implement all the others? |
| 06:10 | ejackson | xor |
| 06:10 | ejackson | or nand, i think |
| 06:11 | fliebel | ejackson: And what about math? or can you define addition using nand? |
| 06:12 | ejackson | yes, you can do a full adder using only nands |
| 06:12 | mrSpec | fliebel: http://en.wikipedia.org/wiki/Negated_AND_gate |
| 06:12 | mrSpec | http://en.wikipedia.org/wiki/File:NandFullAdder.png |
| 06:12 | mrSpec | fliebel: you can ;) |
| 06:15 | fliebel | what is the carry? |
| 06:17 | fliebel | Ah, I see |
| 06:19 | fliebel | It's like adding 2 large number on paper where you 'remember' numbers... |
| 06:23 | shanmu | I'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:29 | shanmu | is there an example on workflow for tdd with clojure |
| 06:31 | AWizzArd | shanmu: there is a nice video from the author of Midje: https://github.com/marick/Midje/ |
| 06:32 | AWizzArd | shanmu: this is a 40 min video, showing you TDD with Top-Down-Testing: http://www.vimeo.com/19404746 |
| 06:33 | shanmu | AWizzArd: Thanks! this is good... |
| 06:42 | bobo | midje is awesome |
| 06:44 | shanmu | bobo: 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:44 | fliebel | ejackson, 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:44 | sexpbot | ⟹ (1 1 0 0 1 0) |
| 06:45 | ejackson | + |
| 06:45 | bobo | shanmu: 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:45 | fliebel | ejackson: meh, to easy... |
| 06:46 | mrSpec | so convert a number to a list :D |
| 06:46 | mrSpec | it will be harder ;) |
| 06:47 | fliebel | hm, maybe there is something fancy with rem that can get me separate bits :) |
| 07:35 | raek | &((fn [n] (loop [i n, bits ()] (if (zero? i) bits (recur (bit-shift-right i 1) (conj bits (bit-and i 1)))))) 52) |
| 07:35 | sexpbot | ⟹ (1 1 0 1 0 0) |
| 07:40 | AWizzArd | raek: is that a demonstration of something or just a fast try cause you have no repl? |
| 07:43 | raek | nothing in particular |
| 08:23 | raek | how 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:24 | raek | type of collection (vectors or lists) and whether the range is inclusive or exclusive are not important |
| 08:50 | pdk | ,(apply list {} {} nil) |
| 08:50 | clojurebot | ({} {}) |
| 08:50 | AWizzArd | Is there a .zip download for Clojure Contrib that contains all Contrib .jars in one folder? |
| 08:51 | __name__ | ,(list nil nil) |
| 08:51 | clojurebot | (nil nil) |
| 08:51 | __name__ | ,(list 1 nil nil) |
| 08:51 | clojurebot | (1 nil nil) |
| 08:57 | pdk | contrib has always been packaged all together into one jar |
| 08:57 | pdk | or do you want a zip of every release of it |
| 08:59 | AWizzArd | pdk: 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:00 | AWizzArd | This 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:00 | AWizzArd | pdk: I am downloading fresh Contribs from build.clojure.org |
| 09:01 | AWizzArd | stuartsierra: is there a .zip file containing all .jars from Contrib in one plain folder? |
| 09:01 | stuartsierra | not at present |
| 09:01 | stuartsierra | could be done |
| 09:01 | AWizzArd | That would be very helpful |
| 09:01 | stuartsierra | But most of my attention is focused on "new" contrib. |
| 09:01 | AWizzArd | What is "new contrib"? |
| 09:02 | pdk | 1.3 i imagine |
| 09:02 | AWizzArd | I 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:02 | stuartsierra | "new contrib" is github.com/clojure |
| 09:03 | stuartsierra | So far it includes Unify and NRepl |
| 09:03 | AWizzArd | vs. build.clojure.org? |
| 09:03 | stuartsierra | No, build.clojure.org continues. |
| 09:03 | stuartsierra | But github.com/clojure/clojure-contrib is "old" contrib and will be discontinued after 1.3. |
| 09:03 | AWizzArd | Ah, good info. |
| 09:04 | stuartsierra | See http://dev.clojure.org/display/design/Common+Contrib+Build |
| 09:04 | AWizzArd | Most 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:04 | stuartsierra | Maven can do that. But again, "new" contrib takes priority. |
| 09:06 | AWizzArd | Currently 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:06 | AWizzArd | At least I did not find it while clicking through the hudson links. |
| 09:06 | AWizzArd | The only download I can find is something that is several months old, on github I saw it I think. |
| 09:07 | pdk | (doc insert-right) |
| 09:07 | clojurebot | No entiendo |
| 09:07 | AWizzArd | I remember there were some "secret" hudson links to build.clojure.org that can't be reached by visiting the initial domain |
| 09:09 | stuartsierra | There's a maven repository at build.clojure.org/snapshots |
| 09:09 | stuartsierra | it should have the latest builds |
| 09:09 | AWizzArd | ah yes, that was this "secret link" |
| 09:10 | AWizzArd | Though the time stamps are pointing to Nov. 2010 |
| 09:10 | stuartsierra | "old" contrib is not under much active development, that may be the latest |
| 09:10 | @chouser | I'll be pushing some lazy-xml changes to old contrib sometime in the next few days |
| 09:11 | @chouser | I miss lazytest |
| 09:11 | stuartsierra | chouser: Did you get an answer on external depenencies? |
| 09:12 | chouser | stuartsierra: nothing since I said I was going ahead anyway |
| 09:12 | chouser | easier to ask forgivenes than permission, etc. |
| 09:31 | pdk | ,(apply list [] '() []) |
| 09:31 | clojurebot | ([] ()) |
| 09:33 | stuartsierra | chouser: Did your ears burn a minute ago? |
| 09:35 | chouser | stuartsierra: heh, nope. Got some news for me? |
| 09:36 | pdk | ,(concat [] [] []) |
| 09:36 | clojurebot | () |
| 09:36 | pdk | ,(concat [[]] [[]] [[]]) |
| 09:36 | clojurebot | ([] [] []) |
| 09:36 | pdk | ,(cons [] (cons [] [[]])) |
| 09:36 | clojurebot | ([] [] []) |
| 09:36 | chouser | pdk? |
| 09:36 | pdk | chouser! |
| 09:36 | pdk | it's [] night |
| 09:36 | stuartsierra | chouser: We discussed external dependencies and lazy-xml. |
| 09:36 | chouser | stuartsierra: cool. and? |
| 09:38 | stuartsierra2 | ah crud, 'net troubles |
| 09:38 | stuartsierra2 | So, short summary: |
| 09:39 | stuartsierra2 | To introduce a new dependency, we want to know 1) what it is, 2) why it's needed, and 3) what is its license. |
| 09:41 | abedra | stuartsierra2, are you cloning yourself? |
| 09:41 | abedra | i'm starting to become concerned |
| 09:41 | stuartsierra2 | Crappy network cable keeps popping out and Adium clones me. |
| 09:41 | chouser | stuartsierra2: 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:42 | abedra | I for one welcome our new stuartsierra overlords |
| 09:43 | stuartsierra2 | chouser: Rich isn't totally against dependencies, just cautious |
| 09:43 | stuartsierra2 | Personally, if it's an integration point for people who want to use the external library, I think it's a good idea. |
| 10:02 | stuartsierra2 | The BDFL was also adamant that no new development happen on "old" clojure-contrib. |
| 10:07 | AWizzArd | $seen rhickey |
| 10:07 | sexpbot | rhickey was last seen quitting 1 week and 3 days ago. |
| 10:11 | Scriptor | busy guy, I guess |
| 10:11 | fogus_ | You think? |
| 10:13 | stuartsierra2 | He was at Clojure NYC Wednesday night. |
| 10:15 | Scriptor | yep, he stayed for a whiles too |
| 10:18 | chouser | stuartsierra2: wait, no new development? So my bug fixes and updates should be... what? |
| 10:19 | chouser | delayed until someone creates new contrib projects for them? |
| 10:19 | stuartsierra2 | chouser: In a "new" contrib project with its own repo. |
| 10:19 | chouser | ok, but I can't do that |
| 10:20 | chouser | stuartsierra2: and you have better things to do. :-P |
| 10:20 | stuartsierra2 | Right. We need a new process for proposing and vetting "new" contrib libs. |
| 10:22 | chouser | well, I didn't really want to do that work anyway. ...was just trying to be responsible. :-P |
| 10:22 | mprentice | happy friday folks |
| 10:24 | stuartsierra2 | chouser: Thanks. We do appreciate it, honest. :) |
| 10:24 | chouser | :-) |
| 10:46 | jweiss | 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:47 | jweiss | couldn't find any example of defining a new task on top of swank |
| 11:11 | raek | jweiss: would that code run in the project clojure instance or in the leiningen clojure instance |
| 11:11 | raek | ? |
| 11:12 | raek | jweiss: you might find this interesting: http://groups.google.com/group/clojure/browse_thread/thread/4d8a1fc669a5a2df# |
| 11:12 | jweiss | raek: the project clojure instance |
| 11:13 | jweiss | well, actually i am not sure - i assume the swank server is not the same jvm as leiningen |
| 11:13 | jweiss | i would want it running in the swank server |
| 11:15 | raek | the swank server is running in the project clojure instance |
| 11:16 | raek | I 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:17 | raek | I usually just C-c C-k my main namespace and run a main function from the repl |
| 11:18 | jweiss | raek: 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:25 | stuartsierra2 | You could also implement something like that in Emacs directly. |
| 11:27 | raek | jweiss: 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:27 | raek | beware: I haven't tested this |
| 11:27 | raek | if it works, you should be able to run it with "lein myinit" |
| 11:31 | AWizzArd | If 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:33 | TimMc | AWizzArd: Looks right. |
| 11:33 | fogus_ | AWizzard: I think multiple ^:blahs fold |
| 11:34 | fogus_ | Hmmm, maybe not |
| 11:34 | AWizzArd | ,*clojure-version* |
| 11:34 | clojurebot | {:major 1, :minor 2, :incremental 0, :qualifier ""} |
| 11:34 | AWizzArd | $*clojure-version* |
| 11:34 | stuartsierra2 | fogus_: They fold in 1.3 |
| 11:35 | AWizzArd | fogus_: so the idea is that (def ^:private :doc "xyz" foo :bar) could work? |
| 11:35 | AWizzArd | ^:doc |
| 11:35 | fogus_ | stuartsierra2: Whew. Thanks |
| 11:36 | stuartsierra2 | AWizzArd: it only works with bare keywords, not key-value pairs like :doc |
| 11:36 | AWizzArd | oki |
| 11:38 | fogus_ | But this should work no? (def ^:private ^:estimate ^{:doc "foo"} pi 3.14) |
| 11:40 | jweiss | raek: thanks will try that |
| 11:42 | fogus_ | Yes, that does work |
| 11:43 | fogus_ | (meta (var pi)) => {:estimate true, :ns #<Namespace user>, :name pi, :private true, :doc "foo" ...} |
| 11:43 | AWizzArd | Hmm strange, I now get a reflection warning for (Exception. (format "foo")). Is the return type of format no longer type hinted as ^String ? |
| 11:43 | fogus_ | Symbols too |
| 11:44 | fogus_ | (def ^:private ^:estimate ^Float ^{:doc "foo"} pi 3.14) => {.... :tag java.lang.Float} |
| 11:45 | AWizzArd | Hmm, seems that more type hints are no longer working in a very recent 1.3 from build.clojure.org |
| 11:46 | AWizzArd | (when-let [c (class %)] (.isArray c)) ==> doesn't know the type of c |
| 11:53 | fogus_ | AWizzard: Now it does. ;-) (when-let [^Class c (class %)] (.isArray c)) |
| 12:00 | AWizzArd | fogus_: what do you mean by "now"? |
| 12:01 | chouser | ,(meta #'class) |
| 12:01 | clojurebot | {: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:04 | AWizzArd | chouser: 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:06 | dnolen | AWizzArd: seems like a legitimate but to me, return type-hints on fns don't seem to work anymore on 1.3.0-alpha5 |
| 12:06 | dnolen | s/but/bug |
| 12:06 | sexpbot | <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:07 | AWizzArd | Seems so. |
| 12:12 | AWizzArd | Although this is not a general issue. 'str' has a :tag in its meta, so (let [c (str "hi")] (.length c)) works fine. |
| 12:24 | Cozey | can I put defmulti/defmethod to different namespaces? how should I use/require those namespace from one another? |
| 12:27 | stuartsierra | Cozey: (ns a) (defmulti foo …) … (ns b (:use [a :only (foo)]) (defmethod foo …) |
| 12:28 | Cozey | tnaks! |
| 12:28 | Cozey | if I would like to have access to all the methods using (:use a) |
| 12:28 | Cozey | will it work? |
| 12:28 | Cozey | (use a) from other code |
| 13:00 | bhenry | how can i parse a date that may or may not include the time? |
| 13:01 | bhenry | i want null if unparsable and the date object if parsable |
| 13:01 | amalloy | bhenry: isn't that basically what java.text.[Simple]DateFormat does? |
| 13:02 | bhenry | it errors if there is no time. |
| 13:03 | amalloy | did you set it to lenient? |
| 13:04 | bhenry | i was toying with it, but since i don't know java i wasn't quite sure where to put it. |
| 13:06 | amalloy | &(-> (doto (java.text.SimpleDateFormat. "yyyy/MM/dd HH:mm") (.setLenient true)) (.parse "2011/02/18")) |
| 13:06 | sexpbot | java.lang.IllegalArgumentException: Malformed member expression |
| 13:06 | amalloy | ,(-> (doto (java.text.SimpleDateFormat. "yyyy/MM/dd HH:mm") (.setLenient true)) (.parse "2011/02/18")) |
| 13:06 | clojurebot | java.text.ParseException: Unparseable date: "2011/02/18" |
| 13:06 | edoloughlin | I 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:07 | amalloy | ,(-> (doto (java.text.SimpleDateFormat. "yyyy/MM/dd HH:mm") (.setLenient true)) (.parse "2011/02/18 10:01")) |
| 13:07 | clojurebot | #<Date Fri Feb 18 10:01:00 PST 2011> |
| 13:07 | amalloy | hm, guess lenient's not the way to go :P |
| 13:07 | amalloy | edoloughlin: have you looked at clojure.walk? |
| 13:08 | edoloughlin | Nope. Haven't seen that before! |
| 13:08 | amalloy | postwalk is probably good enough for you, but if you need more flexibility you can roll your own with walk |
| 13:09 | edoloughlin | amalloy: Looks interesting. Will check it out. Thanks |
| 13:12 | edoloughlin | amalloy: 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:13 | TimMc | I've written this function: (fn interp [binop vals] (map bi (drop-last 1 vals) (drop 1 vals))) |
| 13:13 | TimMc | and now I'm wondering if there's a name for that in functional programming. |
| 13:13 | stuartsierra | edoloughlin: also consider clojure.zip |
| 13:13 | TimMc | (I wrote it for linear interpolation in a graphics program, BTW.) |
| 13:16 | Chousuke | TimMc: you could probably get the same result with somthing like (for [[a b] (partition 2 1 vals)]] (binop a b)) |
| 13:17 | TimMc | Yup, that should work too. |
| 13:17 | amalloy | edoloughlin: if you want to treat a node differently depending on its parent you probably aren't doing it right :P |
| 13:18 | Chousuke | TimMc: I don't think there's a specific name for it though. |
| 13:18 | amalloy | i've actually used multimethods to do this task pretty cleanly, edoloughlin. let me find you a link |
| 13:20 | edoloughlin | amalloy: 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:21 | amalloy | edoloughlin: https://github.com/ninjudd/cake/blob/master/src/cake/tasks/deps.clj#L85 |
| 13:22 | amalloy | it starts with some unrelated stuff about camelCase conversion, but i pointed the link there so the functions don't look confusing later |
| 13:22 | edoloughlin | amalloy: Thanks! My first foray into multimethods. |
| 13:24 | amalloy | heh. mine too, almost |
| 13:31 | amalloy | edoloughlin: 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:40 | edoloughlin | amalloy: Thanks. Will do. |
| 13:50 | khaliG | ugh, what timezone is clj-time using |
| 13:50 | khaliG | :/ |
| 13:53 | semperos | khaliG: pretty sure it defaults to UTC |
| 13:53 | khaliG | that's what the README says |
| 13:54 | semperos | what are you experiencing? code exmaples? |
| 13:56 | khaliG | semperos, i guess i just need to convert to my timezone to get meaningful numbers out, no problem |
| 13:56 | khaliG | i like how sun's Calendar just uses the local one |
| 13:58 | semperos | khaliG: you can apply a timezone to the datetime itself |
| 13:58 | semperos | or just to the formatter used to print it |
| 13:58 | semperos | the formatters use UTC by default as well |
| 13:58 | semperos | try (with-zone) |
| 13:58 | mabes | did 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:59 | khaliG | i dont want to hardcode a TZ in though, semperos, in case someone else uses the app on a difefrent machine |
| 14:04 | semperos | khaliG: you can use DateTimeZone/getDefault |
| 14:04 | semperos | on my system, for example, it defaults to "America/New_York" |
| 14:05 | semperos | it's the org.joda.time.DateTimeZone class, a static method |
| 14:06 | khaliG | oh yea, (clj-time.core/default-time-zone) |
| 14:07 | semperos | points to khaliG for looking at the clojure source instead of the javadoc :) |
| 14:07 | khaliG | :) |
| 14:11 | khaliG | good night, and thanks for the help semperos |
| 14:14 | semperos | khaliG: no problem |
| 14:43 | anonymouse89 | is there a way to exclude functions from clojure.core? |
| 14:44 | anonymouse89 | i'm using clojure.contrib.generic.arithmetic and there are conflicts with +/-/*/etc |
| 14:45 | brehaut | anonymouse89: i think you are looking for refer-clojure |
| 14:46 | amalloy | yeah, that's the ticket. (ns myns (:refer-clojure :exclude [+ - * /])), i think |
| 14:47 | anonymouse89 | brehaut, amalloy : thanks! |
| 14:47 | amalloy | if you need access to both versions, you can (:require [clojure.core :as c :only [+ - * /]]) (c/- 10 2) |
| 14:47 | bmh | any incanter devs/users around? I'd like to add sampling from the conditional mvn distribution, and would like to chat about interface |
| 14:57 | stuartsierra | meow |
| 15:21 | mattmitchell | is 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:22 | mattmitchell | sorry, i mean convert to keywords? |
| 15:22 | brehaut | (keyword "hello") |
| 15:22 | brehaut | ,(keyword "foo") |
| 15:22 | clojurebot | :foo |
| 15:22 | brehaut | ,(keyword :foo) |
| 15:22 | clojurebot | :foo |
| 15:23 | brehaut | ,(name :foo) |
| 15:23 | clojurebot | "foo" |
| 15:23 | brehaut | ,(keyword (apply (str (map name ["one_" :two "_three"])))) |
| 15:23 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$apply |
| 15:24 | brehaut | its apparently way to early |
| 15:24 | brehaut | (keyword (apply str (map name ["one_" :two "_three"]))) |
| 15:24 | brehaut | ,(keyword (apply str (map name ["one_" :two "_three"]))) |
| 15:24 | clojurebot | :one_two_three |
| 15:26 | brehaut | mattmitchell: i dont think there is a builtin though; apropos only returns (keyword? keyword) for fns with keyword in the name |
| 15:26 | jamesswift | hi 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:26 | mattmitchell | brehaut: great thanks for those examples. kinda what i had going, but yours is more concise. |
| 15:27 | brehaut | jamesswift: have you seen david nolen's tutorials ? |
| 15:27 | jamesswift | maybe not. |
| 15:27 | jamesswift | link? |
| 15:27 | clojurebot | your link is dead |
| 15:27 | brehaut | mattmitchell: sorry about the messy thinking there |
| 15:28 | jamesswift | oh yeah seen those |
| 15:28 | mattmitchell | brehaut: oh no problem. it helps me see how i might figure things out on my own. |
| 15:29 | jamesswift | maybe i misunderstand how it's working. will look over it again. thanks brehaut. |
| 15:30 | brehaut | $findfn ["one_" :two "_three"] :one_two_three |
| 15:30 | sexpbot | [] |
| 15:30 | brehaut | yeah nothing built in |
| 15:31 | brehaut | should have done that first |
| 15:31 | brehaut | jamesswift: a lot of my issues learning enlive was realising that its actually a lot more general and reusable than i i first though |
| 15:33 | mattmitchell | brehaut: what is $findfn ? |
| 15:34 | brehaut | mattmitchell: part of sexpbot; it takes as arguments n forms; 1 to n-1 are arguments and n is the return |
| 15:34 | mattmitchell | brehaut: and then if finds a function that matches the arg sig and return value? |
| 15:34 | brehaut | and it runs through all of clojure.core trying to see if anything returns what you want based on the args you provide |
| 15:34 | brehaut | yeah |
| 15:34 | jamesswift | brehaut: 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:34 | mattmitchell | brehaut: wow, that's awesome |
| 15:34 | brehaut | $findfn 1 2 |
| 15:34 | sexpbot | [clojure.core/unchecked-inc clojure.core/inc] |
| 15:34 | mattmitchell | damn |
| 15:35 | mattmitchell | $findfn "t" "T" |
| 15:35 | sexpbot | [clojure.string/upper-case clojure.string/capitalize clojure.contrib.string/swap-case clojure.contrib.string/upper-case clojure.contrib.string/capitalize] |
| 15:35 | brehaut | if you are going to do a bunch of $findfn'ing you are probably best to private message sexpbot |
| 15:36 | mattmitchell | brehaut: yeah good advice |
| 15:38 | brehaut | jamesswift: have a look at https://github.com/cgrand/enlive/blob/master/src/net/cgrand/enlive_html.clj#L568-571 |
| 15:40 | jamesswift | brehaut: i get lost in the macros :) |
| 15:40 | brehaut | jamesswift: oh and template right below that selection; you can see that a template is just a snippet that is composed with emit* |
| 15:41 | brehaut | jamesswift: ok lets look at the important parts |
| 15:41 | brehaut | everything 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:42 | brehaut | ~ just interpolates it verbatim, ~@ takes the seq and splices it into the parent seq |
| 15:42 | clojurebot | amac: 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:43 | brehaut | eg if foo is [1 2 3] then `(bar ~foo) becomes (bar [1 2 3]) and `(bar ~@foo) becomes (bar 1 2 3) |
| 15:43 | brehaut | jamesswift: following? |
| 15:44 | brehaut | jamesswift: 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:46 | jamesswift | brehaut: thanks :) |
| 15:46 | jamesswift | brehaut: I have an example here that works now |
| 15:46 | brehaut | jamesswift: cool :) |
| 15:47 | jamesswift | brehaut: eg (enlive/transform (fetch-url url) [:td] (enlive/remove-attr :colspan)) |
| 15:47 | jamesswift | if someone would write a small enlive cookbook i'd buy it ;) |
| 15:47 | brehaut | cgrand needs to make a 1.0.0 non-snapshot version first ;) |
| 15:48 | jamesswift | heh heh true. it's good enough imho. |
| 15:48 | brehaut | its great! |
| 15:48 | brehaut | but -SNAPSHOT doesnt scream 'release' ;) |
| 15:48 | jamesswift | in fact i think it's great. best templating mechanism i've even seen |
| 15:48 | jamesswift | true |
| 15:49 | bobo | it also doesnt look that great that last commit was almost a year ago. Not that it realy needs any commits |
| 15:50 | brehaut | huh, it depends on clojure 1.1.0 or greater too |
| 15:50 | brehaut | still, its fantastic and i wish i had it for my day job |
| 15:56 | jamesswift | yeah, if i could ask for one change it would be to change the dependancy to 1.2 |
| 15:57 | brehaut | really? |
| 15:57 | brehaut | its [1.1.0,) |
| 15:57 | brehaut | so if you are using 1.2 it should usethat |
| 15:58 | stuartsierra | You can override dependencies in Lein or Maven. |
| 15:58 | jamesswift | thanks for the tip stuart |
| 16:10 | amalloy | brehaut: how do you specify whether you want version v, or version >= v? |
| 16:10 | brehaut | in lein? |
| 16:10 | @rhickey | cemerick: nice - https://github.com/cemerick/bandalore |
| 16:11 | cemerick | rhickey: thanks :-) |
| 16:11 | cemerick | rhickey: 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 | @rhickey | cemerick: I presume deleting-consumer doesn't on exception? |
| 16:12 | cemerick | rhickey: right |
| 16:14 | brehaut | amalloy: http://maven.apache.org/plugins/maven-enforcer-plugin/rules/versionRanges.html |
| 16:14 | cemerick | My 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 | @rhickey | cemerick: any help for idempotency? (not a word) |
| 16:16 | amalloy | brehaut: oh neat. i didn't realize you could do that |
| 16:17 | cemerick | rhickey: Idempotence of what, the fn you pass into deleting-consumer? |
| 16:17 | brehaut | amalloy: building on maven has its advantages :) |
| 16:17 | @rhickey | I guess that's hard to library-ize |
| 16:17 | @rhickey | cemerick: yeah, duplicate msg handling |
| 16:17 | cemerick | rhickey: 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:18 | cemerick | That's enough of a 10% case that people can call delete on their own, I guess. |
| 16:18 | @rhickey | cemerick: yes, but also at least once semantics when that's not the case |
| 16:19 | cemerick | oh, I see |
| 16:19 | @rhickey | that's the trickiest bit of SQS, imo |
| 16:19 | @rhickey | understandable, but tricky |
| 16:20 | cemerick | Right; 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:20 | cemerick | Without understanding the use case, I wouldn't want to go tossing helpers around. |
| 16:21 | @rhickey | understood, it can always be an application problem (or not), and can't do much in a lib except in narrow circumstances (single consumer) |
| 16:22 | cemerick | It 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 | @rhickey | but you could make a version of deleting consumer that tracked recently-handled messages |
| 16:23 | cemerick | only within a single VM though |
| 16:23 | @rhickey | yes, single consumer |
| 16:23 | cemerick | *shrug* |
| 16:23 | @rhickey | not important, just wondering |
| 16:23 | cemerick | Sure. :-) |
| 16:24 | cemerick | rhickey: it's the "recently" part of that description that gets tricky |
| 16:25 | @rhickey | cemerick: could just be a knob |
| 16:25 | cemerick | horizon of N msgs? |
| 16:25 | @rhickey | I'm not advocating for it, I understand SQS and the tradeoffs |
| 16:26 | amalloy | would 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:26 | sexpbot | ⟹ (14 14) |
| 16:26 | @rhickey | cemerick: yes, N, or time |
| 16:26 | cemerick | rhickey: I'm open to most things at the moment. Have only been using SQS for ~2 days at this point. :-) |
| 16:26 | amalloy | i've seen #(%1 %2) written too many times :P |
| 16:26 | @rhickey | cemerick: well, looks nice, I'll be sure to try it next time I'm fiddling with SQS |
| 16:27 | cemerick | thanks |
| 16:27 | @rhickey | SQS rocks (as does most of AWS) |
| 16:27 | cemerick | indeed |
| 16:28 | cemerick | Beanstalk really blew it open for me. |
| 16:28 | @rhickey | yeah |
| 16:28 | @rhickey | great for Clojure |
| 16:28 | opqdonut | invoke would be nice |
| 16:28 | cemerick | finally, finally, a vertically-integrated option :-D |
| 16:30 | jamesswift | brehaut: 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:39 | jcromartie | is there a way to make macros do checking on their arguments so that they fake a "compile time" check? |
| 16:40 | jcromartie | I know that question might not make much sense... |
| 16:40 | cemerick | jcromartie: any conditional that would result in an error at compile time in a macro is a compile time check. ;-) |
| 16:41 | jcromartie | like, 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:42 | jcromartie | never mind, I'm ahead of myself |
| 16:44 | cemerick | jcromartie: it's a reasonable thought, but not a simple thing in practice. There be dragons. |
| 16:44 | jcromartie | I saw a really cool presentation from Naughty Dog (video game devs, Crash Bandicoot, Uncharted series) about their new Scheme scripting engine |
| 16:44 | jcromartie | they basically expose a mini-language to their designers |
| 16:45 | jcromartie | it made me think that a similar approach might be good for certain kinds of apps where you want to let people write scripts |
| 16:45 | jcromartie | but then, if you're on the JVM you might as well just use Rhino and let them write JS |
| 16:50 | ev4l | jcromartie: 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:51 | jcromartie | State Scripting |
| 16:51 | jcromartie | in Uncharted 2 |
| 16:51 | jcromartie | it was from GDC09 |
| 16:52 | ev4l | hmm |
| 16:57 | rata_ | hi |
| 17:07 | jcromartie | if ev4l here's the PDF http://dl.dropbox.com/u/5844871/gdc09-statescripting-uncharted2.pdf |
| 17:08 | ev4l | jcromartie: thx! lemme see |
| 17:09 | jcromartie | it's cool to see that a major part of one of the greatest games ever runs on Lisp |
| 17:10 | ev4l | jcromartie: Naughy Dog have a very interesting lisp history. Jak and Dexter series was coded in a dialect of lisp Naughy dog Developed |
| 17:12 | jcromartie | they were using Lisp from the earliest games |
| 17:12 | jcromartie | Crash Bandicoot |
| 17:12 | jcromartie | there was a hiatus when they were taken under Sony's wing to become 2nd-party devs |
| 17:12 | jcromartie | but they are back with Scheme in Uncharted and Uncharted 2 |
| 17:14 | ev4l | jcromartie: yup, sony greenspuned lots of their stuff :) |
| 17:14 | ev4l | jcromartie: that's cool to see! |
| 17:15 | ev4l | jcromartie: (i saw another presentation of them. this one is new to me) |
| 17:15 | jcromartie | what does "greenspunned" mean? |
| 17:19 | ev4l | jcromartie: http://en.wikipedia.org/wiki/Greenspun's_Tenth_Rule |
| 17:19 | ev4l | jcromartie: When they were acquired by sony, most of their lisp based tools were dropped |
| 17:20 | jcromartie | hah I see |
| 17:21 | jamesswift | another 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:32 | khaliG | clj-time is really nice!! |
| 17:41 | semperos | jamesswift: what do you mean by "text value" of an attribute? |
| 17:42 | semperos | you have an example of what you're trying to select on? |
| 17:44 | semperos | there are the functions attr=, attr-has, attr-starts, attr-ends, attr-contains |
| 17:44 | semperos | which you can use to check against attribute values |
| 17:44 | semperos | in your selectors |
| 17:44 | semperos | it's outline here: http://enlive.cgrand.net/syntax.html |
| 17:46 | jamesswift | semperos: i really need to stop drinking beer while coding. thanks! |
| 17:51 | semperos | jamesswift: :) no problem |
| 18:20 | ev4l | anyone here experienced the following runtime error: "Could not locate clojure/java/io__init.class or clojure/java/io.clj on classpath" ? |
| 18:20 | ev4l | i'm attempting to bootstrap a compojure app , and this error pops out when i try to start the ring server |
| 18:21 | ev4l | i think it's a problem with my clojure installation/version |
| 18:23 | raek | ev4l: sounds like you have a clojure version prior to 1.2, but that your code needs 1.2. |
| 18:23 | ev4l | raek: good! |
| 18:24 | ev4l | raek: my current version is 1.1 |
| 18:24 | ev4l | i'll update it, thx :) |
| 18:24 | raek | are you managing dependencies and the classpath manually? if so, why? |
| 18:24 | ev4l | raek: nope, i'm using leiningen |
| 18:25 | raek | ah, and you had 1.1. declared in your project.clj file? |
| 18:26 | ev4l | raek: yup! both clojure and clojure contrib @ 1.1 version |
| 18:27 | raek | good. :-) |
| 18:27 | ev4l | i'll fix it now |
| 18:56 | Guest8150 | ww |
| 19:19 | ev4l | raek: thx! it worked. Shiny jetty server up |
| 19:56 | markskilbeck | Is this correct for projecteuler #20 (http://projecteuler.net/index.php?section=problems&id=20)? |
| 19:56 | markskilbeck | ,(reduce * (range 1 100)) |
| 19:56 | clojurebot | 933262154439441526816992388562667004907159682643816214685929638952175999932299156089414639761565182862536979208272237582511852109168640000000000000000000000 |
| 19:59 | markskilbeck | Oh, I see. There's more to it. |
| 20:12 | Guest37502 | can someone please tell me why i see nothing print when i run this last line in the repl? http://pastebin.com/0Mvdv31s |
| 20:28 | DespiteItAll | if you're using an IDE connected to a separate REPL, that probably prints to the console that's actually running the REPL. t |
| 20:28 | Guest37502 | doh! i saw that just now before returning here |
| 20:29 | DespiteItAll | you can use binding to fix it |
| 20:29 | Guest37502 | that's exactly what is happening |
| 20:29 | Guest37502 | thank you DespiteItAll |
| 20:29 | DespiteItAll | you're welcome |
| 21:46 | rata_ | $source not-any? |
| 21:46 | sexpbot | not-any? is http://is.gd/y0oEz0 |
| 21:48 | pdk | none? is a more concise name |
| 22:08 | amalloy | pdk: and less explicit |
| 22:08 | amalloy | none? could be interpreted to mean empty?, whereas not-any? seems clearer to me |
| 22:53 | rata_ | does anyone see how to make this code run faster? https://gist.github.com/834802 |
| 22:55 | scottj | profile it and see what is slow? |
| 22:57 | rata_ | 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:59 | rata_ | scottj: the profiler (visualvm) says that c.l.Cons.first takes most of the time, but it's just ~13% |
| 23:02 | rata_ | (I've just edited the gist to write a sample use case) |
| 23:06 | amalloy | rata_: your weird logic about [_ _ p m] looks a lot like (drop 2 (...)) |
| 23:06 | DespiteItAll | combinations can eat up cycles quick |
| 23:06 | amalloy | yeah, and distinct is gonna be pretty slow too |
| 23:06 | amalloy | in fact most of ningun-apellido's let-block looks like (frequencies as) |
| 23:08 | rata_ | amalloy: that seq can have more than 4 elements, so it's not the same as (drop 2 ...) |
| 23:09 | amalloy | (take 2 (drop 2)), then |
| 23:10 | rata_ | but m could be an empty string, not just nil, and I want to filter that out too |
| 23:12 | amalloy | (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:12 | rata_ | is if slow? |
| 23:13 | amalloy | no, 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:13 | amalloy | &(filter seq (take 2 (drop 2 ["useless" "garbage" "apellido" ""]))) |
| 23:13 | sexpbot | ⟹ ("apellido") |
| 23:20 | rata_ | 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:20 | rata_ | $source frequencies |
| 23:20 | sexpbot | frequencies is http://is.gd/oSsjjJ |
| 23:21 | amalloy | &(distinct (filter seq (take 2 (drop 2 ["marco" "explorer" "polo" "polo"])))) |
| 23:21 | sexpbot | ⟹ ("polo") |
| 23:22 | rata_ | that's probably better than what I have |
| 23:22 | rata_ | thanks =) |
| 23:32 | amalloy | rata_: conteo could be written as (count (filter (partial apply pred tol) as)) |
| 23:32 | amalloy | or i see, i guess you're trying to get a ratio |
| 23:32 | rata_ | yes |
| 23:33 | rata_ | you mean conteo in prob-n or ningun-...? |
| 23:33 | amalloy | i meant prob-n |
| 23:33 | rata_ | ok |
| 23:34 | rata_ | 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:40 | amalloy | hm. it sounds like this could be made faster by doing some math ahead of time, then |
| 23:40 | amalloy | like, with K people, you already know that the number of unique subsets of size N will be (/ (! K) (! N) (! (- K N))) |
| 23:40 | amalloy | so you don't need to construct them all and then count them |
| 23:41 | rata_ | yeah, that's right |
| 23:42 | rata_ | but I still have to make the pairs with c/combinations |
| 23:45 | amalloy | likewise 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:45 | amalloy | rata_: ^ |
| 23:46 | rata_ | so instead of counting up should I count down? |
| 23:47 | rata_ | amalloy: ^ |
| 23:53 | amalloy | rata_: what? why? |
| 23:53 | amalloy | rata_: you can count the number of times each name appears |
| 23:54 | amalloy | say there are four guys whose last name is de Seville or whatever |
| 23:55 | amalloy | you 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:56 | rata_ | 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:56 | rata_ | amalloy: ^ |
| 23:58 | rata_ | amalloy: I know almost nothing about combinatorics |
| 23:58 | amalloy | rata_: that's up to you, i guess |
| 23:58 | rata_ | and hate not knowing about that |
| 23:58 | rata_ | it seems so useful sometimes |
| 23:59 | amalloy | yeah, i never went past number theory and discrete math, but counting was my favorite part of the non-calculus stuff |