2009-07-05
| 00:00 | jackdempsey | :-) |
| 00:14 | duncanm | Chouser: oh? |
| 00:15 | Chouser | repl-utils/javadoc |
| 04:41 | hiredman | clojurebot: lisp machine? |
| 04:41 | clojurebot | lisp is the red pill |
| 04:42 | hiredman | clojurebot: lisp machine is <reply>my lisp machine is the jvm |
| 04:42 | clojurebot | 'Sea, mhuise. |
| 05:11 | ChrisPS | join /#emacs |
| 05:38 | ChrisPS | This statement in emacs: (require 'clojure-auto) |
| 05:38 | ChrisPS | in my clojure-mode.el there is no such thing |
| 05:38 | ChrisPS | what does it referr to? |
| 05:39 | ChrisPS | it should be a (defun clojure-auto) right? |
| 05:43 | hoeck | ChrisPS: this is an artifact from earlier versions of clojure-mode |
| 05:44 | ChrisPS | hoeck: Oh, thanks - |
| 05:44 | ChrisPS | So where to find current info? |
| 05:44 | hoeck | for setting up swank-clojure? |
| 05:44 | ChrisPS | yes |
| 05:44 | hoeck | which guide are you following? |
| 05:45 | ChrisPS | I tried Bill Celementson |
| 05:45 | hoeck | I haven't changed my config for a year or so, except removing (require 'clojure-auto) :) |
| 05:48 | hoeck | ChrisPS: clojure-mode has M-x clojure-install |
| 05:49 | ChrisPS | I know |
| 05:49 | hoeck | and it worked? |
| 05:49 | ChrisPS | nope |
| 05:49 | ChrisPS | investigating it now |
| 05:50 | lenst | don't like clojure-install, makes to many assumptions |
| 05:51 | ChrisPS | when I (setq load-path "...") do I just set it to the containing folder, or do I point at the .el file directly |
| 05:52 | lenst | load-path should be a list of folders |
| 05:52 | ChrisPS | ok |
| 05:56 | ChrisPS | what is the command in the .emacs file that actually loads clojure? |
| 05:57 | ChrisPS | what is the paste? |
| 05:57 | ChrisPS | listpaste |
| 05:59 | hoeck | lisppaste8: URL |
| 05:59 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 05:59 | hoeck | ChrisPS: ^^ |
| 05:59 | ChrisPS | thanks :-/ |
| 06:01 | lisppaste8 | ChrisPS pasted "My current .emacs" at http://paste.lisp.org/display/83042 |
| 06:01 | ChrisPS | the paths are a-ok |
| 06:02 | hoeck | ChrisPS: do you want to use slime or only inferior-lisp? |
| 06:02 | ChrisPS | slime please |
| 06:02 | lenst | lol, scrap that and start over |
| 06:03 | ChrisPS | I have Aquaemacs and Carbonemacs installed, in addition to that emacs-22.3.1 |
| 06:04 | lenst | (add-to-list 'load-path "/Users/chris/lisp/clj/clojure-mode") not setq |
| 06:05 | ChrisPS | lenst: ok |
| 06:07 | ChrisPS | when I look in my modes, there is no clojure |
| 06:07 | ChrisPS | M-x |
| 06:07 | ChrisPS | clo.. |
| 06:07 | ChrisPS | so now, I guess, I need to actually start that fun |
| 06:07 | ChrisPS | function |
| 06:07 | lenst | read the comments in the beginning of clojure-mode.el |
| 06:08 | ChrisPS | ok |
| 06:09 | lenst | the README for swank-clojure wasn't very helpful for me |
| 06:10 | lenst | maybe adding (require 'swank-clojure-autoload) to .emacs is enough |
| 06:11 | ChrisPS | but since swank-clojure-autoload is a different file than swank-clojure |
| 06:11 | ChrisPS | I need to (add-to-list ... ) as well? |
| 06:11 | ChrisPS | (just need to understand the basics) |
| 06:11 | lisppaste8 | hoeck annotated #83042 "swank-clojure" at http://paste.lisp.org/display/83042#1 |
| 06:12 | ChrisPS | right |
| 06:12 | hoeck | just add the paths containing the *.el files |
| 06:15 | ChrisPS | oh man, progress |
| 06:15 | ChrisPS | :-) |
| 06:17 | ChrisPS | at least the major and minor modes are ok |
| 06:17 | ChrisPS | (Clojure Slime) |
| 06:17 | lenst | I wish emacs package writers wouldn't require you to put require or load in .emacs. It adds to the startup time of emacs. |
| 06:17 | ChrisPS | if I C-x e (list 1 2 3 4) I get a Not Connected |
| 06:19 | Hun | lenst: that's what autoload is for |
| 06:19 | ChrisPS | ah, M-x slime |
| 06:19 | hoeck | ChrisPS: if you start slime with M-x slime, you should see a *inferior-lisp* buffer with a starting clojure |
| 06:19 | ChrisPS | yes |
| 06:19 | ChrisPS | trye |
| 06:19 | ChrisPS | true |
| 06:20 | ChrisPS | And now, after I started slime, the magic appears |
| 06:21 | ChrisPS | thanks a lot!!! |
| 06:27 | lenst | hoeck: do you use slime-repl? |
| 06:31 | hoeck | lenst: yes, but in case of setting up swank-clojure, the inferior-lisp prints messages in case of not finding clojure.jar |
| 07:16 | mauritslamers | question: when I use map, how can I use the same parameter twice? I have a list with lists and want to map the first list onto the rest |
| 07:16 | mauritslamers | but in some way it doesn't work as I expected |
| 07:18 | lisppaste8 | mauritslamers pasted "route-detection" at http://paste.lisp.org/display/83046 |
| 07:18 | hiredman | mauritslamers: sounds like you want first and rest |
| 07:19 | hiredman | (map (first some-list) (rest some-list)) |
| 07:19 | mauritslamers | that is what I do, but it does not work as I expect |
| 07:19 | mauritslamers | the source material is a list of lists of maps |
| 07:19 | hiredman | what do you expect it to do? |
| 07:19 | hiredman | and what is the first item in the list? |
| 07:20 | mauritslamers | a list of maps |
| 07:20 | hiredman | a list is not a fn and it does not implement IFn |
| 07:20 | hiredman | so you cannot map a list over anything |
| 07:21 | mauritslamers | did you look at the paste above? |
| 07:21 | hiredman | yeah |
| 07:21 | hiredman | seems like a lot to read at 4am |
| 07:21 | mauritslamers | in Europe here, 1.22 pm :) |
| 07:22 | mauritslamers | I'll add the source and expected outcome to the paste |
| 07:22 | hiredman | :( |
| 07:23 | ChrisPS | hehe |
| 07:23 | hiredman | that is just more to read |
| 07:25 | Lau_of_DK | hiredman: Whats been going on with clojurebot ? |
| 07:26 | hiredman | Lau_of_DK: I was camping on the wrong side of a group of mountains from my internet connection |
| 07:26 | hiredman | whoops |
| 07:26 | lisppaste8 | mauritslamers annotated #83046 "route-detection" at http://paste.lisp.org/display/83046#1 |
| 07:27 | mauritslamers | hiredman: sorry about that, but it explains much better what my problem is than I can in the channel |
| 07:29 | hiredman | mauritslamers: it is important to keep in mind that a seq of a map is a seq of key,value pairs |
| 07:29 | hiredman | ,(seq {:a 1 :b 2}) |
| 07:29 | clojurebot | ([:a 1] [:b 2]) |
| 07:30 | hiredman | and map calls seq |
| 07:30 | hiredman | well, MapEntry |
| 07:30 | ChrisPS | it is really cool to have the test as part of the metadata for a function |
| 07:31 | mauritslamers | That explains a lot ... |
| 07:31 | hiredman | and clojure's MapEntrys display as two element vectors |
| 07:31 | hiredman | ,(class (first (seq {:a 1 :b 2}))) |
| 07:31 | clojurebot | clojure.lang.MapEntry |
| 07:32 | mauritslamers | any idea how to concat the mapped item to the result of every map call? |
| 07:33 | hiredman | concat into what? |
| 07:33 | hiredman | well |
| 07:33 | opqdonut | something like (map #(vector (f x) x) seq) ? |
| 07:33 | hiredman | what do you mean |
| 07:33 | hiredman | mapped item is what? |
| 07:34 | hiredman | a list? a list cannot be mapped |
| 07:34 | mauritslamers | map calls the func with every item in the list |
| 07:34 | clojurebot | map is *LAZY* |
| 07:34 | hiredman | if you want to merge maps |
| 07:34 | hiredman | use merge-with |
| 07:34 | mauritslamers | thanks, I'll look into that |
| 07:34 | hiredman | mauritslamers: that is like the very definition of map |
| 07:35 | hiredman | if you want something different, you either need to use something different, or alter your algorithm |
| 07:35 | mauritslamers | map itself cannot map a list, but the function I call can |
| 07:36 | hiredman | so you have (map #(some-logic % (first some-list)) (rest some-list)) |
| 07:36 | mauritslamers | It is a route detection algorithm, creating a route using the :from and :to map keys in the map |
| 07:38 | mauritslamers | it seems merge-with is what I want, thanks! |
| 12:17 | Chouser | maps can be called with key and not-found args, just like the 'get' fn. But sets only take a single arg. |
| 12:49 | krumholt_ | hi i have a vector and i need to create pairs like: [1 2 3 4] => [1 2] [2 3][3 4][4 1] |
| 12:49 | Chousuke | partition |
| 12:49 | Chousuke | and possibly cycle |
| 12:53 | krumholt_ | partition looks good thanks |
| 13:49 | krumholt__ | how can i swap to values of a vector (??? [1 2 3 4] 1 2) => [1 3 2 4] |
| 13:54 | Chouser | (defn swap-key [coll a b] (let [av (coll a), bv (coll b)] (-> coll (assoc a bv) (assoc b av)))) |
| 13:55 | Chouser | works on maps too: (swap-key {:a 1, :b 2, :c 3, :d 4} :a :d) ==> {:a 4, :b 2, :c 3, :d 1} |
| 13:56 | Chouser | I guess you probably only need to store off one of the values, not both. *shrug* |
| 13:59 | krumholt__ | ok thanks again |
| 14:00 | durka42 | clojurebot: welcome back! |
| 14:00 | clojurebot | It's greek to me. |
| 14:00 | durka42 | anyone know if ztellman hangs out here? |
| 14:36 | durka42 | is there an easy way to convert a garden-variety map into a sorted-map? |
| 14:36 | durka42 | ,(reduce conj (sorted-map) {:a 1, :b 2}) |
| 14:36 | clojurebot | {:a 1, :b 2} |
| 14:36 | Chouser | that's it |
| 14:36 | Chouser | or 'into' |
| 14:38 | durka42 | i suppose into is reduce-conj written without using reduce |
| 14:38 | Chouser | yup |
| 14:39 | Chouser | makes what you're intending to do more explicit for human readers |
| 14:52 | Chousuke | into could also potentially get its own interface someday and become more efficient than "reduce conj" :) |
| 14:52 | Chousuke | but whether that will actually happen remains to be seen. |
| 16:24 | AWizzArd | Is there some kind of unification and pattern matching system available for Clojure or Java? I have some collection of data and want to get some elements of it, and I can describe a pattern of properties of those elements. |
| 16:29 | kencausey | AWizzArd: Do you mean like regular expressions? There is syntax for that based on Java support. |
| 16:30 | kencausey | Or something more general perhaps? |
| 16:30 | kencausey | I suspect the second on further reading |
| 16:30 | replaca_2 | AWizzArd: the closest I know of is datalog, which doesn't sound like exactly what you're looking for |
| 16:32 | AWizzArd | Not regexps, but something more like datalog. |
| 16:34 | AWizzArd | For example I could say: all elements in the vector V are hashmaps with the key :type and the value :person. And if there is a person Jim followed by one or more persons who are not Tania and then one person Tania follows, in that case I want to have the persons between them. |
| 16:34 | AWizzArd | Something like that. |
| 16:38 | replaca | AWizzArd: yeah, I've been thinking about the clojure flavor of that too, but I don't think anyone's written that yet |
| 16:38 | AWizzArd | Maybe Jessrules can do it? |
| 16:38 | replaca | AWizzArd: who's that? |
| 16:39 | AWizzArd | http://www.jessrules.com/ |
| 16:39 | AWizzArd | it even comes with a Lisp syntax |
| 16:39 | AWizzArd | I discovered it several months ago, but the homepage was down in the last weeks for some reason |
| 16:39 | AWizzArd | today it seems to be up again |
| 16:39 | replaca | oh, yeah. news to me! |
| 16:40 | replaca | brb |
| 16:40 | AWizzArd | may be something like Common Lisps „Lisa” |
| 16:43 | hiredman | you might be able to do something like that with fnparse |
| 16:44 | AWizzArd | hiredman: is that in contrib? |
| 16:45 | danlarkin | fnparse is for parsing strings |
| 16:45 | hiredman | ~fnparse |
| 16:45 | clojurebot | I don't understand. |
| 16:45 | hiredman | danlarkin: you can define your own combinators |
| 16:45 | Chousuke | actually, I think fnparse can parse pretty much anything :P |
| 16:45 | hiredman | ^- |
| 16:45 | Chousuke | strings are just what you usually need to parse. |
| 16:46 | hiredman | so if you approach the problem as a string of tokens |
| 16:46 | AWizzArd | I will have a look. Maybe it is in core but new or it sits somewhere in contrib. |
| 16:46 | Chousuke | but I guess it'd work for data structures too |
| 16:46 | hiredman | AWizzArd: nah, its on github |
| 16:46 | hiredman | clojurebot: parse? |
| 16:46 | clojurebot | parser is http://github.com/joshua-choi/fnparse/tree/master |
| 16:46 | AWizzArd | thx |
| 16:46 | danlarkin | Hm... interesting, yeah I guess you're right |
| 16:46 | danlarkin | wow! that's like 1000x more useful now |
| 16:46 | hiredman | :) |
| 16:48 | AWizzArd | I will have a look and see if I can provide my own combinators to search through vectors of tokens |
| 16:55 | danlarkin | I haven't looked at fnparse recently, but would you just write a lexer to help your combinators? |
| 16:57 | hiredman | help? |
| 17:20 | meredydd | Hey - how is one supposed to combine routes in Compojure? |
| 17:20 | meredydd | The source is confusing - the comments suggest a Ring function should return :next if it can't match anything |
| 17:20 | meredydd | but in practice, it seems they return empty 200 responses |
| 17:21 | meredydd | and the (routes) function appears to be expecting that they return nil if they don't match |
| 17:55 | drewr | Apparently there's a practical difference between (take 20 (iterate inc 1)) and (range 1 21). |
| 17:56 | drewr | Wait, I think I just realized why. |
| 18:11 | lisppaste8 | drewr pasted "take/iterate vs range" at http://paste.lisp.org/display/83073 |
| 18:12 | drewr | What's the difference between the two? |
| 18:12 | drewr | Even if new LazySeqs are created by each take, wouldn't they be GCed? |
| 18:14 | ChrisPS | Question: Do I need to add the locations clojure and clojure-contrib to my classpath? |
| 18:15 | AWizzArd | ChrisPS: yes |
| 18:15 | AWizzArd | you don't *need* contrib |
| 18:15 | hiredman | ~def iterate |
| 18:15 | ChrisPS | great |
| 18:15 | AWizzArd | but you also don't *need* to program ;-) |
| 18:15 | hiredman | :( |
| 18:19 | ChrisPS | I don't need contrib? why not? |
| 18:20 | ChrisPS | how can I read the classpath from within clojure |
| 18:20 | ChrisPS | from the repl |
| 18:34 | eevar | ChrisPS: (System/getProperties) |
| 18:35 | ChrisPS | hmm |
| 18:38 | hiredman | ~def iterate |
| 18:39 | ChrisPS | I don't understand why a (ns whatever (:require clojure.contrib.str-utils)) give an error message |
| 18:39 | ChrisPS | Could not locate clojure/contrib/str_utils__init.class or clojure/contrib/str_utils.clj on classpath: |
| 18:40 | hiredman | is contrib in you classpath? |
| 18:41 | ChrisPS | my classpath say: /Users/wave/lisp/clj/clojure:/Users/wave/lisp/clj/clojure-contrib |
| 18:41 | ChrisPS | so the clojure-contrib is, but what about contrib?? |
| 18:43 | hiredman | by contrib I mean clojure-contrib |
| 18:43 | hiredman | what is in /Users/wave/lisp/clj/clojure-contrib |
| 18:43 | ChrisPS | then yes it is |
| 18:43 | hiredman | how are you starting clojure? |
| 18:44 | ChrisPS | via slime |
| 18:44 | ChrisPS | emacs |
| 18:44 | hiredman | how are you setting the classpath? |
| 18:44 | ChrisPS | in .bash_profile |
| 18:44 | hiredman | ok |
| 18:44 | hiredman | that will not work |
| 18:44 | ChrisPS | good |
| 18:44 | hiredman | you need to set it some how via slime |
| 18:44 | ChrisPS | ok |
| 18:45 | hiredman | but I don't use slime or emacs for that matter |
| 18:45 | hiredman | basically java ignores CLASSPATH if you use the -cp flag |
| 18:45 | ChrisPS | so if just add it to the string in .emacs |
| 18:45 | ChrisPS | it would work |
| 18:48 | ChrisPS | still, when I do a |
| 18:48 | ChrisPS | (doc clojure.contrib.str-utils/str-join) |
| 18:48 | clojurebot | "/;nil; " |
| 18:48 | hiredman | clojurebot: stop being so broken |
| 18:48 | clojurebot | we can't stop here! this is bat country! |
| 18:48 | ChrisPS | hehe |
| 18:49 | ChrisPS | I get an exception |
| 18:49 | hiredman | so does (require 'clojure.contrib.str-utils) work? |
| 18:50 | ChrisPS | no |
| 18:50 | ChrisPS | same msg |
| 18:50 | hiredman | (System/getProperty "java.class.path") |
| 18:50 | ChrisPS | java.io.FileNotFoundException |
| 18:51 | ChrisPS | "/Users/wave/lisp/clj/clojure/clojure.jar:/Users/wave/lisp/clj/swank-clojure/:/Users/wave/lisp/clj\ |
| 18:51 | ChrisPS | ah fuck, lispaste! |
| 18:51 | ChrisPS | where are thou |
| 18:51 | ChrisPS | @ |
| 18:51 | hiredman | lisppaste8: url? |
| 18:51 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 18:51 | ChrisPS | hehe, thanks |
| 18:51 | ChrisPS | I am getting old |
| 18:52 | lisppaste8 | chrisPS pasted "classpath issue" at http://paste.lisp.org/display/83075 |
| 18:52 | hiredman | do you not have a contrib jar? |
| 18:53 | ChrisPS | I do |
| 18:53 | hiredman | some pieces of contrib rely on being AOT compiled (which happens during the jar building process) |
| 18:53 | hiredman | ChrisPS: the jarfile needs to be on the classpath |
| 18:53 | ChrisPS | I just ant'ed the contrib root |
| 18:53 | hiredman | not the path to the jar file |
| 18:54 | ChrisPS | the jarfile needs to be included the path-statement? |
| 18:54 | hiredman | so it should be /something/something/clojure-contrib.jar |
| 18:54 | ChrisPS | ah |
| 18:54 | ChrisPS | will try now |
| 18:54 | hiredman | there are ways to do it like you are trying to do |
| 18:54 | hiredman | clojurebot: jar dir |
| 18:54 | clojurebot | with java6(jdk1.6) CLASSPATH can contain a "*" so /jar/dir/* will suck in all the jars in the /jar/dir directory, this also works with swank-clojure-extra-classpaths in emacs, alternatively you can use this shell snippet: find .jars/ -type f -name \*.jar -print0|xargs -0|sed "s/ /:/g" |
| 18:55 | ChrisPS | but it will only suck in the dirs immediately below, so it's not recursive? |
| 18:55 | hiredman | eh? which? |
| 18:56 | hiredman | the java classpath does not suck jars out of directories |
| 18:56 | ChrisPS | say /lisp/clj/* |
| 18:56 | ChrisPS | ok ok |
| 18:56 | hiredman | that I dunno |
| 18:56 | ChrisPS | nevermind |
| 18:56 | hiredman | it is kind of weird, because it doesn't use the shell expension |
| 18:56 | hiredman | expansion |
| 18:59 | ChrisPS | it works!! |
| 19:00 | ChrisPS | I am a happy man, thanks hiredman for your assistance!! |
| 22:49 | duncanm | is this a common question: why couldn't clojure automatically convert Fns into some interface if that interface has only one method? |
| 22:50 | duncanm | i'm watching this video on JRuby, and it looks like JRuby can allow Ruby blocks to be used as Swing ActionListeners |
| 22:50 | clojurebot | this is not a bug |
| 22:52 | slashus2 | duncanm: Looks like clojurebot knows what you are talking about. |
| 22:52 | duncanm | heh |
| 22:52 | hiredman | dunno |
| 22:52 | hiredman | I have also fetl pangs of jealousy when watching jruby do that |
| 22:53 | duncanm | hiredman: right? |
| 22:54 | hiredman | (defmacro fn->al [fun] (proxy [ActionListener] [] (actionPerformed [event] (fun event)))) |
| 22:54 | duncanm | why write it as a macro? |
| 22:55 | hiredman | I guess it should be a function |
| 22:55 | hiredman | I wrote it a while ago, but I can't seem to find it |
| 22:57 | hiredman | I started on a macro to generate single method proxies a couple of times |
| 22:58 | gstamp | Towards the bottom of this page: http://www.dearm.co.uk/cgan/ there is a function based one |
| 23:01 | hiredman | something like (adapt ActionListener some-function) |
| 23:01 | duncanm | clojure-contrib has some swing-utils |
| 23:03 | gstamp | Here's a minor nit thing that's been annoying me. When I work with vectors in clojure I often need to run them through functions like map and reduce but the problem there is that they convert the vector to a seq. Is there another way to handle this other than just rewrapping using a (vec ...) call? |
| 23:04 | duncanm | gstamp: are you saying that it turns into a seq because it's printed using ()s ? |
| 23:05 | hiredman | duncanm: it is turned into a seq |
| 23:05 | duncanm | oh |
| 23:05 | hiredman | map, filter, et al call seq on their arguments |
| 23:06 | hiredman | (def vector-map (comp vec map)) |
| 23:06 | hiredman | ~def vec |
| 23:09 | gstamp | Interesting that there is an array-map but not a vector-map |
| 23:10 | gstamp | Love that you can compose together functions so easy though. :-) |
| 23:29 | duncanm | hiredman: so i asked in the #JRuby channel |
| 23:29 | duncanm | hiredman: ruby blocks can turn into any Java interface |
| 23:30 | duncanm | if the interface has 2 methods, the same block gets used for both (kinda surprising) |
| 23:30 | hiredman | yeah |
| 23:31 | hiredman | I wish I had deleted this |
| 23:31 | hiredman | er |
| 23:31 | hiredman | hadn't |
| 23:31 | duncanm | you hacked clojure to support that? |
| 23:40 | duncanm | hiredman? |
| 23:40 | duncanm | oh, a macro |
| 23:41 | duncanm | it'd be more interesting if the language supported it, no? |
| 23:42 | arbscht_ | duncanm: not very much. this is why being a lisp is nice :) |
| 23:43 | duncanm | arbscht_: you prefer to explicitly write out a proxy form than having the compiler do it for you? |
| 23:44 | arbscht_ | no, but extending the language with a macro is almost as good |
| 23:44 | grrrt | hey, I couldn't help overhear your conversation :) |
| 23:44 | grrrt | I like clojure / lisp because there's no magic |
| 23:45 | grrrt | any magic you want you add yourself (like a fn or macro that wraps around a proxy) |
| 23:45 | duncanm | even if there were a macro like (adapt #(...) someJavaInterface), you'd still have to remember the name of the interface, that's why i think it's more interesting that the language supports it |
| 23:45 | duncanm | grrrt: well, it's already 'magically' supporting Runnable and Callable |
| 23:45 | grrrt | well that's fairly straightforward, you know what your're getting |