2010-02-21
| 00:03 | Crowbar7 | :/ |
| 00:10 | hamza | ,(:trigger {:trigger (println "trigger")}) |
| 00:10 | clojurebot | trigger |
| 00:10 | hamza | something like this? |
| 01:07 | zenoli | Needs a lambda to keep the println from being eval'd when it's read, I think. |
| 01:07 | zenoli | ,((:trigger {:trigger #(println "trigger")})) |
| 01:07 | clojurebot | trigger |
| 06:54 | patrkris | have the STM implementation of clojure changed considerably since 1.0? I'm reading http://java.ociweb.com/mark/stm/article.html |
| 06:54 | patrkris | *has |
| 07:09 | AWizzArd | patrkris: no big changes |
| 07:09 | patrkris | AWizzArd: Yeah, just found out I can do a git diff 1.0..1.1.0 LockingTransaction.java :) |
| 07:29 | Raynes | "<dom96> case insensitivity in a programming language is good" |
| 07:36 | AWizzArd | “Good” is a relative word and as such expresses an opinion, not an objective fact. |
| 07:37 | Raynes | In this particular situation, he was declaring that case insensitivity is a good thing. |
| 07:37 | Raynes | Nothing to do with opinions. |
| 07:37 | Raynes | But I can see how that could be otherwise interpreted, as you've just shown. |
| 07:42 | defn | Morning gents |
| 07:59 | Raynes | Oops. I left the black tea pyramid in the cup for nearly 20 minutes. I'm not sure if I should drink it now. |
| 08:01 | noidi | hehe |
| 08:01 | noidi | that probably depends on whether you brew it for the taste or the caffeine :) |
| 08:02 | Raynes | Well, I brew for both. |
| 08:02 | Raynes | The problem is that I'm worried that if I drink this, my eyes will turn black and I'll be walking on the celing. |
| 08:02 | Raynes | ceiling* |
| 08:05 | noidi | some tea you have there :) |
| 08:08 | AWizzArd | can't you mix it with some hot water? |
| 08:08 | Raynes | I suppose, but I'm not sure how much would balance this out. |
| 08:08 | Raynes | I suppose drinking it wont kill me. |
| 08:09 | Raynes | Besides that, it's too delicious to not drink, and half of it is already gone. |
| 08:49 | rrc7cz-hm | how do you have a defmethod which matches on multiple dispatch values? something like (defmethod x [:ul :ol])? |
| 08:51 | AWizzArd | Have your defmulti outputting those. |
| 08:52 | rrc7cz-hm | AWizzArd: that could get ugly fast with many values, but if that's the only way |
| 08:52 | somnium | rrc7cz-hm: multimethods use isa?, so you can use derive to setup relationships |
| 08:53 | rrc7cz-hm | I guess I could also make a macro which expands the defmethod into two, one for each |
| 08:53 | rrc7cz-hm | somnium: that's a great idea |
| 08:54 | somnium | rrc7cz-hm: our BDFL has many great ideas :) |
| 08:56 | rrc7cz-hm | lol yeah |
| 09:01 | dermatthias | anyone ever tried to call an agent update function via (send) in an agent update function? will this work? |
| 09:07 | AWizzArd | Hallo dermatthias, yes, this works. |
| 09:07 | rrc7cz-hm | somnium: how can you use derive when (namesace :ul) is nil? I tried (derive :ul ::list) but it's having a problem without the namespace. I tried qualifying ::list with my namespace, like foo.bar/::list, but that's throwing an invalid token error |
| 09:08 | AWizzArd | Mr. Hickey himself did such a thing in has „Ants” example. |
| 09:09 | dermatthias | ah, ok. thanks. planing something similar right now, an "Invasive weed optimization" algorithm. I finally have to look into that Ants example... |
| 09:15 | somnium | ,(doc derive) |
| 09:15 | clojurebot | "([tag parent] [h tag parent]); Establishes a parent/child relationship between parent and tag. Parent must be a namespace-qualified symbol or keyword and child can be either a namespace-qualified symbol or keyword or a class. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to, and modifies, the global hierarchy." |
| 09:16 | AWizzArd | dermatthias: weed? :) |
| 09:17 | somnium | ,(derive ::ul ::list) |
| 09:17 | clojurebot | nil |
| 09:19 | rrc7cz-hm | somnium: if :: signals a local keyword, then it uses the current ns? but then why doesn't the global : work? |
| 09:19 | somnium | ,(isa? (keyword (str (ns-name *ns*)) :ul ::list) |
| 09:19 | clojurebot | EOF while reading |
| 09:20 | somnium | ,(isa? (keyword (str (ns-name *ns*)) "ul") ::list) |
| 09:20 | clojurebot | true |
| 09:21 | somnium | there may be a better way to make ns-qualified keywords, but that should work in the dispatcher in any case |
| 09:21 | somnium | ,(namespace :foo) |
| 09:21 | clojurebot | nil |
| 09:21 | somnium | ,(namespace ::foo) |
| 09:21 | clojurebot | "sandbox" |
| 09:23 | dermatthias | AWizzArd: yeah, weed :) it's inspired by the distribution of weed and its seeds. everybody asks the same question here..."weed? ;)" |
| 09:24 | AWizzArd | gut :) |
| 09:30 | rrc7cz-hm | why would *ns* return the correct ns of my file when I do something like (prn *ns*) at the top level, but when I put it inside my multimethod dispatch fn it returns clojure.core? |
| 09:30 | opqdonut | macro weirdness? |
| 09:31 | rrc7cz-hm | opqdonut: but wouldn't the macro expand the defmulti in my namespace? |
| 09:32 | opqdonut | hmm, it also might be that your dispatch fn is called from within clojure.core |
| 09:32 | opqdonut | I can't remember by which rules *ns* gets set |
| 09:32 | somnium | ah *ns* is getting rebound, you can use the name of your ns "my-ns" |
| 09:33 | opqdonut | yeah |
| 09:33 | rrc7cz-hm | somnium: yeah, I just was wondering why + it sucks to duplicate the ns |
| 09:34 | krumholt | hi is the author of penumbra in this channel? |
| 09:35 | rrc7cz-hm | but it _does_ work, and I'm quite happy about that |
| 09:37 | somnium | (def this-ns (ns-name *ns*)) works at top-level, *ns* must be getting rebound during macroexpansion |
| 09:40 | rrc7cz-hm | somnium: that works nicely |
| 09:41 | rrc7cz-hm | somnium: i just grab it right after the ns def and use that in the macro |
| 10:24 | vy | Why does Clojure complains that "More than one matching method found: aset" for (doseq [[i j] (keys adjs)] (aset next (int (coord-to-idx n i j)) -1)) expression? |
| 10:27 | AWizzArd | Is coord-to-idx a multimethod? |
| 10:27 | vy | (defn- coord-to-idx [n i j] (+ (* i n) j)) |
| 10:28 | Chousuke | maybe you need to cast the -1 too |
| 10:29 | vy | Yup, that does the trick. Interesting. Should I submit a bug report? |
| 10:29 | Chousuke | nah. |
| 10:29 | Chousuke | I think it's not a bug, just a java interop gotcha |
| 10:30 | clojurebot | hmm… sounds like your out of heap space |
| 10:30 | Chousuke | sometimes you need additional type hints so that the compiler can resolve the correct method. |
| 10:30 | Chousuke | clojurebot: botsnack |
| 10:30 | clojurebot | thanks; that was delicious. (nom nom nom) |
| 10:34 | vy | Chousuke: But there are two alternatives for aset: One with 4 args, and one with 5 args. Why do I need a casting for -1? |
| 10:34 | wlr | clojurebot: it's "you're" not "your"! |
| 10:34 | clojurebot | The bird, bird, bird, the bird is the word. |
| 10:35 | wlr | :) |
| 10:35 | Chousuke | vy: The error is about a java method, not the function |
| 10:42 | jcromartie | boy, we sure are into this stuff to be sitting here on a Sunday morning (I'm making a lot of time-zone-related assumptions here) |
| 11:41 | vy | Is there an easier of turning a [[k0 v0] [k0 v0] ...] into a {k0 v0, k1 v1, ...} map than using (reduce #(let [[k v] %2] (assoc %1 k v)) {} [[k0 v0] [k0 v0] ...])? |
| 11:41 | jcromartie | yes |
| 11:42 | jcromartie | ,(into {} [[1 2] [3 4]]) |
| 11:42 | clojurebot | {1 2, 3 4} |
| 11:42 | vy | jcromartie: Thanks! |
| 12:11 | Licenser | odd thing: |
| 12:11 | Licenser | ,(partition 4 '(1 2 3)) |
| 12:11 | clojurebot | () |
| 12:11 | Licenser | bug or feature? |
| 12:11 | Licenser | and sorry :( hi everyone! |
| 12:13 | Licenser | okay feature |
| 12:23 | vy | How can I place more than one expression in a cond entry? IIRC, there should be a "do" in Clojure. Where it went? |
| 12:24 | vy | Oops! There it is. |
| 13:06 | vy | ,(pos? 0) |
| 13:06 | clojurebot | false |
| 13:06 | vy | Shouldn't 0 be positive? |
| 13:08 | vy | Nevermind. |
| 13:20 | Licenser | hmm quiet tonight :) |
| 13:21 | Licenser | a map that is a ref, and has ref's as keys, will a dosync on the map fail when only the key refs are modified? |
| 13:22 | noidi | a map can't be a ref, but a ref can point to a map |
| 13:23 | Licenser | that was what I mean, like (ref {1 (ref 1) 2 (ref 1)}) when I inc 1 and 2 in threads will there ever be transaction redos? |
| 13:24 | Licenser | problem is I don't can think of a simple way to test it, I think it should not fail since the 'root' ref isn't changed but I'm not entirely sure |
| 13:24 | noidi | there shouldn't be |
| 13:24 | noidi | because you're not modifying the map itself |
| 13:24 | Licenser | *nods* kk |
| 13:26 | noidi | let's call (ref 1) a, and (ref 2) b: the map's value is constantly {1 a, 2 b}, even if you modify the value a and b point to |
| 13:27 | Licenser | that is what I was hoping for :) |
| 13:27 | noidi | at least that's the way I think things work :) |
| 13:27 | Crowbar7 | So, I wrote this ircbot in clojure and he threads. However what would be the best way to have a module based system that loads the modules which contain the trigger and then return what is sent to the connection? |
| 13:27 | Crowbar7 | threads on every instance of a trigger to be specific. |
| 13:30 | Licenser | noidi: so do I but I'm not sure since it still takes 50% longer then just using a single ref pointing to the map |
| 13:35 | Licenser | woha good greif |
| 13:36 | Licenser | non paralell: 11389msec; paralell: 28244msec |
| 13:36 | Licenser | I am doing something hooribly wrong I fear |
| 13:49 | opqdonut | can leiningen be easily used to compile a mixed java-and-clojure project? |
| 13:55 | Crowbar7 | Hmm The clojurebot code is pretty awesome looking |
| 14:04 | tomoj | opqdonut: http://github.com/antoniogarrote/lein-javac |
| 14:04 | tomoj | haven't tried it |
| 14:04 | tomoj | might help |
| 14:10 | ordnungswidrig | hi all |
| 14:10 | vy | FYI: An optimized version of Floyd-Warshall's APSP (All-Pairs-Shortest-Paths) algorithm @ http://paste.lisp.org/display/95370 |
| 14:53 | Crowbar7 | ,(* 1 2 3 4) |
| 14:53 | clojurebot | 24 |
| 15:02 | AWizzArd | ordnungswidrig: good evening |
| 15:08 | ordnungswidrig | helau! |
| 15:11 | ordnungswidrig | does anybody know of some clojure-lucene glue code? I found mailindex on github which I took as a "template" |
| 15:24 | redwyrm | ,((fn [x] (+ x 3) 2) |
| 15:24 | clojurebot | EOF while reading |
| 15:24 | redwyrm | ,((fn [x] (+ x 3)) 2) |
| 15:24 | clojurebot | 5 |
| 15:24 | redwyrm | neat |
| 15:26 | Borkdude | Hello, Ive got some problems getting my classpath right in Clojure Box, somebody wants to help? |
| 15:26 | ordnungswidrig | ,(#(+ % 3) 2) |
| 15:26 | clojurebot | 5 |
| 15:26 | ordnungswidrig | ,((partial + 3) 2) |
| 15:26 | clojurebot | 5 |
| 15:28 | Borkdude | Hello, Ive got some problems getting my classpath right in Clojure Box, somebody wants to help? |
| 15:29 | AWizzArd | Hallo Borkdude. Can you tell a bit more? |
| 15:30 | Borkdude | Yes, I've tried both setf and add-to-list to the variable swank-clojure-classpath in my .emacs |
| 15:31 | Borkdude | the clj file i want to have in the classpath is on c:/temp/examples |
| 15:31 | raek | what is the recommended way of signaling errors in pre-deftype clojure? throwing an instance of an exception class written in ordinary java? |
| 15:32 | AWizzArd | Borkdude: in my .emacs file I have something like (setq swank-clojure-extra-classpaths '("/Users/ath/hg/src/" "/Users/ath/hg/build/" "/Users/ath/clojure/clojure.jar" "/Users/ath/clojure/swank-clojure/")) I have more entries, but those paths go into my CP. |
| 15:33 | Borkdude | hmm let me try |
| 15:35 | AWizzArd | wb ulfster, alles klar? :) |
| 15:36 | ulfster | yeah, everything fine. tortured myself playing soccer |
| 15:40 | Borkdude | AWizzArd: I have this in my .emacs now: |
| 15:40 | Borkdude | (setq swank-clojure-extra-classpaths (list "c:/temp")) |
| 15:40 | Borkdude | and my file, snake.clj is in c:/temp/examples/ |
| 15:41 | Borkdude | but when I do (use 'examples.snake) it gives an error about the file not being found |
| 15:42 | AWizzArd | and what is the NS of snake.clj? |
| 15:42 | AWizzArd | (ns examples.snake ...) ? |
| 15:45 | Borkdude | (ns examples.snake |
| 15:45 | Borkdude | (:import (java.awt Color Dimension) |
| 15:45 | Borkdude | (javax.swing JPanel JFrame Timer JOptionPane) |
| 15:45 | Borkdude | (java.awt.event ActionListener KeyListener)) |
| 15:45 | Borkdude | (:use clojure.contrib.import-static |
| 15:45 | Borkdude | [clojure.contrib.seq-utils :only (includes?)])) |
| 15:46 | ordnungswidrig1 | re |
| 15:55 | Borkdude | AWizzArd, any idea? |
| 16:00 | AWizzArd | Hmm, that looks okay |
| 16:00 | ordnungswidrig1 | perhaps it's the slash? Have you tried "c:\\temp" for the classpath? |
| 16:00 | AWizzArd | Try (System/getProperty "java.class.path") |
| 16:01 | AWizzArd | the slash should not be a problem, I do the same |
| 16:01 | AWizzArd | Emacs and Java understand both, the slashes and backslashes |
| 16:03 | Borkdude | AWizzArd: "c:/Program Files/Clojure Box/swank-clojure/src;c:/Program Files/Clojure Box/lib/clojure-contrib.jar;c:/Program Files/Clojure Box/lib/clojure.jar" |
| 16:04 | Borkdude | it seems c:/temp is not there |
| 16:08 | AWizzArd | your path seems to be missing |
| 16:10 | Borkdude | yes, so clojure box is not picking up this: (setq swank-clojure-extra-classpaths (list "c:/temp")) |
| 16:17 | dabd | is there a generic way of maintaining the original collection type when applying a function that works on seqs? For example. if I call (distinct [1 2 3 1]) I get back a lazyseq but I would to get back a vector |
| 16:23 | chouser | dabd: (into (empty c) (distinct c)) ; usually works well |
| 16:24 | AWizzArd | dabd: nothing that is already prepared, but you can write a function that takes distinct and its arg, and then converts that back |
| 16:24 | chouser | one exception is lists, since (into () s) will reverse the order of s |
| 16:33 | dabd | the seq abstraction is nice but sometimes they are hard to work with. For example if I am working with a vector and conjoining elements to the end it, if I apply a seq function it will return a lazy seq and conj will start adding elements to the start. |
| 16:36 | miltondsilva | hi |
| 16:38 | miltondsilva | when using slime... I often get Unable to resolve symbol... switching the order of the def and calls to def seem to work... but if someone could give me a explanation... and a more convenient way to fix this I would be grateful. |
| 16:41 | chouser | you must define a Var before you use it. Is that what you're talking about? |
| 16:43 | chouser | dabd: I haven't found that to be much of a problem. Vectors and lazy seqs are rather different things, and I usually I find the operations I want to apply group natrually so that conversion back and forth is relatively rare. |
| 16:43 | miltondsilva | yes... but.. I have def it... |
| 16:44 | miltondsilva | example... (defn b [] (a)) below this (defn a[] ) |
| 16:44 | miltondsilva | it says |
| 16:44 | dabd | chouser: say you concat two vectors you need to do something like (into [] (concat v1 v2)) otherwise you will get a lazyseq which has diffrent semantics for conj |
| 16:44 | miltondsilva | Unable to resolve symbol |
| 16:45 | miltondsilva | if I do (defn a[] ) then (defn b [] (a)) it works... |
| 16:46 | opqdonut | miltondsilva: as said, you need to define a symbol before you use it :) |
| 16:47 | miltondsilva | but... can't I get around this? isn't there some way to load the file in such a way that all things are loaded and only then is the top level expression evaluated? |
| 16:48 | opqdonut | you can use the declare form to switch the order of definitions: (declare a) (defn b [] (a)) (defn a []) |
| 16:48 | opqdonut | so for example for mutually recursive functions you must use that |
| 16:48 | miltondsilva | ok thanks :) |
| 16:48 | opqdonut | you see, there is no difference between definitions and other top-level expressions |
| 16:49 | opqdonut | i seem to recall that most other lisps throw the error only when you try to use (call in this case) a nondefined symbol |
| 16:51 | miltondsilva | ok... I was thinking the structure of the code was a bit less restrictive (like java) but it's not a big deal |
| 16:53 | miltondsilva | (java is very restrictive I know.. but it is allowed to use things before declaring it) |
| 16:53 | miltondsilva | again, thanks :) |
| 16:59 | chouser | dabd: or just (into v1 v2) |
| 17:02 | solussd | ,(str "welcome" "atrerus") |
| 17:02 | clojurebot | "welcomeatrerus" |
| 17:15 | atrerus | question for those using emacs/slime... how do you configure the classpath for general libs like clojure-contrib or ant? |
| 17:15 | dabd | ,(distinct #{1 2 1}) |
| 17:15 | clojurebot | java.lang.UnsupportedOperationException: nth not supported on this type: PersistentHashSet |
| 17:16 | dabd | Isn't the distinct function supposed to work on collections? It returns an exception if applied to a Set |
| 17:20 | dnolen | atrerus: lein helps, managing the classpath manually is a serious pain. |
| 17:20 | dnolen | atrerus: you can use 'lein swank' and then connect to a repl with the classpath set |
| 17:21 | atrerus | ok... is lein something specific to Clojure or is that a more general thing for emacs? |
| 17:21 | chouser | dabd: interesting. I think that's a bug, but I |
| 17:21 | chouser | but I'm not sure where. |
| 17:22 | dabd | I was looking at the implementation of distinct but I can't see it either |
| 17:22 | chouser | distinct relies on destructuring |
| 17:23 | atrerus | dnolen: what's a good page to read up on lein? |
| 17:23 | chouser | trying to destructure a set or map with a vector throws an exception because vector destructuring uses 'nth', and maps and sets don't support that. |
| 17:23 | dnolen | atrerus: check github |
| 17:24 | chouser | so I'm not sure, but my guess would be that distinct out to have another (or differently-placed) 'seq' call. |
| 17:24 | chouser | s/out/ought/ |
| 17:24 | atrerus | dnolen: thanks! I'll look into that. |
| 17:24 | dnolen | atrerus: leiningen |
| 17:26 | dabd | chouse: but calling distinct on a set makes as much sense as calling it on an integer right? |
| 17:26 | dabd | so ,(distinct 2) |
| 17:26 | dabd | ,(distinct 2) |
| 17:26 | clojurebot | java.lang.UnsupportedOperationException: nth not supported on this type: Integer |
| 17:26 | dabd | so (distinct 2) equally fails |
| 17:27 | chouser | hm, I suppose you're right. |
| 17:27 | dabd | ditto to maps |
| 17:28 | dabd | but it would be more elegant if it returned the set as is instead of throwing an exception |
| 17:32 | chouser | hm. ditto for maps? |
| 17:35 | dabd | how do you remove distinct entries from a map if it doesn't have duplicate keys? |
| 17:35 | dabd | based on values? |
| 17:35 | dabd | that makes sense |
| 18:14 | ankou | hi, this question is somewhat slime related but since many clojuredeveloper seam to use slime... how can I manage projects? I know how to load a file but usually I want to load the main file of the project, how should I manage my project with slime? |
| 18:21 | atrerus | ankou: I just asked the same and was referred to http://github.com/technomancy/leiningen/tree/56683c38627a9fd69c968d27292444e252f9ecfd/lein-swank#readme |
| 18:22 | atrerus | ankou: reading up on it now |
| 18:22 | Licenser | is there a lein dep für c.c 1.1? |
| 18:23 | atrerus | Licenser: that page I just linked says they have an RC |
| 18:23 | Licenser | heh |
| 18:25 | dnolen | atrerus: ankou: you just need to install leiningen 1.1.0. Then you run "lein self install". Then when you define your project add "lein-swank" as a :dev-dependency. then "lein deps" and "lein swank". You can then run M-x slime-connect and just use the defaults |
| 18:25 | dnolen | http://github.com/swannodette/clj-nehe/blob/master/project.clj, to get an idea of what your project.clj should look like |
| 18:25 | ankou | okay I'll have a look at it. And another question, when there is an error how do I get the line number from slime? with C-C C-K it says: Unknown Location: Error: ... whereas enclojure actually gives me an exception with a concrete line number |
| 18:26 | atrerus | ankou: dunno, slime generally gives me a line number for a failed compile... |
| 18:28 | Licenser | ah 1.1.0 of cc isn't known to lein but 1.2.0 |
| 18:28 | ankou | the error is as simple as (defn main [] (map 'x 'y)) (main) since I just wanted to try how slime handels errors but it says unknown location |
| 18:28 | dnolen | ankou: C-c C-l I think is what you want if you want errors with line numbers. |
| 18:30 | dnolen | ankou: take that back, C-c C-k is right and that gives me line numbers. |
| 18:31 | ankou | C-c C-l gives me everything except for the line number. It looks exactly like the exception message of enclojure but without the line number(enclojure says Don't know how to create ISeq from: Symbol (defpackage.clj:2) followed by the backtrace whereas slime just misses the (file:n) |
| 18:48 | Licenser | could it be that the clojure contrib api isn't up to datE? |
| 18:52 | dnolen | Licenser: did you have a previous install of lein? Are you specifying clojure-contrib 1.1.0 in your deps? |
| 18:52 | Licenser | I sepcifue c.c 1.1.0 in my deps |
| 18:52 | Licenser | but things like c.c.io are still c.c.d-c |
| 18:53 | dnolen | ah, yeah I don't know if what's up on Clojars is up to date. |
| 18:53 | Licenser | well if it says c.c 1.1.0 it should be 1.1.0 it's no snapshot or anything |
| 18:53 | miltondsilva | is it possible to access protected fields of class when using a proxy? |
| 18:53 | Licenser | if it's not 1.1.0 as in the API docs it should not be named 1.1.0 :P but get a different version number |
| 18:56 | dnolen | Licenser: you're right I can't import c.c.io, I'm using the latest versni of lein. Might want to mention this on the Leiningen ML |
| 18:57 | Licenser | hrm odd odd odd |
| 19:20 | the-kenny | What's the best way to do (f [:foo :bar] [42 23]) -> [:foo 42 :bar 23] (I don't want a map) |
| 19:22 | the-kenny | ah, nevermind. interleave is the function |
| 19:53 | lygaret | hey, y'all, hoping someone could help me with a problem, which I'm pretty sure is me not grokking the immutablity thing |
| 19:53 | lygaret | I've got a struct (defstruct window :event_handlers), which needs to hold a list of event handlers in the :event_handlers key |
| 19:54 | lygaret | my goal is to be able to do something like (on-event my_window :event_handlers (fn [e] ...)) and have that function be added to the list of handlers. |
| 19:55 | lygaret | I'm just not sure how to go about doing that - I know I can't use assoc directly, unless I am going to put the new list back in the struct, but that's something else I'm not allowed to change. |
| 20:11 | mudge | wow, clojure |
| 20:11 | mudge | my programming interest raptures |
| 20:12 | mudge | and i sing and dance in functional unmutable persistent data structures |
| 20:13 | mudge | sorry, I couldn't help myself |
| 21:17 | jcromartie | mudge: nice |
| 21:18 | mudge | jcromartie: thanks |
| 21:19 | jcromartie | my code is waxing existential |
| 21:19 | jcromartie | (def *god* (agent nil)) |
| 21:19 | jcromartie | It doesn't help that I'm listening to Tears for Fears at the same time. |
| 21:19 | jcromartie | I need a drink or something |
| 21:20 | mudge | yea |
| 21:20 | jcromartie | and of course, nil becomes the world on the first send :) |
| 21:20 | mudge | hmm? |
| 21:21 | jcromartie | oh the "world" of a game |
| 21:21 | jcromartie | simulation etc |
| 21:21 | mudge | oh okay |
| 21:21 | JayM | mudge: i agree. i didn't know parentheses could be so beautiful |
| 21:22 | scottbot | what's the idiomatic way to schedule a function to be executed in a background thread every n seconds? |
| 21:23 | jcromartie | scottbot: I'm working on this right now, actually |
| 21:23 | mudge | JayM: yea, i don't know what other people's big deal is about parentheses. They're curved and they balance symetrically, qualities of beauty. |
| 21:24 | jcromartie | scottbot: I'm using an agent |
| 21:25 | jcromartie | scottbot: basically, set up your agent, then send a fn that sleeps before sending itself |
| 21:27 | JayM | mudge: well put |
| 21:31 | scottbot | jcromartie: that's what I'm currently using, with a nil agent with send-off and Thread/sleep |
| 21:31 | jcromartie | yup |
| 21:31 | jcromartie | although make sure to understand the differences between send/send-off |
| 21:31 | jcromartie | send generally keeps the thread count down |
| 21:32 | scottbot | jcromartie: upon reflection, send is what I want |
| 21:33 | scottbot | jcromartie: thanks! |
| 21:37 | kwertii | Trying to install 1.1.0 tag from source. Ant works fine, but mvn install gives "[WARNING] JAR will be empty - no content was marked for inclusion!" and then just copies a tiny 1k jar file to the maven repo. what am I missing? |
| 21:41 | jcromartie | scottbot: are you using an anonymous/let-bound fn for your periodic fuction? |
| 21:42 | jcromartie | I'm not sure how to do it without a named var |
| 21:44 | jcromartie | or the Y combinator... :-/ |
| 21:47 | _mst | jcromartie: sounds a bit like you might want letfn to allow your function to refer to itself? |
| 21:48 | jcromartie | letfn yes |
| 21:48 | jcromartie | thanks! |
| 21:48 | jcromartie | another idiom question: how about a way to modify a value at a "key path" in a map? |
| 21:48 | jcromartie | like {:foo {:bar {:bat 5}}} |
| 21:48 | jcromartie | I want to make that 5 a 6 |
| 21:48 | jcromartie | (for example) |
| 21:50 | _mst | ,(assoc-in {:foo {:bar {:bat 5}}} [:foo :bar :bat] 6) |
| 21:50 | clojurebot | {:foo {:bar {:bat 6}}} |
| 21:50 | jcromartie | ah, nice |
| 21:50 | _mst | or there's update-in if you want to provide a function to do the modification (like inc, for example) |
| 21:50 | jcromartie | that should be in the cheatsheet :) |
| 21:50 | jcromartie | beautiful |
| 21:52 | jcromartie | that cuts down on so much code |
| 21:54 | jcromartie | there could be an alter-in too |
| 21:56 | _mst | you can compose it all together with something like (alter myref update-in [:foo :bar :bat] inc) |
| 21:56 | kwertii | update, in case anyone was wondering: there is apparently no standard way to install a self-built Clojure jar into maven. (per http://www.mail-archive.com/clojure@googlegroups.com/msg21784.html) |
| 21:56 | jcromartie | ah yes, that works nicely |
| 22:14 | BrandonW | it definitely seems like clojure core was very well thought out |
| 22:14 | BrandonW | i've already encountered a couple times when i implemented something, then went back to optimize it and instead looked at clojure core more closely |
| 22:14 | BrandonW | and found that it has a function that does the same thing, except more efficiently and concisely |
| 22:14 | BrandonW | and i still haven't used clojure all that much |
| 22:24 | defn | hello |
| 22:37 | KirinDave_ | Does anyone know of any projects that have taken compojure and added on for a less bare-bones experience? |
| 22:39 | qbg | Yes, I have defeated the transient vector with my (functional-like) mutable array deftype. |
| 22:46 | defn | KirinDave: Hmmm -- What do you mean by "less bare-bones"? As I've understood it Compojure was kind of beastly and was going to be split off into a couple different projects... |
| 22:49 | cemerick | ,(with-meta (agent nil) {}) |
| 22:49 | clojurebot | java.lang.ClassCastException: clojure.lang.Agent cannot be cast to clojure.lang.IObj |
| 22:49 | cemerick | hrm |
| 22:49 | cemerick | ,(supers clojure.lang.Agent) |
| 22:49 | clojurebot | #{clojure.lang.AReference clojure.lang.ARef clojure.lang.IDeref clojure.lang.IReference clojure.lang.IMeta java.lang.Object clojure.lang.IRef} |
| 22:53 | Crowbar7 | So, I compiled the snapshots of clojure and clojure works fine, but I can't access the clojure-contrib libs at all. |
| 22:54 | Crowbar7 | It always tells me nil when I try to require. |
| 22:54 | Crowbar7 | any help? |
| 22:54 | Crowbar7 | It shows up in my classpath |
| 22:57 | dakrone | Crowbar7: nil is the proper response when you do (require 'clojure.contrib.foo) |
| 22:58 | dakrone | so if you did (require 'clojure.contrib.seq-utils), the REPL will return nil |
| 22:58 | dakrone | ,(require 'clojure.contrib.seq-utils) |
| 22:58 | clojurebot | nil |
| 23:02 | dakrone | and then you can reference it using the namespace |
| 23:02 | dakrone | ,(clojure.contrib.seq-utils/flatten [1 2 3 [4 5]]) |
| 23:02 | clojurebot | (1 2 3 4 5) |
| 23:05 | Crowbar7 | ok |
| 23:05 | Crowbar7 | thankyou |
| 23:05 | defn | Anyone have any suggestions for libraries that would allow me to automate form submission/surfing etc. |
| 23:05 | dakrone | Crowbar7: you're welcome :) |
| 23:06 | Crowbar7 | dakrone: I'm really new to clojure and so I'm getting my feet wet with a homebrew irc bot. |
| 23:06 | Crowbar7 | thank you for the help |
| 23:08 | dnolen | darkone: your clojure opennlp project looks pretty interesting. Can you use it extract name entities yet? |
| 23:08 | KirinDave | defn: For example, more automation on the generation of the routing table. |
| 23:08 | dnolen | dakrone: ^ |
| 23:08 | KirinDave | defn: More generous facilities for decorators. |
| 23:08 | dakrone | Crowbar7: have you seen this yet? http://nakkaya.com/2010/02/10/a-simple-clojure-irc-client/ |
| 23:08 | KirinDave | defn: Like right now, decorator order is kind of a pain to manage. If you write a decorator that depends on session stuff to be in place, yoi have to manage that by hand. |
| 23:08 | defn | KirinDave: ah -- sorry I don't have any suggestions for you -- the best bet I think would be to check out forks of compojure and see what you can come up with |
| 23:08 | dakrone | dnolen: you could use the proper-noun filter, but not specifically for names yet |
| 23:09 | KirinDave | defn: Today I started writing code to, at compile time, scan the contents of a module and use that to generate a routing table. |
| 23:09 | dnolen | dakrone: cool, yeah I'm interested in extracting named entities - people/organizations. |
| 23:09 | KirinDave | defn: metadata in the module specifies what should be what. |
| 23:10 | dakrone | dnolen: you could do a proper-noun filter coupled with a good dictionary file, anything that doesn't exist is probably a name |
| 23:10 | dakrone | although that's a really messy way to do it |
| 23:11 | dnolen | dakrone: was curious because I've seen java opennlp examples that show names and organizations can both be identified using the write dictionaries. |
| 23:11 | dnolen | write -> right |
| 23:12 | dakrone | dnolen: I've only done a tiny part of the opennlp library so far, so there's probably one I haven't looked at yet |
| 23:37 | Crowbar7 | How do you put variables inside of clojures regex? |
| 23:39 | defn | ooo i know this one |
| 23:40 | defn | Crowbar7: I can't remember the name of the function now, but for some reason I remember it being in str-utils |
| 23:40 | Crowbar7 | ok |
| 23:40 | defn | it let's you compose a regex of several different pieces |
| 23:40 | defn | so one of them could be a variable |
| 23:40 | Crowbar7 | that will make html parsing easier |
| 23:41 | defn | you know about enlive? |
| 23:41 | Crowbar7 | no |
| 23:41 | defn | look it up |
| 23:41 | defn | it might be what you're looking for |
| 23:43 | Crowbar7 | So, clojurebot is pretty cool |
| 23:43 | defn | yeah, it's a neat project to play with |
| 23:47 | Crowbar7 | Who wrote him? |
| 23:47 | defn | hiredman i believe |
| 23:47 | dakrone | yea, http://github.com/hiredman/clojurebot |
| 23:47 | KirinDave | Crowbar7: Enlive is pretty damn awesome. |
| 23:51 | KirinDave | Did clojure.contrib.def get dropped in contrib 1.1.0? |
| 23:56 | atrerus | if I want lein to compile my clojure code into the repl, do I have to specify something in the project file? |
| 23:56 | defn | atrerus: which version of leiningen |
| 23:56 | defn | err oh, in the REPL |
| 23:57 | atrerus | defn: 1.1... just grabbed from git today |
| 23:57 | defn | i use swank-clojure |
| 23:57 | atrerus | right |
| 23:57 | atrerus | sorry that's what I mean |
| 23:57 | atrerus | I fire off "lein swank" then M-x slime-connect |
| 23:58 | atrerus | but I'm expecting the clj files in my src directory to be loaded... |
| 23:58 | defn | why not use M-x swank-clojure-project? |
| 23:59 | atrerus | would that give me the option to connect to the existing swank server? |
| 23:59 | defn | it spawns a new swank server with your dependencies and such on the classpath and the connects to it |
| 23:59 | defn | then* |
| 23:59 | atrerus | ah... so no need to start the swank server via the command line |