#clojure logs

2009-10-14

02:49piccolinoIs anyone here familiar with the administration of clojure-contrib?
02:52mudphone`Anyone know if it's possible to start up a REPL and automatically "use" a library?
02:53jdz-e option
02:54jdzlike, java -cp path/to/clojure.jar clojure.main -e "(require 'your.lib)"
02:54mudphone`great, are those options listed somewhere?
02:54jdzjava -cp path/to/clojure clojure.main --help or something
02:54mudphone`ah
02:54mudphone`jdz: thanks!
02:55jdzmudphone`: have fun!
02:55mudphone`-i seems to be for loading an init path (file or resource)
02:56jdzmudphone`: yes, you're right.
03:00jdzmudphone`: except that in -i case you have to supplay a path, instead of relying on require finding stuff in CP
03:00mudphone`jdz: ah, good point
03:00jdzmudphone`: or maybe -i accepts what require accepts. must check the source...
03:00mudphone`was about to do -i, but would have eventually been tripped up
03:02mudphone`seems the advantage of -e is that you don't have to worry about the location of the file loaded via -i
03:11mudphone`now, if I could just get bash to escape my quotes correctly
03:13LauJensenMorning gents
03:15mudphone`morninig
03:15mudphone`and morning
03:36Fossihi
03:36mudphone`yo
03:36maaclWhen 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?
03:37AWizzArdMoin Fossi
03:37mudphone`you could take multiple args at a time
03:37LauJensenmaacl, there are a few tricks, one of them being (map foo s (next s)) for getting the next value
03:37AWizzArdHi the Lau.
03:37LauJensenHola andré
03:39maaclLauJensen: thanks
03:44LauJensennp
05:17octecan i not use println from an agent function?
05:17octeor is it just a repl issue perhaps?
05:18hiredmanyou can, sure
05:19octestrange
05:19octe(def ag (agent ""))
05:19octe(send ag (fn [x] (println x) (str "a" x)))
05:19octenothing gets printed in the repl
05:19octethe @ag gets set correctly
05:20octehmm
05:20octei take that back, works in the normal repl.. not just when i'm running slime
05:21rottcoddocte: (add-hook 'slime-connected-hook 'slime-redirect-inferior-output)
05:21octerottcodd: thanks, i just noticed it went to the the inferior bufer
05:21octeinstead of teh repl buffer
05:21octeis that because agents are run in a seperate thread?
05:26rottcoddocte: I think so, println from gui threads has the same problem
05:48octei 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?
05:49Chousukelet is serial
05:49octecan you give an example?
05:49Chousukeso just do (let [a 1 b (stuff a) c (stuff b)] (struct thestruct a b c))
05:50octeah
07:25octedoseq does recur internally?
07:31Fossi(source doseq) tells me yes
08:24octecan i update a let-variable?
08:25chouserocte: nope, they're immutable
08:26chouserocte: you can rebind a loop local to a new value when you call 'recur'
08:26octealright
08:26chouseror you can shadow an old local with a new one of the same name
08:43octei'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
08:44octei've written some java code that illustrates how i want to parse it.. http://pastebin.ca/1619263
08:44octeperhaps someone can point me in some direction?
08:45octesimple space-delimited string, but with positions depending on what it starts with..
09:05hoeckocte: maybe this helps http://pastebin.ca/1619296
09:07hoeckocte: we also have a lisppaste bot in here, maybe you can use it for your next pastes
09:07hoecklisppaste8:
09:07hoecklisppaste8: url
09:07lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
09:11octehoeck: nice :)
09:12octei'll use the lispt paste in the future
09:12octejust used to pastebin.ca
09:31snowwhiteping
09:31octepong
09:32snowwhiteocte, I have a list '(1 2 3) and i want to make it "1_2_3" in clojure. Any simple way to do that?
09:33LauJensen,(apply str (interpose \_ '(1 2 3)))
09:33clojurebot"1_2_3"
09:33LauJensensorry octe :)
09:36snowwhiteLauJensen, Thanks :)
09:36LauJensennp
09:36octeLauJensen: hehe, i wouldn't have known the answer anyway :-)
09:36LauJensenphew - I was afraid I pulled a 'cgrand' on you :)
09:37octei don't know what that is, but it sounds scary
09:38LauJensenit's kinda scary :)
09:39octei have a sequences of strings and if one of the elements starts with ":" i want to join it with the elements after it
09:39cgrandLauJensen: I'm not a 1-liner fetichist
09:39octe("a" "b" "c" ":d" "e") -> ("a" "b" "c" ":de") for example
09:39LauJensensee, even that was one line ^^
09:39LauJensen:)
09:39octecan't figure out a good way to do it..
09:40LauJensentake it away, cgrand.... :)
09:42cgrand,(let [[a b] (split-with #(not= \: (first %)) '("a" "b" "c" ":d" "e"))] (concat a [(apply str b)]))
09:42clojurebot("a" "b" "c" ":de")
09:43ngocHi, 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?
09:44LauJensennice
09:45octecgrand: nice!
09:47LauJensenFor those who read my blog there's a new post up http://blog.bestinclass.dk/index.php/2009/10/python-vs-clojure-evolving/
09:49ChousukeI wonder, do they really promote python as suitable for concurrent applications? :P
09:49LauJensenYea
09:50octedoes leave an empty string if there's not an element with : in it though
09:50ChousukeI suppose some of the non-GIL implementations of python might be okay
09:50LauJensenLike Jython ? :)
09:51LauJensenYea it's possible to bend it in that direction, but you get as much help as when using gcc :)
09:52cypher23LauJensen, 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/
09:52chouser,(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))
09:52clojurebot("a" "b" "c" ":de" ":fg")
09:53ChousukeLauJensen: you really need to learn to use the apostrophe correctly :)
09:53LauJensenChousuke, Again!?
09:53LauJensenSomebody 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?!
09:53Chousuke"Clojures" and "pythons" are in plural, you need to write "Clojure's" and "Python's" :P
09:54LauJensenClojure's = Clojure is
09:54Chousukeno
09:54LauJensenThat's what the guy told me :)
09:54Chousukewell, yes
09:54octeChousuke: clarification of specification, it should stop at the first : and combine the rest :)
09:54octe("a" "b" "c" ":de:fg") in your example
09:55chouseroh. pfft. so cgrands was closer
09:55ChousukeClojure's can be both "Clojure is" or the genitive of Clojure
09:55Chousukein formal writing it's the latter because you're not supposed to use contractions
09:55cemerick's generally indicates the possessive, and only colloquially indicates a contraction
09:56LauJensencemerick, excuse me while I decrypt your message
09:56chouserthe big exception there being "it" which has its own rules
09:56octeChousuke: yup, badly written specification i suppose
09:56ChousukeI think this is a common error for Swedish/Danish/Norwegian people because the possessive in those languages doesn't have the apostrophe :/
09:56cemerickcontractions are fine, but the 's contraction is definitely not common when writing.
09:57cemerickLauJensen: you're Dutch, right?
09:57LauJensenOk, so you guys are saying use 's at all times :)
09:57LauJensencemerick, I may sound dutch, but I'm Danish :)
09:57cemerickah, my apologies :-)
09:57LauJensennp
09:57ChousukeLauJensen: not for "its" though :)
09:57cemerickLauJensen: 's is really only appropriate for possessives in writing
09:57LauJensenoh ok
09:58LauJensenso it's borderline slang when I use it for contraction ?
09:58cemerickright
09:58LauJensen*sigh*
09:58chouserI wonldn't go that far.
09:58LauJensenI wish my mother would have taught me
09:58chouserIt seems to be that's a stretch.
09:59LauJensenwell, she should have said something :)
09:59ChousukeWell, a blog post on the internet is probably semi-formal
09:59LauJensenI'll go through it again, thanks guys
09:59Chousukeso contractions might be okay
09:59cemerickI think that's fair w.r.t. writing. I don't think I'd ever write "The clojure language's great."
09:59cemerickchouser: that was for you :-)
09:59Chousukecemerick: but you might write "it's great" instead of "it is great", no?
10:00cemerickah, well, as chouser said earlier, 'it' is special :-D
10:00chousercemerick: but you just use it for "that's"
10:00chouserhm
10:00chouserbut I agree "clojure's great" doesn't feel right.
10:01cemerickI'm guessing 'that', 'who', 'they', etc., all fall into the same basket as 'it' in this regard.
10:01cemerickI'm sure there's a proper term for that part of speech.
10:01LauJensenBut you see why this isn't intuitive for us foreigners? :)
10:01eevar2clojure's great what? ;)
10:02eevar2cemerick: s/speech/grammar :p
10:02cemerickLauJensen: oh yeah, English is rough, no doubt.
10:02chouserLauJensen: trying to help my 2nd-grader learn to spell these days. I have no illusions that English makes any sense.
10:02cemerickeevar2: ooh, don't start with me... ;-)
10:02ChousukeLauJensen: your language is too similar so English
10:03LauJensenGood
10:03ChousukeI'm Finnish so I can't even make the mistake of thinking that English might work like my own language ;(
10:03LauJensenYea I know Sukichou
10:04LauJensenCouldn'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:04Chousukein Finnish the apostrophe is only used with the possessive if the name is not pronounced like it's written :P
10:04Chousukewhich only happens with foreign names. :)
10:05eevar2cemerick: would they be pronouns, btw?
10:06cemerickwell, he/she/they/it, sure, but 'that'?
10:06cemerickI suppose so, intuitively, anywya.
10:07arbscht'that' can be a pronoun (demonstrative)
10:07chouserbut 'this' is a pronoun and the contraction is rarely written there because everyone's uncertain about the rule.
10:07cemerickAh cahn't be bothured wuh gammr an' all dat junk, anyhow.
10:07chouser"this's" or "this'"?
10:08cemerickany word that ends with 's' has a dangling apostrophe. I got that drilled into me after writing "Chas's" in kindergarten.
10:09chousercemerick: oh, really? I thought it was more subtle than that.
10:09cemerickMaybe everyone's been lying to me...but that's one of the most constant rules I know of.
10:10LauJensencemerick, we have the same rule in danish
10:10cemerickor, of which I know. Now I'm all self-conscious about my dangling prepositions.
10:10chouserhttp://alt-usage-english.org/excerpts/fxwheret.html
10:11chousersingular possesive noun that ends in "s" still gets a full "'s" on the end.
10:11chouserunbelievable
10:12cemerickthat's absurd. "class's"?!?
10:12MaddasYes
10:12MaddasHmm...
10:12MaddasI believe that's only one of several accepted ways to form the possessive for nouns that end on 's', though.
10:13eevar2you chug an 'e' in there in some cases, no?
10:13cemerickThat just looks wrong, through and through. I'd never be caught dead writing that.
10:13chouseroh, weird. I don't think I've ever seen a dangling ' after a non-"s" though. "patience'"
10:15MaddasHm, actually, I think I was wrong -- the only exceptions I can think of are names.
10:19chousersooo... back on topic. Does this function exist somewhere?
10:19chouser(defn rename-key [m oldk newk] (-> m (dissoc oldk) (assoc newk (m oldk))))
10:22Fossigerman even has three s words nowadays
10:23LauJensenhaha
10:31cemerickchouser: no, I don't think so
10:33cgrandchouser: clojure.set/rename-keys
10:36chouserah! thanks, guys.
10:37cemerickI never would have thought to look in set.
11:09AWizzArd,(re-find (re-matcher #"--" "clojure--123"))
11:09clojurebot"--"
11:09AWizzArd,(.matches (re-matcher #"--" "clojure--123"))
11:09clojurebotfalse
11:09snowwhiteHow do i write != in clj?
11:10AWizzArdWho spots the problem?
11:10AWizzArdsnowwhite: not=
11:10chousersnowwhite: not=
11:10snowwhiteAWizzArd, chouser Thanks :)
11:10chouserAWizzArd: my guess is that .matches requires the regex match at the start of the string
11:11chouserfail
11:11AWizzArdDoes Contrib have something like Strings indexOf function, but giving me the index(es) inside a string for a regex?
11:12chouseroh, the *entire* string. not just from the begining, but also all the way to the end.
11:13AWizzArd,(.indexOf "clojure--123" "--")
11:13clojurebot7
11:14AWizzArdthis would be enough
11:14AWizzArdbut with "--" being a regex
11:14chouser,(.indexOf "clojure--123" (str #"--"))
11:14chouser:-)
11:15clojurebot7
11:15AWizzArdNot bad would be (indexes-of "a--b--c" #"--") ==> [1 4]
11:16AWizzArdI guess there is nothing like that already included in the jvm and respectively contrib
11:19chouser,(let [m (re-matcher #"-" "xx-xxxx-xxx-xx-xxxx-")] ((fn step [] (lazy-seq (when (.find m) (cons (.start m) (step)))))))
11:19clojurebot(2 7 11 14 19)
11:19cgrandAWizzArd: .find then .start
11:19chouserjust like re-seq
11:19AWizzArd,(.start (re-matcher #"--" "clojure--123"))
11:19clojurebotjava.lang.IllegalStateException: No match available
11:19AWizzArdah okay, first .find
11:19AWizzArd,(.find (re-matcher #"--" "clojure--123"))
11:19clojurebottrue
11:20AWizzArd,(let [m (re-matcher #"--" "clojure--123")] (.find m) (.start m))
11:20clojurebot7
11:20AWizzArdgood, thanks
11:21chouserhm, re-seq could take an optional Matcher mapping fn that would default to re-groups
11:23AWizzArdyes
11:35AWizzArdHi 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:37chouserAWizzArd: doing some high-performance closing?
11:39AWizzArdno, 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:41AWizzArdchouser: 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:42chouserAWizzArd: that's idiomatic for lazy-seq
11:43chouserin 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:43AWizzArdAren't both versions equivalent?
11:43chouserno
11:44Chousukethe first version only evaluates the (.find m) if it's needed
11:48AWizzArdok, that makes sense
11:49konrhow can I deliver my product?
11:49konrhmm, better put:
11:49chouserkonr: I recommend providing a place to download it on the internet.
11:49chouser:-D
11:50konrHow can I pack it with an installer and required libraries? Is there a default way of doing that?
11:50AWizzArdkonr: you could write an ant script which will compile all you want into a .jar file which you can then distribute.
11:50AWizzArdYou can use distribute this .jar file with http://izpack.org/
11:50AWizzArd~max people
11:50clojurebotmax people is 184
11:51konramazing!
11:52licoresseso many lurkers :)
11:53riddochcbut if I said why I'm lurking, I wouldn't be lurking anymore, would I?
11:54konrit's more than 50% of #lisp's 300 users
11:54chouserriddochc: perhaps you could speak for a majority of the other lurkers, allowing them to remain lurking.
11:56ryshehe
11:56rysSome of us lurkers are actually avid readers, we just don't say much ;)
11:58chouserrys: are you dabbling at all in Clojure? Or just picking up background here for eventual use?
11:59rysYeah, I use it
11:59rysIn production too, and for playing
11:59chouserrys: excellent.
12:00cemerickwhat's the hotness in clojure web services?
12:01chouserdunno if it's hot, but I'm using ring and it's been nice.
12:01chouserstays entirely out of my way
12:02AWizzArdcemerick: what do you mean?
12:03AWizzArdAre you looking for a good framework for RESTful webservices? That would be Compojure.
12:03cemerickit's nice that most if not all clojure libs are on github
12:03cemerickstuartsierra: it's almost like a solid foundation of a package repo! :-P /me ducks
12:04cemerickAWizzArd: doesn't compojure drag along yet another sexpr-based templating language?
12:04cemerickchouser: looking at ring now, thanks
12:05cemerickchouser: BTW, you may not know it, but your use of something may be a leading indicator of 'hotness'
12:05chouserha! right.
12:06cemerickooh, ring uses apache's httpcore. That's promising.
12:06cemerick...and it also comes along with an sexpr templating language. Oh bother.
12:07chouserwhat? where?
12:07cemerickI see clj-html as a dependency.
12:09chouseroh, it desn't have its own. I don't use that, whatever it is.
12:09snowwhitecgrand, http://atifhaider.com/blog/2009/10/14/sieve-of-eratosthenes/
12:09AWizzArdcemerick: Compojure includes ring. And you don't need this html macro of Compojure. I never use it.
12:10snowwhitecgrand, my version on find primes.
12:10AWizzArdcemerick: you can spit out anything you like for your webservices. May be xml. Could be Clojure. I am producing json.
12:11AWizzArdcemerick: your Compojure program could at the same time provide websites, files, answer REST requests and answer xml-rpc requests.
12:12cemerickI'll have to give it a second look.
12:12AWizzArdthough rest vs. xml-rpc is a different paradigm, it's just that Jetty (included in Compojure) can be used for xmlrpc.
12:12snowwhitecgrand, ping
12:14cgrandsnowwhite: pong
12:15snowwhitecgrand, the problem with my version is it works fine for 1000 numbers but fails([Thrown class java.lang.StackOverflowErro) on 10000?
12:15cgrandindeed: you are stacking filters
12:16stuartsierracemerick: it *would* be a package repo if any one on github made numbered releases
12:17technomancycorkscrew can check clojure projects out of github and use them as dependencies.
12:17technomancybut yeah, it's a lot more useful if people use tags
12:17cemerickstuartsierra: I wonder if hashes are good enough. Not so human-readable, but nice for computers.
12:17cgrandto get the next prime (first lts), clojure will call the nested filters
12:17snowwhitecgrand, hmm, Any nice suggestion?
12:18stuartsierraHashes aren't good enough; a release promises some degree of "this should work as advertised."
12:18cgrandand at some point you have too many filters (one per prime already found),
12:19riddochcWell, 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:19riddochcIt'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:20cemerickstuartsierra: Aren't releases/tags are orthogonal to hashes w.r.t. enabling automated retrieval, etc.?
12:20cgrandsnowwhite: 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:20cemericki.e. git submodules are a "good enough" mechanism, though they are pretty opaque to a human.
12:20snowwhitecgrand, hmm
12:20technomancycemerick: sure, you just have to test non-released revisions a lot more by hand before you decide on one.
12:22cemericktechnomancy: 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:22technomancycemerick: ah, I see what you mean. Yes, that works.
12:22cgrandsnowwhite: 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:23cgrand~paste
12:23clojurebotlisppaste8, url
12:23lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
12:23cemerickBesides, can't tags get moved in git without disturbing hashes?
12:23cemerick(not that version IDs and such don't point to different binaries in *every* repo all the time)
12:24technomancyright, but if it gets moved, odds are you're going to want the new one. =)
12:24snowwhitecgrand, here it is http://paste.lisp.org/display/88631
12:25Chousukesnowwhite: underscores! bad :-(
12:25snowwhiteChousuke, yeah! right. Sorry will take care :)
12:26Chousukecall it "not-divisible?" or something
12:26cemericktechnomancy: 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:27technomancycemerick: I guess it's possible
12:29cgrandsnowwhite: 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:30riddochcSo, 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:30snowwhitecgrand, ok
12:34cgrandsnowwhite: using something like (some #(zero? (rem n %)) potential-divisors) is the easier alternative to piling filters.
12:36replacariddochc: it's a current topic on the list. see: http://groups.google.com/group/clojure/browse_thread/thread/aa62df2fe8705434/d0491f986aa8cacd#d0491f986aa8cacd
12:36riddochcRight, I should join the list already.
12:37replacariddochc: 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:40riddochcreplaca: I suppose you're right. Change sometimes comes slowly, y'know. ;)
13:10blkutchhi. 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:11blkutchi 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:11blkutchI want a total of alpha's values * beta's costs
13:12chouser,(merge-with * {:cherry 2 :apple 3 :orange 6} {:cherry 2.5 :apple 9185.25 :orange 2772})
13:12clojurebot{:cherry 5.0, :apple 27555.75, :orange 16632}
13:13Chousuke:)
13:14blkutchso to iterate through the values, i'd use something like (merge-with * {(-> alpha :bom)} {(-> beta)})?
13:14Chousukenah
13:14Chousukedon't think too complicated
13:14Chousukeyou want to merge the value of the :bom key with the beta map
13:14Chousukeso (merge-with * (:bom alpha) beta)
13:15blkutchwill it work if beta has more values than alpha?
13:15Chousukeyes.
13:15blkutchso it just essentially does the lookup
13:15blkutchwhat is the error that results if an item isn't in the lookup? or is no error resulting?
13:16chouserI wish I could alias Java package names and maybe even outer class names.
13:16chouserblkutch: check the docs for merge-with
13:16Chousuke,(merge-with + {:a 1 :b 2} {:a 10 :b 20 :c 30})
13:16clojurebot{:c 30, :a 11, :b 22}
13:16blkutchwill do, thanks
13:16chouserblkutch: it only does the operation (* in this case) if the key is in both maps
13:16blkutchah, interesting
13:17chouserotherwise it just uses the value of which map has a value
13:17Chousukethat 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:18blkutchyeah, have to find a way to catch that
13:18chouseras if the cost were 1
13:18blkutchbut better than doseqing it all together
13:18Chousukeblkutch: you could make the bom values be something that would cause exceptions when used as an integer.
13:19Chousukethat'd complicate your merge-with function though.
13:20Chousukea variant of merge-with allowing you to decide what to do with keys that are not shared might be interesting :/
13:21chouserI think that's called 'reduce' :-)
13:21Chousukehmm :)
13:22blkutchthis is weird though
13:22blkutchcan't I do (merge-with + (merge-with ...))
13:22Chousukeyes you can
13:23blkutchI must have a weird syntax error then
13:23blkutchwhen I do the test, I get the right values for everything multiplied, in a list
13:23Chousukethough be aware that merge-with allows more than two maps
13:23Chousukein a list?
13:23chouserblkutch: you want them summed together?
13:23blkutche.g. :cherry 500, :apple 500
13:23blkutchyeah
13:24blkutchthe multiplication worked, but now I want everything added
13:24chouser,(reduce + (vals (merge-with * {:cherry 2 :apple 3 :orange 6} {:cherry 2.5 :apple 9185.25 :orange 2772})))
13:24clojurebot44192.75
13:24Chousuke(apply + (vals (merge-with * ...)))
13:24blkutchwhat is the difference between the two?
13:24chouserin this case, nothing.
13:25chouserif + supported only two args, you'd have to use reduce.
13:25chouserif you're using something like 'str', apply is more efficient.
13:27blkutchgoddamn.
13:27blkutchclojure is so full of awesome.
13:27blkutchthanks :)
13:27Chousuke(into {} (for [k (keys (alpha :bom)) :let v (beta k) :when v] [k (* (k (:alpha bom)) v)])) ; a slightly more verbose version
13:28Chousukethat doesn't have the problem of using the :bom value if the beta map doesn't contain the thing
13:28Chousukethough.
13:28ChousukeI wonder if I can use :let and :when like that :D
13:29chouser:let [v (beta k)] ... but yeah, that's the point of :let, to allow you to then guard with :when or :while
13:30Chousukeactually if you're just looking for the sum it's a bit simpler
13:31blkutchultimately, what will happen is i'll grab from a database a list of values, then throw them into :alpha, then calculate the cost.
13:31blkutchexcept the database's values are never fixed and the components might be very different, and the component costs are calculated from another table.
13:32blkutchso the component table has values like cherries cost 500, nuts cost 30000, ...
13:32chousercould probably do it all in a sql select.
13:32blkutchwell, #1, I don't plan on using sql, #2, the user will supply variables via compojure.
13:32chouserah, ok.
13:32blkutchnosql w/ cassandra
13:32blkutchprobably
13:32blkutchnot sure yet
13:32blkutchjust want to get the logic understood and working
13:37blkutchthe reason I was missing merge-with because it wasn't in the article i'm learning clojure from (http://tinyurl.com/d3lksz)
13:38chouserinteresting. that's a truely substantial piece of work. I'm not sure, though, how thoroughly reviewed it's been.
13:39chouserI imagine the author would be grateful for input from you about anything incorrect or missing you discover as you work through it.
13:39rstehwienchouser: 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:39blkutchwell, 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:39blkutchrstehwien: yeah, the docs for clojure are terrible
13:40rstehwienblkutch: the author updated 10/12
13:40blkutchif you don't know lisp or don't understand FP, they're 100% useless
13:40chouserthere have been many calls for api examples. I think there's even a wiki with quite a few ... somewhere...
13:41snowwhiteI 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:41rstehwienchouser: I've been tempted to offer improving code docs with an example as a learning exercise
13:42rstehwienchouser: http://en.wikibooks.org/wiki/Clojure_Programming/Examples/Cookbook think there is another too
13:42chouserrstehwien: I think rhickey has generally resisted having pervasive examples in the docstrings, perhaps just because of the added verbosity in the .clj files.
13:42chousera very few do have examples though, so I'm not sure.
13:42chouser,(doc for)
13:42clojurebot"([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:42drewrDate -> YMDString: http://gist.github.com/210248
13:42chousereh. clojurebot cut it off before the example.
13:43drewrsnowwhite: For example ^^^
13:43chouserwell, irc cut it off I suppose.
13:44rstehwienchouser: adding an example like the following is so helpful http://livedocs.adobe.com/flex/3/langref/mx/controls/Button.html#includeExamplesSummary
13:45rstehwien(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:47rstehwienchouser: 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:48rstehwienchouser: docs need examples and some organization to subject matter rather than alphabetical... the cheat sheet is great in that respect
13:48rstehwienBut I mostly creep around in the codebase and do searches on github
13:48chouseryeah. find-doc is occasionally helpful.
13:49chouserthe clojure.org pages for data structures and such do have groups of related functions. I hope someone finds that useful occasionally.
13:50rstehwienchouser: I do. Forgot how often I hit the data structures page as well
13:50steigerchouser: i do \o
13:50steigerbut i agree clojure needs better documentation. including better examples
13:50drewrsteiger: it's still young
13:50chouserok, good to know. some day will have to look at getting links to work for the punctuationful names.
13:51steigerdrewr: yeah, i know
13:52Notfonkhi there
13:52Notfonki need to download some files from within a clojure script under linux
13:52Notfonkwich way would you do that, so it's clean ?
13:53chouserNotfonk: depends on how featureful/robust you want it to be.
13:53technomancyNotfonk: the duck streams library from contrib would be simplest
13:54NotfonkIt's a script that has to download around 100 files from my website during the day
13:54Notfonkthe files uris are determined by a script that already exists
13:54Notfonkno parralel downloads
13:54Notfonkchouser : looking into duck streams, thanks
13:55Notfonki don't know if that was clear, but i just need to save them on disk
13:55Notfonkno processing inside of clojure
13:57Notfonkduck-streams looks very low level for what i need
13:57Notfonkshall i only do an external call to wget and be set N
13:57Notfonk?
13:57chousernot a terrible idea (see contrib shell-out), but I think apache commons has a lib that might help too
13:58rstehwiennotfonk: I know I saw a blog post on downloading files recently. Just trying to find it.
13:58Notfonkthanks :)
13:59rstehwiennotfonk: probably overkill and not the blog post but here is a web crawler http://github.com/heyZeus/clj-web-crawler
13:59Notfonkmeanwhile i'm cooking a downloader with wget and clojure.contrib.shell-out
13:59technomancyNotfonk: duck-streams includes low-level functions, but is not all low-level
14:00technomancyfor instance, you can do something like (copy (reader "http://clojure.org&quot;) (writer "/tmp/clojure.org.html"))
14:00Notfonkah great !
14:01Notfonkbut what is the advantage compared to an external wget
14:01Notfonkin your opinion ?
14:01rstehwiennotfonk: wget not cross platform if that is a goal
14:01Notfonkit's not, i'm not really doing a full blown app
14:02Notfonkjust a convenience script
14:02technomancyNotfonk: more idiomatic I guess. both will get the job done.
14:02Notfonkbut well i guess it'd be better if i can run it on windows
14:02Notfonkok
14:02Notfonkthanks guys
14:03rstehwientechnomancy: thanks for the duck-stream copy example... pretty handy
14:03Notfonkand technomancy: thanks again for helping me a few days ago with emacs/slime and all
14:03Notfonki'm really loving the emacs + clojure experience :)
14:03technomancygreat!
14:04bballantineNotfonk, I am shy of calling shell commands from the JVM...
14:04bballantinegeneral 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:05bballantineI'm unfamiliar w/ Duck streams, but I would go with that or build in Java HTTPConnection
14:06Notfonki'm currently trying it with duck streams
14:06Notfonkthe advantage i have with wget is i don't have to parse the filename from the uri
14:06Notfonkbut that's a small regex away so it's no big deal
14:07technomancy(copy (reader uri) (writer (last (.split uri "/")))) ;; <= thereifixedit.
14:07technomancy=)
14:07bballantine:)
14:07Notfonkha :D
14:07Notfonki used re-split to do the same thing
14:07Notfonkis .split faster btw ?
14:07technomancyprobably a bit
14:08Notfonkthanks :)
14:08riddochcIsn't clojure just awesome for golf?
14:26licoresseWhen I am at the repl (slime) and have just (use 'some.thing), how can I programmatically list all functions?
14:35stuartsierranew Clojure/Maven archetype, using 1.1 plugin: http://github.com/stuartsierra/clojure-archetype
14:35licoressemaybe this is not possible :(
14:35chouserlicoresse: (keys (ns-publics 'some.thing))
14:36licoresseok
14:36licoressebut (keys (ns-publics *ns*)) responds to nil
14:36licoresseeven if there are defn's there
14:36Chousukelicoresse: it takes a symbol apparently
14:37chouser,(keys (ns-publics *ns*))
14:37clojurebot(foo)
14:38Chousukeoh, and *ns* is not your 'some.thing
14:39licoresseoh, I see
14:39licoressethat makes sense
14:40stuartsierrarhickey: there's a free maven book online, pretty good
14:40stuartsierrahttp://www.sonatype.com/products/maven/documentation/book-defguide
15:26tomojdoes anyone have that link on how to connect slime to an already-running clojure? can't seem to find it
15:27stuartsierratomoj: the Clojure needs to be running swank server, then run M-x slime-connect in Emacs
15:27tomojright
15:27tomojbut I found some link once on how to start the swank server, now it's gone :(
15:35stuartsierralook for the start-server command in the swank-clojure sources, I think
15:47tomojstuartsierra: thanks, that worked
15:47stuartsierrawelcome
15:48gaznot sure if you're talking to me? but hi stuart
15:48stuartsierrawas talking to tomoj; hi gaz
15:49gaz:)
16:39ambientone thing i miss in clojure is polymorphism according to type
16:40ambientdont know how to achieve that in a consistent way using lisp :/
16:40steigerambient: multimethods?
16:40ambientguess i have to read more about them then
16:41steigerambient: check the official docs and this blog post: http://www.fatvat.co.uk/2009/01/multi-methods-in-clojure.html
16:41Chousukeno need to limit yourself to types with multimethods :)
16:42steigeryeah, off course :)
16:42konrspeaking of multimethods, is there a (doc)-like function to check out the defmethods?
16:42ambientthere's no way i can use +, - etc arithmetic to process my self defined types?
16:42ambientlike vectors, matrices etc
16:42tomojno, those are functions
16:42steigerkonr: i think multimethods don't have docs. only their defmulti. and i guess you can check them normally with doc
16:43tomojyou could make a generalized plus perhaps
16:43ambientdone that already
16:43steigerambient: well, you can define your own +, but then you would have to exclude the existing +, -, etc, from oyur namespace
16:43Chousukeambient: + calls down to java as it is now
16:44Chousukemaking it a multimethod would make it way too slow.
16:44tomoj++ seems available
16:44Chousukecontrib has generic math though
16:44ambientthis is what im doing atm: http://paste.pocoo.org/show/144985/
16:45hiredmanhttp://gist.github.com/209643 anyone know what this is about?
16:46steigerambient: i didn't get your intentions, but maybe it's because i'm quite slow right now
16:46ambienttomoj i cant define // i think, because / is actual syntax
16:47ambientsteiger to be able to (+ number lazy-seq-of-numbers) instead of (map + ...
16:47tomojthat's weird
16:47tomoj,'//
16:47clojurebotInvalid token: //
16:47tomojwhy is it invalid, I wonder...
16:47Notfonkre there
16:47ambientSystem/getProperty
16:47tomojoh, because it's for rationals
16:47steigerambient: hm, i see.
16:47Notfonki hate a very strange problem with the (copy (reader "") (writer ""))
16:47Notfonkhave sorry :D
16:48Chousukesymbols ending in / are not allowed
16:48Chousuke/ is the only exception
16:48Notfonkit generates files 2 times too big
16:48Notfonkand unreadable
16:48Notfonkwhen i parse them from the internet
16:48steigerambient: you could put your code in a ns with (ns) and exclude the local names +, -, ...
16:48tomojalso symbols beginning in / it seems
16:48steigerambient: and then redefine it as you wish
16:52hiredmantomoj: / is for seperating namespaces
16:52hiredmanso using it in symbols allowed or not is a bad idea
16:53ambientseems too hackish for usage. i just use smul sadd sdiv etc
16:54Notfonknobody has an idea for me ?
16:54Notfonkit seems that when i download html like that it works
16:54Notfonkbut when i download files that are not strings it doesn't
16:55Notfonkso it must be an enconding problem i guess
16:56hiredmanNotfonk: can you pastebin your code somewhere?
16:57rstehwiennotfonk: 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:58Notfonkmy code is easy enough
16:59Notfonk(copy (reader "http://www.ntslh.org/test.mp3&quot;) (writer "test.mp3"))
16:59Notfonkand that's the whole of it
16:59Notfonkrstehwien : how would i do that ?
16:59steigerambient: yes, i agree. i would rather name them seq+, seq/, seq-.. but that's a matter of taste :)
16:59rstehwiennotfonk: doing a quick peek at duck-streams
16:59ambientsteiger i cant name them like that
17:00Notfonki'm watching the source too
17:00ambientseg/ > error
17:00steigeroh of course
17:00steigeryou can't use /
17:00steigersorry
17:01hiredmanok
17:01Notfonkrstehwien : java.io.PrintWriter is encoding for string no ?
17:01rstehwiennotfonk: Instead of passing in a string to the writer you might need to pass in a writer you create. Hold on one momemt
17:01Notfonkyeah i was thinking about that too
17:02hiredmanreader and write are both for character data, I believe
17:02hiredmanand mp3 is bytes
17:02Notfonkabsolutely
17:02Notfonki found an old post mentioning a fix just now
17:02Notfonki'll just create a java writer i guess
17:02hiredmanno
17:03hiredmanuse and inputstream and a outputstream
17:03hiredmanan
17:03konris 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:03Notfonkhiredman : ok
17:04rstehwiennotfonk: maybe try passing in (FileOutputStream. "test.mp3")
17:06Notfonki created an outputstream
17:06Notfonkit's working
17:06Notfonkthank you guys very much
17:07Notfonkstill i think it would be good to be able to select the type of the writer in the duck-streams fn
17:07Notfonkwhat do you think ?
17:09hiredmanand outputstream is not a Writer
17:09hiredmanan
17:10hiredmanan OutputStream is not a type of Writer so have the writer producing fn named writer produce one would be odd
17:10hiredmanhaving
17:11Notfonkyeah i know what you mean
17:12hiredmanit might make sense to have a outputstream fn
17:12Notfonkbut a superior layer of abstraction for writing files would be good
17:12Notfonki mean what i'm doing now is rather tedious
17:12Notfonki'll take a shot at it
17:13rstehwiennotfonk: this works (copy (reader "http://www.arcanearcade.com/Flex/SpeedTest/SpeedTest.swf&quot;) (writer (java.io.FileOutputStream. "test.swf")))
17:13rstehwiennotfonk: be easy to write some code to encapsulate that
17:13ambientdoes (int) always truncate/floor?
17:15ambientseems like it
17:17rstehwiennotfonk: 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:21Notfonk:D
17:21Notfonkrstehwien : didn't watch at the irc for a few minutes
17:21Notfonkdid almost the same thing meanwhile tho
17:21Notfonk:)
17:22Notfonkbut
17:22Notfonkyour last fn is not working since you're using a writer,
17:22Notfonkyou have to use the fileoutputstream directly
17:22Notfonkwithout wrapping it into a writer
17:23rstehwienteach me to paste without testing ;)
17:24Notfonk:)
17:24ol3```hello how do i add multible ignore/ingorable to a declaration
17:25hiredmaneh?
17:25ol3```(declare (ignore sym)) and (declare (ignorable sym2))
17:25ol3```can i pack them in one declare statement?
17:26hiredman,(doc ignore)
17:26clojurebotTitim gan éirí ort.
17:26hiredman,(doc ignorable)
17:26clojurebotIt's greek to me.
17:26hiredman*shrug*
17:27Notfonki love this bot
17:27ol3```omg, wrong channel
17:28ol3```sorry folks
17:29hiredman~botsnack
17:29clojurebotthanks; that was delicious. (nom nom nom)
17:46mikehincheytechnomancy: are you planning to backport your use-fixtures patch to 1.0-compat? If not, I'll do it.
17:48rstehwien,(doc send-off)
17:48clojurebot"([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:48jevgeniafter 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:50Notfonkjevgeni : you don't need to press enter, but the slime repl clojure buffer takes some time to load yes
17:51technomancyjevgeni: slime takes a moment to connect; you're probably just hitting enter while it's in process
17:52technomancymikehinchey: I'm not really using 1.0 any more, so it'd be great if you want to tackle that backport; thanks!
17:53mikehincheyok
17:53tomojis there a way to check whether a var is bound?
17:54tomojbesides trying it and catching the IllegalStateException?
17:54chouser(.isBound #'foo)
17:54tomojah, thanks :)
17:58jevgenitechnomancy, 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:58technomancyjevgeni: that _is_ pretty odd; I guess it is not what I thought at first.
17:59technomancyit could be a Windows issue; I haven't heard of that happening myself.
18:01jevgeniokay, I see. thanks, I will dig futher..
18:02wavis,(.isBound #'foo)
18:02clojurebottrue
18:02wavis,(.isBound #'foo-bar)
18:02clojurebotjava.lang.Exception: Unable to resolve var: foo-bar in this context
18:02wavis,(.isBound foo-bar)
18:02clojurebotjava.lang.Exception: Unable to resolve symbol: foo-bar in this context
18:02wavis,(.isBound 'foo-bar)
18:02clojurebotjava.lang.IllegalArgumentException: No matching field found: isBound for class clojure.lang.Symbol
18:04wavis,(with-local-vars [foo-bar 1] (.isBound foo-bar))
18:04clojurebottrue
18:06wavis,(if (find-var 'foo-bar) true false)
18:06clojurebotjava.lang.IllegalArgumentException: Symbol must be namespace-qualified
18:08lpetit,(ns-resolve *ns* 'toto/titi)
18:08clojurebotnil
18:09hiredman,(resolve 'foo)
18:09clojurebot#'sandbox/foo
18:09hiredman,(resolve 'bar)
18:09clojurebotnil
18:09lpetitbetter :)
18:09hiredman,foo
18:09clojurebot5
18:14jensliDecoupling 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:41ambientif i have symbol 'foo in aa like (def aa 'foo) how can i create a function (defn foo []... with referring to aa?
18:41ambientwithout actually redefining aa
18:45AWizzArdwhen 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:47hiredmanambient: eh?
18:48hiredmanAWizzArd: I'd use promise/deliver
18:48ambienthiredman something like this: (doseq [f {'smul * 'sdiv / 'sadd + 'ssub -}] (defn (f 0) [& a] (stemp (f 1) a)))
18:48chouserambient: intern
18:48ambient(that doesnt actually work afaik)
18:48hiredmanugh
18:49hiredmandefn? in a doseq? horrible
18:49ambientwhatever
18:49hiredman:(
18:50AWizzArdhiredman: 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:50ambienti just have a bunch of generic functions which are defined in the same way, i'd like to avoid code repetition
18:50ambientchouser thanks
18:52hiredmanAWizzArd: use a blocking queue
18:52hiredmanor an executor, or agents
18:55hiredmanso the blocking queue would be a communication channel to other threads
18:55hiredmanthe other option is, instead of managing threads directly, you send-off an agent action to service the client
18:56ambienti 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:59AWizzArdi see, thx
18:59Dawgmatixare the clojure docs available as a pdf ?
19:05rstehwienhiredman, 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:05rstehwien,(doc add-watch)
19:05clojurebot"([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:06rstehwienhiredman, 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:07hiredmanrstehwien: depends on this that and the other
19:07hiredmanhe hasn't mentioned needing a priority queue
19:07rstehwienhiredman: hehe true. But some of the code could be borrowed and repurposed.
19:08hiredmanif all he is doing is job dispatching than an agent or an executor can be used just fine
19:10rstehwienhiredman: Would that be a java.util.concurrent.ThreadPoolExecutor or is there a clojure equivalent (peeking in the docs now)
19:11hiredmanagents are built on executors
19:11hiredmanbut yeah, j.u.concurrent
19:12rstehwienhiredman: John also wrote a class that will create a general agent to execute a given function on a timer
19:12hiredman:(
19:12hiredmanScheduledThreadPoolExecutor
19:13rstehwienwell 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:13hiredmanugh
19:14hiredmangist code formating seems to be broken in firefox
19:14hiredmanhttp://gist.github.com/178350
19:14hiredmanand chrome
19:14hiredmanmaybe gist broke
19:14hiredmanlame
19:15hiredmanwhen I pulled it via git the formating was good
19:15rstehwienI spy with my little eye hiredman.schedule in clojurebot schedule.clj
19:15hiredmanindeed
19:16rstehwiensoon work will be over and I get to stop writing AS3 and Java code and curl up with some clojure code.
19:17hiredmanif you aren't exploiting any agent specific stuff (interactions with the STM) you can mostly just interchange agents and executors
19:18rstehwienhiredman: 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:19hiredmanyeah
19:20rstehwienhiredman: 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:20hiredmanclojurebot: destructuring
19:20clojurebotdestructuring is http://clojure.org/special_forms#let
19:21rstehwienok clojure bot is awesome
19:22rstehwiensaw a mention of let somewhere but didn't go look... thinking I knew what let did. how wrong I was
19:23hiredmanlet just happens to be the place where the docs are
19:23rstehwienclojurebot: agent
19:23clojurebotPardon?
19:24rstehwiengoing to read clojurebot code tonight
19:24hiredman:(
19:25rstehwiena 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:34Luytrstehwien: Tell me more please
19:37rstehwienluyt: 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:38rstehwienwith right features/environment
19:39LuytDo you have a list of those great articles lying around somewhere, perhaps?
19:39LuytI'm working my way through http://pragprog.com/titles/shcloj/programming-clojure after seeing some blogposts at news.ycombinator.
19:40rstehwienLuyt: http://mattsears.com/2009/6/6/20-clojure-links-to-get-you-up-to-speed
19:41LuytThanks!
19:41ambientalso: http://java.ociweb.com/mark/clojure/
19:42rstehwienambient: 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:44ambienthmm, if i have a graph of streams instead of a tree i dont really know how to do that with clojure
19:44LuytAs 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:45rstehwienambient: 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:45ambientrstehwien my problem is more with streams
19:46ambienthow to split streams and join them in various places
19:46ambientwhen the streams are described as lazy-seqs
19:46rstehwienambient: could you chunk them up using partition?
19:47ambientrstehwien i dont think that would work. i need to copy each element
19:47ambientlike a multiplexer
19:47rstehwienI probably don't know enough to help, but I was messing around with a lazy-seq of bytes and how to read them.
19:51rstehwienambient: stuff into a vector and use subvec to combine as you need?
19:56ambienti might just need a connectivity matrix and with each stream read just distribute the value for each slot
19:56ambientthat breaks the lazy-seq chain but oh well...
19:57rstehwienambient: sometimes you can't be lazy ;)
19:58tomojwhat's a graph of streams? some kind of feedback loop?
19:58ambientnot necessarily. i just need for one node to be able to split and merge
19:58ambientit can be completely unidirectional
19:58tomojoh, I see
19:59tomojwell.. you can pass a lazy-seq to more than one function
19:59tomojand you can have functions which take two lazy-seqs
19:59tomojI don't see the problem
20:00tomojguess I don't understand what you're trying to do
20:02ambienti dont know how (split-stream my-stream (split-stream #(func-a %) #(abc %) #(def %)) #(func-b %)) would work
20:03ambienttomoj we have the same problem. if i completely understood my problem i wouldnt have it ;)
20:04ambientits just i have to break the nice tree-structure of s-exps and think of something else
20:24technomancyis anyone using jochu's branch of swank-clojure?
20:24technomancyit looks flat out broke to me
23:01rstehwien1is this excessive use of destructuring
23:01rstehwien1(defn file-watcher-create [path & options]
23:01rstehwien1 (println options)
23:01rstehwien1 (let [{:keys [regex recursive? callback check-ms event-watch-seq]
23:01rstehwien1 :or {check-ms *default-file-watcher-check-ms* recursive? false}}
23:01rstehwien1 (apply hash-map options)]
23:01rstehwien1 (println path regex recursive? callback check-ms event-watch-seq)))
23:10hiredmanI don't like the whole apply hash-map internally just to make argument parsing
23:10hiredmaneasier
23:11hiredmanbut I seem to be in the minority
23:11hiredman*shrug*
23:11drewrrstehwien1: have a look at defnk in c.c.def
23:12drewrmakes that pattern a little less obnoxious and lets you supply default values
23:16jlillythe peepcode screencast is pretty good, if a bit fast.
23:19rstehwien1drewr, hiredman: thanks! I'll check out defnk
23:23rstehwien1hiredman: I have a bunch of optional parameters, some that I want defaults for.
23:26rstehwien1drewr, 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:29rstehwien1spent 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:38qedso sexy: http://en.wikipedia.org/wiki/Trie
23:45jgrantThe following seems like it could be a common scenario when attempting to re-write parts of an existing Java application in Clojure.
23:45jgrantLet's say there exists Clojure code and Java code in the same 'project'.
23:45jgrantThe Clojure code depends on the Java code in one direction and then the same is true in the opposite direction.
23:45jgrantGiven that compiling Java and Clojure require separate and different compilation steps, how would circular dependencies be resolved ?
23:45jgrante.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.