#clojure logs

2009-09-08

00:09duck1123Is there any way to make stack traces give out a little more context as to what namespace a file is in? I deal with 3 files for any given name
00:10duck1123I could always add -controller and -view, etc. but I'd rather not have to deal with that all the time
00:10duck1123appname.controller.user-controller (or some variant) seems redundant
00:31technomancyduck1123: with slime you can just press v with the point over the stack trace frame to jump to that function
02:53tomojwhaaat aquamacs is unsupported?
02:54tomojoh, that doesn't mean it doesn't wor
03:10somniumwhat is the idiomatic way to call (fn [x y z] {x (y+z)}) with (seq 1 2 3))?
03:12cark(apply your-func your-seq)
03:12carkthat's if i understood your question
03:13somniumthat did it, thanks
03:13cark=)
03:13somniumdidn't realize apply used the arity of the function you call it with
03:14carkit doesn't
03:14carkapply does not know anything about arity
03:14somnium? then how does it pass the right number of args?
03:14carkmhh that's implementation details i'm not comfortable going into
03:15somniumok... well it seems to use arity :) I don't really care it does what I wanted
03:15carkhehe right =)
03:41jamesp__Hi, I'm sure I'm missing something obvious here, but how do I expand a list into the arguments for a function?
03:41hiredman,(doc apply)
03:41clojurebot"([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."
03:44jamesp__Perfect. Thanks hiredman, one step closer! Cheers
03:50Fossieh. seems like it apply day today
04:20somniumare there any good resources on becoming *really* productive with slime/emacs clojure? I've gotten comfortable enough but always this feeling I'm using 5% of the features
04:34Chousukesomnium: heh, I have the same problem :P
04:34Chousukethat 5% is probably enough for now.
04:34Chousukesomnium: are you already using paredit.el? :)
04:34somniumyeah
04:34somniumthough sometimes it irritates me
04:35somniumhave a hard time deleting parentheses, I'm sure theres some shortcut but I havent found it on the cheat sheet yet
04:35somniumend up using cut and paste
04:35somniumctrl + arrow keys is very handy at times though
04:36Chousukeyou should never need to delete individual parentheses :/
04:36somniumpairs of them
04:36Chousukejust backspace? :)
04:36somniumit refuses unless they're empty
04:37Chousukesometimes I end up with a mismatched paren but C-q ( or ) to match it again and then deleting it works fine.
04:37Chousukesomnium: oh, of course.
04:37Chousukesomnium: use C-k to kill the entire sexp
04:37somniumah, maybe that's what I've been missing
04:38somniumperhaps it will feel like 6% now ;)
04:39somniumI have the cheatsheet but nothing seems to stick, maybe I'll paste it to the wall
04:39Chousukeparedit has more features than that of course but I'm doing well with just C-k, paren matching and barf/slurp
04:40Chousukesomnium: to make it stick I guess you need to spend some time *forcing* yourself to use the more complicated functionality, even if it feels slower than the simple way.
04:40Chousukeonce your hand learns the motions it should become a lot faster :)
04:41somniumyes, I only just remapped ctrl to caps-lock
04:41Chousukeheh
04:42somniumId like to try switching to vim for a slightly simpler life, but I can't get vimclojure to work
04:42Chousukeyou can try viper.el in emacs :P
04:42ChousukeI actually mapped meta to capslock and ctrl to the cmd keys
04:42Chousukehaving two controls helps
04:43Chousukeand they're easy to press with the thumbs
04:44somniumhmm, I tried viper but I just stay in insert mode and use emacs commands out of laziness(?)
04:44somniumand I don't know how to configure (haven't bothered to see how yet)... configuring .vimrc compared to configuring .emacs is... night and day
04:49Fossii guess everybody has that 5% margin left to go
04:50Fossithat's why emacs rocks so much
04:50Fossioh, i misread
04:51somniumit would be nice if it was possible to use clojure instead of elisp
04:51Fossiwell, that's just an emacs rewrite away ;)
04:51somnium!
04:51somniumclojure-emacs-script
04:52somniumelisp-generator, how hard can it be to translate a lisp to another lisp?
04:56Chousukewell, Clojure has lexical scoping and immutable data structures
04:56Chousukeelisp has dynamic scoping and very mutable data structures :P
04:58somniumtrue... pure code-generation might not be so bad, but that would require intimately learning elisp, and by the time I did that I suspect I wouldn't want to write the program anymore
04:58somniumlike removing parentheses from lisp or something
05:00Chousukethe human brain is good enough at removing the parentheses when needed :)
05:01somniumI find indenting my expressions so I can read them again at a glance is far more challenging than parsing parentheses
05:07Fossiis there something like yasnippets for clojure? a more useful slime-complete-form?
05:10somniumyou could use yas if you write your own snippets couldn't you?
05:11somniumis there a standard way to combine two seqs, like (foo bar) and (nil nil nil nil) to get (foo bar nil nil) ?
05:16somniumI guess (take (count b) (cons a b)) isnt so bad
05:19Fossisure i could, but maybe there's something useful already
05:20somniummacros = snippets++ ;)
05:21somnium(= macros (inc snippets)) #=> true
05:25Chousuke(defn dropcat [a b] (lazy-seq (if (seq a) (cons (first a) (dropcat (rest a) (rest b))) b)))
05:28somniumI wish there were more examples in some of the doc-strings
05:29liwpsomnium: and cross references to other related fns
05:29Chousukecross-refs would be more useful as separate metadata
05:29liwpsure
05:33somniumhmm, maybe a doc-string browser like gem-server would do the trick
05:34somniumstill would need the metadata...
05:34liwpI guess ideally the examples would be separate metadata as well
05:35liwpi.e. the doc string would be multiple entries that then get compiled together when you call (doc) or for online documentation
05:36somniumit would be nice to have a little swing app that has a cross-referenced db of core and contrib with hyperlinks to relations
05:36somniumand related javadocs
05:37somnium,(doc lazy-seq)
05:37clojurebot"([& body]); Takes a body of expressions that returns an ISeq or nil, and yields a Seqable object that will invoke the body only the first time seq is called, and will cache the result and return it on all subsequent seq calls."
05:37somniumwhere to get doc for Iseq and Seqable?
05:41tomojsomnium: you could build it yourself with javadoc
05:41tomojbut for ISeq you might as well just look at the source
05:41tomojnot much there
05:41ChousukeThere's no javadoc for the interfaces yet I think :/
05:42Chousukewhich is a shame.
05:42tomojsimilarly for Seqable
05:42tomojSeqable is just one method, seq(), which returns an ISeq
05:42tomojISeqs can do cons(Object), first(), more(), next()
05:43tomojI guess more==rest?
05:43tomoj~def rest
05:43tomojyup
05:44Fossisomnium: well, for defn it would make sense to have a snippet
05:44Fossiand i guess there are other
05:45tomojI guess Reversible is a contract for constant-time rseq like Counted is a contract for constant-time count?
06:02Fossisomnium: i'd also like a thing that's like eldoc, but with a template
06:07cschreinernested #() are not allowed, how to solve?
06:07hiredmanuse fn
06:07cschreinerok
06:07cschreinerso it's a reader-problem
06:08hiredmannesting #() would be a pain anyway
06:08Chousukeit's not that difficult to implement
06:08hiredmanargument names all are the same
06:09Chousukeit just would be confusing :/
06:09hiredmanclojurebot: #()?
06:09clojurebot#() is not a replacement for fn
06:09hiredmanclojurebot: function literals?
06:09clojurebotFunction literals are cute, but overused
06:09cschreineryes, I see the point with % in nested #()
06:11cschreinerI fucking love the expressivity of clojure, is it ok to say that?
06:11liwpcan one use #() in macros?
06:11hiredmanliwp: best not
06:12Chousuke,`(do #(foo %))
06:12clojurebot(do (fn* [sandbox/p1__4222] (sandbox/foo sandbox/p1__4222)))
06:12liwpyeah I've avoided them so far
06:12Chousukethat would fail I think :/
06:13Chousukeyep: Can't use qualified name as parameter: user/p1__2363
06:14liwpindeed
06:14Chousukethough you can use #() in macros as long as it's not part of the generated code.
06:14somniumChousuke: thanks for that dropcat fn, its proving very handy
06:15cschreinerChousuke: yep, thanks for the input
06:15cschreinerkitos, or whatever you say
06:15liwpChousuke: yeah that's right, but I was specifically interested in the generated code case which wasn't working for me IIRC
06:15Chousukecschreiner: two i's
06:15cschreiner:-)
06:16Chousukeliwp: best just use fn in those cases.
06:16liwpso it would seem :)
06:16Chousuke,`(fn [x#] (inc x#))
06:16clojurebot(clojure.core/fn [x__4226__auto__] (clojure.core/inc x__4226__auto__))
06:18liwpso the difference here is that #() generates a qualified name as a param?
06:18liwp,`(do #(inc %))
06:18clojurebot(do (fn* [sandbox/p1__4230] (clojure.core/inc sandbox/p1__4230)))
06:18Chousukeliwp: the difference is that it expands at read time so ` qualifies the symbols.
06:18liwpahh yes
06:18Chousuke,'#(foo bar)
06:18clojurebot(fn* [] (foo bar))
06:18Chousuke,'#(foo bar %)
06:18clojurebot(fn* [p1__4237] (foo bar p1__4237))
06:18Chousuke,`(fn* [p1__4237] (foo bar p1__4237))
06:18clojurebot(fn* [sandbox/p1__4237] (sandbox/foo sandbox/bar sandbox/p1__4237))
06:19liwpcool, thanks
06:20Chousukewonder if I should submit my syntax-quote macro for inclusion in Clojure already :/
06:22Chousukemy reader is not yet ready but syntax-quote only needs a couple tweaks and it should be fine.
06:23liwpChousuke: what is this reader work that you've been doing? Why are you writing your own reader?
06:24Chousukeliwp: well, I thought it might be a fun project, and if it turns out good enough it could replace the current reader (which is written in java)
06:24somniumany chance of sneaking in reader-macros?
06:25Chousukenot until rhickey approves of them :P
06:25liwpwhich does not seem likely ATM
06:25Chousukemy current reader code makes only a few direct calls to java so it could be usable from ClojureCLR and other ports too. that would be a bonus
06:26Chousukethough all this is just talk. I still have a lot of work to do until the reader is really usable
06:26somniumany talk of making a ClojureC by anyone?
06:26Chousukeit's mostly feature-complete already but I haven't even looked at what it would take to make Clojure actually use it. :P
06:27liwpChousuke: that does sound like a nice little project. For some reason I didn't realise that the current reader was writtne in Java althought have seen LispReader.java in the source tree...
06:30Chousukeif you want to see what I have currently just browse http://github.com/Chousuke/clojure/tree/clojure-reader (it's src/clj/clojure/lang/reader.clj, and syntax-quote is in core.clj)
06:32Chousukeit should have no major omissions anymore so feel free to test. I might have forgotten something though. :P
06:32Chousukebut now I must hurry away
06:32liwpI'll have a look...
06:43cemericksomnium: you mean a C compile target?
06:45somniumyeah, a pure C implementation, seems unlikely I guess
06:45cemerickI think targeting chicken scheme, which emits C, is more likely
06:49LauJensenGood afternoon gents
07:09cemerickspeaking of, I don't think I've ever seen a woman's name in the channel or on the group :-/
07:15cemerickjust how evil would it be to use an atom to control the termination of a for comprehension? Any less evil if I'm immediately consuming the comprehension?
07:16cemerickI've got a bit of a nasty nested loop, and I'm toying with reimplementing it using something like (last (for ...))
07:16clojurebot0
07:16Fossi0?
07:18Fossiout of curiosity: how do you format a number, if you don't know whether it might be a BigDecimal?
07:28konr|afkIs there a template system, like php's smarty or python's tenjin, for clojure?
07:28durka42there are a few
07:28durka42enlive is one
07:29konr|afkhmm, any idea which is the fastest?
07:29durka42i do not know
07:31cemerickisn't templating the least of one's concerns, vs DB access, bandwidth/latency, etc? (when templating for a web environment, anyway)
07:32konr|afkI think you are right...
07:32konr|afkthe bottleneck of my application is the DB access
07:33konr|afkI think - at least mysql is the most cpu-consuming app when the server gets laggy
07:35cemerickoptimize thine queries :-)
07:49LauJensencemerick: it would be very evil
07:49cemerickLauJensen: yeah, I know :-)
07:50cemerickI'm working on unifying the loop
07:50LauJensengood - if you fail I'll have to ban you from the group
07:56LauJensenGuys, have you seen 'rising links' on DZone this morning? :)
07:59ambientthe page doesn't work for me, so paste a link
08:00LauJensenwww.dzone.com
08:00ambientjavascript:void(null)
08:00ambienti mean the rising links tab
08:00LauJensenoh.
08:00LauJensenthe only way to see it is to have that js evaled, that'll give you a new tab
08:00LauJensenbut the point was that my 'java vs clojure' post was on top
08:02ambientcool ;)
08:03ambienthmm, i wonder if i can add a macro to vimperator that adds sites to whitelist in adblock+
08:26LauJensenIt happend, Java vs Clojure is #2 on the frontpage of DZone :D
08:27ambientgrats
08:27LauJensenThanks :)
08:53gerryxiaohello
08:53gerryxiaowhat's chunks?
08:54gerryxiaohow to make (range 0 1000) to trunks?
08:58Chouser,(chunked-seq? (seq (range 0 1000)))
08:58clojurebottrue
09:01Chousergerryxiao: does that help?
09:04gerryxiaoi want to know why use chunk,and how
09:05Chouserchunked seqs are an implementation detail -- you're meant to be able to ignore them.
09:05gerryxiaooh
09:05Chousermany builtins now produce chunked seqs when you call 'seq' on them, like range and vectors
09:05gerryxiaobut it seems master branch not support it yet?
09:06ChouserI think it does. Did you try that snippet I showed above?
09:06gerryxiaowhy still have one chunks branch?
09:07Chouserjust hasn't been deleted yet, I guess. Looks like all its patches are in master.
09:08gerryxiaoit works under master
09:09ChouserIf the chunked seq API is documented anywhere, I can't find it. For now I guess you'd have to read the code.
09:10Chouser...if you want more details.
09:10gerryxiaohow to make ant create a new dir to build another branch for clojure?
09:10gerryxiaook
09:10gerryxiaoyes, i can't find any docs about it
09:11ChouserI dunno. If I want different builds of clojure, I usually just check out a whole new local repo.
09:11Chousermaybe there's a better way I don't know about.
09:11gerryxiaoit should work, but i have to change clj script
09:12Chouseryeah, the clj script I use allows aliases, so I can run clj or clj-1.0
09:12Chouserbut it's a bit of a pain to set up, so I haven't published it anywhere.
09:13gerryxiaothat's problem of git?
09:13Chouserhm, dunno.
09:13gerryxiaowhen will 1.1 be released?
09:15Chouserthere's no firm date. I think once the reify a.k.a. "new new" is finished, you can expect a 1.1 release.
09:16gerryxiaoi have only one clojure git local copy, if i want another builds, just check it out and rebuilt it with ant
09:17Chousersure. if you want to keep both, the only way I know is to git clone a new local copy
09:26gerryxiaoi use Math/round in clojure, but complier complain it can't be resolved
09:28Chousercan take float or double, so tell it which, such as (Math/round (double x))
09:28ambienttry (Math/round (double 5.6))
09:29ambienthmm, does this work
09:29ambient,(Math/round (double 5.6))
09:29clojurebot6
09:29gerryxiaoi used (Math/round ( * 3 (float 4)))
09:30Chouserambient: sure. But with a literal like that it's not needed.
09:30gerryxiaoso i have to :(Math/round (float (* 3 (float 4))))?
09:30Chouserambient: Clojure reads 5.6 as a Double, so it knows to generate a call with a double arg.
09:31ambientk
09:31Chousergerryxiao: you don't actually have literals there, do you? But this will work: (Math/round (double (* 3 4.0)))
09:32gerryxiaoChouser: that's just one example, my code is like that
09:32gerryxiaoi think clojure should figure it out
09:33Chousergerryxiao: it does. You only need those casts if you're trying to avoid runtime reflection.
09:33Chouserthose compiler complaints are only warnings -- it'll run fine.
09:33gerryxiaook
09:35gerryxiaoclojure need one good way for type hints
09:35Chouserand in real code even if you want to avoid reflection you can usually put a few hints or casts on some args or locals and be done, rather that repeating them in the body of the code.
09:36Fossinamespace whoes
09:36ambienti don't really completely get clojure namespaces either
09:37Fossii thought my files are getting a little big, so i tried to refer some things
09:37gerryxiaosometimes, i have to repeat type hints
09:37Fossibut apparently i don't get ut either :)
09:38ChouserFossi: 'refer' is hardly ever used anymore.
09:38FossiChouser: but 'load' is ugly :(
09:38ChouserFossi: if you want multiple files for one namespace, use 'load'
09:38gerryxiaoit seems hints in let block not work sometimes
09:39ChouserFossi: if you want multiple namespaces, use 'use' or 'require'
09:39Fossii want multiple files for one namespace
09:40Fossifor example, load wants to load auto-mail.clj
09:40Fossibut the rest of clojure wants me to name it auto_mail
09:40gerryxiaodoes newnew fast than proxy?
09:41gerryxiaowhy in-ns not support :use :import?
09:41Fossiand if i use load, the file compiles, but the symbol don't seem to be "imported"
09:41Fossiah. i guess i can't use another namespace then in the other file
09:42Chousergerryxiao: I would be very surprised if hints on 'let' names sometimes fails. got an example?
09:43ChouserFossi: dashes in file names aren't really supported, because of Java naming rules. I'd try naming the file "auto_mail.clj" and then calling (load "auto_mail")
09:43Chousergerryxiao: yes, newnew is faster than proxy
09:43Fossidashes in filenames are all over the place
09:43ol3(doc circle)
09:43clojurebotExcuse me?
09:43ol3(doc circel)
09:43clojurebotTitim gan éirí ort.
09:44gerryxiaoin my code, in let block [g2d #^Graphics2D g] (doseq [x y] (.drawString g2d ....))
09:44gerryxiaoi got .drawString not resolved
09:44Chousergerryxiao: try (let [#^Graphics2D g2d g] ...)
09:44Fossithat has nothing to do with the type hint
09:45Chousergerryxiao: so that you're hinting the name an not the value.
09:45ChouserFossi: "all over the place"?
09:45FossiChouser: well, half of clojure-contrib has them
09:46ChouserFossi: nope. namespace names, sure, but no dashes in file names
09:46gerryxiaog2d #^Graphics2D g is change g to Graphics2d
09:46gerryxiaotype cast
09:46gerryxiaoright?
09:46liwpgerryxiao: yes, but g2d is still of type Object
09:47liwpwith [#^Graphics2d g2d ...] you've type hinted g2d as of type Graphics2d
09:47gerryxiaoso i have type #^Graphics2D twice?
09:47Chouseractually, that's not the problem
09:47ChouserSorry, I mislead.
09:48liwpgerryxiao: no, just once
09:48ChouserIt's more likely the args to .drawString -- there may be multiple methods, so you'd have to hint one or more of the args as well, if you want to avoid reflection.
09:48Chouseragain, reflection isn't the end of the world, it's just a runtime performance hit.
09:49Fossi"gerryxiao: i got .drawString not resolved" sounds to me as if you call it with the wrong parameters anyway
09:49gerryxiaoChouser, yes, drawString have many overide methods, and it's in Graphics
09:49Fossiafaik things should work without any cast
09:49gerryxiaothat's Graphics2D supper class
09:49Fossi(but a little slower)
09:50gerryxiaoFossi: no, if parameter is wrong, i will get error not warning
09:51Fossiok, i thought it was an error
09:52FossiChouser: sorry, i misread
09:52Fossibut still, it's ugly to have to load "auto_mail" if i would use "auto-mail"
09:52gerryxiaoyes, it works without type hints
09:53ChouserFossi: if you're using 'load', I don't think you'd ever mention 'auto-mail'.
09:53ol3(doc cycle)
09:53clojurebot"([coll]); Returns a lazy (infinite!) sequence of repetitions of the items in coll."
09:53ol3clojurebot: thanks
09:53clojurebotPardon?
09:53Fossiand it's ugly that ns :load etc don't have the same semantics as load etc
09:53FossiChouser: can i still define a namespace in the other file?
09:54Fossior do i have to use require and use directly?
09:54Chousera new namespace?
09:54gerryxiaoi want in-ns support :use :import
09:54Fossipoint is, i might want to use some of these files diretly as well
09:54Chouserif the other file defines a new namespace, it should do so using 'ns' and :use/:require. Then your current file can use :use/:require instead of load.
09:55gerryxiaoi have to use :use :import only in one file
09:55Fossii have foo which wants to use 'service' which is a bunch of services
09:55gerryxiaoi don't want use (use ) (import)
09:56Fossiso i thought i'd :refer auto-mail and other services into a bigger namespace
09:56hchbawFossi: actually, clj/core.clj does (load "core_proxy") and such.
09:56Fossifor a bar, i might refer some other things as 'service' later on
09:56gerryxiaofirst file main.clj (ns www.dfj.com (:use ..) (:import) ...)
09:57Fossihchbaw: i didn't say it doesn't work, i just think it's ugly :)
09:57hchbawOh, sorry :)
09:57gerryxiaosecond file helper.clj (in-ns www.defj.com ) (import ...) ) ???
09:57Fossihchbaw: you wrote the fuzzy-complete, right?
09:58hchbawFossi: yes, almost copied from the original CL implementation.
09:58Fossigerryxiao: normally, i put it in another namespace and use that from main.clj
09:58liwpgerryxiao: can't you use the (ns) macro in your file which does support :use etc.?
09:59Fossihchbaw: almost works here now. it's a little weird what symbols it can complete and which not
09:59liwp,(ns foo (:use bar))
09:59clojurebotjava.io.FileNotFoundException: Could not locate bar__init.class or bar.clj on classpath:
09:59Fossihchbaw: i guess it's best used with hippie-complete
09:59liwp,`(ns foo (:use bar))
09:59clojurebot(clojure.core/ns sandbox/foo (:use sandbox/bar))
09:59ChouserIt's not recommended to use 'ns' for the same namespace in more than one place.
09:59liwpahh, I missed that bit of the problem
10:00liwphow do I get the macro expansion out of clojurebot?
10:00liwp,(macroexpand (ns foo (:use bar)))
10:00clojurebotjava.io.FileNotFoundException: Could not locate bar__init.class or bar.clj on classpath:
10:01liwp,(macroexpand '(ns foo (:use bar)))
10:01clojurebot(do (clojure.core/in-ns (quote foo)) (clojure.core/with-loading-context (clojure.core/refer (quote clojure.core)) (clojure.core/use (quote bar))))
10:01Fossii wish use would support [namespace class class2]
10:01liwpChouser: so why shouldn't one use (ns) for the same namespace from more than one file?
10:02liwpis it that with-loading-context bit that causes problems? Or possibly refer 'clojure.core?
10:03Chouserliwp: well, it mostly works. :refer-clojure wouldn't do what you expect, but other than that I think it's about maintaining a clear difference between the controlling and controlled files.
10:03liwpok
10:04liwpI was just thinking that in the repl you would do (in-ns 'foo) and then def a bunch of stuff which is sort of the same thing as using (ns) with the same namespace in multiple files...
10:04liwpbut apparently not exactly the same thing looking at the expansion of (ns)
10:07ol3hello, is it possible to escape from an doseq form, or should i use something like every?
10:08Chouserol3: other than :while clauses, there's no escape.
10:09ol3hm
10:11ol3(every? (fn [item] (do-something-with-item) (if (continue?) true false)) seq)
10:12Chouserol3: hm... I guess you could do all that in a :while clause
10:12ambientdoes there exist a list anywhere, of all the features and keybindings of clojure-mode for emacs?
10:12ambientor is it simply all in the clojure-mode.el file?
10:13stuartsierraambient: Type "C-h m" in a clojure-mode buffer
10:13Chousercgrand: I can't forget -- every time one gets a feature, I end up porting it to the other!
10:14ambientstuartsierra that does nothing
10:14cgrand"doseq, a sisyphean drama"
10:15ambientweird, C-h m works in repl, but not in file buffer
10:15stuartsierraambient: hmm, I dunno, that's the standard describe-mode command in Emacs
10:19Fossiok, i got load to work. i still think it's an ugly solution
10:20Fossiwhy is refer 'deprecated'?
10:20Fossiit seems like the cleaner way of doing this
10:20Chouserit's not deperecated, it's just usually used via 'use' instead of on its own.
10:21Fossiwell, use doesn't do what i want
10:21ambientis there a way to load a java library to the repl that is not in the classpath?
10:21ambientlike (load-jar "swt.jar")
10:21Fossii want to smash multiple namespaces together
10:23ChouserFossi: 'use' does a 'load' and then a 'refer'
10:23stuartsierraambient: there is add-to-classpath, but it does not work in all situations and is vaguely deprecated
10:23Chouser'refer' by itself doesn't do anything with files -- won't load a new one.
10:23Fossihmmm. so i can call function from other namespaces in that one then?
10:23Fossii thought that was what refer does
10:25Fossi(ns foo (:use some.service :as service)) (service/baz) - ( (ns some.service (:refer service-part)) - (ns service-part) (defn baz)
10:26Fossiwould that work?
10:27Chouserthat would work, though baz would not be visible in foo (using neither 'use' nor 'refer')
10:27Chouseroh
10:27Chousersorry, wait.
10:28Chouserno, service/baz would not work
10:29Fossihmm. too bad.
10:31Fossihmmm. if i load a file then, how do i call functions of the namespace i'm being loaded into?
10:31Fossior can i require it as well?
10:31Fossiah, this is ugly
10:31Chousersome.service could say (def baz service-part/baz) to make it available to users of some.service.
10:31Fossii need to find some other way
10:32Fossithanks for the help so far though
10:57ambientthis is pretty cool http://travis-whitton.blogspot.com/2009/09/hot-code-swapping-with-clojure.html
10:59Chouserreloading a lib is not atomic
10:59ambientyeah that part seemed pure conjecture for me too
11:01ambienthow would one go about making lib reloading atomic?
11:02ambient100% written with clojure?
11:03Chouserambient: maybe try to load everything into a new namespace and then do a CAS swap somehow.
11:20ol3Is it possible to get a sequence of all threads?
11:21Chouser,(keys (Thread/getAllStackTraces))
11:21clojurebotjava.security.AccessControlException: access denied (java.lang.RuntimePermission getStackTrace)
11:21Chouserwell, that'll work outside a sandbox
11:22tmountainhey guys, I wrote that blog post above, I'll update it to indicate that reloading isn't atomic
11:23ol3Chouser: cool thanks
11:24Chousertmountain: sounds good. Depending on the change you're loading, it may not matter.
11:25Chousertmountain: each def (and defn) is atomic, so you won't load a half-redefined function, but if your change is in two different defn's, and those changes rely on each other, you could potentially have problems.
11:25tmountainChouser: ok, good to know. I will include that in my update.
11:25Chouserthanks! nice post, btw. :-)
11:27tmountainthanks, Clojure is just too much fun!
11:28ambientim still having trouble in getting all the edged smoothed out in my development process :/
11:29ambientnetbeans is bad at building simple one-file test projects and emacs takes time to get used to
11:30cemerickambient: are you using enclojure?
11:31ambienti tried it but had trouble managing the files in my project and connecting the repl to the files
11:32ambientseems there's no proper getting started for any IDE, which would explain the whole development process so it's all diving into the deep end of the pool no matter what i try
11:32cemerickYou should just be able to right click on your project, and start a repl for it.
11:32stuartsierraambient: I recommend you first get comfortable configuring your project, classpath, REPL, etc. at the command line.
11:32stuartsierraThen tackle the IDE integration, you'll find it much easier.
11:33ambientyeah, seems that's the only way to *truly* get it
11:33cemerickstuartsierra: is that sort of like "learn math with a pencil, then use the calculator"?
11:33stuartsierracemerick: yes. Or like "learn assembly, then write C"
11:34stuartsierraAlthough I never really learned assembly.
11:34ambienti know both and would just stay with idiomatic K&R C first
11:34cemerickand I never really learned C (though I did plenty of damage with it :-P )
11:35ambientperhaps more appropriate analogy would be to buy a ball before you start playing football
11:35ambientotherwise you're just kicking around on empty air
11:35ambient..hoping to hit something
11:41raphinouhi, any vimclojure user here?
11:49stuartsierraMore Maven-fu, setting up your own public repository: http://stuartsierra.com/2009/09/08/run-your-own-maven-repository
11:52tmountainraphinou: me
11:53raphinoutmountain: I have installed it successfully (I think: syntax coloring works, I can call a repl manually), but the mappings are not working.
11:53AWizzArdOh funny, I found a bug in Suns regex code.
11:53AWizzArd,(re-find #"(a)?123|x" "xyz")
11:53clojurebot["x" nil]
11:53AWizzArd,(re-find #"(a)?1234|x" "xyz")
11:53clojurebotnil
11:54AWizzArdIt's already submitted to Sun.
11:54ol3is it ok to construct a lazy-sequence which values depend on a ref, or is this too clever?
11:55AWizzArdPerl, clppcre and Co perform correctly.
11:55tmountainraphinou: did you define maplocalleader?
11:55tmountainraphinou: let maplocalleader = "," (in your vimrc)
11:56raphinoutmountain: not currently. tried it this morning but without success.
11:56raphinouI'll try again for 100% security
11:56tmountainraphinou: did you confirm nailgun was running?
11:56raphinouyes, laingun is fine, and its classpath ok
11:57tmountainraphinou: I've found it can be slightly challenging to get it setup, but once it's working, you'll love it
11:58raphinouwhen I press the , the screen flashes, which doesn't happen when I have a mapping defined
11:58raphinoutmountain: yes, that's why I'm still trying :-)
12:01tmountainraphinou: do you have let vimclojure#NailgunClient = "/your/path/vimclojure/ng" and let clj_want_gorilla = 1 ?
12:02raphinoutmountain: yes, as explained on the website and the doc
12:02raphinouI think the problem is more that the mappings are not available. Don't know how that comes
12:05tmountainraphinou: they're sourced from clojure.vim (loaded from ~/.vim/ftplugin/clojure.vim)
12:06tmountainraphinou: if you search that file for "vimclojure_namespace", you'll see their definitions
12:07raphinoutmountain: yes. But I suspect not everything is loaded correctly. the function vimclojure#EvalLine is defined and I can call it, but it gives errors: Undefined variable: b:vimclojure_namespace
12:08tmountainraphinou: the definitions are provided via ~/.vim/autoload/vimclojure.vim. it sounds as if that file isn't being sourced properly
12:11tmountainraphinou: what happens if you start vim on a new empty clojure file (i.e., vim new.clj) and then type ,sr ?
12:12raphinoutmountain: starts fine with syntax highlighting ok
12:12raphinouno error messages
12:13raphinouand filetype detexted is clojure
12:14tmountaindoes it start a repl, or no?
12:15raphinoutmountain: no
12:18tmountainraphinou: what operating system?
12:18raphinoudebian linux, vim 7.1
12:19tmountainraphinou: what's the output of ps aux | grep -i nail ?
12:20hamzahey guys, is there a revers of assoc for vectors? instead of using subvec to remove an item at a specified index. the doc dissoc does not say it is suitable for vectors?
12:24raphinoutmountain: martiansoftware on 127.0.0.1
12:30tmountainraphinou: start vim once more on a new file (i.e., foo.clj) and try this - :call vimclojure#Repl.New()
12:32raphinoutmountain: I'm restarting everything from scratch now (clean environment, etc)
12:33tmountainraphinou: ok, if you still have issues, try the previous suggestion to determine whether vim can talk to nailgun
12:34raphinoutmounain: ok, repl is there now, but I don't know why it started working as it's before I restarted from scratch :(
12:36raphinoutmountain: still issues when opening existing file, but it's a problems with classpath. I'll investigate further. Thanks for your help!
12:38tmountainraphinou: no problem, best of luck
12:38tmountainraphinou: try opening a file without a namespace at the top, and I bet it works
12:39raphinoutmountain: you're right
12:40raphinouany idea how to fix this?
12:40raphinoubut the mappings still arent there though :(
12:42tmountainraphinou: the namespace thing is a classpath issue
12:43tmountainbasically the file has to be part of nailgun's classpath
12:43tmountainnot your local shell classpath
12:44raphinoutmountain: classpath (for nail server and the vim I start) contains base directory of the clojure file's namespace
12:45raphinoutmountain: ok, it was the classpath env variabels that was not exported I think....
12:46tmountainraphinou: yeah, it's pretty finicky
12:46raphinoutmountain: it's working at last! wow
12:47tmountainraphinou: awesome ;-)
12:47raphinouthanks a bunch for you help! No I'll be able to see if it was worth the effort as you said :-)
12:47raphinous/No/Now/
12:47tmountainit's great tool for developing without leaving your editor
12:48tmountainjust eval a form, go into a repl, test, etc...
12:48raphinouyes. I already remember the evaluate line mapping :-)
12:48raphinoujust in time as I need to go now. See you later, bye!
13:17ambienti find this curious: if i have music.clj and namespace foo.bar.music, and i want to extend to foo.bar.music.one and foo.bar.music.two i have to destroy music.clj, create music directory and create one and two.clj into that dir?
13:18Chouseryou can have foo/bar/music.clj and foo/bar/music/one.clj
13:18Chouserfor foo.bar.music and foo.bar.music.one respectively.
13:18ambientoh ok :)
13:49Fossiwhat was the idiom again for turning [[1 2] [1 2]] into [[1 1] [2 2]]?
13:50Fossiah, interleave
13:50Fossihmm. almost
13:50Fossi;)
13:52Fossianything better than (partition 2 (apply interleave [[1 2] [1 2]]))?
13:54AWizzArdstuartsierra: about clojure.contrib.profile, I may have found a bug. When you have (defn foo [x] (prof :foo (+ x 10))) and then do (profile (map foo (range 5))) ==> java.lang.IllegalArgumentException: Wrong number of args passed to: core$max
13:54AWizzArdclojurebot: max people
13:54clojurebotmax people is 164
13:56AWizzArdstuartsierra: but (profile (doseq [i (range 5)] (foo i))) works fine.
14:00Fossiactually, the solution to my problem is (let [foo (apply interleave [[[10] [20]] [[11] [21]] [[12] [22]]])] (split-at (/ (count foo) 2) foo)) :)
14:00Fossibut i bet there is a nicer way
14:02stuartsierraAWizzArd: ok I'll take a look. Could you file an Assembla ticket?
14:35stuartsierraAnybody have a link for the slides (not video) to rhickey's talk "Clojure for Java Programmers"?
14:35Chouser,(apply map vector [[1 2] [1 2]])
14:35clojurebot([1 1] [2 2])
14:39stuartsierraah, found it on the Group Files page.
14:43AWizzArdstuartsierra: I need an account on Assembla to open a ticket, yes?
14:43ChouserAWizzArd: no, just use the "support" tab
14:43AWizzArdok good, thx
14:47AWizzArdChouser: hmm, on http://www.assembla.com/spaces/clojure-contrib/support/tickets it tells me "You must login or register to submit a support ticket".
14:48AWizzArdI will try a BugMeNot account
14:49Chouserhm, I wonder if that changed at some point. I guess you need an assembla account, but no special permissions.
14:50LauJensenDid we decide what a Clojure programmer is called? Clojurist? Clojurian ? Clabango?
14:52stuartsierraCluje
14:52drewrLauJensen: "Clojure programmer"
14:53stuartsierra"Smug Java Weenie"
14:53drewra "clojurian" is someone who sits around trying to think about what to call clojure programmers :-)
14:53LauJensennoobs :)
14:55ChouserClojurian
14:56Chouserhttp://clojure-log.n01se.net/date/2008-10-17.html#08:26b
14:59Chouseralso: http://www.computerworld.com.au/article/313989/-z_programming_languages_clojure?pp=3
14:59LauJensenIts settled and documented :)
15:01LauJensenPerfect reference, thank you Mr. Chouser sir
15:02ChousukeClabango :D
15:02ChousukeMaybe that could be used as the title of an experienced Clojurian.
15:03LauJensenChousuke: No, its just something rhickey exclaims when he hands you your black belt
15:07hiredman~suddenly rhickey hands you a belt made of fine black italian leather!
15:07clojurebotCLABANGO!
15:07LauJensenhehe
15:09manic12does clojure have a test library?
15:09Chousukeclojure.test if you're using master, contrib.test-is if 1.0
15:10manic12ok, I'll have to try it on this arm9 that clojure seems to run on
15:10Chousukenote that if you're using 1.0 you need the 1.0-compatible branch of contrib
15:10manic12is 1.0 the newer?
15:11stuartsierra1.0 is the official release; Git master is current development, like SVN trunk
15:11manic12ok
15:12manic12with all the concurrency stuff, a 200mhz arm board is probably a boring target
15:12Chousukeheh.
15:12Chousukewell, it'll be an interesting experiment nonetheless
15:12Chousuketo see what happens :P
15:13manic12it works so far
15:17manic12am i supposed to git test-is or is there a tar.gz or bz2 somewhere?
15:17technomancythe 1.0 release is a tarbomb IIRC, so watch out.
15:17stuartsierramanic12: test-is can be found in the "clojure-1.0-compatible" branch of Clojure-contrib.
15:18stuartsierrahttp://github.com/richhickey/clojure-contrib
15:20manic12for my workstation I do prefer git, but for this arm board, if I could find where that 1.0-compatible tarball is, it would be useful
15:20manic12I guess I could make one
15:20stuartsierrathere is no tarball
15:21hiredmanyou can download the branch as a tarball from github
15:21stuartsierrature
15:21stuartsierratrue
15:22hiredmanactually
15:22hiredmancan you?, I don't see a way to do that anymore
15:22manic12anybody know the git clone repository name for the 1.0 compatible contribs?
15:24Chousukemanic12: it's in the contrib repo
15:24Chousukeyou clone it, then just checkout the master branch in your clone.
15:24Chousukeer
15:24Chouserhttp://github.com/richhickey/clojure-contrib/tarball/clojure-1.0-compatible
15:24Chousukethe compatible branch of course.
15:24Chouserthat's the tarball link
15:24Chousukeor you can do that I guess :)
15:25manic12thx
15:34manic12it takes about 30 seconds from the time you start clojure till the time the user=> prompt shows up on this computer
15:40hiredmanthe jvm startup times can be painful
15:40hiredman(but is five seconds or less here)
15:43ambienthow can i generate character frequencies from a string into a map?
15:44ambientshould i just write loop/recur?
15:45hiredmansounds like reduce
15:46hiredman,(let [+i (fn [n] (inc (or n 0)))] (reduce #(update-in % [%2] +i) (seq "foo bar baz"))
15:46clojurebotEOF while reading
15:47hiredman,(let [+i (fn [n] (inc (or n 0)))] (reduce #(update-in % [%2] +i) (seq "foo bar baz")))
15:47clojurebotjava.lang.ClassCastException: java.lang.Character cannot be cast to clojure.lang.Associative
15:47hiredman,(let [+i (fn [n] (inc (or n 0)))] (reduce #(update-in % [%2] +i) {} (seq "foo bar baz")))
15:47clojurebot{\z 1, \r 1, \a 2, \b 2, \space 2, \o 2, \f 1}
15:47manic12hiredman: jamvm actually, not jvm in this case
15:47hiredmanmanic12: jamvm is a jvm :P
15:48Chouser,(reduce #(assoc % %2 (inc (% %2 0))) {} "foo bar baz")
15:48clojurebot{\z 1, \r 1, \a 2, \b 2, \space 2, \o 2, \f 1}
15:49ambientok, ty.
15:49hiredmanChouser: cute
15:49hiredman(% %2 0)
15:49Chouserheh
15:50Chouserits meaning is obvious, right?
15:50hiredmansure sure
15:50ambientyou're using the key as a function?
15:50hiredman"obvious"
15:50Chouserthe map as a function.
15:50Chousercould say (get % %2 0)
15:50Chouserand waste 4 chars
15:50hiredmanthat might be a little more clear
15:51ambientwell i still need to think about that. functional style programming is just very slowly absorbing information for me
15:52ambientsomehow it's a lot easier with scheme because it has so few core operations
15:53ambienti think almost all my functions exploited some kind of tail recursion, now that i can't do it, i miss it
15:54stuartsierraambient: you can still do tail recursion with loop/recur
15:54ambientyes, but that's not the same :)
15:56stuartsierraUsually it is. Writing recur in a function without an enclosing loop is the same as a tail recursive call in Scheme.
15:56stuartsierraClojure is just a little more restrictive regarding the definition of "tail position."
15:57Chouser,(-> [a b] (fn (assoc a b (-> b (a 0) inc))) (reduce {} "foo bar baz"))
15:57clojurebot{\z 1, \r 1, \a 2, \b 2, \space 2, \o 2, \f 1}
15:57ambientyes, it might be the same semantically but i can wrap my head around scheme's way of doing things a lot better
15:57Chouserthere, that should clear things up
16:00ambientnow priority queue... this will be harder
16:01manic12is there an apropos?
16:01Chouserambient: I've got most of a priority queue working, built on finger trees.
16:02ambientidk, maybe i could use sorted map
16:02Chousermanic12: (find-doc "find-doc")
16:02ambientChouser cool
16:02ambienti hope you blog about them that the rest of us mortals can comprehend ;)
16:02hiredman,(pl (↕reduce "foo bar baz" {} λab (assoc a b (inc · a b 0 ))))
16:02Chouserambient: so as long as you don't need it for a week or so, you can probably just wait 'til I'm done and then use it.
16:02clojurebot{\z 1, \r 1, \a 2, \b 2, \space 2, \o 2, \f 1}
16:03ambienti spy lambda with my little eye
16:04ambientclojure character support is more than ASCII?
16:05stuartsierraambient: yes, it supports anything Java supports, so at least UTF-8.
16:05hiredmanutf8
16:05ambientthat's nice, and weird :)
16:05stuartsierraNot all editors play nice with UTF-8, though.
16:05ambientand not all fonts
16:05hiredman:/
16:05hiredmanclojurebot: the man?
16:05clojurebot☝(^_^)☝
16:05duck1123and those shall not be talked about
16:06ambientyou made me switch to dejavu sans mono :|
16:06hiredmanyeah
16:07hiredmandejavu sans mono has the best coverage of any fixed width font I've tried
16:07duck1123I wonder how crazy a clojure minifier could get. I'm sure you could do some crazy tricks
16:07ambientbut i want to use my old MS-DOS fonts :(
16:07ambientborland turbo c, oh yeah
16:08ambientduck1123 APL is pretty sweet in that regard
16:10ambientwhich will be never
16:10duck1123you don't think it'll happen?
16:10Chouserof course it will happen
16:11ambientif you mean using clojure to write javascript then, yeah
16:11duck1123I was talking more about clojurescript
16:13Chouserquite a lot was working there for a while -- persistent vectors, maps, destructuring, macros, dynamic binding, for, loop/recur, ...
16:13Chouserprobably still works if you don't mind that it's pre-1.0 clojure. :-/
16:14ambientwell im looking at this: http://code.google.com/p/jc-pheap/ atm
16:14hiredmanmaybe clojurebot should export its brain as a set of rdf triples
16:15duck1123I would like to be able to include a certain javascript library and have it load any text/clojurescript script elements and executes them
16:15duck1123hiredman: yes please
16:15hiredmanI'd have to learn how to do that
16:16duck1123I've got some old Jena/clojure code in my archives that I threw out
16:16duck1123I could dig them out and paste them if you want, but i think someone did a library
16:17Chouserrhickey did a library
16:17stuartsierraI did too
16:17duck1123I gave up on actual rdf parsers/libraries when I decided to fake it
17:13drewrstuartsierra: do you have a way to tie in custom deserialization in c.c.json.read?
17:20stuartsierranot sure what you mean
17:21stuartsierraIt just reads JSON. You can't extend its idea of what valid JSON is, if that's what you mean.
17:23drewrI'd like to have a fn called on a value after it's deserialized
17:24stuartsierraLike a callback? No, it doesn't do that.
17:24drewrwanted to make sure I wasn't overlooking something
17:24stuartsierraJust call the function directly on the deserialized object.
17:26stuartsierraIt's not a streaming parser, some Java libraries do that.
17:30drewrok, so I'd like to traverse my resulting object and convert all the Longs to Dates, trying to use walk to do it
17:30drewrwhat's wrong with this?
17:30drewr(walk #(if (= % "bar") :bar_was_here %) identity {:foo "bar"})
17:30drewr=> {:foo "bar"}
17:31stuartsierradon't call walk directly, use prewalk or postwalk
17:32drewrah, thanks
17:33stuartsierrauser> (prewalk #(if (= % "bar") :bar_was_here %) {:foo "bar"})
17:33stuartsierra{:foo :bar_was_here}
17:33clojurebotfoo is is Short, Self Contained, Correct (Compilable), Example http://sscce.org/
17:34hiredmanclojurebot: what is wrong with you?
17:34clojurebotRoger.
17:36lowlycoderhas anyone written a 3d opengl game using clojure? the jogl/jni calls are really hurting me right now
17:36stuartsierrathere are 2 JOGL wrappers in Clojure; look on the mailing list
17:36stuartsierraI think they're still findable there
17:41LauJensenI'm doing a post on PHP (typical webdev) vs Cloure/Servlets, anybody that can find 5 minz to skim, just to see if I touched on the most important stuff?
17:46unlinkAm I missing out on a more obvious way of doing this? (reduce (fn [acc x] (assoc acc x (inc (get acc x 0)))) {} coll)
17:49hiredman,(pl (↕reduce "foo bar baz" {} λab (assoc a b (inc · a b 0 ))))
17:49clojurebot{\z 1, \r 1, \a 2, \b 2, \space 2, \o 2, \f 1}
17:49Chouserthat looks familiar
17:49hiredmanChouser: yeah, almost like you could have written it…
18:15ambientChouser got that finger tree source code lying anywhere on the web?
18:15ambient*laying around
18:20Chouserambient: http://github.com/Chouser/finger-tree
18:21Chousernot yet alpha, but it is what it is.
18:21ambientwell it looks heave, something for me to parse while i listen to trance
18:22ambient*heavy
18:22Chouserheh
18:22Chouseroh, it needs the newnew branch of clojure
18:23hiredman(reify)
18:50jbellhey guys, can anyone show me how to make a powerset function in clojure?
18:55Chousukehmm
18:55Chousuke(doc reductions)
18:55clojurebot"([f coll] [f init coll]); Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init."
18:55Chouser~google clojure powerset
18:55Chousukedamn, no namespace.
18:55clojurebotFirst, out of 5150 results is:
18:55clojurebotCribbage points counter in Clojure « Occasionally sane
18:55clojurebothttp://gnuvince.wordpress.com/2008/10/11/cribbage-points-counter-in-clojure/
18:56jbellsure, I saw that, thanks.. is that the best way to do it? it's quite different from the lisp map way I'm used to
18:59hiredmansomeone must have use'ed that namespace
18:59ChousukeI thought about writing a powerset with reductions but it's not quite a powerset :P
18:59Chousuke,(reductions (fn [a b] (conj a b)) #{} [1 2 3 4])
18:59clojurebot(#{} #{1} #{1 2} #{1 2 3} #{1 2 3 4})
19:01Chousukewait. why did I use that anonymous function.
19:03jbellis the reductions function/macro from another namespace?
19:03ChousukeI think it should be c.c.seq-utils
19:03Chousukeor something
19:03jbellcool, I'll try that
19:26jbellam I right to think that the clojure contrib 1.0.0 jar doesn't include seq-utils
19:26jbell?
19:26hiredmanwhich "the"
19:27hiredmanas far as I know there is no "the" clojure contrib jar
19:27jbellI got it packaged with enclojure
19:29ChousukeI'm not sure if I got the namespace right, even
19:29hiredmanjbell: and what leads you to believe it does not include seq-utils?
19:29Chousuke~def reductions
19:31jbellthanks clojurebot
19:32jbellhow do I get and compile the freshest version of contrib to have a jar in netbeans?
19:33jbellI expect I d/l from github, but then how do I compile it?
19:36Chousukeyou can try without compiling first I suppose.
19:37ChousukeI mean, plain "ant" will give you a jar to use.
19:37jbellhmm, I think it's a maven project
19:37Chousukeif you actually want to compile (the pretty printer requires it) then you need to do ant -Dclojure.jar=/path/to/clojure.jar
19:38Chousukeand I can't give any IDE-specific advice /:
19:38ChousukeI don't use IDEs myself. besides emacs, which is actually the Borg
19:38jbellahh right ok :)
19:38jbellI like vim, although I don't know how much more trouble I'd be in setting that up
19:39Chousukein 50 years emacs will have become self-sufficient and develops itself through mind-washed coder drones
19:41ChousukeActually, maybe that already has happened. :/
19:41technomancyChousuke: I give it five years.
19:41ChousukeChouser: that's what the emacs wants you to think!
19:42Chousukeit's a symbiotic relationship anyway
19:43ChouserChousuke: emacs codes in you!?
19:43Chousukeemacs takes advantage of humans but in exchange we get... emacs.
19:46ChousukeI wonder what it would take to compile and run some ancient version of emacs.
19:46ChousukeI'm kind of interested in what it was like when it was young :P
19:47Chousukebut maybe later.
19:50jbellif you can sum up emacs and its significance to your coding I'd like to know it
19:51technomancyjbell: simple: it's trivial to modify your environment at-will during runtime.
19:51technomancyhttp://technomancy.us/115 <= sums it up in longer format
19:51jbellcool will look
19:52technomancyin interests of full disclosure
19:53technomancydamned if it isn't hard for me to type "closure" correctly these days
19:58tomojtechnomancy: +1 on emacs-starter-kit working fine in aquamacs :)
19:58tomojthanks bunches
19:58technomancytomoj: great!
20:02ambienthmm, there's must be a better way of doing this (reduce #(conj % [(get %2 1) (get %2 0)]) (sorted-set) freqs)
20:05arbschtambient: what is freqs and what is your code supposed to do?
20:05ambientfreqs is character frequency map like {\a 2, \h 5, \m 1} etc
20:05Chouser(into (sorted-set) (map (comp vec reverse) freqs))
20:05Chouserdunno if that's better
20:06Chouser(into (sorted-set) (for [[k v] freqs] [v k]))
20:07ambientyeah, that's better :)
20:08Chouser(reduce (fn [s [k v]] (conj s [v k])) (sorted-set) freqs)
20:08ambientis that in any way better?
20:09ambientah well.. time to construct the binary sequences
20:09Chouser(into (sorted-set) (map vector (vals freqs) (keys freqs)))
20:10Chouserso many ways to skin that particular cat. I guess I like the 'for' best so far.
20:10ambientyeah the first one is the most readable
20:10ambientwith for
20:12jbellChouser, how would you skin the powerset cat?
20:12ChouserChousuke: had a nice one, didn't he?
20:13Chouser,(reductions conj #{} [1 2 3 4])
20:13clojurebot(#{} #{1} #{1 2} #{1 2 3} #{1 2 3 4})
20:13Chouserpretty hard to beat
20:14jbelllol, I've only just realised what clojurebot is
20:16jbellthat one isn't powerset function though
20:17jbellif clojurebot is evaluating it correctly
20:17Chouseroh.
20:17Chouseroh, indeed.
20:18Chouserjbell: I posted a link. the first google hit for: clojure powerset is a blog post with a code snippet
20:19jbellsure, I saw that, I wondered if you had a better way to skin it :P
20:30ambientoh, there was frequencies already in seq-utils :)
20:33nathanmarzhey all
20:33nathanmarzlooking at clojure core code
20:33nathanmarzwhy is reverse defined like this:
20:33nathanmarz(defn reverse
20:33nathanmarz "Returns a seq of the items in coll in reverse order. Not lazy."
20:33nathanmarz [coll]
20:33nathanmarz (reduce conj () coll))
20:34nathanmarzdoesn't conj not guarantee where in the array things will get added?
20:35rhickey_nathanmarz: conjing onto a list puts things at the front, so walking one seq and building a list will reverse it
20:36nathanmarzah right, cool
20:36rhickey_,(conj () 1 2 3)
20:36clojurebot(3 2 1)
20:37rhickey_,(conj [] 1 2 3)
20:37clojurebot[1 2 3]
20:42Chouserrhickey_: I'm currently using consLeft and consRight as method names for double-headed things. How does that strike you?
20:42Chouserfor such a thing 'cons' would call consLeft, 'conj' would call consRight
20:43hiredman:/
20:43hiredmanseems like it would be nice to be able to switch somehow from left conj to right conj
20:44hiredmanIRightConj ILeftConj
20:45ChouserI tried to do that, but at least for finger-trees I couldn't find a way to switch from one way to the other in O(1) time.
20:45hiredmanI see
20:45rhickey_Chouser: sounds ok
20:45Chouserthe problem being when you concat a forward to a reversed tree.
20:51Chouser,((fn pset [c] (when-let [[f & r] c] (concat (map #(conj % f) (pset r)) (pset r) [#{f}]))) [1 2 3 4])
20:51clojurebot(#{1 2 3 4} #{1 2 4} #{1 2 3} #{1 3 4} #{1 4} #{1 3} #{1 2} #{2 3 4} #{2 4} #{2 3} #{3 4} #{4} #{3} #{2} #{1})
20:52Chouserthat'll blow the stack for big input collections
20:52clojurebotfor is not used enough
20:52ambientaw, i don't think there's sorted-set-by :(
20:52ambienti can't set the comparison function for sorted-set
20:53Chouserambient: http://www.assembla.com/spaces/clojure/tickets/79
20:55jbellcool, that's more like what I wanted to do
21:00jbellChouser: I just wanted to write a quick powerset function to test something out, so I was going for natural rather than efficient
21:01ChouserThis is slightly better:
21:02Chouser,(letfn [(pset [[f & r :as c]] (when c (lazy-cat (map #(conj % f) (pset r)) (pset r) [#{f}])))] (pset [1 2 3 4]))
21:02clojurebot(#{1 2 3 4} #{1 2 4} #{1 2 3} #{1 3 4} #{1 4} #{1 3} #{1 2} #{2 3 4} #{2 4} #{2 3} #{3 4} #{4} #{3} #{2} #{1})
21:02Chouserusing lazy-cat means it can give you the head of the seq faster.
21:02hiredmanwill that work with a list instead of a set?
21:02Chouseryes
21:03Chouserjust use (list f) instead of #{f}
21:03Chouseror [f]
21:07jbellI was really intrigued when Rich said about how you could do aspect/context programming by dynamically binding the functions, but my attempt failed, and I couldn't find anything online
21:07hiredmanfailed how?
21:09jbellI tried to use let to bind the function in context, I think I know now... you use letfn?
21:09hiredmannow
21:09hiredmanno
21:09arbscht,(doc binding)
21:09clojurebot"([bindings & body]); binding => var-symbol init-expr Creates new bindings for the (already-existing) vars, with the supplied initial values, executes the exprs in an implicit do, then re-establishes the bindings that existed before."
21:09hiredmanwell, you can use let to bind a name to something else in a lexical scope
21:10hiredmanbut you most likely want dynamic scope, which would use binding
21:13jbellgreat thanks
21:14hiredmanwoa
21:14hiredmanwhat is this?
21:15jbelldoes anyone else think that 'cross-cutting concerns' isn't a great name for aspects covered by AspectJ?
21:16hiredmanrhickey is going to be on the MS campus next week, according to twitter
21:20hiredmanrhickey: is this true?
21:25jbellI guess I won't have to care anymore lol
21:26jbellChouser: why would you want the head of the seq faster?
21:28Chouserwhy not?
21:29Chouserit helps if you only need the first few items, or if you're going to process the seq in parallel with something else such as with pmap or seque
21:30jbellright, so is pset utilising that change?
21:30jbellsorry...
21:30jbellthat was nonsense lol
21:30Chouseroh, good. I couldn't understand. :-)
21:30jbelllol, I saw p for parallel
21:30Chouserah!
21:31Chouseryeah, sorry, bad abbreviation.
21:31ChouserChousuke should have slapped me.
21:32jbellI just couldn't see how in this algorithm getting the head faster would make any improvement. I haven't analysed it very much, though
21:32hiredmanclojurebot: whose job is it to make sure everyone uses good abbreviations?
21:32clojurebotYou don't have to tell me twice.
21:32hiredman:/
21:32Chouserclojurebot: whose job?
21:32clojurebotwhose job is it to make sure everyone uses good abbreviations
21:33hiredmansomething is broken
21:33hiredman*sigh*
21:33ChouserWho's on first.
21:33Chouserjbell: it's just lazy-cat vs. concat.
21:33Chouserjbell: concat is a fn, so all its args are evaluated up front, even if don't need the later items until later
21:34Chouserjbell: lazy-cat is a macro, and it delays evalling the args until they're needed.
21:34Chousernot a big deal under most use cases.
21:36Chouserrhickey has no comment on the MS visit. :-)
21:40duck1123is it possible to use flymake with clojure
21:47Chouser,(inc nil)
21:47clojurebotjava.lang.NullPointerException
21:48Chouser,(first (map inc (list 0 1 2 nil)))
21:48clojurebot1
21:48Chousermap is lazy!
21:50hiredmanclojurebot: whose job is it to make sure everyone uses good abbreviations?
21:50clojurebotthat's hiredman's job
21:50hiredman:(
21:51jbellI like clojure bot... not for that reason!
21:51hiredmanclojurebot: whose job is it to like clojurebot?
21:51clojurebotthat's metric's job
21:53jbellclojurebot: does metric like you though?
21:53clojurebotexcusez-moi
21:54hiredman~scala ((x: Int) => x + 1)(2)
21:54clojurebotInt = 3
21:56jbellclojurebot: metric vous aime, clojurebot?
21:56clojurebotPardon?
21:56jbellhe only pretends he knows french.
21:56hiredmanclojurebot: whose job is it to deal with french?
21:56clojurebotthat's albino's job
21:57Chouserit could pick names in proportion to how often the talk
21:57hiredmanyeah, which would require collecting stats, which it should do
21:58duck1123it would be funny if you had clojurebot open a ticket somewhere whenever that happens
21:58duck1123not in a real ticketing system, however
21:59hiredman~ticket #1
21:59clojurebot{:url http://tinyurl.com/ntftnj, :summary "Add chunk support to map filter et al", :status :test, :priority :normal, :created-on "2009-06-13T14:38:41+00:00"}
21:59duck1123I was saying clojurebot needs to record the fact that it's albino's job to deal with french
22:00hiredmanyeah, but then it would have to remember it
22:00hiredmanclojurebot: whose job is it to deal with french?
22:00clojurebotthat's dthomas's job
22:02duck1123clojurebot: whose job is it to prove P = NP
22:02clojurebotAck. Ack.
22:02jbelllol
22:03hiredmanoh
22:03hiredmanyou broke it
22:03hiredmanclojurebot: whose job is <reply>that's #someone's job
22:03clojurebotAck. Ack.
22:04hiredmanyou need to end a question with "is" in it with a "?"
22:12jbellwhat else can clojurebot do?
22:13jbellthat's implemented?
22:13hiredman~google clojurebot
22:13clojurebotFirst, out of 52 results is:
22:13clojurebothiredman&#39;s clojurebot at master - GitHub
22:13clojurebothttp://github.com/hiredman/clojurebot/tree/master
22:14hiredmanclojurebot: translate to fr from en: hello
22:14clojurebotfrom en: Bonjour
22:14hiredmaner
22:14hiredmanclojurebot: translate to fr: hello
22:14clojurebotbonjour
22:14jbellcool
22:14hiredman1d20+5
22:14clojurebot9
22:15jbelllol
22:16hiredman~quote JAVA
22:16clojurebotexcusez-moi
22:16hiredman~ticker JAVA
22:16clojurebotJAVA; +0.01
22:17ambienthmm, my huffman is just 3 lines and it would need heap queue to finish :/
22:18ambientquess it's time to implement O(n) insertion heapq
22:20jbellyou could make clojurebot translate people on the fly, like clojurebot:translate user from es
22:20ambientor better yet, translate from english->chinese->english->spanish->english and see what comes out
22:21ambienttechnically i think it's mandarin
22:25jbellyou could do something like run skinning challenges (after Chouser's skinning cats), and allow people to vote via clojurebot, and then clojurebot would keep track of the scores lol... yeah.
22:27jbellbut I'm guessing from what you said before that it doesn't keep state
22:45jbellif clojure had a secure aspect then clojurebot could be programmable
22:49jbellhow are generics handled in clojure? I seem to remember Rich mention them, and say that they weren't a problem..?
22:50Chouserright. Java uses type erasure, so you can just ignore them.
22:54jbellso what happens if I want to create an instance of an ArrayList<String> to pass to the Java side?
22:54jbellor is that not done for good reason?
22:55Chouser,(java.util.ArrayList. (map str (range 10)))
22:55clojurebot#<ArrayList [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>
22:55Chouserit just works, as long as the only thing you put in the ArrayList are Strings.
22:56ChouserIf you break the contract, you get a runtime exception.
22:56jbelloh ok, I've also found a log where you explained it to someone else too!
22:56Chouser:-)
22:58jbellnow I know how you can reskin so fast :P
23:31technomancyevening dudes
23:31technomancyalso possibly dudettes
23:33durka42evening technomancy
23:48technomancyany ideas what's wrong here? http://p.hagelb.org/screw%2fmaven.clj.html
23:49technomancyit's a direct port of code from the maven embedder unit tests
23:49technomancythe only difference I can think of is that the classloader it hands off to maven may be different in the context of Clojure
23:49arbscht404
23:50technomancysorry: http://p.hagelb.org/maven.clj.html
23:56technomancystill not sure I understand how classloaders work and how Clojure interacts with it
23:58technomancyI suppose Clojure has its own classloader, and it's not playing nice with the other maven classes that are supposed to be loaded via plexus.
23:59tomojI wish I could even begin to understand what you're talking about
23:59tomojjava is still a mystery to me :(