#clojure log - Oct 14 2009

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

2:49 piccolino: Is anyone here familiar with the administration of clojure-contrib?

2:52 mudphone`: Anyone know if it's possible to start up a REPL and automatically "use" a library?

2:53 jdz: -e option

2:54 like, java -cp path/to/clojure.jar clojure.main -e "(require 'your.lib)"

2:54 mudphone`: great, are those options listed somewhere?

2:54 jdz: java -cp path/to/clojure clojure.main --help or something

2:54 mudphone`: ah

2:54 jdz: thanks!

2:55 jdz: mudphone`: have fun!

2:55 mudphone`: -i seems to be for loading an init path (file or resource)

2:56 jdz: mudphone`: yes, you're right.

3:00 mudphone`: except that in -i case you have to supplay a path, instead of relying on require finding stuff in CP

3:00 mudphone`: jdz: ah, good point

3:00 jdz: mudphone`: or maybe -i accepts what require accepts. must check the source...

3:00 mudphone`: was about to do -i, but would have eventually been tripped up

3:02 seems the advantage of -e is that you don't have to worry about the location of the file loaded via -i

3:11 now, if I could just get bash to escape my quotes correctly

3:13 LauJensen: Morning gents

3:15 mudphone`: morninig

3:15 and morning

3:36 Fossi: hi

3:36 mudphone`: yo

3:36 maacl: When going through a vector of elements using map (or a list comprehension)is there a way of getting at the values of other elements in the vector relative(e.g. the preceding or next) to the element being processed?

3:37 AWizzArd: Moin Fossi

3:37 mudphone`: you could take multiple args at a time

3:37 LauJensen: maacl, there are a few tricks, one of them being (map foo s (next s)) for getting the next value

3:37 AWizzArd: Hi the Lau.

3:37 LauJensen: Hola andré

3:39 maacl: LauJensen: thanks

3:44 LauJensen: np

5:17 octe: can i not use println from an agent function?

5:17 or is it just a repl issue perhaps?

5:18 hiredman: you can, sure

5:19 octe: strange

5:19 (def ag (agent ""))

5:19 (send ag (fn [x] (println x) (str "a" x)))

5:19 nothing gets printed in the repl

5:19 the @ag gets set correctly

5:20 hmm

5:20 i take that back, works in the normal repl.. not just when i'm running slime

5:21 rottcodd: octe: (add-hook 'slime-connected-hook 'slime-redirect-inferior-output)

5:21 octe: rottcodd: thanks, i just noticed it went to the the inferior bufer

5:21 instead of teh repl buffer

5:21 is that because agents are run in a seperate thread?

5:26 rottcodd: octe: I think so, println from gui threads has the same problem

5:48 octe: i want to initialize a struct where some of the fields depends on the previous fields.. is there a cleaner way than nesting a lot of lets?

5:49 Chousuke: let is serial

5:49 octe: can you give an example?

5:49 Chousuke: so just do (let [a 1 b (stuff a) c (stuff b)] (struct thestruct a b c))

5:50 octe: ah

7:25 doseq does recur internally?

7:31 Fossi: (source doseq) tells me yes

8:24 octe: can i update a let-variable?

8:25 chouser: octe: nope, they're immutable

8:26 octe: you can rebind a loop local to a new value when you call 'recur'

8:26 octe: alright

8:26 chouser: or you can shadow an old local with a new one of the same name

8:43 octe: i'm writing some code to parse a string, and i'm having hard time figuring out how to write it in an idomatic clojure way

8:44 i've written some java code that illustrates how i want to parse it.. http://pastebin.ca/1619263

8:44 perhaps someone can point me in some direction?

8:45 simple space-delimited string, but with positions depending on what it starts with..

9:05 hoeck: octe: maybe this helps http://pastebin.ca/1619296

9:07 octe: we also have a lisppaste bot in here, maybe you can use it for your next pastes

9:07 lisppaste8:

9:07 lisppaste8: url

9:07 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

9:11 octe: hoeck: nice :)

9:12 i'll use the lispt paste in the future

9:12 just used to pastebin.ca

9:31 snowwhite: ping

9:31 octe: pong

9:32 snowwhite: octe, I have a list '(1 2 3) and i want to make it "1_2_3" in clojure. Any simple way to do that?

9:33 LauJensen: ,(apply str (interpose \_ '(1 2 3)))

9:33 clojurebot: "1_2_3"

9:33 LauJensen: sorry octe :)

9:36 snowwhite: LauJensen, Thanks :)

9:36 LauJensen: np

9:36 octe: LauJensen: hehe, i wouldn't have known the answer anyway :-)

9:36 LauJensen: phew - I was afraid I pulled a 'cgrand' on you :)

9:37 octe: i don't know what that is, but it sounds scary

9:38 LauJensen: it's kinda scary :)

9:39 octe: i have a sequences of strings and if one of the elements starts with ":" i want to join it with the elements after it

9:39 cgrand: LauJensen: I'm not a 1-liner fetichist

9:39 octe: ("a" "b" "c" ":d" "e") -> ("a" "b" "c" ":de") for example

9:39 LauJensen: see, even that was one line ^^

9:39 :)

9:39 octe: can't figure out a good way to do it..

9:40 LauJensen: take it away, cgrand.... :)

9:42 cgrand: ,(let [[a b] (split-with #(not= \: (first %)) '("a" "b" "c" ":d" "e"))] (concat a [(apply str b)]))

9:42 clojurebot: ("a" "b" "c" ":de")

9:43 ngoc: Hi, clojure-maven-plugin is for compiling, clojureshell-maven-plugin is for REPL, is there a plugin for maven that support running .clj files without having to compile?

9:44 LauJensen: nice

9:45 octe: cgrand: nice!

9:47 LauJensen: For those who read my blog there's a new post up http://blog.bestinclass.dk/index.php/2009/10/python-vs-clojure-evolving/

9:49 Chousuke: I wonder, do they really promote python as suitable for concurrent applications? :P

9:49 LauJensen: Yea

9:50 octe: does leave an empty string if there's not an element with : in it though

9:50 Chousuke: I suppose some of the non-GIL implementations of python might be okay

9:50 LauJensen: Like Jython ? :)

9:51 Yea it's possible to bend it in that direction, but you get as much help as when using gcc :)

9:52 cypher23: LauJensen, don't forget fork. Take, for example, Unicorn, which is a fast web server with high concurrency, even though Ruby has GIL as well (AND green threads): http://unicorn.bogomips.org/

9:52 chouser: ,(for [[[p] t n] (partition 3 1 (cons nil '("a" "b" "c" ":d" "e" ":f" "g"))) :when (not= p \:)] (if (= (first t) \:) (str t n) t))

9:52 clojurebot: ("a" "b" "c" ":de" ":fg")

9:53 Chousuke: LauJensen: you really need to learn to use the apostrophe correctly :)

9:53 LauJensen: Chousuke, Again!?

9:53 Somebody actually emailed me a ton of examples from my posts where I had misused it (and I had done so per the advice of an American), so I went and corrected every single one, and now you're complaining?!

9:53 Chousuke: "Clojures" and "pythons" are in plural, you need to write "Clojure's" and "Python's" :P

9:54 LauJensen: Clojure's = Clojure is

9:54 Chousuke: no

9:54 LauJensen: That's what the guy told me :)

9:54 Chousuke: well, yes

9:54 octe: Chousuke: clarification of specification, it should stop at the first : and combine the rest :)

9:54 ("a" "b" "c" ":de:fg") in your example

9:55 chouser: oh. pfft. so cgrands was closer

9:55 Chousuke: Clojure's can be both "Clojure is" or the genitive of Clojure

9:55 in formal writing it's the latter because you're not supposed to use contractions

9:55 cemerick: 's generally indicates the possessive, and only colloquially indicates a contraction

9:56 LauJensen: cemerick, excuse me while I decrypt your message

9:56 chouser: the big exception there being "it" which has its own rules

9:56 octe: Chousuke: yup, badly written specification i suppose

9:56 Chousuke: I think this is a common error for Swedish/Danish/Norwegian people because the possessive in those languages doesn't have the apostrophe :/

9:56 cemerick: contractions are fine, but the 's contraction is definitely not common when writing.

9:57 LauJensen: you're Dutch, right?

9:57 LauJensen: Ok, so you guys are saying use 's at all times :)

9:57 cemerick, I may sound dutch, but I'm Danish :)

9:57 cemerick: ah, my apologies :-)

9:57 LauJensen: np

9:57 Chousuke: LauJensen: not for "its" though :)

9:57 cemerick: LauJensen: 's is really only appropriate for possessives in writing

9:57 LauJensen: oh ok

9:58 so it's borderline slang when I use it for contraction ?

9:58 cemerick: right

9:58 LauJensen: *sigh*

9:58 chouser: I wonldn't go that far.

9:58 LauJensen: I wish my mother would have taught me

9:58 chouser: It seems to be that's a stretch.

9:59 LauJensen: well, she should have said something :)

9:59 Chousuke: Well, a blog post on the internet is probably semi-formal

9:59 LauJensen: I'll go through it again, thanks guys

9:59 Chousuke: so contractions might be okay

9:59 cemerick: I think that's fair w.r.t. writing. I don't think I'd ever write "The clojure language's great."

9:59 chouser: that was for you :-)

9:59 Chousuke: cemerick: but you might write "it's great" instead of "it is great", no?

10:00 cemerick: ah, well, as chouser said earlier, 'it' is special :-D

10:00 chouser: cemerick: but you just use it for "that's"

10:00 hm

10:00 but I agree "clojure's great" doesn't feel right.

10:01 cemerick: I'm guessing 'that', 'who', 'they', etc., all fall into the same basket as 'it' in this regard.

10:01 I'm sure there's a proper term for that part of speech.

10:01 LauJensen: But you see why this isn't intuitive for us foreigners? :)

10:01 eevar2: clojure's great what? ;)

10:02 cemerick: s/speech/grammar :p

10:02 cemerick: LauJensen: oh yeah, English is rough, no doubt.

10:02 chouser: LauJensen: trying to help my 2nd-grader learn to spell these days. I have no illusions that English makes any sense.

10:02 cemerick: eevar2: ooh, don't start with me... ;-)

10:02 Chousuke: LauJensen: your language is too similar so English

10:03 LauJensen: Good

10:03 Chousuke: I'm Finnish so I can't even make the mistake of thinking that English might work like my own language ;(

10:03 LauJensen: Yea I know Sukichou

10:04 Couldn't we just agree on using Japanese? Once you have the spitting, the violent gestures and the angry face down, it is a walk in the park from there on out... oh wait, I'm thinking of Korean

10:04 Chousuke: in Finnish the apostrophe is only used with the possessive if the name is not pronounced like it's written :P

10:04 which only happens with foreign names. :)

10:05 eevar2: cemerick: would they be pronouns, btw?

10:06 cemerick: well, he/she/they/it, sure, but 'that'?

10:06 I suppose so, intuitively, anywya.

10:07 arbscht: 'that' can be a pronoun (demonstrative)

10:07 chouser: but 'this' is a pronoun and the contraction is rarely written there because everyone's uncertain about the rule.

10:07 cemerick: Ah cahn't be bothured wuh gammr an' all dat junk, anyhow.

10:07 chouser: "this's" or "this'"?

10:08 cemerick: any word that ends with 's' has a dangling apostrophe. I got that drilled into me after writing "Chas's" in kindergarten.

10:09 chouser: cemerick: oh, really? I thought it was more subtle than that.

10:09 cemerick: Maybe everyone's been lying to me...but that's one of the most constant rules I know of.

10:10 LauJensen: cemerick, we have the same rule in danish

10:10 cemerick: or, of which I know. Now I'm all self-conscious about my dangling prepositions.

10:10 chouser: http://alt-usage-english.org/excerpts/fxwheret.html

10:11 singular possesive noun that ends in "s" still gets a full "'s" on the end.

10:11 unbelievable

10:12 cemerick: that's absurd. "class's"?!?

10:12 Maddas: Yes

10:12 Hmm...

10:12 I believe that's only one of several accepted ways to form the possessive for nouns that end on 's', though.

10:13 eevar2: you chug an 'e' in there in some cases, no?

10:13 cemerick: That just looks wrong, through and through. I'd never be caught dead writing that.

10:13 chouser: oh, weird. I don't think I've ever seen a dangling ' after a non-"s" though. "patience'"

10:13 * Maddas doesn't plan to be writing and dead at the same time

10:15 Maddas: Hm, actually, I think I was wrong -- the only exceptions I can think of are names.

10:19 chouser: sooo... back on topic. Does this function exist somewhere?

10:19 (defn rename-key [m oldk newk] (-> m (dissoc oldk) (assoc newk (m oldk))))

10:22 Fossi: german even has three s words nowadays

10:23 LauJensen: haha

10:31 cemerick: chouser: no, I don't think so

10:33 cgrand: chouser: clojure.set/rename-keys

10:36 chouser: ah! thanks, guys.

10:37 cemerick: I never would have thought to look in set.

11:09 AWizzArd: ,(re-find (re-matcher #"--" "clojure--123"))

11:09 clojurebot: "--"

11:09 AWizzArd: ,(.matches (re-matcher #"--" "clojure--123"))

11:09 clojurebot: false

11:09 snowwhite: How do i write != in clj?

11:10 AWizzArd: Who spots the problem?

11:10 snowwhite: not=

11:10 chouser: snowwhite: not=

11:10 snowwhite: AWizzArd, chouser Thanks :)

11:10 chouser: AWizzArd: my guess is that .matches requires the regex match at the start of the string

11:11 fail

11:11 AWizzArd: Does Contrib have something like Strings indexOf function, but giving me the index(es) inside a string for a regex?

11:12 chouser: oh, the *entire* string. not just from the begining, but also all the way to the end.

11:13 AWizzArd: ,(.indexOf "clojure--123" "--")

11:13 clojurebot: 7

11:14 AWizzArd: this would be enough

11:14 but with "--" being a regex

11:14 chouser: ,(.indexOf "clojure--123" (str #"--"))

11:14 :-)

11:15 clojurebot: 7

11:15 AWizzArd: Not bad would be (indexes-of "a--b--c" #"--") ==> [1 4]

11:16 I guess there is nothing like that already included in the jvm and respectively contrib

11:19 chouser: ,(let [m (re-matcher #"-" "xx-xxxx-xxx-xx-xxxx-")] ((fn step [] (lazy-seq (when (.find m) (cons (.start m) (step)))))))

11:19 clojurebot: (2 7 11 14 19)

11:19 cgrand: AWizzArd: .find then .start

11:19 chouser: just like re-seq

11:19 AWizzArd: ,(.start (re-matcher #"--" "clojure--123"))

11:19 clojurebot: java.lang.IllegalStateException: No match available

11:19 AWizzArd: ah okay, first .find

11:19 ,(.find (re-matcher #"--" "clojure--123"))

11:19 clojurebot: true

11:20 AWizzArd: ,(let [m (re-matcher #"--" "clojure--123")] (.find m) (.start m))

11:20 clojurebot: 7

11:20 AWizzArd: good, thanks

11:21 chouser: hm, re-seq could take an optional Matcher mapping fn that would default to re-groups

11:23 AWizzArd: yes

11:35 Hi stuartsierra. I noticed several reflection warnings in duck-streams. The .close call couldn't be resolved, for example in (binding [*default-encoding* "UTF-8"] (with-out-append-writer "/foo.txt" (println "Hi")))

11:37 chouser: AWizzArd: doing some high-performance closing?

11:39 AWizzArd: no, but I often C-c C-k in slime when I make changes in in my code. And this spams my repl with reflection warnings :)

11:41 chouser: btw, why is lazy-seq in the source of re-seq before the when and not inside? (lazy-seq (when (. m (find)) ...)) vs. (when (.find m) (lazy-seq ...))

11:42 chouser: AWizzArd: that's idiomatic for lazy-seq

11:43 in this case, don't do the work of searching for the next match (and possibly discovering there isn't any) until that item is required.

11:43 AWizzArd: Aren't both versions equivalent?

11:43 chouser: no

11:44 Chousuke: the first version only evaluates the (.find m) if it's needed

11:48 AWizzArd: ok, that makes sense

11:49 konr: how can I deliver my product?

11:49 hmm, better put:

11:49 chouser: konr: I recommend providing a place to download it on the internet.

11:49 :-D

11:50 konr: How can I pack it with an installer and required libraries? Is there a default way of doing that?

11:50 AWizzArd: konr: you could write an ant script which will compile all you want into a .jar file which you can then distribute.

11:50 You can use distribute this .jar file with http://izpack.org/

11:50 ~max people

11:50 clojurebot: max people is 184

11:51 konr: amazing!

11:52 licoresse: so many lurkers :)

11:53 riddochc: but if I said why I'm lurking, I wouldn't be lurking anymore, would I?

11:54 konr: it's more than 50% of #lisp's 300 users

11:54 chouser: riddochc: perhaps you could speak for a majority of the other lurkers, allowing them to remain lurking.

11:56 rys: hehe

11:56 Some of us lurkers are actually avid readers, we just don't say much ;)

11:56 * rys gets back to lurking

11:58 chouser: rys: are you dabbling at all in Clojure? Or just picking up background here for eventual use?

11:59 rys: Yeah, I use it

11:59 In production too, and for playing

11:59 chouser: rys: excellent.

12:00 cemerick: what's the hotness in clojure web services?

12:00 * cemerick is stepping way outside of his game

12:01 chouser: dunno if it's hot, but I'm using ring and it's been nice.

12:01 stays entirely out of my way

12:02 AWizzArd: cemerick: what do you mean?

12:03 Are you looking for a good framework for RESTful webservices? That would be Compojure.

12:03 cemerick: it's nice that most if not all clojure libs are on github

12:03 stuartsierra: it's almost like a solid foundation of a package repo! :-P /me ducks

12:04 AWizzArd: doesn't compojure drag along yet another sexpr-based templating language?

12:04 chouser: looking at ring now, thanks

12:05 chouser: BTW, you may not know it, but your use of something may be a leading indicator of 'hotness'

12:05 chouser: ha! right.

12:06 cemerick: ooh, ring uses apache's httpcore. That's promising.

12:06 ...and it also comes along with an sexpr templating language. Oh bother.

12:07 chouser: what? where?

12:07 cemerick: I see clj-html as a dependency.

12:09 chouser: oh, it desn't have its own. I don't use that, whatever it is.

12:09 snowwhite: cgrand, http://atifhaider.com/blog/2009/10/14/sieve-of-eratosthenes/

12:09 AWizzArd: cemerick: Compojure includes ring. And you don't need this html macro of Compojure. I never use it.

12:10 snowwhite: cgrand, my version on find primes.

12:10 AWizzArd: cemerick: you can spit out anything you like for your webservices. May be xml. Could be Clojure. I am producing json.

12:11 cemerick: your Compojure program could at the same time provide websites, files, answer REST requests and answer xml-rpc requests.

12:12 cemerick: I'll have to give it a second look.

12:12 AWizzArd: though rest vs. xml-rpc is a different paradigm, it's just that Jetty (included in Compojure) can be used for xmlrpc.

12:12 snowwhite: cgrand, ping

12:14 cgrand: snowwhite: pong

12:15 snowwhite: cgrand, the problem with my version is it works fine for 1000 numbers but fails([Thrown class java.lang.StackOverflowErro) on 10000?

12:15 cgrand: indeed: you are stacking filters

12:16 stuartsierra: cemerick: it *would* be a package repo if any one on github made numbered releases

12:17 technomancy: corkscrew can check clojure projects out of github and use them as dependencies.

12:17 but yeah, it's a lot more useful if people use tags

12:17 cemerick: stuartsierra: I wonder if hashes are good enough. Not so human-readable, but nice for computers.

12:17 cgrand: to get the next prime (first lts), clojure will call the nested filters

12:17 snowwhite: cgrand, hmm, Any nice suggestion?

12:18 stuartsierra: Hashes aren't good enough; a release promises some degree of "this should work as advertised."

12:18 cgrand: and at some point you have too many filters (one per prime already found),

12:19 riddochc: Well, speaking for myself, I'm hoping to pick up on the wisdom while I code, so I might learn the clojure way, since it seems a little different from the CL way.

12:19 It's possible some of the lurkers here who are also on #lisp are doing the same, but either knowing the CL way or the Scheme way.

12:20 cemerick: stuartsierra: Aren't releases/tags are orthogonal to hashes w.r.t. enabling automated retrieval, etc.?

12:20 cgrand: snowwhite: besides "don't do that"? Seriously, in Clojure, don't write code that indefinitely stack filter/map/remove or you'll get stack overflows.

12:20 cemerick: i.e. git submodules are a "good enough" mechanism, though they are pretty opaque to a human.

12:20 snowwhite: cgrand, hmm

12:20 technomancy: cemerick: sure, you just have to test non-released revisions a lot more by hand before you decide on one.

12:22 cemerick: technomancy: the selection of a revision can be done by tags if they're available, but after that, all of the tracking can be purely hash-driven.

12:22 technomancy: cemerick: ah, I see what you mean. Yes, that works.

12:22 cgrand: snowwhite: in that case, it may be possible to skew lazy evaluation by 1. Do you have the code somewhere I can copy/paste it?

12:23 ~paste

12:23 clojurebot: lisppaste8, url

12:23 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

12:23 cemerick: Besides, can't tags get moved in git without disturbing hashes?

12:23 (not that version IDs and such don't point to different binaries in *every* repo all the time)

12:24 technomancy: right, but if it gets moved, odds are you're going to want the new one. =)

12:24 snowwhite: cgrand, here it is http://paste.lisp.org/display/88631

12:25 Chousuke: snowwhite: underscores! bad :-(

12:25 snowwhite: Chousuke, yeah! right. Sorry will take care :)

12:26 Chousuke: call it "not-divisible?" or something

12:26 cemerick: technomancy: really? I've gotten badly burned by someone pushing v1.4.3a (or whatever) of something into an ivy repo, and then updating with new binaries under a different rev number later.

12:27 technomancy: cemerick: I guess it's possible

12:29 cgrand: snowwhite: thanks, can't find a quick fix. Really don't write this kind of code. Did you read http://clj-me.cgrand.net/2008/06/07/primes/#comments ?

12:30 riddochc: So, has anyone used clojure to make something meant to run in a browser's java plugin? I'm not much of a java person, I'm just curious what's involved.

12:30 snowwhite: cgrand, ok

12:34 cgrand: snowwhite: using something like (some #(zero? (rem n %)) potential-divisors) is the easier alternative to piling filters.

12:36 replaca: riddochc: it's a current topic on the list. see: http://groups.google.com/group/clojure/browse_thread/thread/aa62df2fe8705434/d0491f986aa8cacd#d0491f986aa8cacd

12:36 riddochc: Right, I should join the list already.

12:37 replaca: riddochc: you don't even really need to join. Just go to http://groups.google.com/group/clojure and browse around until you feel like posting something :-)

12:40 riddochc: replaca: I suppose you're right. Change sometimes comes slowly, y'know. ;)

13:10 blkutch: hi. what's the most efficient/clojureish way to calculate the values in this gist? http://gist.github.com/210183 I want to multiply alpha's :bom values with beta's costs.

13:11 i started to do it with a doseq but I don't think I understand how to use bindings to get to my final result.

13:11 I want a total of alpha's values * beta's costs

13:12 chouser: ,(merge-with * {:cherry 2 :apple 3 :orange 6} {:cherry 2.5 :apple 9185.25 :orange 2772})

13:12 clojurebot: {:cherry 5.0, :apple 27555.75, :orange 16632}

13:13 Chousuke: :)

13:14 blkutch: so to iterate through the values, i'd use something like (merge-with * {(-> alpha :bom)} {(-> beta)})?

13:14 Chousuke: nah

13:14 don't think too complicated

13:14 you want to merge the value of the :bom key with the beta map

13:14 so (merge-with * (:bom alpha) beta)

13:15 blkutch: will it work if beta has more values than alpha?

13:15 Chousuke: yes.

13:15 blkutch: so it just essentially does the lookup

13:15 what is the error that results if an item isn't in the lookup? or is no error resulting?

13:16 chouser: I wish I could alias Java package names and maybe even outer class names.

13:16 blkutch: check the docs for merge-with

13:16 Chousuke: ,(merge-with + {:a 1 :b 2} {:a 10 :b 20 :c 30})

13:16 clojurebot: {:c 30, :a 11, :b 22}

13:16 blkutch: will do, thanks

13:16 chouser: blkutch: it only does the operation (* in this case) if the key is in both maps

13:16 blkutch: ah, interesting

13:17 chouser: otherwise it just uses the value of which map has a value

13:17 Chousuke: that means though that if you have a key in the bom map from which there is no corresponding val in the beta map, you'll get the bom value in the result :P

13:18 blkutch: yeah, have to find a way to catch that

13:18 chouser: as if the cost were 1

13:18 blkutch: but better than doseqing it all together

13:18 Chousuke: blkutch: you could make the bom values be something that would cause exceptions when used as an integer.

13:19 that'd complicate your merge-with function though.

13:20 a variant of merge-with allowing you to decide what to do with keys that are not shared might be interesting :/

13:21 chouser: I think that's called 'reduce' :-)

13:21 Chousuke: hmm :)

13:22 blkutch: this is weird though

13:22 can't I do (merge-with + (merge-with ...))

13:22 Chousuke: yes you can

13:23 blkutch: I must have a weird syntax error then

13:23 when I do the test, I get the right values for everything multiplied, in a list

13:23 Chousuke: though be aware that merge-with allows more than two maps

13:23 in a list?

13:23 chouser: blkutch: you want them summed together?

13:23 blkutch: e.g. :cherry 500, :apple 500

13:23 yeah

13:24 the multiplication worked, but now I want everything added

13:24 chouser: ,(reduce + (vals (merge-with * {:cherry 2 :apple 3 :orange 6} {:cherry 2.5 :apple 9185.25 :orange 2772})))

13:24 clojurebot: 44192.75

13:24 Chousuke: (apply + (vals (merge-with * ...)))

13:24 blkutch: what is the difference between the two?

13:24 chouser: in this case, nothing.

13:25 if + supported only two args, you'd have to use reduce.

13:25 if you're using something like 'str', apply is more efficient.

13:27 blkutch: goddamn.

13:27 clojure is so full of awesome.

13:27 thanks :)

13:27 Chousuke: (into {} (for [k (keys (alpha :bom)) :let v (beta k) :when v] [k (* (k (:alpha bom)) v)])) ; a slightly more verbose version

13:28 that doesn't have the problem of using the :bom value if the beta map doesn't contain the thing

13:28 though.

13:28 I wonder if I can use :let and :when like that :D

13:29 chouser: :let [v (beta k)] ... but yeah, that's the point of :let, to allow you to then guard with :when or :while

13:30 Chousuke: actually if you're just looking for the sum it's a bit simpler

13:31 blkutch: ultimately, what will happen is i'll grab from a database a list of values, then throw them into :alpha, then calculate the cost.

13:31 except the database's values are never fixed and the components might be very different, and the component costs are calculated from another table.

13:32 so the component table has values like cherries cost 500, nuts cost 30000, ...

13:32 chouser: could probably do it all in a sql select.

13:32 blkutch: well, #1, I don't plan on using sql, #2, the user will supply variables via compojure.

13:32 chouser: ah, ok.

13:32 blkutch: nosql w/ cassandra

13:32 probably

13:32 not sure yet

13:32 just want to get the logic understood and working

13:37 the reason I was missing merge-with because it wasn't in the article i'm learning clojure from (http://tinyurl.com/d3lksz)

13:38 chouser: interesting. that's a truely substantial piece of work. I'm not sure, though, how thoroughly reviewed it's been.

13:39 I imagine the author would be grateful for input from you about anything incorrect or missing you discover as you work through it.

13:39 rstehwien: chouser: the article is pretty good. I bounce between it, the api, and the code. One thing I wish the code docs had were examples of use (I've seen many API docs that do)

13:39 blkutch: well, I think he intended it to be more of an introduction, and since now there's at least one book and a couple of others on the way, probably outdated

13:39 rstehwien: yeah, the docs for clojure are terrible

13:40 rstehwien: blkutch: the author updated 10/12

13:40 blkutch: if you don't know lisp or don't understand FP, they're 100% useless

13:40 chouser: there have been many calls for api examples. I think there's even a wiki with quite a few ... somewhere...

13:41 snowwhite: I have a datetime obj #<Date Wed Oct 14 00:00:00 IST 2009> and i want to convert into string using http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html?

13:41 rstehwien: chouser: I've been tempted to offer improving code docs with an example as a learning exercise

13:42 chouser: http://en.wikibooks.org/wiki/Clojure_Programming/Examples/Cookbook think there is another too

13:42 chouser: rstehwien: I think rhickey has generally resisted having pervasive examples in the docstrings, perhaps just because of the added verbosity in the .clj files.

13:42 a very few do have examples though, so I'm not sure.

13:42 ,(doc for)

13:42 clojurebot: "([seq-exprs body-expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more modifiers, and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. Supported modifiers are: :let [binding-form expr ...], :while test, :when test.

13:42 drewr: Date -> YMDString: http://gist.github.com/210248

13:42 chouser: eh. clojurebot cut it off before the example.

13:43 drewr: snowwhite: For example ^^^

13:43 chouser: well, irc cut it off I suppose.

13:44 rstehwien: chouser: adding an example like the following is so helpful http://livedocs.adobe.com/flex/3/langref/mx/controls/Button.html#includeExamplesSummary

13:45 (was a C++ then Java then C# and now AS dev... don't like AS3 much but it is a living... get more satisfaction from clojure lately)

13:47 chouser: I ran the (doc for) in my repl and it is helpful to have that example. It would be a pain to do it for all of them, but a great learning experience I'm sure.

13:48 chouser: docs need examples and some organization to subject matter rather than alphabetical... the cheat sheet is great in that respect

13:48 But I mostly creep around in the codebase and do searches on github

13:48 chouser: yeah. find-doc is occasionally helpful.

13:49 the clojure.org pages for data structures and such do have groups of related functions. I hope someone finds that useful occasionally.

13:50 rstehwien: chouser: I do. Forgot how often I hit the data structures page as well

13:50 steiger: chouser: i do \o

13:50 but i agree clojure needs better documentation. including better examples

13:50 drewr: steiger: it's still young

13:50 chouser: ok, good to know. some day will have to look at getting links to work for the punctuationful names.

13:51 steiger: drewr: yeah, i know

13:52 Notfonk: hi there

13:52 i need to download some files from within a clojure script under linux

13:52 wich way would you do that, so it's clean ?

13:53 chouser: Notfonk: depends on how featureful/robust you want it to be.

13:53 technomancy: Notfonk: the duck streams library from contrib would be simplest

13:54 Notfonk: It's a script that has to download around 100 files from my website during the day

13:54 the files uris are determined by a script that already exists

13:54 no parralel downloads

13:54 chouser : looking into duck streams, thanks

13:55 i don't know if that was clear, but i just need to save them on disk

13:55 no processing inside of clojure

13:57 duck-streams looks very low level for what i need

13:57 shall i only do an external call to wget and be set N

13:57 ?

13:57 chouser: not a terrible idea (see contrib shell-out), but I think apache commons has a lib that might help too

13:58 rstehwien: notfonk: I know I saw a blog post on downloading files recently. Just trying to find it.

13:58 Notfonk: thanks :)

13:59 rstehwien: notfonk: probably overkill and not the blog post but here is a web crawler http://github.com/heyZeus/clj-web-crawler

13:59 Notfonk: meanwhile i'm cooking a downloader with wget and clojure.contrib.shell-out

13:59 technomancy: Notfonk: duck-streams includes low-level functions, but is not all low-level

14:00 for instance, you can do something like (copy (reader "http://clojure.org") (writer "/tmp/clojure.org.html"))

14:00 Notfonk: ah great !

14:01 but what is the advantage compared to an external wget

14:01 in your opinion ?

14:01 rstehwien: notfonk: wget not cross platform if that is a goal

14:01 Notfonk: it's not, i'm not really doing a full blown app

14:02 just a convenience script

14:02 technomancy: Notfonk: more idiomatic I guess. both will get the job done.

14:02 Notfonk: but well i guess it'd be better if i can run it on windows

14:02 ok

14:02 thanks guys

14:03 rstehwien: technomancy: thanks for the duck-stream copy example... pretty handy

14:03 Notfonk: and technomancy: thanks again for helping me a few days ago with emacs/slime and all

14:03 i'm really loving the emacs + clojure experience :)

14:03 technomancy: great!

14:04 bballantine: Notfonk, I am shy of calling shell commands from the JVM...

14:04 general lack of control (typically spawns a new process and gives you a handle to stdin and stdout and a process ID) and just seems... dirty ;-)

14:05 I'm unfamiliar w/ Duck streams, but I would go with that or build in Java HTTPConnection

14:06 Notfonk: i'm currently trying it with duck streams

14:06 the advantage i have with wget is i don't have to parse the filename from the uri

14:06 but that's a small regex away so it's no big deal

14:07 technomancy: (copy (reader uri) (writer (last (.split uri "/")))) ;; <= thereifixedit.

14:07 =)

14:07 bballantine: :)

14:07 Notfonk: ha :D

14:07 i used re-split to do the same thing

14:07 is .split faster btw ?

14:07 technomancy: probably a bit

14:08 Notfonk: thanks :)

14:08 riddochc: Isn't clojure just awesome for golf?

14:26 licoresse: When I am at the repl (slime) and have just (use 'some.thing), how can I programmatically list all functions?

14:35 stuartsierra: new Clojure/Maven archetype, using 1.1 plugin: http://github.com/stuartsierra/clojure-archetype

14:35 licoresse: maybe this is not possible :(

14:35 chouser: licoresse: (keys (ns-publics 'some.thing))

14:36 licoresse: ok

14:36 but (keys (ns-publics *ns*)) responds to nil

14:36 even if there are defn's there

14:36 Chousuke: licoresse: it takes a symbol apparently

14:37 chouser: ,(keys (ns-publics *ns*))

14:37 clojurebot: (foo)

14:37 * rhickey orders Maven book...

14:38 Chousuke: oh, and *ns* is not your 'some.thing

14:39 licoresse: oh, I see

14:39 that makes sense

14:40 stuartsierra: rhickey: there's a free maven book online, pretty good

14:40 http://www.sonatype.com/products/maven/documentation/book-defguide

15:26 tomoj: does anyone have that link on how to connect slime to an already-running clojure? can't seem to find it

15:27 stuartsierra: tomoj: the Clojure needs to be running swank server, then run M-x slime-connect in Emacs

15:27 tomoj: right

15:27 but I found some link once on how to start the swank server, now it's gone :(

15:35 stuartsierra: look for the start-server command in the swank-clojure sources, I think

15:47 tomoj: stuartsierra: thanks, that worked

15:47 stuartsierra: welcome

15:48 gaz: not sure if you're talking to me? but hi stuart

15:48 stuartsierra: was talking to tomoj; hi gaz

15:49 gaz: :)

16:39 ambient: one thing i miss in clojure is polymorphism according to type

16:40 dont know how to achieve that in a consistent way using lisp :/

16:40 steiger: ambient: multimethods?

16:40 ambient: guess i have to read more about them then

16:41 steiger: ambient: check the official docs and this blog post: http://www.fatvat.co.uk/2009/01/multi-methods-in-clojure.html

16:41 Chousuke: no need to limit yourself to types with multimethods :)

16:42 steiger: yeah, off course :)

16:42 konr: speaking of multimethods, is there a (doc)-like function to check out the defmethods?

16:42 ambient: there's no way i can use +, - etc arithmetic to process my self defined types?

16:42 like vectors, matrices etc

16:42 tomoj: no, those are functions

16:42 steiger: konr: i think multimethods don't have docs. only their defmulti. and i guess you can check them normally with doc

16:43 tomoj: you could make a generalized plus perhaps

16:43 ambient: done that already

16:43 steiger: ambient: well, you can define your own +, but then you would have to exclude the existing +, -, etc, from oyur namespace

16:43 Chousuke: ambient: + calls down to java as it is now

16:44 making it a multimethod would make it way too slow.

16:44 tomoj: ++ seems available

16:44 Chousuke: contrib has generic math though

16:44 ambient: this is what im doing atm: http://paste.pocoo.org/show/144985/

16:45 hiredman: http://gist.github.com/209643 anyone know what this is about?

16:46 steiger: ambient: i didn't get your intentions, but maybe it's because i'm quite slow right now

16:46 ambient: tomoj i cant define // i think, because / is actual syntax

16:47 steiger to be able to (+ number lazy-seq-of-numbers) instead of (map + ...

16:47 tomoj: that's weird

16:47 ,'//

16:47 clojurebot: Invalid token: //

16:47 tomoj: why is it invalid, I wonder...

16:47 Notfonk: re there

16:47 ambient: System/getProperty

16:47 tomoj: oh, because it's for rationals

16:47 steiger: ambient: hm, i see.

16:47 Notfonk: i hate a very strange problem with the (copy (reader "") (writer ""))

16:47 have sorry :D

16:48 Chousuke: symbols ending in / are not allowed

16:48 / is the only exception

16:48 Notfonk: it generates files 2 times too big

16:48 and unreadable

16:48 when i parse them from the internet

16:48 steiger: ambient: you could put your code in a ns with (ns) and exclude the local names +, -, ...

16:48 tomoj: also symbols beginning in / it seems

16:48 steiger: ambient: and then redefine it as you wish

16:52 hiredman: tomoj: / is for seperating namespaces

16:52 so using it in symbols allowed or not is a bad idea

16:53 ambient: seems too hackish for usage. i just use smul sadd sdiv etc

16:54 Notfonk: nobody has an idea for me ?

16:54 it seems that when i download html like that it works

16:54 but when i download files that are not strings it doesn't

16:55 so it must be an enconding problem i guess

16:56 hiredman: Notfonk: can you pastebin your code somewhere?

16:57 rstehwien: notfonk: wonder if duck-streams is making a string writer by default and you might need to coerce it to do raw bytes. Only a guess on my part

16:58 Notfonk: my code is easy enough

16:59 (copy (reader "http://www.ntslh.org/test.mp3") (writer "test.mp3"))

16:59 and that's the whole of it

16:59 rstehwien : how would i do that ?

16:59 steiger: ambient: yes, i agree. i would rather name them seq+, seq/, seq-.. but that's a matter of taste :)

16:59 rstehwien: notfonk: doing a quick peek at duck-streams

16:59 ambient: steiger i cant name them like that

17:00 Notfonk: i'm watching the source too

17:00 ambient: seg/ > error

17:00 steiger: oh of course

17:00 you can't use /

17:00 sorry

17:01 hiredman: ok

17:01 Notfonk: rstehwien : java.io.PrintWriter is encoding for string no ?

17:01 rstehwien: notfonk: Instead of passing in a string to the writer you might need to pass in a writer you create. Hold on one momemt

17:01 Notfonk: yeah i was thinking about that too

17:02 hiredman: reader and write are both for character data, I believe

17:02 and mp3 is bytes

17:02 Notfonk: absolutely

17:02 i found an old post mentioning a fix just now

17:02 i'll just create a java writer i guess

17:02 hiredman: no

17:03 use and inputstream and a outputstream

17:03 an

17:03 konr: is anybody using run-tests here? It's last call, (report), is always returning nil, and I cannot debug it, since I don't have access to its source code

17:03 Notfonk: hiredman : ok

17:04 rstehwien: notfonk: maybe try passing in (FileOutputStream. "test.mp3")

17:06 Notfonk: i created an outputstream

17:06 it's working

17:06 thank you guys very much

17:07 still i think it would be good to be able to select the type of the writer in the duck-streams fn

17:07 what do you think ?

17:09 hiredman: and outputstream is not a Writer

17:09 an

17:10 an OutputStream is not a type of Writer so have the writer producing fn named writer produce one would be odd

17:10 having

17:11 Notfonk: yeah i know what you mean

17:12 hiredman: it might make sense to have a outputstream fn

17:12 Notfonk: but a superior layer of abstraction for writing files would be good

17:12 i mean what i'm doing now is rather tedious

17:12 i'll take a shot at it

17:13 rstehwien: notfonk: this works (copy (reader "http://www.arcanearcade.com/Flex/SpeedTest/SpeedTest.swf") (writer (java.io.FileOutputStream. "test.swf")))

17:13 notfonk: be easy to write some code to encapsulate that

17:13 ambient: does (int) always truncate/floor?

17:15 seems like it

17:17 rstehwien: notfonk: with no import or use needed (defn download-file [url dst] (clojure.contrib.duck-streams/copy (clojure.contrib.duck-streams/reader url) (clojure.contrib.duck-streams/writer (java.io.FileOutputStream. dst))))

17:21 Notfonk: :D

17:21 rstehwien : didn't watch at the irc for a few minutes

17:21 did almost the same thing meanwhile tho

17:21 :)

17:22 but

17:22 your last fn is not working since you're using a writer,

17:22 you have to use the fileoutputstream directly

17:22 without wrapping it into a writer

17:23 rstehwien: teach me to paste without testing ;)

17:24 Notfonk: :)

17:24 ol3```: hello how do i add multible ignore/ingorable to a declaration

17:25 hiredman: eh?

17:25 ol3```: (declare (ignore sym)) and (declare (ignorable sym2))

17:25 can i pack them in one declare statement?

17:26 hiredman: ,(doc ignore)

17:26 clojurebot: Titim gan éirí ort.

17:26 hiredman: ,(doc ignorable)

17:26 clojurebot: It's greek to me.

17:26 hiredman: *shrug*

17:27 Notfonk: i love this bot

17:27 ol3```: omg, wrong channel

17:28 sorry folks

17:29 hiredman: ~botsnack

17:29 clojurebot: thanks; that was delicious. (nom nom nom)

17:46 mikehinchey: technomancy: are you planning to backport your use-fixtures patch to 1.0-compat? If not, I'll do it.

17:48 rstehwien: ,(doc send-off)

17:48 clojurebot: "([a f & args]); Dispatch a potentially blocking action to an agent. Returns the agent immediately. Subsequently, in a separate thread, the state of the agent will be set to the value of: (apply action-fn state-of-agent args)"

17:48 jevgeni: after installing clojure mode and running m-x slime I get the *inferior-lisp* buffer. Then, after pressing 3-4 times enter I am jumped to the *slime-repl clojure* buffer. Is it supposed to be that way?

17:50 Notfonk: jevgeni : you don't need to press enter, but the slime repl clojure buffer takes some time to load yes

17:51 technomancy: jevgeni: slime takes a moment to connect; you're probably just hitting enter while it's in process

17:52 mikehinchey: I'm not really using 1.0 any more, so it'd be great if you want to tackle that backport; thanks!

17:53 mikehinchey: ok

17:53 tomoj: is there a way to check whether a var is bound?

17:54 besides trying it and catching the IllegalStateException?

17:54 chouser: (.isBound #'foo)

17:54 tomoj: ah, thanks :)

17:58 jevgeni: technomancy, Notfonk: if I start the emacs, run the slime and press 'enters', then the buffer opens immediately. However, I have just restarted emacs and waited for few minutes to test - nothing happened. Could it be somehow related to the fact I am running emacs from windows?

17:58 technomancy: jevgeni: that _is_ pretty odd; I guess it is not what I thought at first.

17:59 it could be a Windows issue; I haven't heard of that happening myself.

18:01 jevgeni: okay, I see. thanks, I will dig futher..

18:02 wavis: ,(.isBound #'foo)

18:02 clojurebot: true

18:02 wavis: ,(.isBound #'foo-bar)

18:02 clojurebot: java.lang.Exception: Unable to resolve var: foo-bar in this context

18:02 wavis: ,(.isBound foo-bar)

18:02 clojurebot: java.lang.Exception: Unable to resolve symbol: foo-bar in this context

18:02 wavis: ,(.isBound 'foo-bar)

18:02 clojurebot: java.lang.IllegalArgumentException: No matching field found: isBound for class clojure.lang.Symbol

18:04 wavis: ,(with-local-vars [foo-bar 1] (.isBound foo-bar))

18:04 clojurebot: true

18:06 wavis: ,(if (find-var 'foo-bar) true false)

18:06 clojurebot: java.lang.IllegalArgumentException: Symbol must be namespace-qualified

18:08 lpetit: ,(ns-resolve *ns* 'toto/titi)

18:08 clojurebot: nil

18:09 hiredman: ,(resolve 'foo)

18:09 clojurebot: #'sandbox/foo

18:09 hiredman: ,(resolve 'bar)

18:09 clojurebot: nil

18:09 lpetit: better :)

18:09 hiredman: ,foo

18:09 clojurebot: 5

18:14 jensli: Decoupling polymorphism from data inheritance is a GoodThing, inablity to keep those two separated causes confusion for me right now in the java app Im trying to understand.

18:41 ambient: if i have symbol 'foo in aa like (def aa 'foo) how can i create a function (defn foo []... with referring to aa?

18:41 without actually redefining aa

18:45 AWizzArd: when I want to have one or more threads waiting some time until I want to notify them to continue, should i then use .wait or is there a mechanism in Clojure?

18:47 hiredman: ambient: eh?

18:48 AWizzArd: I'd use promise/deliver

18:48 ambient: hiredman something like this: (doseq [f {'smul * 'sdiv / 'sadd + 'ssub -}] (defn (f 0) [& a] (stemp (f 1) a)))

18:48 chouser: ambient: intern

18:48 ambient: (that doesnt actually work afaik)

18:48 hiredman: ugh

18:49 defn? in a doseq? horrible

18:49 ambient: whatever

18:49 hiredman: :(

18:50 AWizzArd: hiredman: i was more thinking of having several threads waiting (not burning cpu cycles) in a web application, while the connection stays open. And when some event occured i (.notifyAll of-them) to serve the still waiting clients.

18:50 ambient: i just have a bunch of generic functions which are defined in the same way, i'd like to avoid code repetition

18:50 chouser thanks

18:52 hiredman: AWizzArd: use a blocking queue

18:52 or an executor, or agents

18:55 so the blocking queue would be a communication channel to other threads

18:55 the other option is, instead of managing threads directly, you send-off an agent action to service the client

18:56 ambient: i wonder if this is the best way of introducing generic functions into the namespace: (doseq [f {'smul *, 'sdiv /, 'sadd +, 'ssub -}] (intern *ns* (f 0) (fn [& a] (stemp (f 1) a))))

18:59 AWizzArd: i see, thx

18:59 Dawgmatix: are the clojure docs available as a pdf ?

19:05 rstehwien: hiredman, AWizzArd: What about a watcher that waits for you to add something to a queue then performs an action ,(doc add-watch) or ,(doc add-watcher)

19:05 ,(doc add-watch)

19:05 clojurebot: "([reference key fn]); Experimental. Adds a watch function to an agent/atom/var/ref reference. The watch fn must be a fn of 4 args: a key, the reference, its old-state, its new-state. Whenever the reference's state might have been changed, any registered watches will have their functions called. The watch fn will be called synchronously, on the agent's thread if an agent, before any pending sends if agent or ref. Note tha

19:06 rstehwien: hiredman, AwizzArd: I also added a priority_queue that John Harrop posted to the mailing list recently to here http://github.com/rstehwien/clojure-utils/blob/master/src/main/clojure/com/arcanearcade/clojure/utils/priority_queue.clj

19:07 hiredman: rstehwien: depends on this that and the other

19:07 he hasn't mentioned needing a priority queue

19:07 rstehwien: hiredman: hehe true. But some of the code could be borrowed and repurposed.

19:08 hiredman: if all he is doing is job dispatching than an agent or an executor can be used just fine

19:10 rstehwien: hiredman: Would that be a java.util.concurrent.ThreadPoolExecutor or is there a clojure equivalent (peeking in the docs now)

19:11 hiredman: agents are built on executors

19:11 but yeah, j.u.concurrent

19:12 rstehwien: hiredman: John also wrote a class that will create a general agent to execute a given function on a timer

19:12 hiredman: :(

19:12 ScheduledThreadPoolExecutor

19:13 rstehwien: well not really a timer as the agent sleeps and resends to itself and can be started and stopped. I'll have to look at ScheduledThreadPoolExecutor

19:13 hiredman: ugh

19:14 gist code formating seems to be broken in firefox

19:14 http://gist.github.com/178350

19:14 and chrome

19:14 maybe gist broke

19:14 lame

19:15 when I pulled it via git the formating was good

19:15 rstehwien: I spy with my little eye hiredman.schedule in clojurebot schedule.clj

19:15 hiredman: indeed

19:16 rstehwien: soon work will be over and I get to stop writing AS3 and Java code and curl up with some clojure code.

19:17 hiredman: if you aren't exploiting any agent specific stuff (interactions with the STM) you can mostly just interchange agents and executors

19:18 rstehwien: hiredman: Is this how to use destructuring to transform the arguments into a hashtable ... been wondering it all day (defn fixedrate ([{:keys [name task start-delay rate unit]}]

19:19 hiredman: yeah

19:20 rstehwien: hiredman: Thanks! Was wanting to do that (somewhere around 4am this morning after I woke up) and it has plagued me all day. Tried finding some docs or looking in my clojure book but it didn't address that. Was going to search the code tonight but now I can just write

19:20 hiredman: clojurebot: destructuring

19:20 clojurebot: destructuring is http://clojure.org/special_forms#let

19:21 rstehwien: ok clojure bot is awesome

19:22 saw a mention of let somewhere but didn't go look... thinking I knew what let did. how wrong I was

19:23 hiredman: let just happens to be the place where the docs are

19:23 rstehwien: clojurebot: agent

19:23 clojurebot: Pardon?

19:24 rstehwien: going to read clojurebot code tonight

19:24 hiredman: :(

19:25 rstehwien: a few years ago anyone who said I'd read lisp like code for fun would have gotten smacked. How Clojure has changed my evil ways (among other things)

19:34 Luyt: rstehwien: Tell me more please

19:37 rstehwien: luyt: just didn't like the lisp syntax (lack of use). then I was wrting parsers and realized that lisp was a text representation of AST (no news to anyone here). That plus some great articles and my use of emacs pushed me to learning a lisp. Clojure came at right time

19:38 with right features/environment

19:39 Luyt: Do you have a list of those great articles lying around somewhere, perhaps?

19:39 I'm working my way through http://pragprog.com/titles/shcloj/programming-clojure after seeing some blogposts at news.ycombinator.

19:40 rstehwien: Luyt: http://mattsears.com/2009/6/6/20-clojure-links-to-get-you-up-to-speed

19:41 Luyt: Thanks!

19:41 ambient: also: http://java.ociweb.com/mark/clojure/

19:42 rstehwien: ambient: that is a great tutorial and on the top 20. Also found http://en.wikibooks.org/wiki/Clojure_Programming and more particularly http://en.wikibooks.org/wiki/Learning_Clojure which I mean to read as well

19:44 ambient: hmm, if i have a graph of streams instead of a tree i dont really know how to do that with clojure

19:44 Luyt: As always, lots of reading todo. I use C++ and Python on a daily basis, and dabbled a bit with common lisp, but I find Clojure more elegant.

19:45 rstehwien: ambient: would the clojure-contrib graph class be of help? I keep meaning to look it over and see if I could use it for the AStar algo

19:45 ambient: rstehwien my problem is more with streams

19:46 how to split streams and join them in various places

19:46 when the streams are described as lazy-seqs

19:46 rstehwien: ambient: could you chunk them up using partition?

19:47 ambient: rstehwien i dont think that would work. i need to copy each element

19:47 like a multiplexer

19:47 rstehwien: I probably don't know enough to help, but I was messing around with a lazy-seq of bytes and how to read them.

19:51 ambient: stuff into a vector and use subvec to combine as you need?

19:56 ambient: i might just need a connectivity matrix and with each stream read just distribute the value for each slot

19:56 that breaks the lazy-seq chain but oh well...

19:57 rstehwien: ambient: sometimes you can't be lazy ;)

19:58 tomoj: what's a graph of streams? some kind of feedback loop?

19:58 ambient: not necessarily. i just need for one node to be able to split and merge

19:58 it can be completely unidirectional

19:58 tomoj: oh, I see

19:59 well.. you can pass a lazy-seq to more than one function

19:59 and you can have functions which take two lazy-seqs

19:59 I don't see the problem

20:00 guess I don't understand what you're trying to do

20:02 ambient: i dont know how (split-stream my-stream (split-stream #(func-a %) #(abc %) #(def %)) #(func-b %)) would work

20:03 tomoj we have the same problem. if i completely understood my problem i wouldnt have it ;)

20:04 its just i have to break the nice tree-structure of s-exps and think of something else

20:24 technomancy: is anyone using jochu's branch of swank-clojure?

20:24 it looks flat out broke to me

23:01 rstehwien1: is this excessive use of destructuring

23:01 (defn file-watcher-create [path & options]

23:01 (println options)

23:01 (let [{:keys [regex recursive? callback check-ms event-watch-seq]

23:01 :or {check-ms *default-file-watcher-check-ms* recursive? false}}

23:01 (apply hash-map options)]

23:01 (println path regex recursive? callback check-ms event-watch-seq)))

23:10 hiredman: I don't like the whole apply hash-map internally just to make argument parsing

23:10 easier

23:11 but I seem to be in the minority

23:11 *shrug*

23:11 drewr: rstehwien1: have a look at defnk in c.c.def

23:12 makes that pattern a little less obnoxious and lets you supply default values

23:16 jlilly: the peepcode screencast is pretty good, if a bit fast.

23:19 rstehwien1: drewr, hiredman: thanks! I'll check out defnk

23:23 hiredman: I have a bunch of optional parameters, some that I want defaults for.

23:26 drewr, hiredman: in the end most of those values are going into a struct so destructing them into named values is probably a bit much... but tonight was the night I decided to learn destructuring. "everything looks like a nail" and all

23:29 spent so much time playing with destructuring I didn't get what I wanted done :( there is always the morning. Night all and thanks for the great help today.

23:38 qed: so sexy: http://en.wikipedia.org/wiki/Trie

23:45 jgrant: The following seems like it could be a common scenario when attempting to re-write parts of an existing Java application in Clojure.

23:45 Let's say there exists Clojure code and Java code in the same 'project'.

23:45 The Clojure code depends on the Java code in one direction and then the same is true in the opposite direction.

23:45 Given that compiling Java and Clojure require separate and different compilation steps, how would circular dependencies be resolved ?

23:45 e.g. A class is defined in the Clojure code that references Java classes(yet to be compiled) and the same is true for the Java code referencing classes defined in Clojure(yet to be compiled). It doesn't seem like compiling one before the other would solve this issue.

Logging service provided by n01se.net