#clojure log - Jul 13 2010

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

0:07 cais2002: is there a built-in or easy way to do transposing of matrix ? (transpose [ [1 2] [3 4] [5 6] ] ) => [ [1 3 5] [2 4 6] ]

0:08 qbg: ,(apply map vector [[1 2] [3 4] [5 6]])

0:08 clojurebot: ([1 3 5] [2 4 6])

1:54 TimMc: Man, debugging Clojure code *stinks*.

1:54 I suspect this is mainly due to poor error messages.

1:55 (on the part of library authors)

1:57 technomancy: TimMc: clj-stacktrace is a huge help for that

1:57 highly recommended

1:58 * TimMc pokes chouser with a type check

2:00 TimMc: clojure.contrib.shell-out/sh assumes all arguments are strings. My code passed in an argument that was supposed to be a string, but turned out to be an int. The result? "ava.lang.IllegalArgumentException: array element type mismatch"

2:01 The joys of dynamic type.

2:05 So, in the case of clojure.contrib.shell-out, where does responsibility lie for ensuring all args are strings? http://github.com/richhickey/clojure-contrib/blob/master/src/main/clojure/clojure/contrib/shell_out.clj

4:12 esj: (map greetings #clojure)

4:25 mikem: is it possible to add metadata to functions? at the point of definition (with defn)?

4:39 esj: mikem: try (defn ^{:doc "foo" :bar "baz"} mfoo [] :foo-bar)

4:40 then (:bar (meta mfoo)) gives you "baz"

4:41 mikem: ok, it's working :)

4:41 esj: thanks

4:41 esj: np dude.

4:45 ponzao____: esj, is the meta call somehow cached. I created the function and tried (meta mfoo) -> {:ns #<Namespace user>, :name mfoo}

4:45 and when I redefined the function it gave me {:ns #<Namespace user>, :name mfoo, :file "NO_SOURCE_PATH", :line 1, :arglists ([]), :doc "foo", :bar "baz"}

4:45 mikem: yeah, also there's a difference in the results of (meta mfoo) and (meta #'mfoo)

4:47 ponzao____: (meta #'mfoo) seems to give up-to-date information

4:47 Chousuke: note that metadata on functions is new in 1.2

4:48 docstrings etc. are metadata on the *var*, not the function

4:48 mikem: Chousuke: ah, ok, so that's the difference between (meta mfoo) and (meta #'mfoo)?

4:49 the former is metadata of the function, while the latter is metadata of the var?

4:49 Chousuke: mikem: the latter is (meta (var foo))

4:49 mfoo*

4:50 mikem: so yes

4:50 mikem: the former is new stuff; it means you can now add metadata to functions you store in data structures

4:50 mikem: which wasn't possible previously

4:51 mikem: Chousuke: so is this the correct way to add this metadata to the function? (defn ^{:custom-metadata "stuff"} mfoo "docstring" [& args] (...)) ?

4:52 Chousuke: mikem: with defn, yes.

4:52 esj: whew !

4:53 Chousuke: mikem: for anonymous functions I think you need to use either with-meta or (fn ^{:metadata 'here} [] ...) but I'm not sure about the latter.

4:53 mikem: what happens when you call defn twice? I notice that the metadata of the function is not updated. Does this mean the var is updated, but the function object (IFn instance?) is not?

4:53 Chousuke: the function object is immutable

4:53 so it can't be updated

4:54 mikem: hehe of course :) hm...

4:54 Chousuke: what happens when you redefine a function is simply that the var gets a new value

4:54 mikem: so in that case, is the function object only created once, and reused in future calls to defn with the same name? that doesn't sound right

4:55 Chousuke: no, a new function object is created

4:55 with the same name

4:55 the old one is then garbage-collected if you haven't stored it anywhere

4:56 just like any other value

4:57 at least, that should happen :P

4:57 if it's not actually happening then something weird is going on.

5:00 mikem: it doesn't seem to be working quite as advertised: http://paste.lisp.org/display/112420

5:06 Chousuke: that looks like a bug to me

5:11 mikem: doesn't look like I'm able to create new tickets in assembla

5:21 can someone here file that as a bug? otherwise I could post it to the mailing list

5:31 bsteuber: in a mixed clojure/java project, how can I have dependencies in both directions without too much headache?

5:39 Chousuke: bsteuber: probably, as long as they're not circular

5:40 bsteuber: Chousuke: they're not, but I'm not sure how to correctly setup maven

5:40 I thought I read a post about this issue once - but I can't find it anymore

5:42 tomoj: are the java and clojure parts separate modules?

5:42 I'm not asking because I think I can help you, just because I'm curious :)

5:43 neotyk: bsteuber: have you considered lein? http://github.com/neotyk/lein-javac

5:44 bsteuber: you could try doing something like

5:44 ***

5:44 http://github.com/neotyk/lein-javac/blob/hook/src/leiningen/hooks/javac.clj

5:44 as long as you use lein 1.2-RC2

5:45 bsteuber: neotyk: interesting - I once made the choice for maven, but if this issue is easier using lein, I might switch over again

5:47 djpowell: i have mixed clojure/java stuff. i 'solved' it by making a base subproject of java interfaces, then clojure that compiles against them, then the main java project compiles against the clojure

5:47 not entirely happy with that tho - doesn't seem very scalable

5:48 seems like lots of admin if you need to change things around

5:48 neotyk: bsteuber: I've been have maven user for long time, lein takes all

5:48 *** good parts of maven, and improves rest

5:48 djpowell: i use ant btw

5:49 neotyk: djpowell: you know that ant creator have said he is sorry for

5:49 *** creating ant?

5:49 bsteuber: I think most use cases will be calling java from clojure from java

5:49 djpowell: i heard that, he must be more polite than the maven creator

5:49 bsteuber: so once back and forth

5:50 djpowell: yeah ant does seem vaguely ridiculous - but if you are doing basic stuff, and you have a project to copy and paste from, it isn't too bad

5:50 neotyk: djpowell: that takes some guts to admit, true

5:51 djpowell: at least I don't have to write a 'module' or whatever maven calls them to do any kind of custom task, and start writing jar files and manifests.

5:51 neotyk: bsteuber: you could create your own plugin for lein it is as

5:51 *** simple as putting thinkgs in proper packages

5:52 bsteuber: so you would like to build first-part-java, clojure

5:52 *** aot, second-part-java?

5:52 bsteuber: but no matter which tool I use, I guess I have to give it the right compilation order, right?

5:52 so compile standalone java classes, then clojure stuff, then dependent java classes

5:53 neotyk: bsteuber: my usecase for lein-java was simple wrapper in java

5:53 *** that clj depended upon

5:53 I was thinking of it

5:53 bsteuber: would be nice to have an automatic resolution of this

5:54 djpowell: at the moment, my interfaces are defined in java, and the gen-classed clojure is implementation. with clojure 1.2, and protocols, interfaces are more likely to be defined in clojure, so things might need a rethink

5:54 neotyk: that should be no biggie to do with lein-javac

5:54 bsteuber: automatic resolution is asking a lot :P

5:54 but agree, it would be very nice

5:55 djpowell: it would be handy if you could compile gen-classed stuff in a mode that creates the java linkage classes, but doesn't worry about compiling anything else in there

5:55 bsteuber: sure, always asking for much :)

5:55 djpowell: spose that would work for gen-class, but not for deftype tho

5:56 bsteuber: how about trying to parse import statements from all clj and java files, building a dependency graph and then doint the compilation?

5:56 this could even resolve cyclic deps by inserting dummy methods at first

5:56 neotyk: in java there I ways to include w/o including

5:56 Class.forName and alike

5:56 bsteuber: hrmpf

5:57 djpowell: neotyk: that wouldn't matter tho would it

5:57 neotyk: if it isn't a compile-time dependency, then you don't need to compile it first

5:57 neotyk: djpowell: true, true

5:57 djpowell: but it isn't just include - explicitly qualified references in code too

5:59 easiest way might be to get clojure to compile some stub classes for gen-class, deftype etc, that didn't contain implementation. then compile the java, then either recompile the clojure

5:59 bsteuber: so I guess automatic dependency resolution will never work then, right?

5:59 djpowell: I like that

6:00 would that always work?

6:00 djpowell: no idea

6:01 bsteuber: so how would I implement this, say as a lein plugin

6:02 I guess I'd have to macroexpand the clj files completely to make sure I'll get all gen-class etc.

6:03 and then replace it by dummy defs

6:04 djpowell: I suspect it would be hard

6:04 What if the classes corresponding to the parameter types are in the java?

6:05 was only a vague idea - probably not practical without some hacking of the compiler, and even then, I haven't thought it through

6:06 bsteuber: djpowell: I agree, too bad

6:06 so I'll have to give the order by hand

6:07 djpowell: would it be practical to avoid using gen-class for linkage and dynamically look up the function from java using RT

6:13 bsteuber: djpowell: maybe, I'll think that over

6:17 robtp: ?paste

6:17 hi - can anyone tell me why http://gist.github.com/473695

6:18 results in clojure.lang.PersistentArrayMap cannot be cast to java.lang.String

6:20 okay - then my problem actually is that clojure-http.resourcefully/get is somehow being referred in the namespace

6:20 which i don't want, and i thought i had worked my way around

6:23 esj: robtp: if that's the case then an :exclude clause in the (ns ...) should work around ?

6:24 robtp: esj: but i'm referreing resourcefully as :res, so why does it still trample on clojure.core/get?

6:25 esj: robtp: i haven't a clue :)

6:25 robtp: i can (:refer-clojure :exclude [get]), and then use clojure.core/get

6:25 i was also wondering why i variously see :use and use, :require and require

6:27 esj: robtp: I might have this wrong but I think its to do with (ns ...) being a macro and (use ...) etc being functions.

6:38 robtp: when does one use binding vs let?

6:41 esj: binding is for dynamic binding, let for lexical

6:41 Chousuke: robtp: they both do binding, but the semantics are very different.

6:41 robtp: if i were to let *connect-timeout* 10, and then call a fn that checks *connect-timeout*, would that not have an effect, where binding would?

6:42 Chousuke: right.

6:42 esj: yup

6:42 Chousuke: lexical means code that's "textually" within the scope

6:43 dynamic affects code that's executed within the scope at runtime.

6:43 though note that binding only establishes thread-local dynamic bindings.

6:43 robtp: Chousuke, esj: thanks

6:44 Chousuke: i think that's all i'm looking for

6:44 Chousuke: also laziness can bite you if you're not careful :)

6:44 altogether dynamic binding can be useful sometimes but it's easy to make mistakes :P

6:45 robtp: hmmm, http://gist.github.com/473714 is not right then

6:45 *connect-timeout* is used in res/post

6:46 but i get an error complaining "cannot resolve var ... in this context"

6:46 and then my second question is why referring resourcefully as res still causes its get to trample on clojure.core/get

6:46 Chousuke: *connect-timeout* is in the res-namespace isn't it?

6:46 without the -

6:46 so you need to do (binding [res/*connect-timeout*] ...)

6:47 robtp: because of :use. you want :require

6:47 robtp: the ns macro is kind of confusing :P

6:48 robtp: why can i write both :use and use, :require and reuqire?

6:48 Chousuke: the :keywords are part of ns structure, use and require are the macros/functions it actually uses to do the work

6:48 robtp: which is preferable to use?

6:49 hmm (:require [clojure-http.resourcefully :as res] still results in an error?

6:49 Chousuke: It shouldn't. :/

6:49 are you sure you properly re-evaluated everything?

6:49 robtp: no

6:49 Chousuke: if you're in a repl maybe the old stuff is still there

6:50 happens often with slime

7:13 r2q2: Can I generate xml with hiccup?

7:21 robtp: i have a lazy sequence of strings, what's the generally-accepted clean way to force evalutaion - i need to join that sequence - but (str-join "," body-seq) gives me c,l,o,j ... ie the class name

7:33 Chousuke: robtp: call seq on body-seq

7:37 robtp: btw, your annotate function has weird use of assoc

7:37 robtp: what ought i do?

7:37 this code is probably very un-idiomatic :)

7:38 Chousuke: you're doing (do (assoc options :ontologiesToExpand ontologies) (assoc options :ontologiesToKeepInResult ontologies))

7:38 which doesn't even work

7:38 options never changes.

7:38 it's immutable

7:39 robtp: how can i accomplish that which i'm trying?

7:39 Chousuke: I'm not sure what your intention is

7:40 robtp: set default values

7:40 so i should probably just merge another map, huh?

7:40 Chousuke: hm

7:41 robtp: wait, no, sorry, i misspoke

7:41 Chousuke: you need to restructure the code first so that you actually capture the new options map

7:41 robtp: if an :ontologies option is given, i want to set those two keys :ontologiesToExpand, ... in options

7:41 Chousuke: right. options is immutable so the way you're doing it does exactly nothing :)

7:42 what you need to do is (let [new-options (assoc options :ontologiesToExpand ontologies, :ontologiesToKeepInResult ontologies)] ...)

7:42 robtp: so if :ontologies is in the options map, i want to set those two keys, otherwise continue as normal

7:43 Chousuke: "set" is kind of imperative terminology

7:43 what you mean is you want a new map with those keys

7:43 robtp: exactly

7:44 Chousuke: the key names are pretty unidiomatic btw. Camelcase is generally avoided.

7:45 robtp: not my choice on that :)

7:45 Chousuke: I'd make a new function for dealing with the defaults

7:46 something like (defn ensure-defaults [options] (if whatever (assoc options :key 'default) options))

7:47 then you can just skip the when-let in annotate and do (let [parameters (select-keys (ensure-defaults options) ...)] ...)

7:49 also your uri, timeout, parse-xml let can be made more idiomatic by using destructuring: (let [{:keys [uri timeout parsexml] :or {:uri default-uri :timeout default-timeout}} options] ...) :)

7:52 robtp: so the doseq part is also ineffective, right?

7:52 Chousuke: ah, yeah

7:52 robtp: the idea there is to join a sequence by commas (this is a web service, some params are comma-delimited lists)

7:53 i really need to be going, but i'd appreciate if you could leave a suggestion :)

7:53 thanks for all of your help

7:54 Chousuke: you want (into {} (map (fn [[k v]] (if (vector? v) ...) [k (str-join ...)]) parameters))

7:54 robtp: cool - thanks again

7:54 this is on tomorrow's todo list...

7:54 Chousuke: ie. for all key-value pairs in the map, return a new key-value pair, and stuff those into an empty map

7:55 remember, maps can be treated as a sequence of [k v] vectors

7:55 robtp: right, i vaguely recalled reading that

7:55 i'm outta here

7:56 thanks!

7:56 Chousuke: you're welcome

7:56 it takes a while to get used to doing things the functional way, but you'll get there :P

8:42 kib2: Hi. I have a problem with a macro: http://paste.lisp.org/display/112423

9:01 dnolen: kib2: hard to know what you are trying todo. but remember macros aren't functions. Looks like you want html-region to work like a function. Might make sense to create an fn like html-region* that explicitly takes a symbol for its first parameter. Then the macro html-region will just use that.

9:19 bsteuber: kib2: use another macro! (defmacro html-regions [[names] ...] `(do ,@(for [name names] ...

9:21 kib2: In fact I've translated this article to Clojure: http://cybertiggyr.com/lh/

10:19 AWizzArd: How can set! operate on *warn-on-reflection* on toplevel?

10:19 Is *warn-on-reflection* not an ordinary Var?

10:33 Chousuke: AWizzArd: in a repl?

10:34 AWizzArd: Chousuke: yes, in a repl or file.

10:34 Chousuke: AWizzArd: *warn-on-reflection* is dynamically bound to false by the repl function before the main loop

10:34 AWizzArd: (I typically always set this to true.)

10:48 Chousuke: thanks for the tip, makes sense.

10:54 Lajla: Chousuke, olet matelijanen

12:00 mattrepl: anyone ever implement a pack/unpack capability for Clojure similar to Python's `struct` module?

12:04 rbxbx: mattrepl: http://snipplr.com/view/13559/serializing-clojure-data-structures/ perhaps?

12:05 mattrepl: rbxbx: thanks, I should've been more specific. I'd like to be able to (de)serialize between byte streams and primitive types

12:07 cschreiner: I'm want a list of n (random-color) Doing (repeat 10 (random-color)) gives me the same color repeatedly. How can I create a list of n length with different (random-color)'s?

12:09 rbxbx: mattrepl: it looks like patches have been proposed a few times, but I'm not sure if there's anything natively available in clojure to do what you'd like. Google and good luck, or maybe someone who knows what's up will chime in :)

12:09 cschreiner: how is random-color implemented?

12:09 mattrepl: yeah, I recall it being mentioned. think I have an opportunity to scratch the itch. =)

12:10 rbxbx: mattrepl: good on you :)

12:10 wlangstroth: cschreiner: what format are the colors taking?

12:10 cschreiner: rbxbx: (defn random-color [] (Color. (n! 255) (n! 255) (n! 255))) and (defn n! [x] (. rnd nextInt x))

12:11 (def rnd (new java.util.Random)

12:11 Color is the java.awt.Color

12:12 rbxbx: hm

12:13 mattrepl: you want repeatedly

12:13 (repeatedly 10 random-color)

12:13 repeat just returns a value n times

12:13 cschreiner: mattrepl: indeed I do, thanks

13:58 robtp: Chousuke: hey, if you're still there question re your suggestion yesterday

13:58 Chousuke: robtp: sure.

13:58 robtp: ; also your uri, timeout, parse-xml let can be made more idiomatic by using destructuring: (let [{:keys [uri timeout parsexml] :or {:uri default-uri :timeout default-timeout}} options] ...)

13:59 i don't understand what that does? the first element of the vector does not even have a name?

14:00 Chousuke: it's map destructuring

14:01 the :keys [keys here] part is a shortcut for {keys :keys here :here} which means "from the map, bind keys to the value of :keys, and here to the value of :here"

14:01 and the :or supplies a "defaults" map that is merged with the actual map that is destructured

14:01 so if a key isn't specified, it's taken from the defaults

14:02 dsantiago: How does one import or typehint nested Java classes?

14:02 lancepantz: dsantiago: you import them like java.lang.Class$Inner

14:02 dsantiago: Ah, OK, thanks.

14:02 Chousuke: ,(let [{:keys [foo bar] :or {:foo 1}} {:bar 5}] [foo bar]) like this

14:02 clojurebot: [nil 5]

14:03 Chousuke: hmm, wait.

14:03 duncanm: dum de dum

14:03 Chousuke: oh, damn, :or is only used if the map is not specified at all it seems :(

14:04 robtp: oh wowo, i missed all of that

14:06 Chousuke: so :keys is a special reserved keyword in destructuring maps?

14:06 Chousuke: robtp: yeah

14:06 robtp: Chousuke: i can just merge the defaults first

14:06 Chousuke: robtp: there's a similar keyword for :syms and :strs

14:06 robtp: to address the :or doesn't work problem

14:06 Chousuke: yep

14:07 qbg: ,(let [{:keys [foo bar] :or {foo 1}} {:bar 5}] [foo bar])

14:07 clojurebot: [1 5]

14:07 dpritchett: thanks for the tip on registering, Chousuke

14:07 Chousuke: huh

14:07 oh! I just remembered wrong how the thing works.

14:08 dpritchett: I suppose it should be more prominent in the topic

14:08 or a chanserv notice or something maybe

14:12 robtp: Chousuke: are there docs for :keys :syms :strs anywhere?

14:12 qbg: http://clojure.org/special_forms#Special%20Forms--%28let%20[bindings*%20]%20exprs*%29

14:13 robtp: qbg: just found that, thanks

14:13 should've been obvious?

14:30 dpritchett: I realize this is a simple one but could someone critique my first code sample on clojuredocs.org? I'd like to make sure my style is consistent http://clojuredocs.org/v/1553

14:31 qbg: You have a trailing )

14:32 And with the cond forms being that small, I would put matching pairs on the same line

14:33 Indentation for the contents of defn is also larger than normal

14:35 dpritchett: i'm wrestling with some auto-indenting in vim

14:35 i don't remember where i got it

14:35 thanks for the tips!

14:40 robtp: Chousuke: in the :or part of the form, i have to use symbols, and not keywords, as the keys

14:40 meaning i can't define that default-options map earlier

14:43 Chousuke: right. So just use merge?

14:44 robtp: Chousuke: did so, but could i do it the other way?

14:45 Chousuke: if you want to separately define the defaults, then no

15:08 dpritchett: bhenry: Is it normal to remove the test output from clojuredoc exampels? I think it's instructive to see exactly what the repl spits out...

15:08 ^examples

15:09 bhenry: i agree? did i accidentally remove something of yours?

15:10 i don't know why i agree questionably...

15:10 dpritchett: Whoops - looks like I accidentally removed it myself and then you edited something else.

15:10 My bad, thanks for improving the example I posted.

15:11 bhenry: yes i like your style of posting the user=> stuff. i just displayed my output in a comment in the code sample.

15:28 dpritchett your example for bound? isn't a good example of how you'd use it http://clojuredocs.org/v/1947

15:29 dpritchett: I am an FP neophyte, feel free to replace it with something better

15:29 I'm just stubbing out some of the functions I don't know very well by testing them at the REPL

15:30 bhenry: i just lost my terminal and it seems as though only a restart will bring it back. i will try it in a bit.

15:32 Raynes: Why does clojure.java.shell/sh print out "{:out UTF-8, :dir nil, :env nil}" every time it'se called?

15:32 it's*

15:33 technomancy: Raynes: bugzors

15:33 clojurebot: ticket #398

15:33 Raynes: clojure.java.anything seems to be buggy. :\

15:33 clojurebot: {:url http://tinyurl.com/2c4paol, :summary "Stray println snuck into clojure.java.shell/sh", :status :fixed, :priority :normal, :created-on "2010-07-08T17:28:57-07:00"}

15:34 Raynes: raek: Did you ever create an issue for that bug you found in clojure.java.io?

15:34 Whoa, there is a clojure.string now? :o!

15:44 TimMc: Raynes: Link?

15:45 ataggart: clojure.string shows up in clojuredocs but not the official api docs

15:47 Raynes: TimMc: Link to what?

15:47 TimMc: Raynes: clojure.string

15:49 Raynes: http://github.com/clojure/clojure/blob/master/src/clj/clojure/string.clj

15:49 dpritchett: Just finished adding simple explanations to all of the boolean functions I could find on clojuredocs.org

15:50 the ones ending in ? anyway

15:50 TimMc: Raynes: Ah, much obliged.

15:53 Man, how come I never heard of this site?

15:53 (Clojuredocs)

15:53 rbxbx: It's about 3 days old, for starters ;)

15:53 Raynes: Because it came out about 3 days ago.

15:53 ataggart: impressive for being so new

15:54 dpritchett: Warning: built with Rails ;)

15:54 * rbxbx aghast

15:54 technomancy: that's a shame; it means they can't use the reader to verify that the examples are syntactically correct.

15:55 jkkramer: there's also http://clojure-examples.appspot.com/ written in clojure ;)

15:56 not as featureful though

16:05 pjstadig: maybe if it's run on jruby there's a chance to clojurify

16:12 rbxbx: Does anyone have Conjure up and running on mysql with 0.7(RC1 or RC2) ?

16:19 eevar_: random question: if you wander off the beaten path and use clojure; why stick with mysql as your rdbms?

16:20 qbg: Why not?

16:20 rbxbx: agreed.

16:20 perhaps for relational data? ;)

16:20 lpetit: eevar_: maybe because mysql is not your current rdbms :-p

16:21 rbxbx: ah

16:21 eevar_: because it's a crappy non-standard toy-db retrofitted to something nearly-acid-compliant?

16:21 rbxbx: touche. the default one conjure uses is h2, and I don't want to use their heinous web interface for database management

16:22 and I was being lazy because it offers support for mysql out of the box (or at least it does in theory)

16:23 bozhidar: rbxbx: you don't have to use the web interface

16:23 rbxbx: ha! I wonder who dirtmcgirt is, anyone that likes FP and ODB is a friend of mine.

16:23 bozhidar: I use H2 heavily

16:23 and love it

16:23 rbxbx: no?

16:23 hm

16:23 bozhidar: but hate the interface also

16:23 so I use it from my IDE

16:23 rbxbx: I did a cursory glance of the docs and didn't see connecting via other means.

16:23 bozhidar: (insert here Eclipse/NetBeans/IntelliJ)

16:24 everything that has jdbc support

16:24 rbxbx: ah. is there a cli client?

16:24 bozhidar: can be used to work with h2

16:24 rbxbx: I don't use an ide :\

16:24 bozhidar: you can use http://squirrel-sql.sourceforge.net/ I guess

16:24 I use Emacs most of the time

16:25 but for Java development I find myself forced to use an IDE

16:26 rbxbx: perhaps I'll give an IDE another chance, have heard that eclipse has decent support for Vi bindings :\

16:26 bozhidar: I wish every language had some good mode like slime, cperl, ccmode, but unfortunately that is not the case...

16:26 rbxbx: or learn emacs ;_;

16:26 bozhidar: IntelliJ has decent support as well

16:27 and an open source edition

16:27 rbxbx: fantastic :)

16:27 bozhidar: since several months

16:27 rbxbx: sorry for the newbish questions, the java ecosystem is still very o_O to me though.

16:27 bozhidar: and Emacs has viper-mode for hardcore vi users ;-)

16:27 rbxbx: and google just doesn't cut it sometimes.

16:27 I've tried emacs in viper-mode

16:27 it went OK-ish.

16:28 bozhidar: nothing can replace the human interaction :-)

16:28 rbxbx: :D

16:29 perhaps the better clojure tooling is worth taking another stab though, last time I had no real reason for trying it.

16:31 nickik: I used eclipse but the startuptime and some otherthings where bad. So I went headfirst into emacs ....

16:31 still hard

16:32 have to trie that viper-mode so I don't have to learn to mutch new stuff at once :)

16:32 rbxbx: aye.

16:32 I've even started learning some java in support of this clojure addiction :(

16:33 mattrepl: nickik: have you read yegge's bit on emacs? http://sites.google.com/site/steveyegge2/effective-emacs

16:36 nickik: @mattrepl "The tips in this little document are geared towards Emacs power-users"

16:37 mattrepl: nickik: heh, I never noticed that. it was one of the articles that convinced me to learn emacs

16:37 nickik: but thx I will read if as soon i have some basics. I can't even copy or cut stuff jet

16:39 rbxbx: that's actually what caused me to pursue emacs the first time (now clojure)

16:39 nickik: Can you help me with that? What are these shortcuts <cut> <copy>

16:39 mattrepl: nickik: have you become famliiar with EmacsWiki? http://www.emacswiki.com.org

16:40 nickik: sure

16:40 rbxbx: alt+d and ctrl+y aye?

16:41 er.

16:41 mattrepl: C-w (ctrl + w) is kill-region. this is roughly equivalent to "cut"

16:42 M-w (meta + w) is kill-ring-save which is sort of like "copy". there's more going on behind the scene, just search emacswiki for kill ring to learn more about the implementation

16:43 if you want to paste, C-y

16:43 nickik: mattrepl: Didn't look in any wikis so far. I spend to mutch time on tools stuff. Atm I just want to keep reading Joy of Clojure.

16:44 But I going to do the tutorial stuff that is in emacs eventully

16:44 mattrepl: and, to cut/copy a region you'll want to be able to define that reigion. Move your cursor to where you want the region to begin, hit C-Space, then jump to the end of the region.

16:45 yeah, that's a lot to learn at once. Lisp does seem to bring many to Emacs

16:47 nickik: I never liked the IDE stuff to mutch

16:48 Not to mention swank, paredit, slime ....

16:55 dpritchett: I'm playing in emacs with clojure-mode and viper-mode

16:56 I dunno if that's going to confuse me more than it helps but I feel like I'm making progress moreso than I would with vi or vanilla emacs

17:20 TimMc: Can clojure.core/for do filtering? I see :when, but I can't get it to affect anything.

17:21 kotarak: ,(for [x [:Tim :Mc] :when (not= x :Mc)] x)

17:21 clojurebot: (:Tim)

17:21 qbg: ,(for [x (range 3) :when (even? x) y (range 3)] [x y])

17:21 clojurebot: ([0 0] [0 1] [0 2] [2 0] [2 1] [2 2])

17:23 alexyk: how do I find out teh number of CPUs avaiable for the JVM?

17:23 TimMc: Oh, so :when takes a test, not a function.

17:23 qbg: (.. Runtime getRuntime availableProcessors)

17:23 TimMc: I was using a function, which of course was always "true". :-P

17:24 alexyk: qbg: thx

17:25 qbg: (stole that from the source of pmap)

17:31 anonymouse89: anyone a vimclojure user? I'm trying to install and am confused by gradle/clojuresque etc.

17:33 dpritchett: I've tried vimclojure a few times but didn't get too far. It

17:33 's worth noting the stable release is nearly a year old

17:44 dakrone: anonymouse89: are you installing from a zip, or from source/hgclone?

17:46 anonymouse89: dakrone: source seems very old so I was trying source/hg but was running into trouble with clojuresque/gradle

17:46 sorry zip seems old

17:47 dakrone: anonymouse89: I'd recommend trying the snapshots, they're very recent: http://groups.google.com/group/vimclojure/msg/ce3fe24b57372799

17:48 that way you don't have to mess with gradle

17:55 anonymouse89: dakrone: that's perfect. he should update his site.

17:56 dakrone: yea, that build is an RC, so hopefully we'll see the actual release on the site soon.

17:56 anonymouse89: ah, so he just picked up work on it again (?)

17:57 dakrone: yea, check out the mailing list if you have any problems or questions

18:12 neotyk: Hi *

18:13 do you know if aleph can be used to stream?

18:29 alexyk: I'm doing social networking research and am wondering how many folks here have a github account, and whether you guys use the same nick here and there?

18:29 also, on twitter?

18:34 TimMc: alexyk: I do. No Twitter. I'd guess the channel as a whole is a mix, and there are a lot of people in here.

18:35 alexyk: TimMc: so far I found many who have the whole three. Which makes me ponder various data mining schemes.

18:36 TimMc: I tend to use TimMc/timmc for more professional accounts (code publishing, e.g.) and phyzome for personal stuff.

18:36 However, both are public nicks.

18:37 alexyk: TimMc: ok

18:37 TimMc: why no twitter yet? :)

18:37 TimMc: Technically, I have one, but don't use it. I find it utterly useless.

18:38 Raynes: alexyk: I has a github account.

18:38 And a Twitter account.

18:38 Github account is the same as my nick here.

18:38 IORaynes on Twitter, because Raynes is taken.

18:38 alexyk: Raynes: as a Haskell man, you're a superior being and are not to be overunderestimated

18:39 Raynes: o.o

18:39 TimMc: alexyk: You should grab the /who list and check it against GitHub and Twitter.

18:39 Perhaps you could even use clojure for that... ;-)

18:40 alexyk: TimMc: I found many programming language people are using twitter with a language tag to publish their own stuff or retweet others' cool ones, say with #clojure

18:40 TimMc: yeah, clojure is good for this kind of stuff

18:40 TimMc: That will make your program even easier to write. :-)

18:42 Raynes: alexyk: You could use gotmilk to look for accounts. ;) $#google gotmilk github#$

18:42 sexpbot: First out of 11 results is: jfkw's Profile - GitHub

18:42 http://github.com/jfkw

18:42 Raynes: Aw.

18:42 I figured it would be the first result.

18:42 alexyk: http://github.com/Raynes/gotmilk

18:42 :p

18:43 alexyk: see, he got milk first or what

18:43 Raynes: is it a repo for facialized ads or what?

18:44 ...ah, more boring stuff :)

18:44 Raynes: Huh? O.o

18:44 alexyk: got milk ads, mind you! but, command line is very cool too

18:44 Raynes: Haha.

18:45 alexyk: dnolen: are you a contributor for Incanter?

18:46 Raynes: so you suggest to google github nicks by repo name?

18:46 * Raynes notes enthusiastically that you could find that out with a gotmilk command. :>

18:46 dnolen: alexyk: no

18:46 alexyk: Raynes: cool

18:46 Raynes: alexyk: gotmilk is a tool for doing github stuff without going to the github website. Such as searching for users, getting info about users and such. I was implying you could use it for that.

18:47 lancepantz: alexyk: i believe rapleaf's service does something along the lines of what you are suggesting

18:47 not even sure if those guys are still around

18:48 i use this nick for github, irc, twitter, reddit, digg, facebook, xbox live, psn

18:48 * Raynes kills boogs

18:50 Raynes: Way to be inconsistent, Github.

18:50 If searching repos, it returns "username" rather than "owner" which it uses for pretty much everything else repo-related.

18:51 alexyk: Raynes: very very cool.

18:52 Raynes: :D

19:51 TimMc: Ooh, I think I found a bug in clojure.contrib.sql -- how do I check if one has already been filed?

19:52 TeXnomancy: clojurebot: assembla?

19:52 clojurebot: assembla is http://www.assembla.com/spaces/clojure

19:52 TeXnomancy: clojurebot: botsnack

19:52 clojurebot: thanks; that was delicious. (nom nom nom)

19:55 TimMc: Ah!

19:55 I did a web search for Clojure bugs and nothing came up.

19:56 defn: lancepantz: get your jruby + rails + clojure bridge code online yet? :X

19:56 * defn continues to annoy you

19:56 lancepantz: haha

19:56 saw your message last week, tried to get back, you were gone

19:56 defn: ah, sorry

19:56 lancepantz: but it's actually rails + clojure, not jrails

19:57 goes through a compojure api

19:59 TimMc: http://github.com/richhickey/clojure-contrib/blob/master/src/main/clojure/clojure/contrib/sql.clj#L137 <- Column names are not wrapped in backticks, so MySQL is choking on table names like "foo-bar".

20:01 Looks like a bug, yeah? Or is there some JDBC/MySQL/etc. nonsense that I'm not aware of?

20:43 map_reduce: ,(range 10)

20:43 clojurebot: (0 1 2 3 4 5 6 7 8 9)

20:44 map_reduce: hey, i was reading through the src code for lazy-seq and I noticed a reference to fn*, but I can't find the definition for fn* or reader macro. Can someone explain wheat the fn* means?

20:50 tomoj: ,(contains? clojure.lang.Compiler/specials 'fn*)

20:50 clojurebot: true

20:52 map_reduce: ah, thanks :)

20:52 tomoj: it's just a primitive special form, you'd never use it I think

20:54 not sure why lazy-seq uses it when fn is available

20:54 map_reduce: fair nuff, i'm just trying to learn by going through the source code

20:54 tomoj: I believe you should be safe pretending that the fn* there is fn, as far as understanding lazy-seq

20:54 ,((fn* [x] x) 3)

20:54 clojurebot: 3

20:54 tomoj: just missing some features of fn I guess

20:55 map_reduce: gotcha, cool

20:57 tomoj: I wonder what that ^{:once true} stuff is

20:58 TeXnomancy: it's for futures and delays IIRC

20:58 kind of a low-level memoization

21:00 tomoj: ,(meta (first (nth (macroexpand-1 '(lazy-seq nil)) 2)))

21:00 clojurebot: {:once true}

21:00 tomoj: ,(first (nth (macroexpand-1 '(lazy-seq nil)) 2))

21:00 clojurebot: fn*

21:04 map_reduce: hmph, fn* is a Symbol, weird

21:06 tomoj: weird why?

21:09 map_reduce: I would have expected to see someting like clojure.core$fn*

21:09 with my limited 2 week experience of clojure.... :)

21:15 TimMc: map_reduce: I am also a beginner, but...

21:15 fn* is a "special form", meaning it is defined by the compiler, not by calls to other Clojure code.

21:17 map_reduce: I gather so, tomoj just introduced me to clojure.core.Compiler so I'm largely talking out of my a** right now...

21:17 TimMc: Unlike "when" and "repeatedly" and such, it is one of the true primitives of the language.

21:17 map_reduce: sorry, clojure.lang.Compiler

21:18 still, I expected to see an underlying Java class other than Symbol but I'm sure all this will make more sense as I keep learning

21:20 TimMc: What I'm gathering is that all "names" are symbols, just that some are at the compile-time level and others at run-time.

21:20 (Experts, please jump in to correct my educated wild-ass guesses.)

21:23 map_reduce: crud, i had to run, but I'll check the logs later to see if an expert clears this up:) thanks for the help everyone!

21:24 TimMc: Each symbol has a name and a namespace.

21:25 tomoj: hmm

21:26 I wonder if map_reduce would have also been surprised that + is a symbol, given:

21:26 ,+

21:26 clojurebot: #<core$_PLUS_ clojure.core$_PLUS_@1643de1>

21:26 TimMc: Hah.

21:26 stuarthalloway: ,(.getNamespace 'plain-symbol)

21:26 clojurebot: nil

21:27 stuarthalloway: ,(.getNamespace 'org.clojure/foo)

21:27 clojurebot: "org.clojure"

21:27 TimMc: Hrm.

21:27 So, fully-qualified symbols have a namespace.

21:28 stuarthalloway: what was the original question?

21:28 TimMc: "Why is fn* a Symbol in clojure.lang.Compiler?"

21:29 stuarthalloway: implementation detail

21:30 no deep conceptual significance

21:30 TimMc: I had claimed that it was a compiler primitive, instead of being definable in terms of further Clojure.

21:31 ...but I'm a newb with just enough compiler education to confuse other newbs. :-P

21:34 tomoj: oh, he meant FN?

21:35 TimMc: tomoj: I believe so.

21:35 alexyk: is there a "flip" function to splice ->> / -> arguments into front or back as needed?

21:36 clojay: Guys, I need some help. I'm switching from procedural and OO programming to functional programming. In particular I'm interested in Lisp dialects (especially Clojure). I'm looking for books that will help me learn how to think as a functional programmer, and how to write idiomatic Lisp/Clojure code. I'm a good programmer but I would probably struggle to write a compiler, a simple computer algebra system, or even a well written html parser.

21:36 budget is somewhat limited ($100) but I'd like to get a couple of good books that will blow my mind and help me become a better functional programmer. There are countless books out there and it's hard to pick something within my budget. What are your suggestions? I already own the available Clojure books.

21:36 alexyk: (-> "x" (apply flip get mymap))

21:36 defn: there's one that's escaping my brain right now clojay

21:36 alexyk: or something

21:36 defn: it's a book on FP algorithms IIRC

21:37 clojay: defn: purely functional data structures?

21:37 defn: yes!

21:37 definitely worth a buy

21:37 alexyk: clojay: Real World Haskell

21:37 TimMc: clojay: I learned Scheme with HTDP: http://htdp.org/

21:37 tomoj: alexyk: it wouldn't work anyway

21:37 alexyk: tomoj: well how 'bout a macro?

21:38 tomoj: (-> "x" (apply flip get mymap)) is (apply "x" flip get mymap)

21:38 alexyk: tomoj true

21:38 clojay: alexyk: I'm afraid Real World Haskell would be a little too far from Clojure

21:38 tomoj: alexyk: don't ask for a macro that generalizes -> and ->> :P

21:38 alexyk: clojay: well if you want FP, than it's FP

21:38 TimMc: clojay: HtDP helps you think in terms of algebraic data structures. I suspect SICP does that too, but I haven't read it.

21:39 alexyk: tomoj: all I ask is to move the damn arg into front dammit! :)

21:39 TimMc: HDP is free to read online, though. :-P

21:39 clojay: TimMc: so is SICP

21:39 TimMc: Yay!

21:39 alexyk: clojay: and RWH too :)

21:39 clojay: TimMc: but yes, SICP and HDTP are two possible candidates

21:40 TimMc: PLT Scheme was very friendly to learn.

21:40 alexyk: clojay: skip it all and get TheJoyofClojure.com by our very own Chouser-san

21:40 TimMc: That's what they use in the freshman Fundamentals of Computer Science course at my university.

21:40 mikem: anyone mentioned Practical Common Lisp? http://gigamonkeys.com/book/

21:40 tomoj: really?

21:41 clojay: mikem: apparently CL is not very functional

21:41 tomoj: oh, I had missed that idiomatic lisp was also part of the question

21:41 clojay: alexyk: I'm planning to get The Joy of Clojure when it's finished

21:42 alexyk: clojay: or you can get the MEAP PDF and read it on screen or kindle

21:42 mikem: yeah, i sense some dislike towards PCL in this channel :) i dono, it helped me grok the Lisp approach. as well as The Little Schemer

21:42 qbg: PCL is good for CL; not so much for Clojure

21:43 clojay: I guess my bigger question is, am I mostly wasting time by reading books that are written for Scheme and CL, when I'm trying to become a kick butt Clojure programmer?

21:43 alexyk: so, a macro to move an arg to the front, going 1...

21:44 TimMc: clojay: I think the answer will partly depend on whether existing Clojure books assume you are already familiar with FP.

21:45 tomoj: I think reading scheme books is an excellent idea

21:45 alexyk: the little schemer

21:45 chouser: On Lisp is great

21:45 alexyk: or lisper

21:46 qbg: The SICP lecture videos are classics

21:46 alexyk: PCL makes for good toilet reading, pardon my French

21:46 chouser: You might not want to dig too deep into CL-specific stuff -- that's a very deep vein, but the deeper you go the less it has to do with Clojure, I suspect.

21:47 alexyk: in about 53 sittings you can finish PCL, and it's what it deserves as it's not very fun.

21:47 clojay: chouser: How about this progression? Programming Clojure + Little Schemer + SICP + The Joy of Clojure?

21:48 chouser: Haven't read the middle two, but from what I know that doesn't sound too bad.

21:48 stuarthalloway: and if you get tired before you are done at least you started well :-)

21:48 alexyk: clojay: just cut from PC to TJoC! :)

21:49 clojay: stuarthalloway: haha

21:49 * chouser chuckles

21:49 stuarthalloway: clojar: I liked Little Schemer, but it will be redundant with the others

21:49 alexyk: stuarthalloway: when's the 1.2 edition?

21:49 stuarthalloway: alexyk: of what?

21:49 alexyk: stuarthalloway: of your one! :)

21:50 stuarthalloway: I am working on this 1.2 edition: http://clojure.org/downloads

21:50 TimMc: stuarthalloway: I found what I believe is a bug in clojure.contrib.sql. Do I simply file a ticket on Assembla?

21:50 stuarthalloway: TimMc: please discuss on mailing list first

21:50 TimMc: Clojure-dev?

21:50 clojurebot: clojure-dev is the eclipse plugin http://code.google.com/p/clojure-dev/

21:50 alexyk: stuarthalloway: I'll buy the 1.2-synced book of yours in 2 copies at once, paper and kindle!

21:51 stuarthalloway: TimMc: main list is fine

21:51 TimMc: Ah, OK.

21:51 stuarthalloway: main list can help rally support, if others are also feeling the pain

21:51 alexyk: stuarthalloway: specifically would like to see a concise explication of the new 1.2 features. Given there's a settled subset of those, you can start a MEAP/PragProg draft! I'll buy that right away too.

21:52 clojay: stuarthalloway: when will the new edition of your book be released?

21:52 alexyk: (even before prims are settled)

21:52 stuarthalloway: well, gosh

21:52 TimMc: stuarthalloway: The Clojure-dev page said scary things about Contributor Agreements. :-P

21:52 chouser: stuarthalloway: how can you say no?

21:52 stuarthalloway: there is no new edition in the works

21:52 clojay: stuarthalloway: oh, sorry

21:52 alexyk: stuarthalloway: until now! :) clojay: don't weaken your flank

21:52 stuarthalloway: but I have done extensive slide decks (free!) and a video

21:53 Most of the 1.2 stuff is covered at http://github.com/stuarthalloway/clojure-presentations/downloads

21:53 clojay: stuarthalloway: can you tell me how your book differs from Practical Clojure (the Apress one)

21:53 stuarthalloway: and protocols are at http://vimeo.com/11236603

21:53 alexyk: ok! cool. Still printed book feels like The Truth.

21:54 stuarthalloway: clojay: I sit next to the author of PracCloj, but I haven't read it yet :-)

21:54 clojay: stuarthalloway: Is it a parallel universe where all Clojure saints are sent to?

21:55 stuarthalloway: clojay: kind of :-) http://clojure.com/about.html

21:56 tomoj: data encapsulation is folly, huh

21:57 alexyk: how do we diff two maps?

21:57 subtract

21:57 clojay: has anyone tried The Joy of Clojure on Kindle? Does it look good?

21:58 alexyk: clojay: reasonable

21:58 (on teh old DX)

21:58 tomoj: alexyk: you mean take two maps, throw out the keys they share (and the associated values), and merge the rest?

21:59 alexyk: tomoj: even simpler, throw out the keys from m2 whihc are in m2

21:59 dissoc I guess

21:59 * qbg is reading the 1.2 changelog

21:59 clojay: alexyk: i may go for the ebook version then

21:59 tomoj: throw out the keys from m1 which are in m2, you mean?

21:59 alexyk: tomoj: yeah

22:00 clojay: you'll enjoy it

22:00 clojay: If I get this right, Scheme is closer to Clojure than Common Lisp is. And Clojure is purely functional, unlike both Scheme and CL which are multi-paradigm. Scheme less so, but still is. Right?

22:00 stuarthalloway: qbg: let me know if you have questions

22:02 if anybody wants to download the 1.2 beta and tell me if they see any problems, that would be great

22:02 qbg: stuarthalloway: It says the docs are at http://richhickey.github.com/clojure/

22:02 Given the move of the repos, shouldn't that be updated?

22:03 stuarthalloway: yeah

22:03 alexyk: stuarthalloway: how are the prims settled then?

22:03 stuarthalloway: alexyk: Release.next

22:04 mikem: stuarthalloway: I had some issues with adding metadata to functions: http://groups.google.com/group/clojure/browse_thread/thread/f2594a96860f4f91#

22:04 alexyk: ok

22:04 mikem: maybe I was doing it wrong?

22:05 stuarthalloway: ,(let [f ^{:awesome true} (fn [])] (meta f))

22:05 clojurebot: {:awesome true}

22:05 qbg: stuarthalloway: get is listed twice at the end

22:05 (section 4)

22:05 stuarthalloway: thanks, fixed

22:05 qbg: So is count

22:05 stuarthalloway: mikem: that was a trivial example of doing it right

22:06 mikem: stuarthalloway: i'm not sure how to translate that properly when using defn

22:06 stuarthalloway: mikem: and yes, there are issues with fn metadata. Consider it alpha

22:07 mikem: stuarthalloway: ah, noted :) at least it's coming

22:08 clojay: How oudated is programming clojure now that 1.2 is coming out?

22:09 oudated -> outdated

22:11 stuarthalloway: clojay: almost nothing is *wrong*

22:11 but more could now be said

22:11 clojay: stuarthalloway: got it

22:12 stuarthalloway: the only significant chance since the book is the metadata reader macro, formerly #^ and now ^

22:15 * alexyk is very happy about ^

22:16 alexyk: stuarthalloway: were you in Philly before and in Durham now?

22:16 stuarthalloway: alexyk: for some values of before :-)

22:16 but i have not lived in Philly

22:16 alexyk: stuarthalloway: I thought you were there for some reason

22:17 (I used to live there)

22:17 so Durham is far from anything, I bet you guys move to SF in 1 year

22:17 stuarthalloway: alexyk; not likely :-)

22:17 alexyk: stuarthalloway: Seattle then :)

22:19 or, let's say you'll have to open an office in the Bay Area. Just a bet.

22:20 clojay: ok, I'll ask one last stupid question, and then I'll go back to my Clojure reading. Will there be Kindle editions of the Manning books about Clojure?

22:22 alexyk: clojay: I think so; but I'd buy from Manning directly as you'd get upgrades. PragProg gives you mobi and epub and PDF, and so does O'Reilly. I'd buy ebook from teh publishers since Amazon doesn't have an upgrade path.

22:23 (and treats ebook just as a paper book for now in terms of one-off-ness)

22:23 clojay: alexyk: I thought Amazon would give you a significantly better version though (when read on a Kindle dx)

22:24 alexyk: clojay: I bought some very crappy PDF versions for DX. They get them from publishers anyways

22:24 clojay: (in terms of layout, etc)

22:24 alexyk: clojay: the best is mobi converted by publisher

22:24 i.e. from PragProg, .mobi is better than PDF on the Kindle

22:24 PDF is for the computer and search

22:26 clojay: alexyk: too bad Manning doesn't offer a .mobi

22:26 alexyk: clojay: they were talking about offering it somewhere/at some point IIRC

22:26 and/or we can bug them

22:30 robtp: what does the "*" denote: ([f args* argseq])?

22:33 ahh, okay, varargs

22:34 so & name is end-defn varargs, name* is middle of defn? or is that completely wrong?

22:34 rhudson: Where are you seeing arg* ?

22:35 robtp: ,(doc apply)

22:35 clojurebot: "([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."

22:36 clojay: how do I "unpack" a list? If my-list is '(1 2 3) (max my-list) returns my-list. I'd like to unpack it so that I get something like (max 1 2 3).

22:36 rhudson: OK, that's notation for the usual 0-or-more meaning of * . It's not part of Clojure syntax per se.

22:36 robtp: clojay: that's what apply is for

22:36 rhudson: ahh, got it

22:36 clojay: which is exactly what i was just looking at

22:37 clojay: robtp: oh we had a similar problem then

22:37 robtp: rhudson: so the definition of apply is actually like (defn apply [fn & more]), and the seq is taken as the last element of more?

22:37 and the args are any remaining elements

22:38 clojay: (apply max my-list)

22:38 robtp: clojay: looks right to me?

22:38 clojay: robtp: it works

22:38 Raynes: apply is a macro.

22:38 rhudson: (apply f a b [c d e f]) is equivalent to (f a b c d e f)

22:39 tomoj: ,apply

22:39 clojurebot: #<core$apply clojure.core$apply@1b55ca5>

22:39 Raynes: Isn't it?

22:39 Oh. It isn't.

22:39 * Raynes facepalms

22:41 rhudson: ,(apply map + [[1 2 3], [10 20 30]])

22:41 clojurebot: (11 22 33)

22:43 robtp: rhudson: whoa, i thought map took one fn argument, *args, and an argseq

22:43 how is having that + in there legit?

22:44 tomoj: *args can be [+]

22:44 rhudson: map takes 1 or more seq arguments, and applies the function to elements in the same position until the shortest seq is exhausted

22:44 (map + [1 2 3] [10 20 30])

22:46 clojay: so apply basically removes one set of parenthesis?

22:46 rhudson: (map vector [:a :b :c] [1 2 3] [4 5])

22:46 That's one way to think of it.

22:47 ,(apply max [3 1 4 1 5 9])

22:47 clojurebot: 9

22:47 cemerick: clojay: that sort of shorthand is going to trip you up eventually

22:48 robtp: rhudson: that (apply map + double-vec) is still freaky

22:48 cemerick: apply invokes the provided fn with the provided arguments

22:49 clojay: cemerick: ok, but that doesn't explain this one: (apply map + [[1 2 3] [10 20 30]]) So apply invokes map to the provided arguments which are?

22:50 robtp: rhudson: so behind the scenes, what does (apply map + [[etc] [etc2]]) look like

22:50 clojay: the provided arguments are + and [[vec] [vec2]]

22:50 tomoj: no, +, [1 2 3], and [10 20 30]

22:50 cemerick: clojay: that's functionally equivalent to (map + [1 2 3] [10 20 30])

22:51 robtp: which i think becomes (+ (1 2 3) (10 20 30))

22:51 tomoj: eh?

22:51 robtp: tomoj: apply doesn't seem to give any special treatment to a + in that pesition

22:51 tomoj: there is no special treatment indeed

22:51 + is just passed to map the same way apply passes args to any function

22:51 cemerick: The point is, the fn *and* the arguments are data that do not need to be coincident with the apply usage.

22:51 robtp: tomoj: oh, i think we agree, i read "no, +, [1 2 3] and [10 20 30]" wrong

22:52 cool, thanks all

22:53 cemerick: e.g.:

22:53 ,(let [some-data [(range 10) (range 30 50)]] (apply map + some-data))

22:53 clojurebot: (30 32 34 36 38 40 42 44 46 48)

22:54 robtp: cemerick: so (range a b) attempts to match the other given range?

22:54 cemerick: ,(doc range)

22:54 clojurebot: "([] [end] [start end] [start end step]); Returns a lazy seq of nums from start (inclusive) to end (exclusive), by step, where start defaults to 0, step to 1, and end to infinity."

22:54 robtp: wait, nevermind

22:54 cemerick: ,(range 5 10)

22:54 robtp: math issues

22:54 clojurebot: (5 6 7 8 9)

22:56 rhudson: Note that the first range has 10 elements, the second 20, and the result (using map) has 10

22:56 robtp: yeah, i got that now. math is tough!

22:56 cemerick: This might help, insofar as it is very clear about the args going into apply having nothing to do with literals:

22:57 ,(apply + (take 10 (repeatedly rand)))

22:57 clojurebot: 4.596899040906102

22:59 clojay: wtf... we have a repeatedly function?

22:59 cemerick: remarkably useful

22:59 clojay: fantastic

22:59 scgilardi: oh yes, it's very nice

23:00 cemerick: scgilardi: hi Stephen, long time no chat :-)

23:00 scgilardi: heya chas. good to see you too.

23:00 cemerick: what are you up to these days?

23:01 scgilardi: working on fun stuff at Sonian... (avengers and all that)

23:01 clojay: I know it's a Lisp but to be honest Clojure looks a bit like Haskell to me

23:02 cemerick: right, right; forgot you were there, sorry. You're the quiet one. ;-)

23:02 defn: Then you don't know Haskell ;)

23:02 scgilardi: fell behind on mailing list and chat, but trying to catch up

23:02 danlarkin: it's impossible

23:02 there's too much

23:03 * defn gave up on the mailing list long ago

23:03 scgilardi: 6000 message backlogs are daunting

23:03 cemerick: clojay: there's lots of influences

23:03 defn: you could probably finish it all in a few days

23:03 cemerick: I manage to keep up for a while, fall behind for around 5K, and then just dump and start over.

23:03 defn: lots of it you wont care to read anyway

23:03 danlarkin: my clojure ML backlog is 22445 :)

23:03 scgilardi: dan wins again!

23:04 danlarkin: lazy execution wins again!

23:06 wdouglas: Is there an idiomatic way of getting for with two seqs to return a dot product instead of all combinations of the seqs?

23:08 qbg: If it doesn't need to be in for, you could use map

23:08 clojay: by the way thoughts on Clojure in Action? (it looks like it will be completed in 2011 but the MEAP give us access to a bunch of chapters already)

23:08 wdouglas: I was having a tough time making map work for my case

23:09 rhudson: wdouglas: (map dot seq1 seq2) didn't do it for you?

23:09 wdouglas: I think I can do it but goodness it'd be really easy with for

23:09 qbg: ,(for [x (map vector [:a :b :c] [:do :re :mi])] x)

23:09 clojurebot: ([:a :do] [:b :re] [:c :mi])

23:10 wdouglas: qbg: oh

23:10 cemerick: clojay: Joy of Clojure is more my style, but YMMV.

23:10 wdouglas: qbg: Very nice

23:11 clojay: cemerick: I was thinking AND more than OR

23:11 cemerick: *shrug* :-)

23:12 clojay: cemerick: got it

23:12 tomoj: just use (map vector ..) unless you need the for for some other reason

23:47 Bahman: Hi all!

23:47 qbg: Hello Bahman

23:47 Bahman: Hi qbg!

23:52 miltondsilva: ok... so I want to disprove the whole "the right tool for the job" thing with some empirical evidence... but before I make a proposal(on clojure group), I would like to discuse some ideas... anyone up for this? maybe several people?

23:53 tomoj: what is the whole "the right tool for the right job" thing?

23:53 jhawk28: use a hammer when you need a hammer or a screwdriver when you need a screwdriver

23:53 makes you more productive

23:54 tomoj: so miltondsilva wants to prove that you would be more productive using a screwdriver when you need a hammer?

23:54 seems unlikely..

23:54 miltondsilva: hmmm...

23:55 ok so... I think that there is a better programming language... something like a silver bullet

23:55 yes yes.. ridicule

23:55 but

23:55 the think is.. I can't find any paper.. study or something like that... that studies this

23:56 the thing*

23:56 technomancy: you don't need a study to tell you that you can't use a language with a 2MB runtime for embedded work.

23:56 nor a language that relies on persistent data structures in an environment without a good GC

23:57 jhawk28: sometimes its a good sales technique to get your management to let you use a bunch of different tools

23:57 miltondsilva: but why can't you use a common descriptor to express your ideas? and have it compile to whatever you want?

23:59 jhawk28: different dynamics of languages produce vastly different results

23:59 and everyone has their opinion about each one

23:59 after all, text editors all to the same thing, but try convince someone that emacs is better than vim or vice versa

23:59 miltondsilva: yes! it's all about opinion.. so I would like to get some facts...

Logging service provided by n01se.net