#clojure log - Feb 07 2008

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

11:31 rhickey: Clojure has a logo - courtesy of my brother Tom - http://groups.google.com/group/clojure

12:52 bgeron: nice

17:12 sweeze: i want to somehting like (. object (strcat("set" "Attribute"))).... is this possible?

17:14 (alternatively, if there's another way to dynamically call a method....)

17:26 Chouser: I'm still very new at this, so excuse the question ... if I have a function (foo) that returns a fn, can't I invoke that fn just by putting it at the head of a list? ((foo)) ?

17:30 oh. It appears I can do that, or use (apply (foo)). My error must be coming from elsewhere.

17:34 ah, got it. I'm such a lisp newbie.

17:34 bgeron: doesn't matter, everyone was a beginner once :)

17:35 sweeze: you might want to ask the question again when rhickey (the author of Clojure) is here, he must know

17:35 Chouser: ok, so I'm running my foo.clj file like the 'getting started' page says, with my file on the end: java -cp ... src/boot.clj foo.clj

17:36 sweeze: ok, thanks bgeron... does he keep regular hours? :)

17:36 Chouser: That works, but it gives me a prompt. any way to skip the prompt? ... quit before it gets that for or something?

17:36 bgeron: sweeze: yesterday he was here at this time

17:37 I don't see a pattern in his joining/leaving, just wait and I'm sure he'll come

17:38 * bgeron hasn't actually used Clojure, but listens in for the interesting conversations o:)

17:38 bgeron: so I'm afraid I can't answer your question

17:39 maybe someone else here?

17:41 Chouser: sweeze: I guess you want to convert a string to a symbol?

17:41 sweeze: Chouser: yeah, pretty much

17:43 Chouser: Seems like there ought to be a way, but I don't see how.

17:44 Ah, (sym "setAttribute")

17:45 sweeze: thnks, i'll try taht out

17:50 well, it creates the symbol, but i think the magic of how (.) works just looks at the literals... i'll have to ask again when rich is around

18:04 la_mer: sweeze: what are you trying to do, exactly?

18:06 FWIW, calling a method on a java object goes like so:

18:07 (def sb (new StringBuffer))

18:07 (. sb (append "foo"))

18:07 (. sb (toString)) => "foo"

18:13 sweeze: la_mer: yeah, i can call a method that i know ahead of time, but i'd like to construct the desired method @ runtime

18:14 specifically, i'd like to be able to pass a map of {attr : value}, and then call (. obj (setAttr value))

19:11 scramflot: Is there a way to silence the nils in the output?

19:12 make it "pretty" and such

19:15 rhickey: hey, I've made some progress on my directory walker.. is there a way to silence the returned nills? to make the output more pretty?

20:08 nm.. I think the nils are accidental

20:36 Chouser: Any idea how to get the logarithm of an number?

20:36 or convert it to a string?

20:38 rhickey: (. Math (log 42))

20:38 (str 42)

20:38 Chouser: perfect, thanks!

20:39 scramflot: which function might one use for "for a in coll, if a == b, return a"? filter?

20:39 rhickey: see also http://groups.google.com/group/clojure/msg/4b900ecf29b58f29

21:03 filter or for

21:11 scramflot: sweet thanks.

21:12 This is weired: http://pastebin.com/m2940a048 Looks like a nullpointerexception half way through a map

21:21 ah, for is in the svn

21:29 hmm.. maybe dirs is undefined if x isn't a directory?

22:31 I've pretty much spent two days of my free time working on this directory walker function, having a real hard time getting it to work

22:31 It's been floating around 10 and 12 lines

22:32 and then bam... this hits me: (defn dw [d] (println d) (map dw (seq (. (new File (str d)) (listFiles))))

22:32 so much simpler

22:33 (dw "home/name/whatever") and away it goes

22:36 now if I can just get it those nils to go away

23:08 jay: greetings mates

23:09 Is there something like a (time (some expressions)) macro for timing a call?

23:14 scramflot: yea, (time (whatever))

23:16 user=> (time (pr "hi")) -> "hi""Elapsed time: 0.152053 msecs"

Logging service provided by n01se.net