2009-04-10
| 00:28 | something | I'm trying to get clojure mode running in emacs. I added (require 'clojure-auto), but I'm getting the following error: File error: Cannot open load file, clojure-auto |
| 00:28 | something | actually I'm using Aquaemacs. |
| 00:30 | something | I don't actually see a file named clojure-auto in the clojure-mode git clone. |
| 01:28 | dakrone_hb | ,(size '(1 2 3)) |
| 01:28 | clojurebot | java.lang.Exception: Unable to resolve symbol: size in this context |
| 01:28 | dakrone_hb | ,(len '(1 2 3)) |
| 01:28 | clojurebot | java.lang.Exception: Unable to resolve symbol: len in this context |
| 01:28 | dakrone_hb | ,(length '(1 2 3)) |
| 01:28 | clojurebot | java.lang.Exception: Unable to resolve symbol: length in this context |
| 01:28 | dakrone_hb | bah, what is it... |
| 01:28 | slashus2 | ,(count '(1 2 3)) |
| 01:28 | clojurebot | 3 |
| 01:29 | dakrone_hb | slashus2, that's it! thanks :) |
| 01:37 | bradford | suppose i have many key value pairs in a map like this {"open" (rand) "high" (rand) "low"} |
| 01:37 | clojurebot | map is *LAZY* |
| 01:37 | bradford | and i want a small function to pass a key to and get back a key value pair (i.e. extract that rand bit |
| 01:37 | bradford | what does that function return? |
| 01:38 | hiredman | ,(:open {:open (rand) :high (rand) :low (rand)}) |
| 01:38 | clojurebot | 0.021964224049019876 |
| 01:43 | bradford | hiredman, what is the colon doing htere? |
| 01:43 | bradford | i know - stupid questions, but bear with me :-) |
| 01:43 | slashus2 | bradford: Makes them keywords. |
| 01:44 | slashus2 | Which represent themselves. |
| 01:44 | hiredman | http://clojure.org/data_structures#toc8 |
| 01:44 | hiredman | clojurebot: keywords? |
| 01:44 | clojurebot | excusez-moi |
| 01:44 | hiredman | clojurebot: keywords is <reply>http://clojure.org/data_structures#toc8 |
| 01:44 | clojurebot | Ok. |
| 01:45 | bradford | yea, i'm reading about keywords and the reader |
| 01:46 | bradford | so these keywords evaluate to themselves and have a name, which is the string |
| 01:47 | bradford | so it is always idiomatic clojrue to use these as keys rather than strings in maps and suhc, correct? |
| 01:47 | durka42 | yes |
| 01:47 | durka42 | and you can do tricks like calling them as functions (and pass the map in which they are a key) |
| 01:48 | bradford | could you give me a simple example of such a trick? |
| 01:48 | durka42 | what hiredman did |
| 01:48 | hiredman | it's what I did with :open |
| 01:48 | durka42 | of course you can do it the other way |
| 01:48 | durka42 | ,({:a 1 :b2 } :a) |
| 01:48 | clojurebot | java.lang.ArrayIndexOutOfBoundsException: 3 |
| 01:48 | hiredman | ,({:a 1} :a) |
| 01:48 | clojurebot | 1 |
| 01:48 | hiredman | ,(:a {:a 1}) |
| 01:48 | clojurebot | 1 |
| 01:49 | hiredman | maps are functions of their keys, keywords are functions of maps |
| 01:49 | hiredman | similar with vectors |
| 01:49 | hiredman | ,([1] 0) |
| 01:49 | clojurebot | 1 |
| 01:50 | bradford | ok, let me try to testate "maps are functions of their keys, keywords are functions of maps" to see if i understand |
| 01:50 | clojurebot | maps are functions |
| 01:50 | dakrone_hb | can maps contain functions as the values also? |
| 01:50 | hiredman | sure |
| 01:51 | dakrone_hb | ,({:fn (fn [] (println "foo"))}) |
| 01:51 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args passed to: PersistentArrayMap |
| 01:51 | hiredman | or even as keys |
| 01:51 | bradford | a key can be used as a function that takes a map and returns the value associated with the key? |
| 01:51 | hiredman | ,{:fn (fn [] (println "foo"))} |
| 01:51 | clojurebot | {:fn #<sandbox$eval__2222$fn__2224 sandbox$eval__2222$fn__2224@5ba0d9>} |
| 01:51 | hiredman | bradford: a keyword can, and so can a symbol, but not any other kind of key you might use |
| 01:52 | bradford | right, such as in my initial code when i sued strings |
| 01:52 | hiredman | there is also get |
| 01:52 | hiredman | ,(get {:a 1} :a) |
| 01:52 | clojurebot | 1 |
| 01:52 | bradford | right, i have been using get but now it seems inferior |
| 01:53 | bradford | and so it works the other way around as well...,({:a 1} :a) |
| 01:53 | hiredman | yes |
| 01:54 | bradford | because the map is a function ath when applied to a key (or keyword?) retuns the value associated with that key |
| 01:54 | bradford | do I ahve it right? |
| 01:54 | hiredman | yes |
| 01:54 | bradford | damn, that is pretty powerful |
| 01:54 | hiredman | a map as a function can take any kind of key |
| 01:54 | hiredman | ,({"foo" 1} "foo") |
| 01:54 | clojurebot | 1 |
| 01:54 | hiredman | you can also provide defaults |
| 01:54 | hiredman | ,({"foo" 1} :bar 3) |
| 01:54 | clojurebot | 3 |
| 01:55 | hiredman | returns 3 because :bar is not in the map |
| 01:55 | hiredman | ,(:bar {"foo" 1} 3) |
| 01:55 | clojurebot | 3 |
| 01:56 | bradford | and what is going on there with those commas? |
| 01:56 | hiredman | they just get clojurebot's attention |
| 01:56 | hiredman | commas are white space in clojure |
| 01:56 | bradford | ah, i see |
| 01:57 | bradford | so this works regardless ,({"foo" 1} :bar 3) map as a function applied to a key |
| 01:57 | hiredman | yes |
| 01:58 | bradford | but (:a {:a 1}) that is only valid if the key is a function or a keyword (which you can use as a function) ? |
| 01:58 | hiredman | yes |
| 01:58 | hiredman | symbols too |
| 01:58 | hiredman | ,('a {'a 1}) |
| 01:58 | clojurebot | 1 |
| 01:58 | durka42 | ,(ifn? :a) |
| 01:58 | clojurebot | true |
| 01:59 | durka42 | ,(ifn? {}) |
| 01:59 | clojurebot | true |
| 01:59 | durka42 | ,(ifn? 3) |
| 01:59 | clojurebot | false |
| 01:59 | bradford | ah, neat |
| 01:59 | durka42 | ~def ifn? |
| 02:01 | bradford | ok, now that i get this, back to the initial question: {:open (rand) :high (rand) :low (rand) :close (rand)} |
| 02:02 | bradford | how would i am stract a little function that produces the pair for the keyword and a rand? |
| 02:02 | hiredman | (seq {:open (rand) :high (rand) :low (rand) :close (rand)}) |
| 02:02 | hiredman | ,(seq {:open (rand) :high (rand) :low (rand) :close (rand)}) |
| 02:02 | clojurebot | ([:open 0.8407993627078036] [:high 0.7140756192186338] [:low 0.39123758183484647] [:close 0.7588801724644191]) |
| 02:03 | hiredman | wait |
| 02:03 | hiredman | I know this set |
| 02:03 | hiredman | you doing markets? |
| 02:03 | bradford | indeed :-) |
| 02:04 | bradford | right now starting out building a time series database on tp of hbase |
| 02:04 | bradford | seems like a good starter porject to learn clojure |
| 02:04 | hiredman | ,(let [a (java.util.ArrayList. (seq {:open (rand) :high (rand) :low (rand) :close (rand)}))](java.util.Collections/shuffle a) (first a)) |
| 02:04 | clojurebot | [:open 0.6810614330271418] |
| 02:05 | hiredman | ,(let [a (java.util.ArrayList. (seq {:open (rand) :high (rand) :low (rand) :close (rand)}))](java.util.Collections/shuffle a) (first a)) |
| 02:05 | clojurebot | [:close 0.08798164520592999] |
| 02:05 | hiredman | that might not be the best way to pick a random item |
| 02:07 | bradford | ah, right. my ultiamte goal is to create random time series |
| 02:07 | bradford | so this map will be the value in another map where the keys are data/time |
| 02:07 | bradford | |
| 02:07 | bradford | ERC> |
| 02:07 | bradford | ERC> (defn random-trades [count] (for [x (range count)] [{:price (rand) :volume 1000}])) |
| 02:08 | bradford | something liek that |
| 02:15 | bradford | so now I ahve this: (defn random-trades-starting-at [count] |
| 02:15 | bradford | (for [x (range count)] [{:price (rand) :volume 1000}]) |
| 02:16 | bradford | if I want to generate a sequence that is a map of key-vales wher ehte key is a date and the value is the {:price :volume} - what sould I do? |
| 02:24 | hiredman | ,(java.util.Date.) |
| 02:24 | clojurebot | #<Date Thu Apr 09 23:26:21 PDT 2009> |
| 02:24 | bradford | right |
| 02:24 | bradford | my problem is to generate a mp using the for macro |
| 02:24 | hiredman | you need into |
| 02:24 | bradford | ,(defn random-trades-starting-at [count] |
| 02:24 | clojurebot | EOF while reading |
| 02:24 | bradford | (for [x (range count)] {:price (rand) :volume 1000})) |
| 02:25 | bradford | results in a big list |
| 02:25 | hiredman | ,(into {} '([:a 1])) |
| 02:25 | clojurebot | {:a 1} |
| 02:25 | hiredman | ,(into {} '([:a 1] [:b 2])) |
| 02:25 | clojurebot | {:b 2, :a 1} |
| 02:25 | hiredman | or reduce |
| 02:29 | bradford | (defn random-trades-starting-at [count] |
| 02:29 | bradford | (into {} (for [x (range count)] [x {:price (rand) :volume 1000}]))) |
| 02:29 | bradford | cool |
| 02:29 | cp2 | yeah |
| 05:10 | Carsten | hi |
| 05:11 | Carsten | Does anynoe know how to call a macro from clojure and get the evaluated result and not just the expanded expr |
| 05:21 | Neronus | use it like a function |
| 05:23 | AWizzArd_ | Carsten: how are you trying this right now? |
| 05:23 | AWizzArd_ | For example, AND is a macro |
| 05:23 | AWizzArd_ | ,(and (= 5 5) true true) |
| 05:23 | clojurebot | true |
| 05:24 | Carsten | I defined my own macro to get the arglists of a function |
| 05:25 | Carsten | and it only returns a Cons |
| 05:25 | Carsten | ((clojure.core/meta (var #'org.enclojure.ide.nb.editor.ClojureSourceTemplate/abb)) :arglists) |
| 05:25 | Carsten | abb is the function, in the REPL it returns ([a [b] [& c]]) |
| 05:26 | Neronus | could you paste the code defining the macro somewhere? |
| 05:26 | Carsten | (defmacro extr [fun] `((meta (var ~fun)) :arglists)) |
| 05:27 | Carsten | rats - I meant: how to call a macro from _Java_ |
| 05:27 | Neronus | ahhh.. sorry, I can't help you there. Maybe someone else can |
| 05:29 | Chousuke | Carsten: call it, get the form, then eval the form? |
| 05:30 | Neronus | Question is, though, why this doens't happen transparently |
| 05:30 | Carsten | This is what I am looking for: How to I eval the form returned? |
| 05:31 | Chousuke | I'm pretty sure there should be a java .eval function somewhere. |
| 05:31 | Chousuke | ~source eval |
| 05:31 | Neronus | Well, macros are just functions which get and return s-exprs, and are treated specially by the compiler |
| 05:31 | Chousuke | clojure.lang.Compiler.eval |
| 05:33 | Chousuke | Neronus: I guess it's because it's not really a macro call; what you have in java is the function object :/ |
| 05:33 | Chousuke | hmm |
| 05:33 | Chousuke | ,#^-> |
| 05:33 | clojurebot | EOF while reading |
| 05:33 | Chousuke | meh |
| 05:33 | Chousuke | ,(var ->) |
| 05:33 | clojurebot | #'clojure.core/-> |
| 05:33 | Chousuke | ,((var ->) 'test 'moretest) |
| 05:33 | clojurebot | (moretest test) |
| 05:34 | Chousuke | that's what happens with java I guess. |
| 05:36 | Neronus | probably |
| 05:42 | Carsten | tryied both Compiler.eval and eval.invoke -> ClassCastException: clojure.lang.Var cannot be cast to clojure.lang.Symbol |
| 05:46 | Chousuke | hmmh |
| 05:46 | Chousuke | remember that eval takes a form |
| 05:46 | Chousuke | ,(eval '(+ 1 1)) |
| 05:46 | clojurebot | DENIED |
| 05:46 | Chousuke | ... oh, right. |
| 05:47 | Carsten | It must be something special with the macro - this macro works like a function |
| 05:47 | Carsten | (defmacro iif [test clause] |
| 05:47 | Carsten | `(if ~test |
| 05:47 | Carsten | ~clause |
| 05:47 | Carsten | )) |
| 05:47 | Chousuke | um, isn't that just when |
| 05:48 | Carsten | something wrong with (defmacro extr [fun] `((meta (var ~fun)) :arglists)) ? |
| 05:49 | Chousuke | nah |
| 05:50 | Carsten | For my problem I can work around it (RT.meta works fine) |
| 05:50 | Carsten | But might it be a bug? |
| 05:57 | Chousuke | I have no idea :/ |
| 05:57 | Chousuke | I haven't used clojure from java. |
| 06:33 | csaager | I created issue 104 for this problem |
| 08:08 | Neronus | ignore = Name *spool |
| 08:10 | Neronus | sorry |
| 09:56 | alinp | hi |
| 09:56 | alinp | there is a function in clojure like haskell's [1..] |
| 09:56 | alinp | ? |
| 09:56 | alinp | or haskell's [1..9] |
| 09:57 | hiredman | ,(range 10) |
| 09:57 | clojurebot | (0 1 2 3 4 5 6 7 8 9) |
| 09:57 | hiredman | ,(take 10 (iterate inc 0)) |
| 09:57 | clojurebot | (0 1 2 3 4 5 6 7 8 9) |
| 09:57 | alinp | oh, ok |
| 09:57 | alinp | thanks |
| 10:05 | alinp | why range is not giving all the elements from start to end ? |
| 10:05 | alinp | I mean: |
| 10:05 | alinp | ,(range 1 9) |
| 10:05 | clojurebot | (1 2 3 4 5 6 7 8) |
| 10:06 | alinp | shouldn't give (1 2 3 4 5 6 7 8 9) ? |
| 10:06 | hiredman | range is sort of like array or vector indexing like that |
| 10:06 | hiredman | ,(doc range) |
| 10:06 | clojurebot | "([end] [start end] [start end step]); Returns a lazy seq of nums from start (inclusive) to end (exclusive), by step, where start defaults to 0 and step to 1." |
| 10:06 | alinp | oh, end (exclusive), skipped that |
| 10:06 | alinp | thank you |
| 10:26 | marklar | Is there any function that takes a vector and an index/value and returns a vector with that index/value removed? |
| 10:36 | Neronus | I guess compojure is listening to 127.0.0.1 per default? |
| 10:37 | cconstantine | ,(doc disj) |
| 10:37 | clojurebot | "([set] [set key] [set key & ks]); disj[oin]. Returns a new set of the same (hashed/sorted) type, that does not contain key(s)." |
| 10:38 | Neronus | ah, no. Its 0.0.0.0 |
| 10:55 | marklar | cconstantine: thank you |
| 11:08 | storkme | HEY GUISE |
| 11:08 | storkme | what's going on in this thread |
| 11:09 | Hun | thread? |
| 11:11 | storkme | wat? |
| 11:11 | Hun | dat! |
| 11:18 | storkme | wat |
| 12:04 | Cark | ~def send |
| 12:57 | eyeris | I have a (defn main [] ...) in my clj file but clojure.lang.Compiler still raises java.lang.NoSuchMethodError: main |
| 12:58 | hiredman | ~compilation |
| 12:58 | clojurebot | compilation is see compile |
| 12:58 | hiredman | ~compile |
| 12:58 | clojurebot | the unit of compilation in clojure is the namespace. namespaces are compiled (not files). to compile a namspace the namespace needs to be on the classpath and so does ./classes/ (and the directory needs to exist) because clojure writes the class files to that directory. http://clojure.org/compilation |
| 13:07 | eyeris | Okay. I change main to -main [s] and I'm trying to compile the namespace instead of the file, but I still get the NoSuchMethodError exception |
| 13:08 | hiredman | pastebin |
| 13:08 | lisppaste8 | ozzilee pasted "Messy Assoc" at http://paste.lisp.org/display/78368 |
| 13:09 | hiredman | ,(doc update-in) |
| 13:09 | clojurebot | "([m [k & ks] f & args]); 'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, and returns a new nested structure. If any levels do not exist, hash-maps will be created." |
| 13:09 | ozzilee | hiredman: Cool, that will help. |
| 13:10 | eyeris | http://pastebin.ca/1388133 |
| 13:13 | hiredman | don't do that |
| 13:14 | hiredman | java clojure.main -e "(compile 'wiscaid.reporting)" |
| 13:14 | hiredman | that exception is because clojure.lang.Compiler does not have a main() |
| 13:17 | eyeris | Oh! |
| 13:17 | ozzilee | hiredman: Hmm. Is there a way for update-in to work on all values in a vector? (update-in document [:sections * :items * :quantity] inc) ? |
| 13:18 | hiredman | nope |
| 13:18 | hiredman | also keep in mind, that using standard sequence functions (filter,map,etc) you will end up with a sequence instead of a vector |
| 13:18 | ozzilee | hiredman: Is there another way to clean that pasted mess up, then? The update-in only helps the innermost assoc. |
| 13:18 | ozzilee | hiredman: Crap, you're right. |
| 13:19 | ozzilee | hiredman: Maybe I should be using zip? |
| 13:19 | hiredman | writing a vector map wouldn't be too hard |
| 13:20 | hiredman | ,(keys [1]) |
| 13:20 | clojurebot | java.lang.Integer cannot be cast to java.util.Map$Entry |
| 13:20 | hiredman | bah |
| 13:20 | ozzilee | hiredman: No, it's not, I've done that once already. Still doesn't help the overall mess though. |
| 13:21 | hiredman | my attack would be to decompose the operations into several functions |
| 13:23 | hiredman | although, I do like the zippers |
| 13:26 | ozzilee | Yeah... it seems like an issue I've run into a number of times. There should be a simple jQuery-esque solution somewhere. |
| 13:28 | hiredman | the jquery-esque solution would be zippers, I guess |
| 13:28 | ozzilee | (update-in foo [:bar [] :baz [:one :two]] inc) |
| 13:29 | ozzilee | To update keys :one and :two in :baz in every map in the vector :bar in foo. |
| 13:29 | ozzilee | Eh maybe that's too compicated of a syntax. |
| 13:31 | hiredman | is there a reason you are using vectors instead of just seqs for :items? |
| 13:32 | ozzilee | hiredman: clojure-json uses vectors, not sure if it will encode seqs correctly, I'll give it a shot. |
| 13:33 | duncanm | la la la |
| 13:34 | ozzilee | hiredman: Yeah, it will. So that doesn't matter. |
| 13:34 | hiredman | ,(org.danlarkin.json/encode '(foo bar)) |
| 13:34 | clojurebot | java.lang.Exception: No such var: org.danlarkin.json/encode |
| 13:35 | ozzilee | ,(org.danlarkin.json/encode-to-str '(foo bar)) |
| 13:35 | clojurebot | "[\"foo\",\"bar\"]" |
| 13:37 | hiredman | (update-in document [:sections] (partial map update-items)) |
| 13:38 | hiredman | or something |
| 13:40 | ozzilee | hiredman: Yeah, I suppose that would work. I need to do a number of updates to each item, so that would be more effecient than walking the document for each one, using the imaginary update-in with wildcards multiple times. |
| 13:42 | hiredman | you could always write the update with wild cards :P |
| 13:43 | hiredman | ,:* |
| 13:43 | clojurebot | :* |
| 13:43 | lisppaste8 | ozzilee annotated #78368 "Less Messy Assoc" at http://paste.lisp.org/display/78368#1 |
| 13:44 | ozzilee | hiredman: Yeah, that's an option :-) I was thinking a vector of keys to mean "all of these keys", not sure what to mean "all keys" though. Don't want to use something that could actually be a key. |
| 13:45 | eyeris | Does the latest clojureql 03Feb work with the latest Clojure 30Mar? |
| 13:45 | ozzilee | Maybe I'll drop a message on the google group. I'm going to grab some lunch now, thanks for the help. |
| 13:46 | eyeris | I get an Exception "Unable to resolve symbol: lazy-cons in this context" |
| 13:47 | hiredman | that would be a no |
| 13:48 | eyeris | Darn. It doesn't work with the 20080217 Clojure release either (Unable to resolve condp). |
| 13:49 | hiredman | Lau_of_DK: well, whats the deal with clojureql? |
| 13:50 | Lau_of_DK | We're a few hours of work away from 1.0, but hestitant to put that work into it |
| 13:51 | eyeris | Lau_of_DK What Clojure revision are you using to develop? |
| 13:52 | Lau_of_DK | We're always working on the HEAD |
| 13:52 | dakrone_hb | I'm having trouble accessing the Field.Store.YES from this javadoc: http://lucene.apache.org/java/2_4_1/api/org/apache/lucene/document/Field.Store.html I've tried (Field.Store/YES) and (Field/Store/YES), but it still isn't correct, what's the right way to access the static field? |
| 13:52 | Lau_of_DK | eyeris, you submitted limits right? |
| 13:52 | hiredman | dakrone_hb: $ |
| 13:52 | eyeris | Lau_of_DK Yeah |
| 13:52 | hiredman | or not |
| 13:53 | Lau_of_DK | eyeris, Thank you for that - The code looked good and Im sorry I havent taken the time to implement it, its on the top of my list |
| 13:53 | dakrone_hb | hiredman, like (Field$Store/YES)? |
| 13:53 | hiredman | possibly |
| 13:53 | dreish | No parens, right? |
| 13:53 | dakrone_hb | what's the rule of thumb for putting in the '$'? |
| 13:53 | hiredman | the javadoc doesn't make a whole lof of sense |
| 13:53 | stuhood | yea... you need the $ for inner classes |
| 13:53 | hiredman | $ is for inner classes |
| 13:53 | eyeris | Lau_of_DK np, I've been keeping a private copy for that project. |
| 13:53 | stuhood | even static inner classes |
| 13:54 | dakrone_hb | okay, so since I imported Field, Field.Store is an inner class right? |
| 13:54 | hiredman | you have to import Field$Store |
| 13:55 | hiredman | but yeah |
| 13:55 | hiredman | Field.Store |
| 13:55 | hiredman | just does not compute |
| 13:55 | hiredman | it seems like the class name is Field.Store |
| 13:55 | dakrone_hb | hiredman, got it, importing Field$Store worked, I didn't realize I needed to import the inner class also |
| 13:55 | dakrone_hb | thanks! |
| 13:56 | dreish | I think the actual class Java compiles Field.Store to is Field$Store. |
| 13:56 | dreish | I'm guessing you'd see that in the .class binary. |
| 13:56 | dakrone_hb | is that a java-ism or a clojure-ism then? |
| 13:56 | hiredman | but the javadoc is so unhelpful |
| 13:56 | dreish | I believe it's a Javaism. |
| 13:57 | dreish | Clojure just isn't doing the namespace->name translation that Java would do. |
| 13:59 | blbrown_lt | ,(list nil nil nil) |
| 13:59 | clojurebot | (nil nil nil) |
| 13:59 | blbrown_lt | how do I condense that list so that the list is empty |
| 14:00 | blbrown_lt | ,(zip (list nil nil nil)) |
| 14:00 | clojurebot | java.lang.Exception: Unable to resolve symbol: zip in this context |
| 14:00 | dreish | (filter identity '(nil nil nil)) |
| 14:00 | blbrown_lt | there you go |
| 14:01 | hiredman | ,(remove nil? (list nil nil nil)) |
| 14:01 | clojurebot | () |
| 14:01 | blbrown_lt | ,(filter identity '(nil nil nil)) |
| 14:01 | clojurebot | () |
| 14:01 | dreish | hiredman's is better -- mine also removes false. |
| 14:01 | hiredman | I actualy use filter identity |
| 14:02 | blbrown_lt | hiredman, just curious, are you from a lisp background or java background or neither |
| 14:03 | hiredman | neither, I guess |
| 14:03 | blbrown_lt | dreish, in terms of self documenting code, hiredman's seems a little better |
| 14:03 | hiredman | clojure is my first lisp (besides trying to write one in ruby with cons cells based on lambdas after watching sicp) |
| 14:03 | dreish | blbrown_lt: Way to twist the knife, guy. |
| 14:04 | blbrown_lt | shrug, no feelings hurt |
| 14:04 | dreish | I kid, of course. |
| 14:04 | blbrown_lt | I was the one that through zip in there |
| 14:04 | hiredman | the java I have written was just enough to pass CS142 and 143 (intro to Programming^W Java) |
| 14:05 | st3fan | i would like to use clojure to write some web services that i would normally do in java |
| 14:05 | hiredman | all though I do think my java had a certain flare |
| 14:05 | st3fan | just haven't found the time to make a good start with that |
| 14:06 | blbrown_lt | st3fan, I plan on using json-lib with google appengine and clojure pretty soon |
| 14:06 | blbrown_lt | st3fan, use json-lib and axis2 if you want web services and a json library |
| 14:06 | hiredman | blbrown_lt: are you using json-lib just cause it's in contrib? |
| 14:07 | st3fan | blbrown_lt: i wrote a framework to do rest style + json result kind of web services |
| 14:08 | blbrown_lt | contrib has a json library or is contrib using json-lib? and how complete is it |
| 14:08 | st3fan | blbrown_lt: just add some annotations to a pojo and you expose a bean as a service action .. want to do something similar in clojure |
| 14:08 | st3fan | http://code.google.com/p/polarrose-wsf-examples/w/list |
| 14:09 | danlarkin | all hail clojure-json! |
| 14:09 | st3fan | yeah i will look into it soon |
| 14:09 | st3fan | i think it will be a good project for me to get into clojure |
| 14:11 | hiredman | blbrown_lt: maybe I am confusing contrib's json with json-lib |
| 14:12 | hiredman | the only json lib I've used is danlarkin's |
| 14:13 | cads | I'd like to create a browser based repl tutorial similar in spirit to Why's interactive ruby tutorial at http://tryruby.hobix.com |
| 14:13 | cads | and I was wondering first if you guys have already run across something like that |
| 14:14 | gnuvince | It's funny that #clojure has more users than #scala ;) |
| 14:14 | hiredman | it has come up, I think Chouser was working on an applet based repl? |
| 14:15 | Chouser | haven't touched it in a while: http://clojurescript.n01se.net/ |
| 14:15 | hiredman | depending on how involved a tutorial you might get away with just clojurescript :P |
| 14:15 | Chouser | but it's the javascript runtime, so no agents, no real stm, etc... |
| 14:16 | hiredman | the other option I guess would be something like clojurebot |
| 14:17 | hiredman | (running code in a sandbox) |
| 14:17 | gnuvince | That would probably be the best choice |
| 14:17 | cads | yeah, a friend already told me about the limitations of of java in browsers, how many are coming with it disabled these days |
| 14:18 | cads | I thought to have the complete repl running in an applet, but feel like having it serverside in a sandboxed VM would be better |
| 14:18 | hiredman | I wonder if appengine's jvm has the security manager enabled |
| 14:18 | cads | well there's another thing, there are all the different implementations, could be hard to get working right |
| 14:19 | cads | on the other hand I feel like it would be easier for me to create an interface in an applet |
| 14:21 | Chouser | well, that would be another option -- pure java applet (or web start) |
| 14:21 | hiredman | there was some javascript terminal widget thing |
| 14:21 | drewolson | can anyone help me out with some vim clojure questions? |
| 14:22 | Chouser | that gets you argents, stm, etc. |
| 14:22 | Chouser | appengine for java doesn't currently allow spawning threads |
| 14:23 | cads | Chouser, your repl would be a good starting point |
| 14:24 | cads | can you describe its implementation a bit? |
| 14:25 | Chouser | dom+javascript to collect the repl input, which is sent as a string (via liveconnect) to the applet. |
| 14:25 | Chouser | The applet includes all of clojure plus the clojurescript compiler -- it translates the given repl string to javascript and returns that. |
| 14:26 | Chouser | the javascript in the page then evals the returned javascript and displays the output via the dom |
| 14:27 | Chouser | all the javascript I just mentioned is actually also compiled from clojure sources |
| 14:27 | Chouser | all the code for this is in contrib |
| 14:28 | cads | very nice |
| 14:29 | dakrone_hb | drewolson, probably best just to ask and see if anyone can help |
| 14:29 | Chouser | so you could just cut out the clojurescript stuff and get more features, better performance, and a smaller applet |
| 14:30 | cads | I think so too |
| 14:31 | cads | that's pretty fantastic, kudos |
| 14:43 | blbrown_lt | only bad thing about the new lazy sequences is that it can hard to detect errors. E.g. before it seem like you could navigate to line 123 and that is where the error is. Now we have to remember a seq is lazy |
| 14:44 | marklar | Is there a way to control the output of find-doc? i.e. How many items are returned? |
| 14:55 | eyeris | Could someone interpret this compile exception for me? http://pastebin.ca/1388243 |
| 14:56 | hiredman | clojurebot: compile |
| 14:56 | clojurebot | the unit of compilation in clojure is the namespace. namespaces are compiled (not files). to compile a namspace the namespace needs to be on the classpath and so does ./classes/ (and the directory needs to exist) because clojure writes the class files to that directory. http://clojure.org/compilation |
| 14:57 | hiredman | I know this is the second time I have referenced that |
| 14:57 | hiredman | but I need you to read it |
| 14:58 | eyeris | I know. I did read it. I just can't find the answer. |
| 14:58 | dakrone_hb | it doesn't look like you have ./classes in your classpath |
| 14:58 | eyeris | I'm pretty jvm-ignorant, so most of the gen-class stuff is over my head. |
| 14:59 | dakrone_hb | does ./classes/ exist and is it in your classpath? |
| 14:59 | clojurebot | classpath is (System/getProperty "java.class.path") |
| 14:59 | hiredman | ~botsnack |
| 14:59 | clojurebot | thanks; that was delicious. (nom nom nom) |
| 14:59 | eyeris | I see. It needs ./classes for the intermediate steps. |
| 14:59 | eyeris | I thought that was in the example cmd line simply for other .class files |
| 15:00 | hiredman | not intermediate steps |
| 15:00 | radarsat1 | hi, is there an easy way to do a lazy reduce in clojure? |
| 15:00 | hiredman | the compiled classes are written to ./classes/ |
| 15:01 | hiredman | radarsat1: reduce as a lazy operation is, like unpossible |
| 15:01 | radarsat1 | okay |
| 15:01 | hiredman | reduce by it's nature consumes a whole sequence and outputs one value |
| 15:01 | hiredman | you could wrap it in a (delay ...) |
| 15:02 | radarsat1 | i want to translate '((0 1 2) (3 4 5)) into '(0 1 2 3 4 5) lazily |
| 15:02 | hiredman | replaca: that is not reduce |
| 15:02 | radarsat1 | it works with (reduce concat...) but that's not lazy |
| 15:02 | hiredman | ,(apply concat '((0 1 2) (3 4 5))) |
| 15:02 | clojurebot | (0 1 2 3 4 5) |
| 15:03 | dreish | ,(flatten '((0 1 2) (3 4 5))) |
| 15:03 | clojurebot | java.lang.Exception: Unable to resolve symbol: flatten in this context |
| 15:03 | dreish | I guess that's in seq-utils. |
| 15:03 | dreish | It's lazy, anyway. |
| 15:03 | radarsat1 | apply is lazy? |
| 15:03 | clojurebot | lazy is hard |
| 15:04 | dreish | (apply concat '((0 1 2) (3 4 5))) is equivalent to (concat '(0 1 2) '(3 4 5)), and concat is lazy. |
| 15:05 | radarsat1 | okay thanks |
| 15:05 | radarsat1 | ah i see my problem here |
| 15:05 | radarsat1 | i was using '(0 1 2) as examples but they are also calculated lazily |
| 15:06 | radarsat1 | anyways i'll think about it thanks |
| 15:06 | dreish | You probably want seq-utils/flatten |
| 15:06 | radarsat1 | i'll try that |
| 15:13 | radarsat1 | i just tried with a few more list items and found that applying concat is lazy, its just that it starts by calculating the first 3 or 4 in advance, that's why i was confused. thanks. |
| 15:14 | radarsat1 | the 5th and 6th entries are being evaluated as needed. |
| 15:44 | __mj__ | Has the route function been removed in clojure? |
| 15:44 | __mj__ | I mean compojure? |
| 15:58 | lisppaste8 | thickey pasted "show-doc" at http://paste.lisp.org/display/78375 |
| 15:58 | marklar | That is great |
| 15:59 | thickey | marklar: it was based on your comment earlier, i've been wanting the same |
| 15:59 | marklar | thickey: Thank you! It will be incredibly helpful learning |
| 16:00 | thickey | np |
| 16:04 | duncanm | is there a way to access the binding vector inside a LET? |
| 16:04 | hiredman | interesting |
| 16:04 | hiredman | uh |
| 16:04 | hiredman | for why? |
| 16:05 | duncanm | i want to check that they're not zero |
| 16:05 | rsynnott | sounds like the sort of thing you don't really WANT to do |
| 16:05 | hiredman | ,(show-doc "vec") |
| 16:05 | duncanm | i have something like this |
| 16:05 | clojurebot | [ 0] org.danlarkin.json.decoder/decode-array [ 1] clojure.contrib.seq-utils/flatten [ 2] clojure.contrib.seq-utils/group-by [ 3] clojure.contrib.seq-utils/separate [ 4] clojure.core/assoc [ 5] clojure.core/contains? [ 6] clojure.core/for [ 7] clojure.core/letfn [ 8] clojure.core/peek [ 9] clojure.core/pop [10] clojure.core/proxy [11] clojure.core/re-groups [12] clojure.core/replace [13] clojure.core/require [14] clojure.core/rseq [15] clojure.core/spli |
| 16:06 | hiredman | ,(show-doc "vec" 0) |
| 16:06 | clojurebot | ------------------------- org.danlarkin.json.decoder/decode-array ([b-reader]) Decodes a JSON array and returns a vector. |
| 16:06 | duncanm | (let [x (f) y (g)] (if (some zero? (list x y)) 'boo 'woohoo)) |
| 16:06 | duncanm | i was just thinking of a way to not have to write (list x y) |
| 16:06 | hiredman | ah, uses print-doc |
| 16:07 | hiredman | if you want a list, make a list |
| 16:07 | hiredman | (let [x (list (f) (g))] ... |
| 16:07 | hiredman | actually |
| 16:07 | hiredman | (let [l (list (f) (g)) [x y] l] ... |
| 16:10 | Chouser | duncanm: would the 'if' always be the first thing inside the 'let'? |
| 16:10 | Chouser | if so, a macro do to that would be pretty reasonable. |
| 16:13 | twansit | quick question... how do you remove a symbol from a namspace? |
| 16:13 | twansit | remove/unload |
| 16:13 | hiredman | clojurebot: namespaces |
| 16:13 | clojurebot | namespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it |
| 16:14 | hiredman | er |
| 16:14 | hiredman | wait |
| 16:14 | hiredman | not what I was looking for |
| 16:14 | hiredman | clojure.org/namespaces |
| 16:14 | hiredman | functions for doing stuff with namespaces |
| 16:15 | twansit | cool thanks |
| 16:15 | twansit | i know the function that does this exists but its not on that page |
| 16:16 | twansit | cause the issue is im trying require a clj library using an alias |
| 16:16 | hiredman | ... |
| 16:17 | twansit | i would like to switch to another library but still using the same alias |
| 16:17 | twansit | do i have to remove-ns |
| 16:17 | twansit | or is there a fuction that just removes the alias |
| 16:17 | pjstadig | look under 'n' at http://clojure.org/api |
| 16:17 | pjstadig | ns-unalias |
| 16:17 | pjstadig | ns-unmap |
| 16:18 | hiredman | or look under "Remove" on clojure.org/namespaces |
| 16:18 | hiredman | well |
| 16:18 | hiredman | "Removing things" |
| 16:19 | twansit | ah |
| 16:19 | twansit | didnt see that for some reason |
| 16:19 | twansit | thanks guys |
| 16:21 | twansit | danlarkin: you here? |
| 16:22 | danlarkin | twansit: yessir |
| 16:22 | twansit | I'm using your json library |
| 16:22 | twansit | actually the decode-from-reader fn |
| 16:23 | danlarkin | cool |
| 16:23 | twansit | whats the difference if i pass a BufferedReader or InputStreamReader, is there a preference? |
| 16:24 | twansit | danlarkin: ? |
| 16:25 | twansit | danlarkin: right now i pass (BufferedReader. (InputStreamReader. stream *default-encoding*)) |
| 16:26 | danlarkin | you don't necessarily need to wrap it in a BufferedReader yourself |
| 16:27 | hiredman | there is a seperate decode-from-buffered-reader |
| 16:27 | danlarkin | decode-from-reader checks if the reader you pass is a BufferedReader, and if it's not it wraps it itself |
| 16:27 | twansit | cool thanks |
| 16:27 | twansit | i should have just looked at the src... but im lazy :) |
| 16:31 | hiredman | ,(show-doc "decode-from-reader") |
| 16:31 | clojurebot | [ 0] org.danlarkin.json/decode-from-reader |
| 16:31 | hiredman | ,(show-doc "decode-from-reader" 0) |
| 16:31 | clojurebot | ------------------------- org.danlarkin.json/decode-from-reader ([reader]) Takes a java.io.Reader pointing to JSON-encoded data and returns a clojure datastructure. |
| 16:31 | hiredman | hmmm |
| 16:31 | hiredman | if I am going to use that, print-doc needs a rebinding |
| 16:32 | dakrone_hb | why does it print all the '-'s? |
| 16:32 | hiredman | ,(doc print-doc) |
| 16:32 | clojurebot | "([v]); " |
| 16:32 | hiredman | nice |
| 16:32 | hiredman | print-doc is used and print-doc prints all the dashes and the heading |
| 16:33 | drewolson | hey all, i'm having an issue with vimclojure. syntax highlighting seems fine, ngserver runs cleanly and ng runs fine, however none of the key mappings seem to have any effect. |
| 16:35 | hiredman | is clj_want_gorilla set? |
| 16:35 | drewolson | yep, it is |
| 16:35 | drewolson | it's almost as if nothing is mapped |
| 16:35 | drewolson | i try \sr, and it simply does a replacement of the current character with r |
| 16:35 | hiredman | actaully |
| 16:35 | hiredman | I had that too |
| 16:36 | drewolson | really? |
| 16:36 | drewolson | and how did you solve it |
| 16:36 | drewolson | thanks :) |
| 16:36 | drewolson | wait, is it clj_want_gorilla or clj_wants_gorilla? |
| 16:37 | hiredman | want, I think |
| 16:37 | drewolson | wow, that was it :) |
| 16:38 | drewolson | ugh, now back to the issue i was seeing earlier |
| 16:38 | drewolson | Error detected while processing function vimclojure#ExecuteNailWithInput: |
| 16:38 | drewolson | line 23: |
| 16:38 | drewolson | E605: Exception not caught: Couldn't execute Nail! ng de.kotka.vimclojure.nails.NamespaceOfFile </var/folders/+e/+eeVZjm3E+y-FujQq60a8U+++TM/-Tmp-/v396957/0 |
| 16:38 | drewolson | Error detected while processing function <SNR>12_activateNode: |
| 16:38 | drewolson | line 12: |
| 16:38 | drewolson | E171: Missing :endif |
| 16:38 | hiredman | uh |
| 16:38 | hiredman | pastbin |
| 16:38 | hiredman | the ng binary needs to be in your path |
| 16:38 | drewolson | it is |
| 16:38 | hiredman | is it in the path of vim? |
| 16:39 | hiredman | :!ng |
| 16:39 | drewolson | $ which ng |
| 16:39 | drewolson | let me check |
| 16:39 | drewolson | yep, sure is |
| 16:39 | hiredman | is the fail you are editing all namespaced up? |
| 16:40 | hiredman | file |
| 16:40 | hiredman | :P |
| 16:40 | drewolson | let me try with a simple empty file |
| 16:40 | drewolson | breaks on an empty file as well |
| 16:41 | hiredman | what kind of classpath are you starting the ngserver with? |
| 16:41 | drewolson | let me find the command |
| 16:41 | drewolson | http://pastie.org/443200 |
| 16:41 | drewolson | that's the ngserver command |
| 16:42 | hiredman | *shrug* |
| 16:42 | hiredman | I have found vimclojure to be very finicky about classpaths |
| 16:43 | drewolson | yeah, apparently...i had the old version working with gorilla, would love to get this back up and running |
| 16:44 | hiredman | I would make sure the file you are editing is in the classpath |
| 16:45 | drewolson | hrm, really? i suppose then i would need to create a separate launcher for every project i was working on |
| 16:45 | pjstadig | or just have a huge classpath that includes everything you'd need |
| 16:46 | drewolson | let me give that a quick shot |
| 16:47 | drewolson | still fails if the file i'm editing is in the classpath |
| 16:47 | drewolson | of the server |
| 16:51 | dakrone_hb | ,(show-doc "xml") |
| 16:51 | clojurebot | [ 0] clojure.core/xml-seq [ 1] clojure.zip/xml-zip [ 2] clojure.xml/parse [ 3] hiredman.clojurebot.svn/summary |
| 16:52 | dakrone_hb | ,(show-doc "xml" 2) |
| 16:52 | clojurebot | ------------------------- clojure.xml/parse ([s] [s startparse]) Parses and loads the source s, which can be a File, InputStream or String naming a URI. Returns a tree of the xml/element struct-map, which has the keys :tag, :attrs, and :content. and accessor fns tag, attrs, and content. Other parsers can be supplied by passing startparse, a fn taking a source and a ContentHandler and returning a parser |
| 17:01 | dakrone_hb | ,(show-doc "json") |
| 17:01 | clojurebot | [ 0] org.danlarkin.json.decoder/json-ws? |
| 17:03 | twansit | i need a clojure sticker for my notebook |
| 17:03 | twansit | where can I cop one? |
| 17:07 | twansit | or a large clojure icon will do? |
| 17:09 | pjstadig | there are some files at the google group |
| 17:09 | pjstadig | http://clojure.googlegroups.com/web/Clojure-glyph.svg?gda=4BZz8kMAAAC2LrkjeC7f10uHiY7GOiyxp_O1uqTqpaVnLTdRwwRk4Xcahxnv5uvgTxaQgfZeUAYytiJ-HdGYYcPi_09pl8N7FWLveOaWjzbYnpnkpmxcWg |
| 17:09 | stuhood | http://clojure.org/file/detail/clojure_cake.png |
| 17:11 | stuhood | oh... svg |
| 17:11 | stuhood | that works |
| 17:11 | twansit | thanks! |
| 17:11 | pjstadig | np |
| 17:12 | stuhood | heh, that svg is on wikipedia too |
| 17:12 | stuhood | but it has some copyright restrictions http://en.wikipedia.org/wiki/File:Clojure-glyph.svg |
| 17:14 | pjstadig | yeah i'm not sure what the restrictions are |
| 17:14 | pjstadig | is there something published somewhere that would say |
| 17:14 | pjstadig | i mean i wouldn't go selling stickers or anything else |
| 17:15 | pjstadig | i think thickey made the logo, maybe he could shed some light? |
| 17:18 | twansit | nah i wouldnt sell them anyways |
| 17:22 | pjstadig | http://groups.google.com/group/clojure/browse_thread/thread/7f179c79f0d0bb3e/e065944bbbcb84e9 |
| 17:22 | pjstadig | some discussion, but the status of the logo was never specified |
| 17:25 | twansit | ,(java.net.URLEncoder/encode. "string" "UTF-8") |
| 17:25 | clojurebot | java.lang.IllegalArgumentException: No matching method: encode. |
| 17:26 | twansit | ,(.java.net.URLEncoder/encode "string" "UTF-8") |
| 17:26 | clojurebot | java.lang.Exception: No such namespace: .java.net.URLEncoder |
| 17:26 | hiredman | erm |
| 17:27 | hiredman | ,(java.net.URLEncoder/encode. "string") |
| 17:27 | clojurebot | java.lang.IllegalArgumentException: No matching method: encode. |
| 17:27 | hiredman | bah |
| 17:27 | twansit | ,(java.net.URLEncoder/encode "string" "UTF-8") |
| 17:27 | clojurebot | "string" |
| 17:27 | hiredman | ,(java.net.URLEncoder/encode "string") |
| 17:27 | clojurebot | "string" |
| 17:27 | hiredman | I live in the future |
| 17:27 | hiredman | everything is UTF-8 |
| 17:27 | twansit | oh ok |
| 17:27 | twansit | thanks man |
| 18:29 | lisppaste8 | Neronus pasted "compiling clauses" at http://paste.lisp.org/display/78380 |
| 18:31 | Neronus | How efficient is function compilation in clojure? Say, I want to write a function which compiles a clause, e.g. what I just pasted. How often do I have to evaluate that function to make compiling this thing worthwile in comparison to just "interpreting" such a clause |
| 18:31 | Neronus | for example via every? |
| 18:31 | hiredman | clojure does interpret anything |
| 18:31 | hiredman | er |
| 18:31 | hiredman | doesn't |
| 18:31 | hiredman | everytyhing is compiled |
| 18:32 | hiredman | and using eval is horrible |
| 18:32 | hiredman | so don't, ever |
| 18:32 | Neronus | right, I know that. What I mean by interpretation: (fn check [clause assignment] (every? #(assignment %1) clause)) |
| 18:33 | hiredman | I am not going to bother and figure what you are doing |
| 18:33 | hiredman | have fun |
| 18:33 | Neronus | I'll do my best |
| 18:35 | zakwilson | Using eval is likely the right thing if you're doing genetic programming or writing a REPL. |
| 18:37 | Neronus | why for genetic programming? |
| 18:39 | lisppaste8 | Neronus annotated #78380 "macro instead of evil eval" at http://paste.lisp.org/display/78380#1 |
| 18:40 | Neronus | clojurebot: eval? |
| 18:40 | clojurebot | eval is evil |
| 18:40 | Neronus | thought as much |
| 18:42 | durka42 | clojurebot: macros? |
| 18:42 | clojurebot | Holy Crap. |
| 18:42 | dakrone_hb | Vn1m4ith |
| 18:42 | dakrone_hb | bleh |
| 18:42 | durka42 | whoops |
| 18:42 | durka42 | change that password |
| 18:42 | dakrone_hb | heh |
| 18:43 | dakrone_hb | only my screen password, so no worries |
| 18:43 | durka42 | don't worry, all i saw was ******** |
| 18:44 | dakrone_hb | heh |
| 18:44 | Neronus | you mean, if I enter my password, everybody sees just stars? OK, I'll try it |
| 18:44 | Neronus | oldbutbeautifuljoke |
| 18:44 | Neronus | there, all stars |
| 18:54 | mek` | Hi all, I'm just switching to clojure from common lisp and I'd really like to start by writing code correctly (conventionally). Does anyone know of an authoritative resource on clojure commenting and programming conventions? And links to resources would be greatly appreciated. |
| 18:55 | mek` | Any* links, rather. |
| 18:56 | hiredman | core.clj :P |
| 18:56 | hiredman | ~def quote |
| 18:56 | hiredman | ah |
| 18:56 | mek` | Thank you kindly. :o) |
| 18:56 | hiredman | ~def unquote |
| 18:57 | hiredman | actually |
| 18:57 | hiredman | core.clj is kind of dated |
| 18:58 | hiredman | (. clojure.lang.RT (toArray coll)) would be (clojure.lang.RT/toArray coll) these days |
| 18:58 | hiredman | example of calling a static java method |
| 18:59 | hiredman | ,(macroexpand '(clojure.lang.RT/toArray coll)) |
| 18:59 | clojurebot | (. clojure.lang.RT toArray coll) |
| 18:59 | hiredman | hmm |
| 18:59 | hiredman | ,(macroexpand '(. clojure.lang.RT (toArray coll))) |
| 18:59 | clojurebot | (. clojure.lang.RT (toArray coll)) |
| 18:59 | hiredman | ,(. clojure.lang.RT (toArray [])) |
| 18:59 | clojurebot | #<Object[] [Ljava.lang.Object;@11c0dc6> |
| 19:00 | hiredman | ,(. clojure.lang.RT toArray []) |
| 19:00 | clojurebot | #<Object[] [Ljava.lang.Object;@1f96306> |
| 19:01 | hiredman | towards the end you get some more modern style |
| 19:08 | mek` | This is just what I was looking for. Thank you kindly, hiredman. |
| 19:16 | elg | what would be the idiomatic way to do the equivalent to this ruby code? ARGF.each_line{|l| foo, bar, baz = l.split} |
| 19:16 | elg | (and obviously do something with them, stuff them into an array or something - but that's irrelevant) |
| 19:16 | hiredman | map |
| 19:17 | hiredman | uh |
| 19:17 | hiredman | well you would not stuff into an array |
| 19:17 | elg | naturally |
| 19:17 | hiredman | or do assignment |
| 19:17 | elg | i was speaking about the ruby side - that code by itself is pointless |
| 19:18 | elg | I assume there's something more elegant than java.util.Scanner |
| 19:18 | hiredman | ruby .each* is somekind of map |
| 19:18 | elg | yes. ARGF is stdin/files on ARGV |
| 19:19 | hiredman | I've never used Scanner |
| 19:19 | elg | it's not pretty |
| 19:19 | gnuvince_ | Those who know something about compilers: my Clojure code is spend a large majority of its time in clojure.lang.Var.deref and get; do you think it would be possible to "change" those to let-vars if the compiler could determine that they're used not for their threading semantics, but just for naming things? |
| 19:20 | hiredman | well, I guess .each* could be doseq as well |
| 19:20 | hiredman | elg: what do you want to do? loop over lines in something? |
| 19:21 | elg | i want to create a data structure from the lines in a file |
| 19:21 | hiredman | so if you have a bufferedreader you can use line-seq |
| 19:21 | hiredman | and doseq or map |
| 19:21 | hiredman | ,(doc line-seq) |
| 19:21 | clojurebot | "([rdr]); Returns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader." |
| 19:22 | slashus2 | gnuvince_: Maybe you should write the part that is slow in java, and the rest in clojure. |
| 19:23 | gnuvince_ | slashus2: the part that is slow (or at least, I think is slow if I'm reading those profiling figures right) is the one I *really* want to write in Clojure :) |
| 19:23 | slashus2 | :-( |
| 19:24 | eevar__ | gnuvince: considered using let? |
| 19:24 | gnuvince_ | eevar__: I'm trying now, but it does not seem to have a lot of effect |
| 19:24 | eevar__ | assuming you don't _have_ to dereference, that is |
| 19:24 | gnuvince_ | Went down from 113 seconds to 111 |
| 19:24 | gnuvince_ | Which is probably just a question of margin of error |
| 19:26 | gnuvince_ | Not to mention that it makes some code really ugly; (def my-func (let [; 20 lines of local function definitions ] (fn [...] ...))) |
| 19:27 | Neronus | gnuvince_: You could pack it all into a map, if you always use it together; only one deref that way |
| 19:27 | gnuvince_ | If anyone's interested in doing some tests of their own, the code is here: http://github.com/gnuvince/clj-starcraft/tree/master |
| 19:27 | Neronus | Doesn't seem you real performance bottleneck, though. What do you use for profiling? |
| 19:27 | gnuvince_ | I could provide you with the data I'm testing against. |
| 19:28 | gnuvince_ | Neronus: -Xrunhprof:cpu=times |
| 19:29 | Neronus | Thanks. I'm still looking for a nice profiling solution |
| 19:30 | gnuvince_ | Neronus: there's also -Xprof |
| 19:30 | gnuvince_ | Faster, but less precise |
| 19:32 | eevar__ | yea, i'd go with cpu=samples |
| 19:32 | Neronus | But the benchmarks I did also indicated that dynamic variable lookup is slow. Which is sad, as defn'd functions are variables |
| 19:33 | Neronus | Well, got to go |
| 19:33 | Neronus | bye |
| 19:34 | Neronus | or maybe profiling influences the outcome a lot, because the overhead induced by profiling is bigger than the time needed for the lookup of variables |
| 19:35 | elg | hiredman: essentially what I'm trying to do is http://pastie.org/443376 |
| 19:35 | gnuvince_ | eevar__: what's samples? |
| 19:35 | elg | i'm still very new at clojure, and trying to feel out the standard idioms |
| 19:35 | elg | i can see how to do it by naively porting equivalent java code, but i doubt that's idiomatic |
| 19:36 | hiredman | elg: do you have contrib? |
| 19:38 | hiredman | it contrib's duckstreams there is a reader function that will turn just about anthing into some kind of BufferedReader |
| 19:38 | hiredman | then you call lazy-seq on it, then you just call map |
| 19:38 | hiredman | and you can use String's split method |
| 19:39 | hiredman | "structs" and hashs are the samething in clojure |
| 19:39 | eevar__ | gnuvince_: periodic sampling of the stack frame, rather than trying to time every method call or whatever 'times' does. way way faster |
| 19:39 | eevar__ | and still reasonably accurate |
| 19:39 | hiredman | structs are just hashes optimized for a smaller number of keys |
| 19:40 | gnuvince_ | eevar__: very nice, I'll try it in a few minutes |
| 19:40 | elg | hiredman: thanks, I'll look at duckstreams |
| 19:40 | hiredman | ,(doc defstruct) |
| 19:40 | clojurebot | "([name & keys]); Same as (def name (create-struct keys...))" |
| 19:48 | lisppaste8 | gnuvince pasted "For elg" at http://paste.lisp.org/display/78384 |
| 19:48 | hiredman | oh jesus |
| 19:49 | hiredman | next thing he'll be in here asking why elg won't compile |
| 19:49 | hiredman | :( |
| 19:49 | gnuvince_ | hmmm? |
| 19:49 | hiredman | gnuvince_: foo.elg |
| 19:50 | hiredman | or something, not a single segment namespace |
| 19:51 | gnuvince_ | Why would he name the file foo.elg? |
| 19:51 | hiredman | I have no idea |
| 19:51 | gnuvince_ | It runs fine here |
| 19:51 | gnuvince_ | Dunno about AOT compilation |
| 19:51 | gnuvince_ | but that's for another time. |
| 19:51 | hiredman | sure it'll run, but after he has been using it for a few days, and tries to compile, he'll be back in here |
| 19:52 | hiredman | and I'll have to do this |
| 19:52 | hiredman | ~namespaces |
| 19:52 | clojurebot | namespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it |
| 19:52 | hiredman | or even breakout ~compile |
| 20:04 | mattrepl | single segment namespace not allowed because compiled classes would be in default package? |
| 20:58 | dysinger | Strange I am getting 502 on several google code svn repos @app_engine outage related I wonder. |
| 20:59 | dysinger | clojure & clojure-contrib = 502 |
| 21:08 | hiredman | clojurebot's svn watcher is throw exceptions |
| 21:14 | dysinger | clojure should be on git not svn /ducks |
| 21:15 | dysinger | poorman's alternative would be hg /ducks again |
| 21:16 | dysinger | :P |
| 21:17 | cmvkk | you can get clojure off of github if you want |
| 21:17 | cmvkk | it's just a clone of the svn version |
| 21:18 | gnuvince_ | I prefer Mercurial myself, but I don't have a problem with Clojure being managed with Subversion if that's what Rich likes/knows. |
| 21:20 | gnuvince_ | eevar__: cpu=samples is pretty nice. |
| 21:21 | gnuvince_ | It's giving me very different results. |
| 21:21 | gnuvince_ | WHich make more sense I think and are more consistent with results from -Xprof |
| 21:23 | rlb | Is is very easy to create new container types? |
| 21:23 | rlb | s/Is is/Is it/ |
| 21:24 | rlb | i.e. something that can be used as a container but with a custom implementation? |
| 21:25 | hiredman | Yes |
| 21:25 | hiredman | what do you mean by "container" |
| 21:26 | Cark | i would say no =P |
| 21:26 | hiredman | I would say Yes |
| 21:26 | Cark | for what value of yes ? |
| 21:26 | hiredman | they are just java classes |
| 21:27 | Cark | right, you have to go to genclass or java |
| 21:27 | hiredman | you can gen-class, write java, or use proxy |
| 21:27 | hiredman | it depends |
| 21:27 | Cark | ah proxy might be cool indeed |
| 21:27 | clojurebot | proxy is <Chouser> proxy teases with its ease of use, then suddenly betrays. |
| 21:27 | hiredman | clojurebot: shove off |
| 21:27 | clojurebot | No entiendo |
| 21:27 | hiredman | ~you heard me |
| 21:27 | clojurebot | hiredman: I'm just giving you a second chance |
| 21:29 | hiredman | like I said, it depends |
| 21:29 | hiredman | rlb: what do you mean by "container" |
| 21:29 | hiredman | a Collection type? |
| 21:29 | hiredman | I don't see why you would |
| 21:30 | Cark | hum making a trie for instance ? |
| 21:30 | Cark | i'm working with telephone number and prefixes a lot |
| 21:31 | hiredman | it's possible to do that using vectors |
| 21:31 | Cark | i think i read somewhere that rich was thinking about mmoving more of the implementation to clojure code |
| 21:31 | Cark | hiredman : what do you mean ? |
| 21:32 | hiredman | you can make tree structures using vectors like cons cells |
| 21:33 | Cark | i have my implementation of a trie in clojure ....but it's neither a map nor a seq |
| 21:33 | Cark | trie /= tree |
| 21:33 | hiredman | it is a tree |
| 21:34 | hiredman | are you kidding? |
| 21:34 | Cark | right it's a tree ...just not your vanilla binary tree |
| 21:35 | Cark | anyways i didn't think about using proxy |
| 21:35 | hiredman | why would you? |
| 21:35 | Cark | so that i can use my trie as a seq and as a map |
| 21:35 | rlb | I was thinking about something like a very large disk-backed container. |
| 21:35 | rlb | bbiab. |
| 21:35 | Cark | i wonder what's the performance penalty |
| 21:35 | hiredman | I guess he must mean Collection |
| 21:36 | hiredman | they have those, called "files" |
| 21:37 | Cark | file based persitent data structures .... pray that the gc never collects |
| 21:37 | hiredman | it's an idea that keeps coming up |
| 21:38 | Cark | that's i beleive how some db engine are doing transactions |
| 21:38 | hiredman | because people never get tired of fighting with virtual memory systems? |
| 21:39 | hiredman | most operating systems implement a type of "disk-backed container" called a file |
| 21:41 | Cark | i'm not sur how good is java when running on the virtual memory |
| 21:41 | Cark | *not sure |
| 22:14 | slashus2 | Is there a Java framework like the python framework twisted? |
| 22:15 | hiredman | there are many |
| 22:16 | hiredman | #java recomends xnio or netty |
| 22:16 | slashus2 | Thank you. I will check them out. |
| 22:16 | hiredman | (netty seems to be higher level built ontop of xnio) |
| 22:16 | hiredman | the apache foundation has there own, mina |
| 22:16 | hiredman | their |
| 22:17 | hiredman | which is what twitter used with scala for thei message queue thing |
| 22:17 | hiredman | but #java seems to look down on it |
| 22:17 | hiredman | (the primary author of xnio hangs out in #java) |
| 22:18 | slashus2 | I think I will take a close look at Netty |
| 22:19 | slashus2 | I was going to play around and try to write an IRC server or something. |
| 22:21 | rlb | hiredman: I'll have to go investigate this "File" thing you speak of. Thanks. |
| 22:25 | hiredman | netty seems to use annotations, which could be a problem |
| 22:26 | slashus2 | hiredman: Looks like Netty uses annotations a lot, how do you deal with that in clojure? They are just properties, right? |
| 22:26 | hiredman | I don't know |
| 22:30 | rlb | For anyone who actually cares, what I was thinking of was something that would allow you to use something like filter on very large homogeneous vectors -- say a 3GB file of 64-bit integers. |
| 22:31 | rlb | Perhaps something like line-seq, but customizable. |
| 22:41 | mattrepl | slashus2: the java compiler emits bytecode for class and runtime annotations, so gen-class would need to mimic that |
| 22:41 | rlb | Ahh, OK, after looking at the source, it looks like it might be pretty easy to just create something that does at least part of what I wanted. |
| 23:02 | nzkoz | Hey guys, do you have any pointers to a good example application using clojure's concurrency support? I'm looking to build something really simple where a few UI threads feed a few more worker threads. But I want to make sure I approach it 'right' rather than just 'java with parens) ;) |
| 23:03 | Cark | have a look to the ants simulation |
| 23:04 | Cark | ~ants? |
| 23:04 | clojurebot | Excuse me? |
| 23:04 | Cark | i think the code is on the google group |
| 23:04 | mattrepl | ~ants |
| 23:04 | clojurebot | Excuse me? |
| 23:05 | Cark | might be based on an old version of clojure though |
| 23:05 | mattrepl | (thought it was question mark) |
| 23:05 | hiredman | it gets updated |
| 23:05 | nzkoz | ?ants |
| 23:05 | nzkoz | irc bots never liked me anyway :) |
| 23:05 | Cark | clojurebot does not like anybody |
| 23:05 | nzkoz | from the google group homepage? |
| 23:06 | Cark | in the file section |
| 23:06 | Cark | let me check |
| 23:07 | Cark | clojurebot : ants is http://clojure.googlegroups.com/web/ants.clj |
| 23:07 | Cark | clojurebot: ants is http://clojure.googlegroups.com/web/ants.clj |
| 23:07 | clojurebot | Roger. |
| 23:07 | Cark | ~ants? |
| 23:07 | clojurebot | ants is http://clojure.googlegroups.com/web/ants.clj |
| 23:08 | nzkoz | thanks |
| 23:09 | Cark | mzkoz : you should watch the videos too |
| 23:09 | nzkoz | yeah, saw the boston lisp ones, really good. if somewhat long :) |
| 23:16 | gnuvince_ | nzkoz: as I understand it, it was supposed to be 90 minutes, but went over 3 hours :) |
| 23:16 | gnuvince_ | And people didn't seem to mind |
| 23:17 | hiredman | which vidoes are those? |
| 23:17 | gnuvince_ | Boston Lisp User Group |
| 23:17 | hiredman | ~google boston lisp user group videos |
| 23:17 | clojurebot | First, out of 13800 results is: |
| 23:17 | clojurebot | Find a Meetup Group Near You! - Ruby Meetups - Boston |
| 23:17 | clojurebot | http://ruby.meetup.com/cities/us/ma/boston/ |
| 23:18 | hiredman | *blink* |
| 23:18 | cmvkk | google: it's not perfect. |
| 23:19 | hiredman | this is the clojure for lisp programmers stuff? |
| 23:20 | slashus2 | mattrepl: I see an example in the group of how to annotations for methods inside of a class, but how do you do it for a class itself. |
| 23:20 | gnuvince_ | hiredman: yes. |
| 23:21 | mattrepl | slashus2: if you're talking about the thread I started, that hasn't been implemented. there so far hasn't been much interest in it. for classes, we'd just need to add another option to gen-class to define all the class annotations |
| 23:24 | replaca | Boston Lisp Group videos are at http://clojure.blip.tv |
| 23:25 | replaca | look at "Clojure for Lisp Programmers" part 1 & 2 |
| 23:25 | replaca | watching that video was, for me, like a junkie's first taste of heroin |
| 23:30 | hiredman | I can't wait for the qcon videos |
| 23:39 | Raynes | It's 10:36pm. I've had 4 hours of sleep in the last 36. I've been monitoring a severe weather event all day. I have a fried porkchop in my mouth, a cold Coca-Cola in my hand I'm trying to concentrate on learning Scala with little object oriented background. This must be what the life of a programmer is really like. |
| 23:41 | Cark | that's the life of a bug writer |
| 23:43 | Raynes | Cark: That was offensive :( |
| 23:43 | Cark | ah sorry ... |
| 23:43 | Cark | but you know |
| 23:43 | Cark | you have to be carefull with your body if you want to write great software using your mind |
| 23:44 | Cark | i don't quite know how to formulate this in english |
| 23:44 | clojurebot | this is not a bug |
| 23:44 | Cark | in a non offensive way =P |
| 23:45 | Raynes | Cark: I'm competent. I'm just sleepy. I'm in one of those states where I can read an entire chapter before realizing I haven't been paying attention to what I was reading. Then have to re-read the whole thing. |
| 23:45 | Raynes | And I was just joking about it being offensive. |
| 23:45 | Raynes | \o/ |
| 23:45 | Cark | hehe ok |
| 23:45 | Cark | anyways that's bad habits i had too back then |
| 23:46 | Cark | then i became older, and i have to sleep now =P |
| 23:47 | gnuvince_ | Raynes: any thoughts on Scala? I was considering translating my Starcraft program to it to compare its speed and ease of use with Clojure. |
| 23:47 | Raynes | I normally /do/ sleep. I intended on going to sleep last night then the first complex of storms that came through caught me off guard and I monitored that severe weather until 5AM and slept for 4 hours before the next wave of storms. Those lasted all day so here I am. |
| 23:47 | Raynes | gnuvince_: I'm only on the first actually-learning-something chapter. |
| 23:48 | gnuvince_ | ok |
| 23:48 | cmvkk | if sleeplessness and junk food were good enough for john carmack, then they're good enough for me :) |
| 23:48 | Raynes | When they say Programming in Scala is a slow-paced book they mean it. They spend 2 chapters just running random crap by you. |
| 23:48 | gnuvince_ | heh |
| 23:48 | Raynes | I'm on the second introduction chapter :| |
| 23:49 | gnuvince_ | From what I've seen, I most likely know that I prefer Clojure (more liberal, less concepts), but I don't dislike static typing and really like to try new languages |
| 23:49 | Cark | cmvkk : looks like i'm not the next john carmack =( |
| 23:49 | gnuvince_ | So.. :) |
| 23:49 | Raynes | I'm learning it because I need Object Orientation, but I don't want to learn Java. |
| 23:49 | Raynes | Not now anyway. |
| 23:49 | Cark | ~OOP? |
| 23:49 | clojurebot | Gabh mo leithsc�al? |
| 23:49 | Cark | ~oop |
| 23:49 | clojurebot | Huh? |
| 23:49 | Cark | ~oop? |
| 23:49 | clojurebot | Gabh mo leithsc�al? |
| 23:50 | Cark | bah |
| 23:50 | gnuvince_ | object oriented programming |
| 23:50 | Raynes | ~OOP |
| 23:50 | clojurebot | Huh? |
| 23:50 | hiredman | ~mock objects |
| 23:50 | clojurebot | Your mock object is a joke; that object is mocking you. For needing it. -- rhickey |
| 23:51 | Cark | there need to be some sarcastic oop definition in clojurebot |
| 23:51 | danlarkin | Raynes: you don't need OO |
| 23:51 | Raynes | I really want to learn Factor. But I can't bring myself to do it with absolutely /no/ beginner material. |
| 23:51 | Raynes | danlarkin: I need better knowledge of OO. |
| 23:51 | Cark | factor looks nice |
| 23:52 | Cark | but i don't like to have these stack manipulation words in the code |
| 23:53 | gnuvince_ | Factor *is* nice, but I guess my brain's just not made for concatenative code |
| 23:53 | gnuvince_ | I guess I'll just you Haskell and (.) if I want point-free programming :) |
| 23:53 | gnuvince_ | s/you/Use/ |
| 23:54 | Cark | there definetly is some commonality between these 2 |
| 23:55 | Cark | (-> data action1 action2 action3) |
| 23:55 | Cark | there's a stack in there too |
| 23:56 | Cark | (-> data action1 (action2 avalue) action3) |
| 23:56 | Cark | what if the parameter that should be passed to avalue was in second position ? |
| 23:56 | Raynes | I love everything about Factor, besides the fact that the creator makes this wonderful language and can't even write something of a comprehensive introduction to the language to help people learn it. :\ |
| 23:57 | Cark | (-> data action1 (switch action2 avalue) action3) |
| 23:57 | hiredman | doesn't work |
| 23:57 | Cark | (-> data action1 ((switch action2 avalue)) action3) |
| 23:57 | Cark | ! |
| 23:57 | hiredman | -> is a macro so it happens before the function switch |
| 23:57 | Cark | how about that last form ? |
| 23:58 | hiredman | it might |
| 23:58 | hiredman | clojurebot: pl? |
| 23:58 | clojurebot | have you heard about the bird? is<reply>The bird, bird, bird, the bird is the word. |
| 23:58 | hiredman | clojurebot: transform |
| 23:58 | clojurebot | transform is http://github.com/hiredman/odds-and-ends/blob/8a84e6ddbad9d71f714ba16c3e1239633228a7eb/functional.clj |
| 23:58 | hiredman | I have a few odds and ends there |
| 23:58 | hiredman | uncurry and flip |
| 23:59 | Cark | ah flip that's the correct name ! |
| 23:59 | Cark | uncurry ....i don't understand that one |
| 23:59 | hiredman | ,(doc pl) |
| 23:59 | clojurebot | "([& forms]); replaces a $ b with (a b) walking right to left replaces a � b with (comp a b) left to right ?a with (uncurry a) left to right ?a with (flip a) left to right" |