2009-10-07
| 00:00 | rongenre | somnium: i'd use that to reduce all the vectors? |
| 00:01 | arbscht | sorry, I'm not familiar with R dataframes. can you describe the structure? |
| 00:01 | rongenre | um. Basically a named set of equal-length vectors |
| 00:01 | rongenre | they function a lot like a relational table |
| 00:03 | arbscht | can you give an example of what you want to accomplish in clojure? |
| 00:06 | rongenre | Say it's account information. User name, password, last login, stuff like that. I want to find everyone who logged in in the last 30 mins. |
| 00:06 | somnium | ,(filter (fn [x] (some #(> % 7) x)) '([1 3 5] [2 4 6] [3 5 7] [4 6 8])) |
| 00:06 | clojurebot | ([4 6 8]) |
| 00:07 | somnium | rongenre: some composition of filters and preds should get you where you want |
| 00:08 | rongenre | Is there a way.. if I get the indexes of values in one vector to extract the values in all the other vectors? Like nth which takes a vector of indices as an argument |
| 00:09 | rongenre | Or alternately a boolean vector which I can apply to another one of the same side and pull out those which are true. That's kind of like a filter. |
| 00:09 | somnium | sure |
| 00:11 | somnium | ,(map (fn [[x y z]] [x z]) '([1 2 3] [4 5 6] [7 8 9])) |
| 00:11 | clojurebot | ([1 3] [4 6] [7 9]) |
| 00:12 | rongenre | Gotcha. So if I could make [x z] take a vector of booleans I'd be good. |
| 00:12 | somnium | I'm sure there's more than one way |
| 00:12 | rongenre | That's helpful though, thanks |
| 00:12 | arbscht | rongenre: if you described your actual problem, we might be able to give an idiomatic solution :) |
| 00:13 | clojurebot | "There is no problem in computer programming which cannot be solved by an added level of indirection." -- Dr Maurice Wilkes |
| 00:13 | rongenre | Let me go make it up.. |
| 00:17 | slashus2 | ,(mapcat vals (keys (clojure.set/index #{[1 2 3] [4 5 6]} [0 1]))) |
| 00:17 | clojurebot | (5 4 2 1) |
| 00:18 | slashus2 | rongenre: Something like that? |
| 00:19 | rongenre | say I have this: (def *db* {:c1 (vector (range 10)) :c2 (map (fn [x] (rand)) (range 10))}) |
| 00:20 | rongenre | I want to find the c1 values where c2 < 0.2 |
| 00:20 | rongenre | sorry, (vec (range 10)) |
| 00:24 | rongenre | slashus2: does that make sense? |
| 00:26 | somnium | , (filter (fn [[x y]] (< y 0.2)) [[:a 0.1] [:b 0.2]]) |
| 00:26 | clojurebot | ([:a 0.1]) |
| 00:26 | slashus2 | ,(filter #(if (< (second %) 0.2) [(first %) (second %)]) (apply zipmap (vals {:c1 (vec (range 10)) :c2 (map (fn [x] (rand)) (vec (range 10)))}))) |
| 00:27 | clojurebot | () |
| 00:27 | slashus2 | or that... |
| 00:27 | somnium | (map (fn [[x y]] x) '([:a 0.1])) |
| 00:28 | somnium | if you split it out into separate transformations and filters |
| 00:28 | somnium | it should compose in a very understandable way |
| 00:28 | slashus2 | The zipmap thing works I suppose. |
| 00:29 | slashus2 | So as a combination of our solutions.. |
| 00:29 | slashus2 | ,(filter (fn [[x y]] (< y 0.2)) (apply zipmap (vals {:c1 (vec (range 10)) :c2 (map (fn [x] (rand)) (vec (range 10)))}))) |
| 00:29 | clojurebot | ([3 0.08506635579071331] [6 0.03744368136130927] [9 0.05586704315213442]) |
| 00:30 | rongenre | nice. Let me look at that more. |
| 00:34 | konr | hmmm, I have two functions defined, (defn foo [] 1) and (defn bar [] (foo)), but if I declare bar before foo, evaluating the file will raise an exception. Is this a way around this? |
| 00:35 | somnium | konr: put them in the right order? |
| 00:35 | konr | somnium: well, besides that :P |
| 00:39 | slashus2 | declare? |
| 00:40 | slashus2 | (declare foo) |
| 00:41 | konr | hmm, this will work! Thanks! |
| 00:42 | slashus2 | You are welcome. |
| 00:52 | Makoryu | ,(doc 'declare) |
| 00:52 | clojurebot | java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol |
| 00:52 | Makoryu | ,(doc declare) |
| 00:53 | Makoryu | Pffft |
| 00:53 | clojurebot | "([& names]); defs the supplied var names with no bindings, useful for making forward declarations." |
| 01:43 | namor | nick namor |
| 01:43 | namor | oups |
| 03:05 | LauJensen | Morning gents |
| 03:07 | Fossi | hi |
| 04:03 | snowwhite | how do i use compojure in the existing clojure project? |
| 04:08 | snowwhite | ping |
| 04:11 | LauJensen | eh? |
| 04:12 | LauJensen | snowwhite, could you clarify? |
| 04:14 | snowwhite | LauJensen, Thanks, just got the solution |
| 04:21 | adityo | hey snowwhite |
| 04:21 | snowwhite | pong |
| 04:22 | snowwhite | adityo, pong |
| 05:28 | LauJensen | Any regex junkies here today? |
| 05:35 | voldern | LauJensen: just ask your question |
| 05:38 | LauJensen | ,(re-find #"<([A-Z][A-Z0-9]*)\b[^>]*>(.*?)</\1>" "foo bar <title>quux</title> baz 1 2 3") |
| 05:38 | clojurebot | nil |
| 05:38 | LauJensen | Why am I not trapping quux ? |
| 05:39 | jdz | nice, regexps. used for parsing. i'm not reading your next blog entry lau, no way. |
| 05:39 | LauJensen | haha |
| 05:44 | raek | #"<([A-Za-z][A-Za-z0-9]*)\b[^>]*>(.*?)</\1>" |
| 05:44 | raek | ,(re-find #"<([A-Za-z][A-Za-z0-9]*)\b[^>]*>(.*?)</\1>" "foo bar <title>quux</title> baz 1 2 3") |
| 05:44 | clojurebot | ["<title>quux</title>" "title" "quux"] |
| 05:45 | raek | small letters... :) |
| 05:48 | LauJensen | aaah, good catch, thanks |
| 05:48 | LauJensen | so we got it worked out and as usual, no thanks to jdz :) |
| 05:49 | jdz | i'm not taking part of increasing the number of regexp-wielding monkeys in the world. |
| 05:56 | raek | ,(re-find #"<([A-Za-z][A-Za-z0-9]*)\b[^>]*>(.*?)</\1>" "foo bar <p>quux</p><p>foo-foo foo-bar</p> baz 1 2 3") |
| 05:56 | clojurebot | ["<p>quux</p>" "p" "quux"] |
| 05:57 | raek | ah, (.*?) |
| 06:08 | crios_ | ,(eval (list '+ 2 8)) |
| 06:08 | clojurebot | DENIED |
| 06:08 | crios_ | well, anyway: is there a shorter way to do it? |
| 06:08 | Chousuke | (+ 2 8)? :P |
| 06:08 | clojurebot | *suffusion of yellow* |
| 06:09 | crios_ | yes Chousuke :) besides that |
| 06:09 | crios_ | I mean, executing a dinamically created list |
| 06:09 | crios_ | I was guessing ((list '+ 2 8)) |
| 06:09 | crios_ | but it does not work |
| 06:09 | Chousuke | no, you need eval |
| 06:10 | Chousuke | though using eval is often suspicious. what are you doing :) |
| 06:10 | Chousuke | +? :P |
| 06:12 | crios_ | well, sort of studying, following some Scheme example: http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-16.html#%_sec_2.3.2 |
| 06:12 | crios_ | there you find: (define (make-sum a1 a2) (list '+ a1 a2)) |
| 06:13 | Chousuke | ah, well, studying eval is okay I guess. |
| 06:14 | Chousuke | helps you understand why you shouldn't use it too often :P |
| 06:15 | crios_ | yes; just wondering why that Scheme example works without an explicit "eval" function, but maybe there is some different approach to the "executing step" |
| 06:15 | Chousuke | hmm |
| 06:15 | jdz | ,(let [l '(2 8) f '+] (apply f l)) |
| 06:15 | clojurebot | 8 |
| 06:16 | jdz | huh? |
| 06:16 | Chousuke | '+ is a function, but it's not + :) |
| 06:16 | jdz | oh, right |
| 06:16 | Chousuke | ,('+ '{+ 1}) |
| 06:16 | clojurebot | 1 |
| 06:16 | jdz | ,(let [l '(2 8) f +] (apply f l)) |
| 06:16 | clojurebot | 10 |
| 06:16 | Chousuke | ,('+ '{- 1} 2) |
| 06:16 | clojurebot | 2 |
| 06:17 | jdz | ,'+ |
| 06:17 | clojurebot | + |
| 06:17 | jdz | ,(apply '+ :foo) |
| 06:17 | clojurebot | java.lang.IllegalArgumentException: Don't know how to create ISeq from: Keyword |
| 06:17 | jdz | ,(apply '+ '(:foo)) |
| 06:17 | clojurebot | nil |
| 06:18 | Chousuke | '+ looks itself up in whatever associative thing you give it |
| 06:18 | jdz | hmm, clojurebot should add evaluation numbers so we can refer to them in the chat :) |
| 06:18 | Chousuke | or returns its second argument (which is nil by default) |
| 06:20 | jdz | i'd probably expect that from keywords, but from ordinary symbols... |
| 06:20 | crios_ | So, if you were implementing in Clojure the some "derivate" example in http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-16.html#%_sec_2.3.2 (Representing algebraic expressions), would you use "eval" ? |
| 06:20 | crios_ | or some other trick? |
| 06:20 | Chousuke | crios_: the (+ a1 a2) list in that code is not evaluated at any point. it's just a data structure used by the derivation function |
| 06:21 | crios_ | yes, but when actually doing the (deriv '(+ x 3) 'x) |
| 06:21 | crios_ | it is evaluated |
| 06:22 | Chousuke | where is deriv defined? |
| 06:22 | Chousuke | oh wait, duh |
| 06:23 | Chousuke | no, it's not evaluated :) |
| 06:23 | Chousuke | if it were, there would be a call to eval |
| 06:24 | crios_ | it is defined in "The differentiation program with abstract data" |
| 06:24 | crios_ | and used when sum? is true |
| 06:24 | crios_ | sum is true when the operator is + |
| 06:25 | crios_ | it seems to me that in Scheme you (in that example) don't need to call an "eval" |
| 06:25 | jdz | crios_: it seems to you wrong |
| 06:26 | Chousuke | crios_: it never looks for the function +. all it deals with are symbols |
| 06:26 | crios_ | jdz: :) I was guessing it, but why? |
| 06:26 | jdz | crios_: if there is no need for eval in scheme code, you don't need it in Clojure code |
| 06:27 | Chousuke | oh damnation, my emacs is broken |
| 06:27 | crios_ | Chousuke: so you mean it never really do a real sum? |
| 06:27 | crios_ | ok, I understood :) |
| 06:27 | Chousuke | crios_: yeah. |
| 06:27 | jdz | crios_: you can define function make-sum like (define (make-sum a1 a2) (list 'this-is-a-plus-symbol a1 a2)) |
| 06:28 | jdz | crios_: and change the sum? function accordingly |
| 06:28 | Chousuke | crios_: deriv only transforms the list '(+ x 2) to '(+ 1 0) |
| 06:28 | crios_ | ok, I see that. Pardon for causing confunsion |
| 06:28 | crios_ | thanks |
| 06:29 | Chousuke | you can eval those to get the sum, but that's not relevant to deriv :) |
| 07:44 | pixelman | how can i check if a variable exists? |
| 07:45 | pixelman | like (isset? *debug*) |
| 07:48 | pixelman | ,(resolve '*debug*) |
| 07:48 | clojurebot | nil |
| 08:07 | benns | how do i install swank-clojure manually ? |
| 08:08 | eevar2 | benns: git clone |
| 08:08 | benns | everything i found out so far says to run clojure-install from emacs |
| 08:08 | benns | eei mean the configuration bit |
| 08:10 | benns | i mean who came up with that crap anyway |
| 08:11 | benns | i don't want to download clojure/etc/etc i have them installed |
| 08:11 | eevar2 | my .emacs looks something like this: http://pastebin.com/m64f9ee22 |
| 08:11 | benns | ok thanks |
| 08:12 | noidi | i followed these instructions to install slime/clojure http://riddell.us/tutorial/slime_swank/slime_swank.html |
| 08:13 | noidi | just used my own paths instead of dumping everything under /opt |
| 08:14 | noidi | nothing ubuntu specific in the tutorial, despite the title |
| 08:19 | G0SUB | what's the best way to recursively modify the values of a map (they themselves can be maps)? (I am fine with creating a new map) |
| 08:25 | chouser | it's good that you're ok with that, because maps are immutable, so you must create a new one. |
| 08:27 | benns | how do i start clojure from emacs ? |
| 08:27 | benns | i have other lisps in slime-lisp-implementations |
| 08:27 | ambient | M-x slime |
| 08:27 | benns | slime runs clozure cl |
| 08:27 | ambient | ah, then I don't know. i have only clojure installed |
| 08:27 | benns | the guy who wrote swank-clojure should be hanged |
| 08:29 | chouser | ,(letfn [(double-value [m] (zipmap (keys m) (map #(if (map? %) (double-value %) (* 2 %)) (vals m))))] (double-value {:a 1, :b 2, :c {:d 3, :e 4, :f {:g 5}, :h 6}})) |
| 08:29 | clojurebot | {:c {:h 12, :f {:g 10}, :e 8, :d 6}, :b 4, :a 2} |
| 08:29 | chouser | G0SUB: ^^^ |
| 08:30 | eevar2 | benns: did you read the docs? -- http://github.com/jochu/swank-clojure mentions something about running clojure alongside cl |
| 08:30 | benns | i did that |
| 08:31 | benns | basically swank-clojure-config is broken |
| 08:31 | benns | he should simply say what configuration options exist and let _me_ set them up |
| 08:31 | benns | instead of assuming things that do not exist |
| 08:32 | ambient | well you could fix it if you know so much about it for the benefit of the rest of us? |
| 08:34 | benns | no dude i won't waste my time with this pile of crap |
| 08:34 | benns | if he can't be bothered to release stuff that works, i won't do his job for him |
| 08:35 | benns | i have 4 cl implementations working perfectly with slime and swank-clojure fucks everything up because he can't be bothered to document his own stuff |
| 08:45 | danlei | benns: what I do is: just compile swank.clojure.jar, use swank.swank/start-server in the clojure repl, and connect via slime-connect. (ymmv) |
| 08:47 | benns | this is an option, but clojure-mode depends on swank-clojure being loaded |
| 08:47 | benns | so i can't even get the first without the second |
| 08:47 | danlei | bens, a sec |
| 08:47 | G0SUB | chouser: wow. thanks. |
| 08:48 | danlei | benns: I require (in that order) clojure-mode, swank-clojure, and swank-clojure-autoload in my .emacs. that's all I have set-up, and it works |
| 08:49 | danlei | benns: and I don't like clojure-install either, I compiled swank.clojure.jar via maven |
| 08:49 | G0SUB | chouser: so that calls the function recursively. that's stack consuming, right? |
| 08:50 | chouser | G0SUB: yes |
| 08:51 | G0SUB | chouser: ok. thanks for reminding me about zipmap. that's awesome. many thanks. |
| 08:51 | chouser | but it consumes stack relative to the depth of the map nesting, not relative to the size of each map |
| 08:51 | chouser | np |
| 08:52 | G0SUB | right. |
| 08:54 | chouser | and it's necessary to keep the partially-complete higher-level maps somewhere while working on lower-level ones. Using the JVM stack is by far the most convenient. |
| 08:56 | chouser | if you maps can be deeper than the JVM stack allows (and increasing the size of the JVM stack isn't acceptible), you have to build up an accumulator either with tail-recursive calls or 'reduce'. More code, harder to get right, and likely slower. |
| 08:59 | benns | danlei: the problem i have here is that he assumes i do not have slime installed and configured |
| 08:59 | benns | i tried clojure-installed, not even that works |
| 09:03 | danlei | benns: hm. I'm not sure why it won't work. I use jochu's clojure-mode and swank-clojure repos, both are up-to-date. If you want to take a look at my .emacs, it's at http://github.com/danlei/emacs/ if you want to take a look. I can assure you, I never ran clojure-install, just what's in my .emacs and compiled swank-clojure with maven ... hth |
| 09:09 | benns | danlei: how do you start clojure instead of clisp though ? |
| 09:09 | benns | M-x slime starts ccl here |
| 09:09 | benns | M-- M-x slime clojure does not exist |
| 09:09 | danlei | benns: as I said, I use swank-connect exclusively |
| 09:10 | pixelman | how can I loop a collection and have access to the current index? I want to track progress |
| 09:15 | danlei | benns: s/swank-connect/slime-connect/ |
| 09:17 | jdz | pixelman: how do you loop? |
| 09:18 | pixelman | jdz: dorun, but now I am re writing with loop/recur it'll work |
| 09:18 | pixelman | jdz: I was searching for a construct like rubys .each_with_index |
| 09:18 | jdz | pixelman: well, if you use map, like (map my-function collection) |
| 09:19 | pixelman | jdz: I want to prinnt out 45% done etc. |
| 09:20 | jdz | pixelman: then you can instead do (map my-function-that-takes-item-and-index collection (iterate inc 1)) |
| 09:20 | Chousuke | map is probably not the best choice though |
| 09:20 | chouser | clojure.contrib.seq-utils/indexed |
| 09:20 | Chousuke | because it's lazy |
| 09:21 | jdz | Chousuke: well, i saw pixelman uses dorun at the moment |
| 09:21 | pixelman | chouser: indexed will fit the bill! |
| 09:22 | pixelman | just noticed today the documentation for clojure contrib |
| 09:22 | pixelman | http://richhickey.github.com/clojure-contrib/seq-utils-api.html#seq-utils/indexed |
| 09:22 | pixelman | I like that it's possible to click to the source |
| 09:37 | benns | ok i managed to make it work |
| 09:37 | benns | thanks danlei |
| 09:38 | danlei | benns: slime-connect or M-- M-x slime? |
| 09:38 | danlei | benns: welcome |
| 09:38 | benns | M-- M-x slime |
| 09:38 | benns | or M-x slime-clojure |
| 09:38 | liwp | benns: did you have to fix something in swnak-clojure or was it just a pain to configure it? |
| 09:38 | benns | as this is the scheme i'm using with the rest of the lisps |
| 09:38 | danlei | I see |
| 09:38 | danlei | did you have to do something besides what's in my .emacs, if yes, what? |
| 09:39 | benns | i will paste the relevant bits |
| 09:39 | danlei | thanks |
| 09:42 | benns | http://paste.lisp.org/display/88333 |
| 09:43 | benns | the clojure binary is the one he gives with modified classpath to include swank-clojure |
| 09:43 | benns | s/binary/script |
| 09:47 | danlei | benns: ok, ty |
| 09:55 | jdz | http://paste.lisp.org/display/88333#1 |
| 09:57 | Chousuke | hm. something has gone wrong with my emacs |
| 09:57 | Chousuke | the option key seems to have stopped working |
| 09:58 | Chousuke | makes it kinda difficult to write clojure code, as I can't type [ or { :P |
| 09:58 | benns | jdz: it would be good if he would put these examples in the docs for swank-clojure |
| 10:07 | jfields | how do I take an argument passed to a macro and make it a string? I tried (defmacro foo [x] `(println "~x")) but that printed ~x |
| 10:08 | chouser | try 'str' |
| 10:08 | jdz | jfields: why do you want a macro? |
| 10:09 | jdz | oh, nvm. misunderstood the question. |
| 10:09 | jdz | i think. |
| 10:09 | jfields | jdz I'm being lazy for a function that I use all the time and I don't want to type the quotes anymore. |
| 10:09 | jfields | chouser cool. thanks. |
| 10:21 | ngoc | Hi, how to create interdependent namespaces? |
| 10:21 | Chousuke | I don't think you can. |
| 10:22 | cemerick | ngoc: you'd have to control the load order explicitly, which is generally a sign you're doing something wrong |
| 10:22 | cemerick | e.g. factor out the base functionality into its own ns, and have the two existing ns' refer to it |
| 10:23 | ngoc | Functions in namespce a use functions in namespace b and functions in namespace b use functions in namespace a |
| 10:23 | chouser | right. stop doing that :-) |
| 10:23 | cemerick | then it sounds like there shouldn't be two namespaces |
| 10:24 | cemerick | ~max |
| 10:24 | clojurebot | max people is 182 |
| 10:24 | chouser | ngoc: it could probably be made to work, but it seems likely there's a better way |
| 10:25 | cemerick | we have one spot where there's an interdependency -- in that case, namespace a sets up an empty atom which is reset by a dependent namespace when it loads |
| 10:25 | cemerick | not ideal, but it had to happen, and I regret it immensely :-| |
| 10:31 | ngoc | I think "resolve" form can be used to evalutate namespace/function dynamically? |
| 10:32 | cemerick | yes, that's the fn used to look up vars dynamically |
| 10:32 | Chousuke | but do you really want that? |
| 10:32 | cemerick | it's definitely intended to be used sparingly |
| 10:33 | Chousuke | and I really wish we had some "canonicalize" function for symbols :P |
| 10:33 | Chousuke | and keywords |
| 10:33 | cemerick | outside of the normal interning? |
| 10:34 | ngoc | I "factor out the base functionality into its own ns, and have the two existing ns' refer to it" <-- but the functions in the new one has to call functions in the 2 others, so the problem remains? |
| 10:34 | Chousuke | cemerick: I had a need to figure out the full namespace-qualified form of a given. turns out it's not exactly trivial |
| 10:34 | Chousuke | a given symbol |
| 10:35 | cemerick | ngoc: the objective is to eliminate the ns interdependencies. If that can't be done, why have just one namespace? |
| 10:37 | cemerick | I mean, why *not* have just one namespace? |
| 10:37 | Chousuke | cemerick: the way to do it is try resolve first, then if it succeed, extract the namespace and name strings from the var and reassemble them into a symbol, or if it fails, see if the symbol has a namespace part that is an alias for some other namespace, and if so, expand it. unless you're done by now, you either need to add the current namespace to the symbol OR leave it as it |
| 10:37 | Chousuke | is... |
| 10:39 | cemerick | I remember writing a fn to get a ns-qualified symbol from a var. |
| 10:39 | cemerick | It wasn't pretty. |
| 10:39 | Chousuke | I still haven't implemented this fully for my syntax-quote macro because I (obviously) can't use any functions that depend on macros using syntax-quote... :P |
| 10:39 | cemerick | Chousuke: by 'alias', do you mean symbol mappings in ns declarations? |
| 10:39 | ngoc | cemerick: OK, if in a same namespace, function f1 calls f2, and f2 calls f1, some kind of "forward definition" is used? |
| 10:40 | Chousuke | cemerick: the :as stuff, yeah |
| 10:40 | Chousuke | ngoc: declare works |
| 10:42 | triddell | ok, I'm the one who wrote the tutorials at http://riddell.us for clojure, slime/swank, etc. They are out of date right now but I'm trying to update them this morning. question: what repository is everyone pulling swank-clojure from these days? |
| 10:44 | eevar2 | triddell: git://github.com/jochu/swank-clojure.git |
| 10:45 | eevar2 | clojure-mode is git://github.com/jochu/clojure-mode.git |
| 10:46 | Chousuke | I use technomancy's repos for both |
| 10:46 | triddell | eevar2: ok, I thought I saw something about technomancy forking it and other using that |
| 10:46 | eevar2 | ^^ seems some do |
| 10:47 | danlarkin | I believe technomancy has been a more active maintainer |
| 10:48 | Chousuke | the repos do merge periodically though |
| 10:49 | triddell | but is his mostly for the clojure-install method of installation, where he keeps versions in sync |
| 10:50 | triddell | my install is manual and just takes each repos current HEAD |
| 10:51 | triddell | which could have mixed results depending on when it's done |
| 10:51 | triddell | well, I'll just try with jochu today and see if that works |
| 10:53 | danlarkin | it seems jochu maven-ized swank-clojure, which I don't really get |
| 10:56 | Chousuke | well, most of it is clojure, isn't it? it could be used with apps other than emacs |
| 10:58 | danlarkin | Hm I suppose that's true |
| 11:00 | Fossi | triddell: a hint on your (excellent, thanks) page that there is now clojure-install would be great |
| 11:10 | tmountain | the first two articles on hacker news are both clojure related ... gaining some mindshare ! |
| 11:14 | cemerick | yeah, things have really picked up lately...of course, right as I had to step away! :-/ |
| 11:17 | tmountain | I wonder what the numbers look like regarding downloads of Clojure over the past year |
| 11:39 | ngoc | Is it true that ;;; is used for namespace comments, ;; for function comments, ; for comments inside functions? |
| 11:42 | Chousuke | ngoc: that's the convention |
| 11:43 | ngoc | Sometimes I see that ;; is used for comments inside functions. Is this worse than ;? |
| 11:43 | ngoc | ; ? |
| 11:43 | stuartsierra | ngoc: emacs will right-align comments starting with ; |
| 11:56 | ngoc | How often are you all using gotapi.com? Is there any plan to add Clojure doc to it? |
| 11:56 | stuartsierra | don't use it |
| 11:57 | ngoc | Is there a better place? (find-doc keyword)? :D |
| 11:57 | chouser | never heard of it |
| 11:58 | stuartsierra | every web-based javadoc search I've tried is slower than google |
| 11:59 | chouser | I like (javadoc x) |
| 11:59 | ngoc | Is there an easy way to join elements of an array together? |
| 12:00 | chouser | ngoc: into a string? |
| 12:00 | mtm | I've been using kiwidoc.com (caveat: written by a friend of mine) |
| 12:00 | ngoc | yes, like ["a", "b"] and ", " into "a, b" |
| 12:00 | danlei | technomancy: are you there? |
| 12:01 | chouser | ngoc: that's a vector not an array, but either way you can use str-utils/str-join, str-utils2/join, or apply str/interpose |
| 12:02 | technomancy | danlei: yeah, hi |
| 12:02 | ngoc | Is a vector a fix-sized array? |
| 12:03 | chouser | ngoc: no |
| 12:03 | chouser | ngoc: a vector is an indexed persistent collection |
| 12:04 | chouser | ngoc: http://clojure.org/data_structures#Vectors |
| 12:05 | danlei | technomancy: hi, I tried to set up swank-clojure under windows, and it appends "/src" to my swank-clojure-path, which I set to [...]/swank-clojure/target/classes/, which breaks everything for met. (since slime-lisp-implementations tries to call java -cp [...]/swank-clojure/target/classes/src/, which won't work |
| 12:05 | ngoc | There are str-utils and str-utils2. Will str-utils be removed in the future? |
| 12:05 | danlei | technomancy: I do appreciate that clojure-install makes things easier for newbies, but somehow it's getting in my way pretty much (I remember that I had this working some time ago) |
| 12:06 | stuartsierra | ngoc: probably, time unspecified |
| 12:07 | chouser | stuartsierra: I don't think I've heard a single person suggest they'd like str-utils to stick around, so that's good. |
| 12:08 | stuartsierra | 'k |
| 12:09 | chouser | I guess they might come out of the woodwork if 'require'ing it started to print warnings. :-) |
| 12:10 | ngoc | Is there a way to create a normal Java array? Or is a vector must be created first, then casted into Java array? |
| 12:10 | stuartsierra | ,(doc make-array) |
| 12:10 | clojurebot | "([type len] [type dim & more-dims]); Creates and returns an array of instances of the specified class of the specified dimension(s). Note that a class object is required. Class objects can be obtained by using their imported or fully-qualified name. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE." |
| 12:10 | chouser | vectors and arrays aren't really related |
| 12:10 | arohner | can I get quick opinions on a name I'm thinking of for a clojure library? |
| 12:10 | arohner | scriptjure |
| 12:10 | tmountain | isn't there an issue with namespace collissions and str-utils2? |
| 12:11 | stuartsierra | tmountain: it's a feature :) |
| 12:11 | danlei | technomancy: worse than that, under cygwin it even prepends "/home/danlei/" to my set-up paths ("c:/cygwin/home/danlei/.../blabla" -> "/home/danlei/c:/cygwin/..."), can't it just leave my paths as I set them? |
| 12:11 | chouser | tmountain: yeah, don't 'use' it. (require '[clojure.contrib.str-utils2 :as str2]) |
| 12:11 | tmountain | stuartsierra: ahh, of course |
| 12:11 | tmountain | as an aside, I'm a big fan of str-utils... use it all the time |
| 12:23 | triddell1 | FYI: I've updated my clojure and slime/swank tutorials: http://riddell.us/blog/2009/10/07/tutorials-updated.html |
| 12:23 | triddell1 | I still see a lot of reference to them and they were very out of date |
| 12:25 | chouser | triddell1: updating old docs isn't fun, but I'm sure it'll help a lot of people. thanks for doing it! |
| 12:29 | triddell1 | chouser: np, this route maybe passe with most people using the clojure-install method but there's no sense in having a broken tutorial out there for those new to clojure |
| 12:31 | danlei | triddell1: ah, using s-c-extra-classpaths for swank-clojure :) |
| 12:31 | danlei | triddell1: that's an option |
| 12:32 | triddell1 | danlei: yes, that is the part I needed to figure out today! |
| 12:33 | triddell1 | danlei: wasn't sure what another would be |
| 12:33 | triddell1 | danlei: option that is |
| 12:33 | danlei | triddell1: well, basically it's jumping through hoops, I guess |
| 12:34 | danlei | triddell1: look at slime-swank-implementations, it adds the path itself, but /wrong/ (at least for me) |
| 12:34 | danlei | triddell1: so basically, this /shouldn't/ be neccessary |
| 12:36 | danlei | triddell1: oh, slime-lisp-implementations, i meant |
| 12:36 | abbe | hi everyone |
| 12:36 | abbe | how to generate API documentation like the one on clojure-contrib site ? is it downloadable ? |
| 12:37 | triddell1 | danlei: yes, the path changed for swank.clj and it wasn't in the classpath... this is the only way I could fix that (or atleast the first way I found) |
| 12:37 | danlei | triddell1: yes |
| 12:38 | abbe | I think its gen-html-docs, is there any script using that ? |
| 12:38 | triddell1 | danlei: but yes, it shouldn't be necessary |
| 12:38 | danlei | triddell1: in my opinion, just setting swank-clojure-path should suffice |
| 12:38 | abbe | oh, got it, from gh-pages branch |
| 12:38 | danlei | triddell1: but for me, it adds a /src at the end of the path, which gets passed as -cp in slime-lisp-implementations, which breaks it |
| 12:39 | danlei | danlarkin: so your hack is the rescue :) |
| 12:39 | danlei | danlarkin: oops |
| 12:39 | benns | why does it add stuff in slime-lisp-implementations by itself |
| 12:39 | benns | this is what broke it here |
| 12:39 | danlei | benns: to be convenient, I'd say |
| 12:39 | danlarkin | danlei: my hack? |
| 12:40 | benns | wel that's fine if it describes how to do it manually |
| 12:40 | benns | but as it is now it doesn't |
| 12:40 | triddell1 | danlei: good!, ping me later if you find this step unnecessary |
| 12:40 | danlei | danlarkin: sorry, name got copletet wrongly |
| 12:41 | danlei | triddell1: well, it *should* be unneccessary, but atm it is neccessary :) |
| 12:41 | triddell1 | danlei: right, in the future though :-) |
| 12:41 | danlei | triddell1: at least it words |
| 12:41 | danlei | *works |
| 12:41 | danlei | triddell1: ok |
| 12:43 | technomancy | danlei: sorry, was on the phone |
| 12:43 | technomancy | you're using jochu's fork? |
| 12:43 | danlei | technomancy: np, we're talking about jochus anyway, but I |
| 12:43 | danlei | technomancy: yes |
| 12:44 | technomancy | man... I tried to look at that yesterday, but I couldn't get it to work either. = |
| 12:44 | technomancy | =\ |
| 12:45 | danlei | technomancy: adding it to extra-classpaths, as tridell1 did gets around the problem |
| 12:46 | technomancy | shouldn't be necessary in my fork, but if you got it to work that's cool |
| 12:46 | danlei | technomancy: C-h v slime-lisp-implementations helps a lot there |
| 12:46 | technomancy | the automated install uses my fork now since there was too much confusion about these kinds of things |
| 12:48 | danlei | it's really a mess, at least if you don't use clojure-install |
| 12:50 | danlei | e.g. it wants it's swank-clojure-jar-path set, even If I just want to connect via M-x slime-connect, ohterwise it barfs. that's weird (doesn't even matter what the path is set to) |
| 12:51 | technomancy | heh; I don't even have a swank-clojure-jar-path |
| 12:52 | danlei | either swank-clojure-jar-path or wank-clojure-binary must be set, if I remembercorrectly |
| 12:52 | danlei | anyway, at least it works .. somehow |
| 12:55 | ngoc | Hi, thanks all for all your help these days. I was able to create a very simple chat server as a Clojure exercise: http://github.com/ngocdaothanh/telchat. I'm newbie, comments are very welcome. |
| 13:19 | avital | Hello friends. Is [] just a reader macro for (vector)? It seems not: If I eval the following: (ns clojure.core) (defn vector [& rest] "YES") (vector 1 2 3) I get "YES" but if I then eval [1 2 3] I get [1 2 3]. Is there any way to modify []'s behavior? What actually is [] then? |
| 13:24 | Chousuke | avital: no, it's not. it's a real vector |
| 13:24 | danlei | avital: it's a "reader form" and there is no way to modify it I knew of |
| 13:24 | Chousuke | ,(read-string "[]") |
| 13:24 | clojurebot | [] |
| 13:24 | Chousuke | so it's not (vector) |
| 13:25 | Chousuke | if it were (vector ...) then you should be able to do (defn foo (vector a b c) ... ) but that of course fails :) |
| 13:26 | avital | Right. |
| 13:26 | avital | I'll try to explain what we're trying to do. |
| 13:26 | avital | We'd like to allow for a purely functional way to do something similar to logging but not exactly that. It is part of work we are doing on a google wave robot. |
| 13:27 | avital | Our idea was to have all functions always return results with metadata containing the "log" information |
| 13:27 | avital | Then we wrap all functions with something that concatenates all the logs of the arguments and returns a result with that concatenated log as its metadata |
| 13:27 | avital | This way we hoped that any function call would end up returning the full log in its metadata |
| 13:27 | Chousuke | problem 1: not everything can have metadata ;/ |
| 13:27 | avital | (Of course there are issues with primities, etc - we are aware of this.) |
| 13:30 | avital | As far as I understand, if we make an assumption that all values in our program are not primitives then other than reader forms, this solution would work. |
| 13:30 | avital | Even macros would magically work because they eventually call functions and if we redefine vector, map, ... that would work. |
| 13:31 | Chousuke | that sounds like way too much magic |
| 13:31 | Chousuke | but you can't modify the reader. it's written in java and exposes no hooks to itself |
| 13:32 | Chousuke | you'd need your own reader |
| 13:32 | danlei | or chosuke's ;) |
| 13:32 | Chousuke | if it were complete :P |
| 13:32 | avital | Right, I get it that it's impossible but I'd like to understand this in a quasi-theoretical way |
| 13:32 | danlei | :) |
| 13:33 | Chousuke | avital: so what are you actually not understanding here? |
| 13:34 | avital | Is there a purely functional way to do something that is like logging, but is _not_ logging (meaning I can't use print). I want it to be purely functional because it is actually applicative and i need to be able to unit test it etc (so I don't want to use thread-local vars). |
| 13:34 | avital | Not in clojure |
| 13:34 | avital | This is a general question about functional programming |
| 13:35 | avital | I'm sorry if this seems like a strange question the way it's posed but this is truly a specific issue we are having now, we can work around it now but we are going to have difficulties with it. |
| 13:35 | avital | We'll end up using thread-local vars but that will make testing more difficult. |
| 13:35 | Chousuke | well, for haskell there is the monad that allows you to "write" arbitrary information to an accumulator. |
| 13:35 | Makoryu | avital: Sure, there's a monad-based solution some Haskell folks came up with |
| 13:36 | Chousuke | with clojure you could do the same, but you'd probably have to pass around the accumulator explicitly |
| 13:36 | Chousuke | unless of course, you use the clojure monad library :) |
| 13:36 | Makoryu | avital: Are you familiar with the concept of monads? |
| 13:36 | avital | Makoryu: Not enough - isn't it just a wrapper for side-effect causing code? |
| 13:37 | Chousuke | no |
| 13:37 | Makoryu | avital: Nope |
| 13:37 | avital | Ok I'll go read a bit. |
| 13:37 | Makoryu | avital: The fact that Haskell has an IO monad (which is exactly that) is incidental to the idea of monads in general |
| 13:37 | avital | Does this accumulator monad have a name? |
| 13:38 | Chousuke | my current high-level definitions of monads is that they provide a way to define how functions in a category are composed |
| 13:38 | Chousuke | and probably something else too |
| 13:38 | Chousuke | it's like function composition, except you get to define what the composition operation is |
| 13:39 | noidi | this might be a stupid idea, but maybe you could put your log information in a map stored in a ref, which uses the "things" as keys? |
| 13:39 | Chousuke | and thus you can do all kinds of things like enforce serial execution or whatever |
| 13:40 | noidi | so that you could check (@log return-value-of-a-function) for the logging information |
| 13:40 | danlei | like monad-comprehensions -> list-comprehensions |
| 13:40 | avital | noidi: It should not be shared between threads |
| 13:41 | Chousuke | avital: put it in a ref with a nil root binding |
| 13:41 | Chousuke | er |
| 13:41 | Chousuke | regular def I mean |
| 13:41 | noidi | avital, threads can shere refs |
| 13:41 | noidi | share |
| 13:41 | avital | Chousuke: That will work, and will probably be what we'll end up doing but that will make it non-functional and this harder to test. |
| 13:41 | avital | noidi: No, I meant I don't want our log data to be shared between threads |
| 13:42 | noidi | ah, I missed the "not" :) |
| 13:42 | avital | Again, this is not really logging - it is the list of operations to return to the wave server. It is actual applicative code and must be unit tested |
| 13:46 | noidi | I haven't really understood monads (yet), but from the little I did understand, they might be what you want |
| 13:46 | noidi | like Chousuke and Makoryu suggested |
| 13:47 | avital | Yes, I am reading about it now and it seems to be exactly what we are looking for. |
| 13:47 | avital | So where is this clojure monad library again? ;) |
| 13:47 | noidi | http://onclojure.com/2009/03/05/a-monad-tutorial-for-clojure-programmers-part-1/ |
| 14:00 | ambient | it's also in clojure.contrib afaik |
| 14:08 | technomancy | stuartsierra: did you catch the second patch for #194? |
| 14:09 | technomancy | first one had the tests not really testing anything |
| 14:13 | stuartsierra | clojurebot: #194 |
| 14:13 | clojurebot | Gabh mo leithscéal? |
| 14:14 | stuartsierra | technomancy: got it; will test later |
| 14:14 | technomancy | ok, cool |
| 14:15 | chouser | ~ticket #194 |
| 14:15 | clojurebot | {:url http://tinyurl.com/y8nhyty, :summary "clojure.test use-fixtures function composes fixture functions repeatedly", :status :test, :priority :normal, :created-on "2009-10-07T17:54:39+00:00"} |
| 14:42 | phpwner | anyone in south florida? a CTO buddy of mine is looking for a hire |
| 14:47 | phpwner | PM me |
| 14:57 | ambient | php work for 7 bucks an hour ;) |
| 15:00 | mgarriss | can i ask a function what it's arity is? |
| 15:02 | pixelman | how can I get read-line to work from emacs? |
| 15:03 | pixelman | I type many newlines but not much happens |
| 15:14 | phpwner | ambient: no clojure work for probably $30-40/hr |
| 15:14 | kotarak | mgarriss: not programmatically. You get the arglists in the docstring however |
| 15:15 | mgarriss | bummer |
| 15:15 | kotarak | mgarriss: why do you need to know? |
| 15:15 | chouser | mgarriss: also can reflect on the invoke methods of function class |
| 15:16 | mgarriss | kotarak: i'm writing something that randomly puts together a function out of fn and data symbols i pass it |
| 15:17 | mgarriss | chouser: is that a java call? |
| 15:18 | chouser | yeah, it's a bit of a mess. somebody put together a nice function |
| 15:19 | kotarak | mgarriss: and you need to know how much arguments to pass to the fn? |
| 15:20 | mgarriss | kotarak: yeah |
| 15:21 | mgarriss | the fn that builds the new fn needs to know the arity of the fn's it can choose from |
| 15:21 | mgarriss | i think i'm going to just enforce an arity requirement on the passed in fn's |
| 15:22 | mgarriss | but that kind of sucks |
| 15:22 | kotarak | mgarriss: it depends. |
| 15:23 | kotarak | mgarriss: What's the purpose of the random generation? |
| 15:23 | chouser | mgarriss: http://groups.google.com/group/clojure/browse_thread/thread/d9953ada48068d78/1823e56ffba50dbb?q=argument+count+group:clojure#1823e56ffba50dbb |
| 15:24 | chouser | gah. sorry, that's a horrible url |
| 15:25 | mgarriss | i'm rewriting an old aLife sim i wrote in c++, each "cell" in the sim had a byte string that was interpreted as a mini language, new cells might mutate that little program. clojure/lisp allows me to write the little programs in clojure itself. i'm excited about it |
| 15:25 | Chousuke | heh |
| 15:25 | Chousuke | genetic programming, huh? |
| 15:25 | mgarriss | yeah |
| 15:26 | mgarriss | i think it cold be very cool in clojure |
| 15:26 | mgarriss | *could |
| 15:26 | phpwner | need clojure programmers in sofla. pm me |
| 15:27 | mgarriss | chouser: awesome, thanks for the link |
| 15:31 | nathanmarz | hey all |
| 15:31 | nathanmarz | are there any continuations-based web application frameworks being developed in clojure? |
| 15:45 | mgarriss | that arities fn works well |
| 15:55 | kotarak | dnolen, cgrand: did you continue your discussion on template inheritance? My idea (stolen from eg. blogofile) was to have two types of templates, pages and snippets. Pages basically nest and are put into the place of a <content/> tag in the parent page template. Snippets may be used in arbitrary positions with maybe a <snippet name="xxx"/> to invoke the xxx snippet at that position. After each snippet (or page template) is expanded a special |
| 15:55 | kotarak | snippet expands and snippet tags. |
| 15:55 | ambient | i have a dream, dream in which clojure runs flawlessly on both .NET and JVM, using portable code |
| 15:55 | kotarak | dnolen, cgrand: I'm not sure this really works, but I'll probably give it a try. |
| 15:56 | chouser | ambient: and the browser and on the iPhone. |
| 15:56 | dnolen | kotarak: not yet, still thinking about it myself. but I was thinking along those lines as well. |
| 15:57 | eyeris | I get a compilation error while trying to compile current clojureql from gitorious against clojure 1.0.0. Has clojureql moved away from clojure 1.0.0? |
| 15:57 | kotarak | eyeris: good question. I wouldn't think so. Let me check. |
| 16:00 | technomancy | nathanmarz: clojure doesn't have continuations |
| 16:01 | kotarak | eyeris: nope, works for me with 1.0. |
| 16:01 | kotarak | eyeris: what specific problem do you have? |
| 16:01 | eyeris | I will paste the stacktrace. Give me one sex. |
| 16:01 | eyeris | sec* |
| 16:03 | eyeris | http://pastebin.ca/1602299 |
| 16:03 | eyeris | Maybe it's expecting me to have Derby installed? |
| 16:03 | kotarak | you need the Derby jar. |
| 16:03 | kotarak | Yes. You need it for compilation. |
| 16:03 | kotarak | Or you manually disable the backend in the build.xml. |
| 16:04 | eyeris | Where do I put the derby jar? |
| 16:05 | kotarak | Into the lib directory. |
| 16:05 | kotarak | If you use Ivy it's fetched for you. |
| 16:10 | eyeris | After upgrading my code to the newest clojureql, my (ns (:require...)) fails with this dump: http://pastebin.ca/1602318 |
| 16:11 | kotarak | eyeris: I had such errors with messed up builds. Try a clean and then a compile. Also check that, there is not a second clojure.jar with a different version. |
| 16:14 | emacsen | Anyone here going to the Clojure class in Reston |
| 16:14 | kotarak | too far away |
| 16:15 | leafw | actually only 30 min from here -- what class is that? |
| 16:15 | leafw | if we mean Reston, VA |
| 16:15 | emacsen | http://pragmaticstudio.com/clojure |
| 16:15 | kotarak | yes, class with Rich and the book Stuart |
| 16:15 | emacsen | "The book Stuart" hehe |
| 16:16 | leafw | xD |
| 16:16 | leafw | for $1500 I know enough already. |
| 16:16 | ambient | the channel 9 clojure talk is really nice |
| 16:17 | kotarak | emacsen: well, there are several Stuarts. Eg. Stuart Sierra. |
| 16:18 | emacsen | true |
| 16:18 | emacsen | channel 9? |
| 16:19 | emacsen | like NY Channel 9? |
| 16:19 | emacsen | WWOR |
| 16:19 | ambient | http://channel9.msdn.com/shows/Going+Deep/Expert-to-Expert-Rich-Hickey-and-Brian-Beckman-Inside-Clojure/ |
| 16:19 | emacsen | Oh. I was more in favor of something on Channel 9 |
| 16:20 | emacsen | maybe a Rich Hickey, Uncle Floyd show |
| 16:20 | technomancy | that guy liked to talk about how much he knew about obscure languages. =) |
| 16:20 | technomancy | but yeah, it was pretty good |
| 16:32 | eyeris | haha! |
| 16:32 | eyeris | It works! |
| 16:32 | eyeris | Thank kotarak |
| 16:32 | kotarak | eyeris: what was the problem? |
| 16:35 | kotarak | man, clojure's compilation model sure is resistant to easy handling. |
| 16:35 | chouser | kotarak: in what way? |
| 16:36 | kotarak | because you have to specify namespaces. |
| 16:36 | chouser | instead of files? |
| 16:36 | kotarak | You either have to specify them manually, or you need some discovery mechanism. |
| 16:36 | kotarak | Yes |
| 16:36 | kotarak | I'm currently writing a Gradle plugin. |
| 16:37 | kotarak | Where Java and Groovy just say "Look there is this src dir. Compile the stuff there.", I have to jump through hoops with Clojure. |
| 16:37 | kotarak | Compile could figure out the namespaces itself. |
| 16:38 | kotarak | I could read all files and check the first form for ns or in-ns. But that would be best done with Clojure. Maybe I should use Clojure to write the plugin.... |
| 16:39 | leafw | kotarak: I agree. Compiling clojure is still a pain. |
| 16:39 | LauJensen | ztellman, you here? |
| 16:39 | ztellman | LauJensen: yeah |
| 16:39 | LauJensen | ztellman, your tetris game throws this: Can't take value of a macro: #'penumbra.opengl/color |
| 16:39 | LauJensen | I just got it from Github - am I doing something wrong? |
| 16:39 | ztellman | um, I changed around some stuff in opengl.clj |
| 16:39 | eyeris | Yeah, it's especially strange that it requires a namespace as an argument because the files are named the same as the namespace. |
| 16:39 | kotarak | eyeris: not necessarily |
| 16:40 | kotarak | You can also (load) subfiles. |
| 16:40 | ztellman | changed color into a function that targets color-3 and color-4 |
| 16:40 | kotarak | eyeris: I actually used this in several projects now. |
| 16:40 | ztellman | search for color-3 in src/penumbra/opengl.clj |
| 16:40 | ztellman | my guess is that it's not there, for whatever reason |
| 16:41 | eyeris | kotarak: What I mean is that the argument to compile, while a namespace, will always match the filename path. |
| 16:41 | chouser | kotarak: I think you could (binding [*compile-files* true] (load-file "foo.clj")) |
| 16:41 | LauJensen | ztellman, You gotta fix that, you just got linked by disclojure.org :) |
| 16:41 | kotarak | chouser: ??? I don't understand. |
| 16:42 | ztellman | LauJensen: I think the problem is limited to you |
| 16:42 | ztellman | other people have already gotten it working |
| 16:42 | LauJensen | so a git clone will fix it? |
| 16:42 | ztellman | that's my belief |
| 16:42 | LauJensen | pull even |
| 16:42 | chouser | kotarak: look at the source of 'compile' -- you could do what it does, but load a file by name instead of namespace. |
| 16:43 | wooby | hi, i've got this simple web server working: http://gist.github.com/203329 |
| 16:43 | kotarak | chouser: but how about the (load) case? I have to load the master file and ignore the children. |
| 16:43 | wooby | however, when a client disconnects abruptly a socketexception is thrown that kills it... and i'm not sure how to fix it |
| 16:44 | LauJensen | ztellman, I wasted your time, sorry, git pull solved it |
| 16:44 | ztellman | LauJensen, no problem at all |
| 16:44 | Guest70798 | hi there, i need some help with setting up emacs with clojure |
| 16:44 | ztellman | don't hesitate in the future to bother me about this kind of stuff, next time I really might have broken something |
| 16:44 | LauJensen | :) |
| 16:44 | Guest70798 | i installed everything right, slime mode is working |
| 16:45 | Guest70798 | only my setq swank clojure extra classpaths command |
| 16:45 | Guest70798 | is not working |
| 16:47 | technomancy | Guest70798: if you're working with the latest git version, the variable changed to the less verbose swank-clojure-classpath |
| 16:47 | hiredman | wooby: use try/catch to handle the exception |
| 16:47 | Guest70798 | technomancy |
| 16:47 | technomancy | although extra-classpaths should still be aliased to the new variable |
| 16:47 | Guest70798 | gotta be that |
| 16:47 | Guest70798 | ah .. |
| 16:47 | Guest70798 | i'm gonna test |
| 16:48 | Guest70798 | but has the setq command to be placed in a special place in the .emacs ? |
| 16:48 | Guest70798 | or just hanging in there ? |
| 16:48 | technomancy | Guest70798: as long as it gets executed before you launch slime you're OK |
| 16:48 | kotarak | chouser: I'll just go about it and read the first form for every file. If it's in-ns, ignore the file, otherwise compile it. Does that sound reasonable? |
| 16:49 | Guest70798 | yay |
| 16:49 | Guest70798 | techno, the aliasing wasn't working apparently |
| 16:49 | Guest70798 | now i have my full cp |
| 16:49 | Guest70798 | thank you very much |
| 16:49 | technomancy | Guest70798: thanks for letting me know; I'll see if I can fix that. |
| 16:49 | Guest70798 | great :) |
| 16:50 | chouser | kotarak: you're trying to compile every .clj file in a directory tree, with no further direction or configuration? |
| 16:52 | kotarak | chouser: I want to hook up as much as possible in the existing gradle infrastructure. There everything is file based with the usual includes/excludes clauses based on filename. And I don't want to specify the namespaces manually all the time. |
| 16:52 | wooby | hiredman: cool, got it, thank you |
| 16:53 | hiredman | someone should spin out a nice namespace extraction library |
| 16:53 | ambient | hmm, what I'm missing? both clojure.jar and clojure-contrib.jar are in classpath: java.io.FileNotFoundException: Could not locate clojure/contrib/def__init.class or clojure/contrib/def.clj on classpath: (opengl.clj:9) |
| 16:54 | kotarak | hiredman: there is c.c.find-namespace |
| 16:54 | hiredman | ,(doc find-namespace) |
| 16:54 | clojurebot | Excuse me? |
| 16:54 | hiredman | oh |
| 16:54 | hiredman | right |
| 16:54 | kotarak | c.contrib.f-n |
| 16:55 | hiredman | well dang |
| 17:02 | gosub80 | hi |
| 17:02 | gosub80 | i was playing with clojure |
| 17:03 | gosub80 | and there is something I can't understand |
| 17:03 | gosub80 | can anybody explain to me why (remove #(Character/isDigit %) "test123") works while (remove Character/isDigit "test123") raise an exception? |
| 17:04 | hiredman | Character/isDigit is not a clojure function |
| 17:04 | chouser | unfortunately. :-/ |
| 17:04 | hiredman | it is a java static method |
| 17:05 | gosub80 | ok, but then why works inside the anonimous function? |
| 17:05 | hiredman | so generally it is not a value, so you cannot really pass it to other functions |
| 17:05 | gosub80 | uhm |
| 17:05 | gosub80 | so it resolves as a function only as the first element of a list? |
| 17:06 | hiredman | not really |
| 17:06 | hiredman | but more or less |
| 17:06 | rstehwien | hmm, this works for me in slime |
| 17:06 | rstehwien | user> (remove #(Character/isDigit %) "test123") |
| 17:06 | rstehwien | (\t \e \s \t) |
| 17:06 | rstehwien | user> |
| 17:06 | hiredman | rstehwien: correct |
| 17:06 | gosub80 | yes, for me too |
| 17:07 | hiredman | Character/isDigit never is a function |
| 17:07 | hiredman | and it never "resolves" as one |
| 17:07 | gosub80 | so why it behaves as one in #(Character/isDigit %) ? |
| 17:07 | rstehwien | ah but I wouldn't be able to pass it around as a "real" clojure function? |
| 17:07 | gosub80 | is a trick in the reader? |
| 17:08 | rstehwien | unless I wrapped it |
| 17:08 | hiredman | yes |
| 17:08 | hiredman | ,(. Character (isDigit \1)) |
| 17:08 | clojurebot | true |
| 17:08 | gosub80 | ok |
| 17:08 | gosub80 | so, another question... |
| 17:09 | gosub80 | is there a standard function to turn a sequence of characters into a string? |
| 17:09 | kotarak | Java methods were born a second class citizens... |
| 17:09 | hiredman | ,(apply str (seq "foo")) |
| 17:09 | clojurebot | "foo" |
| 17:09 | hiredman | kotarak: I guess you could turn them into values via reflection |
| 17:17 | gosub80 | I think it would be prettier if map, filter and reduce returned strings when applied to strings, like in Haskell, but this is just an helper function away |
| 17:18 | chouser | gosub80: that's interesting. how would map in (map f1 (filter f2 "mystring")) know it's supposed to return a string? |
| 17:19 | kanak | hi, can anyone tell me how to add my directory to swank-clojure's classpath? |
| 17:19 | technomancy | kanak: (add-to-list 'swank-clojure-classpath "/path/to/foo.jar") |
| 17:20 | technomancy | use swank-clojure-extra-classpaths on older versions of swank-clojure |
| 17:20 | kanak | technomancy: how do i know if i'm using an older version? |
| 17:20 | technomancy | kanak: if swank-clojure-classpath is defined in Emacs, you're using a newer one |
| 17:20 | gosub80 | chouser: in Haskell the String type is just syntactic sugar for [Char], a list of Char |
| 17:21 | chouser | Haskell has a static type system |
| 17:21 | kanak | technomancy: thanks. Is "~/Code" allowed or do i need to expand the "~" part? |
| 17:21 | gosub80 | I know |
| 17:23 | gosub80 | there should be two internal String types, one as a Java String and one as a list of chars, freely and transparently interchangable |
| 17:23 | gosub80 | i don't know if something like this is even possible :) |
| 17:25 | Chousuke | it's not :p |
| 17:25 | Chousuke | because you can't have another string type that is compatible with String |
| 17:26 | Chousuke | so you'd lose a lot of interoperability with Java if you started using something that's not String |
| 17:26 | chouser | it would also break complexity guarantees of the various collection types. |
| 17:27 | chouser | (next x) is O(1), but if it returned a String it would have to be O(n) |
| 17:27 | hiredman | chouser: well, if you did have two types, it would return the [String] type |
| 17:28 | hiredman | er [Char] |
| 17:28 | chouser | or if it returned a string-like thing that wasn't a String, turning it into a String could perhaps be transparent, but it would not be free |
| 17:28 | hiredman | CharSequence |
| 17:28 | hiredman | ~ticket search CharSequence |
| 17:28 | clojurebot | ("#112: GC Issue 108: All Clojure interfaces should specify CharSequence instead of String when possible" "#98: GC Issue 94: \t (ancestors ClassName) does not include tag ancestors of ClassName's superclasses ") |
| 17:28 | chouser | in order to be consistent you'd have to be able to do the same thing with vectors and maps |
| 17:29 | hiredman | chouser: really? |
| 17:29 | chouser | there's no way to do (-> (next my-vec) (conj my-vec)) and end up with a vector in O(1) |
| 17:30 | chouser | ...without retaining the earlier part of the vector anyway. |
| 17:31 | chouser | hiredman: if (map foo "astring") returns a string, shouldn't (map foo [1 2 3]) return a vector? |
| 17:31 | hiredman | chouser: it wouldn't return a String it would return a StringSequence or some nonsense |
| 17:32 | hiredman | well |
| 17:32 | chouser | that you could call String methods on, right? |
| 17:33 | hiredman | chouser: hey, I'm not say this would work and I am not advocating it, I am just saying, the lynch pin is merely compatibility with Java's String, if there was a run around that, this would all just sort of fall together |
| 17:34 | Chousuke | hmm |
| 17:35 | Chousuke | but for (map foo "string") to return a CharSequence, you'd have to know that foo is Char -> Char :/ |
| 17:35 | gosub80 | what I was thinking was: |
| 17:35 | hiredman | Oh |
| 17:35 | Chousuke | (instance? CharSequence (seq "foo")) |
| 17:35 | Chousuke | ,(instance? CharSequence (seq "foo")) |
| 17:35 | clojurebot | false |
| 17:36 | Chousuke | hmm |
| 17:36 | Chousuke | maybe that should be fixed. |
| 17:37 | Chousuke | though... is it useful? :P |
| 17:37 | hiredman | that would be kind of cool |
| 17:37 | hiredman | except everyone specifies String everywhere |
| 17:37 | Chousuke | how often would you call seq on a string and pass it onto something excepting CharSequence... |
| 17:37 | Chousuke | especially since a String is a CharSequence |
| 17:37 | hiredman | Never |
| 17:38 | hiredman | and nothing takes CharSequences |
| 17:38 | Chousuke | yeah :( |
| 17:38 | gosub80 | if strings, in the general sense, are sequences they should be naturally operated on with functional operations, like maps and reduces. The fact that they return sequences of chars instead of other strings is just to retain interoperability with Java. |
| 17:39 | Chousuke | interop with Java is important :) |
| 17:39 | Chousuke | practicality trumps purity in this case |
| 17:41 | gosub80 | yeah |
| 17:42 | chouser | my point is that each collection type has functionality that depends on its internal representation, which it may not be able to provide with the same performance profile after you've done seq'y stuff on it. |
| 17:42 | gosub80 | but maybe there is a way to retain interop and not lose purity :) |
| 17:45 | gosub80 | chouser: I do agree, in the end if you need to convert this hypotethical string representation to Java String, there is a performance hit. |
| 17:51 | gosub80 | to have a transparent HypotheticalCharSequence, Java String should not be a Class, but an Interface :) |
| 17:52 | technomancy | there's not really a way to get a seq for items that come from a resource that must be closed, is there? |
| 17:52 | technomancy | I guess if you force the user of the seq to fully consume it you could close it once you detect the last item |
| 17:53 | technomancy | but without that contract you'd end up leaking resources |
| 17:56 | hiredman | ~ticket #2 |
| 17:56 | clojurebot | {:url http://tinyurl.com/l6lcfw, :summary "Scopes", :status :new, :priority :normal, :created-on "2009-06-15T12:35:58+00:00"} |
| 17:56 | hiredman | :/ |
| 17:57 | Chousuke | gosub80: I guess making String an interface would prevent many useful optimisations :/ |
| 17:58 | Chousuke | for example string interning. |
| 18:35 | mgarriss | is there any wrappers for basic AWT work? i just need to build an image and be able to grab a mouse click |
| 19:03 | technomancy | stuartsierra: do you think it'd be possible to have some kind of use-fixtures invocation that would run once for every new "testing" block? |
| 19:03 | technomancy | we're using the nested style a lot at work now, and fixtures would clean it up a fair bit |
| 19:04 | stuartsierra | hmm |
| 19:05 | technomancy | you'd have to tweak the testing macro a bit... not sure how that would work |
| 19:05 | stuartsierra | Maybe. I'd have to think about it. |
| 19:05 | technomancy | do you use that macro? |
| 19:05 | stuartsierra | almost never |
| 19:05 | stuartsierra | I just put it in there to keep the RSpec fanatics quiet. :) |
| 19:05 | technomancy | I hate asking for features that the maintainers never use. =) |
| 19:06 | technomancy | it's awesome how simple the implementation is though |
| 19:06 | technomancy | just doesn't play well with fixtures |
| 19:06 | technomancy | it'd be easy if you didn't mind wrapping the body in a new function |
| 19:06 | stuartsierra | That was my next question |
| 19:06 | technomancy | that would be the only way you could do it, actually |
| 19:07 | stuartsierra | Are you calling other test functions inside (testing ...) or just assertions? |
| 19:07 | technomancy | definitely more than just calls to "is" if that's what you mean. |
| 19:08 | stuartsierra | I mean something like (deftest foo...) (deftest grouped (testing "foo tests" (foo))) |
| 19:08 | technomancy | oh, I see. no, I don't do that. |
| 19:08 | stuartsierra | ok |
| 19:08 | technomancy | but I don't know if it's fair to disallow it just because I don't use it myself |
| 19:08 | stuartsierra | So would the fixture be attached to a particular (testing ...) block? |
| 19:09 | technomancy | I was thinking of it like one level deeper than :each |
| 19:09 | technomancy | running for every testing block |
| 19:09 | stuartsierra | Oh, I see. |
| 19:10 | stuartsierra | But (testing...) can be nested! |
| 19:10 | technomancy | yeah, I'm not sure if that really makes sense |
| 19:10 | technomancy | it's probably not a problem for clojure.test |
| 19:11 | stuartsierra | At one point I tried to figure out how to do multi-level hierarchies of tests, with fixtures attaching at any level. |
| 19:11 | stuartsierra | I gave up because it seemed too complicated. |
| 19:11 | technomancy | I can see that. |
| 19:11 | stuartsierra | And I couldn't find any other test framework that could do that. |
| 19:12 | stuartsierra | Even RSpec only does fixtures at the class level. |
| 19:12 | technomancy | you could make it so adding fixtures inside a testing block makes it run for all enclosed ones |
| 19:12 | technomancy | but it's probably not worth it. |
| 19:12 | stuartsierra | I think it would have to be a new construct... |
| 19:13 | stuartsierra | (deftest foo (with-each-feature feature-fn (testing ...) (testing ...) (testing...))) |
| 19:15 | stuartsierra | (with-feature :each|:once feature-fn & exprs) would eval exprs wrapped in the given feature-fn. |
| 19:15 | stuartsierra | I mean with-fixture |
| 19:38 | icey | is there a clojure web framework that is particularly well suited for ajax / comet / web *application* style development? (or one that's better suited for that style of development than others) |
| 20:37 | replaca_ | getting ready to start the bay area clojure group meeting in SF! |
| 20:38 | ju|io | next one in MV? |
| 21:07 | replaca_ | ju|io: I think so. The idea is to alternate |
| 23:53 | itistoday | Is Rich's "A deconstruction of object-oriented time" talk available in video from? |
| 23:53 | itistoday | *form? |
| 23:54 | hiredman | which talk was that? |
| 23:54 | itistoday | http://news.ycombinator.com/item?id=829268 |
| 23:55 | hiredman | doesn't sound familiar, so maybe no |
| 23:55 | hiredman | the jvmlang talks were supposedly videoed and will be made available |
| 23:56 | itistoday | does hickey frequent this channel often? perhaps he knows? |
| 23:57 | hiredman | ~seen rhickey |
| 23:57 | clojurebot | rhickey was last seen quiting IRC, 6396 minutes ago |
| 23:57 | hiredman | ,(int (/ 6396 60)) |
| 23:57 | clojurebot | 106 |
| 23:57 | itistoday | ,(int (/106 24)) |
| 23:57 | clojurebot | Invalid token: /106 |
| 23:57 | hiredman | so like four or five days ago |
| 23:57 | itistoday | ,(int (/ 106 24)) |
| 23:57 | clojurebot | 4 |
| 23:58 | itistoday | thanks :-) |
| 23:58 | hiredman | ~seen rhickey_ |
| 23:58 | clojurebot | rhickey_ was last seen joining #clojure, 6442 minutes ago |
| 23:58 | itistoday | any reason he has two names? |
| 23:58 | itistoday | or is that some irc thing meaning I'm away or something? |