#clojure logs

2010-07-13

00:07cais2002is 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] ]
00:08qbg,(apply map vector [[1 2] [3 4] [5 6]])
00:08clojurebot([1 3 5] [2 4 6])
01:54TimMcMan, debugging Clojure code *stinks*.
01:54TimMcI suspect this is mainly due to poor error messages.
01:55TimMc(on the part of library authors)
01:57technomancyTimMc: clj-stacktrace is a huge help for that
01:57technomancyhighly recommended
02:00TimMcclojure.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"
02:01TimMcThe joys of dynamic type.
02:05TimMcSo, 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
04:12esj(map greetings #clojure)
04:25mikemis it possible to add metadata to functions? at the point of definition (with defn)?
04:39esjmikem: try (defn ^{:doc "foo" :bar "baz"} mfoo [] :foo-bar)
04:40esjthen (:bar (meta mfoo)) gives you "baz"
04:41mikemok, it's working :)
04:41mikemesj: thanks
04:41esjnp dude.
04:45ponzao____esj, is the meta call somehow cached. I created the function and tried (meta mfoo) -> {:ns #<Namespace user>, :name mfoo}
04:45ponzao____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"}
04:45mikemyeah, also there's a difference in the results of (meta mfoo) and (meta #'mfoo)
04:47ponzao____(meta #'mfoo) seems to give up-to-date information
04:47Chousukenote that metadata on functions is new in 1.2
04:48Chousukedocstrings etc. are metadata on the *var*, not the function
04:48mikemChousuke: ah, ok, so that's the difference between (meta mfoo) and (meta #'mfoo)?
04:49mikemthe former is metadata of the function, while the latter is metadata of the var?
04:49Chousukemikem: the latter is (meta (var foo))
04:49Chousukemfoo*
04:50Chousukemikem: so yes
04:50Chousukemikem: the former is new stuff; it means you can now add metadata to functions you store in data structures
04:50Chousukemikem: which wasn't possible previously
04:51mikemChousuke: so is this the correct way to add this metadata to the function? (defn ^{:custom-metadata "stuff"} mfoo "docstring" [& args] (...)) ?
04:52Chousukemikem: with defn, yes.
04:52esjwhew !
04:53Chousukemikem: for anonymous functions I think you need to use either with-meta or (fn ^{:metadata 'here} [] ...) but I'm not sure about the latter.
04:53mikemwhat 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?
04:53Chousukethe function object is immutable
04:53Chousukeso it can't be updated
04:54mikemhehe of course :) hm...
04:54Chousukewhat happens when you redefine a function is simply that the var gets a new value
04:54mikemso 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
04:55Chousukeno, a new function object is created
04:55Chousukewith the same name
04:55Chousukethe old one is then garbage-collected if you haven't stored it anywhere
04:56Chousukejust like any other value
04:57Chousukeat least, that should happen :P
04:57Chousukeif it's not actually happening then something weird is going on.
05:00mikemit doesn't seem to be working quite as advertised: http://paste.lisp.org/display/112420
05:06Chousukethat looks like a bug to me
05:11mikemdoesn't look like I'm able to create new tickets in assembla
05:21mikemcan someone here file that as a bug? otherwise I could post it to the mailing list
05:31bsteuberin a mixed clojure/java project, how can I have dependencies in both directions without too much headache?
05:39Chousukebsteuber: probably, as long as they're not circular
05:40bsteuberChousuke: they're not, but I'm not sure how to correctly setup maven
05:40bsteuberI thought I read a post about this issue once - but I can't find it anymore
05:42tomojare the java and clojure parts separate modules?
05:42tomojI'm not asking because I think I can help you, just because I'm curious :)
05:43neotykbsteuber: have you considered lein? http://github.com/neotyk/lein-javac
05:44neotykbsteuber: you could try doing something like
05:44neotyk***
05:44neotyk http://github.com/neotyk/lein-javac/blob/hook/src/leiningen/hooks/javac.clj
05:44neotyk as long as you use lein 1.2-RC2
05:45bsteuberneotyk: interesting - I once made the choice for maven, but if this issue is easier using lein, I might switch over again
05:47djpowelli 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
05:47djpowellnot entirely happy with that tho - doesn't seem very scalable
05:48djpowellseems like lots of admin if you need to change things around
05:48neotykbsteuber: I've been have maven user for long time, lein takes all
05:48neotyk*** good parts of maven, and improves rest
05:48djpowelli use ant btw
05:49neotykdjpowell: you know that ant creator have said he is sorry for
05:49neotyk*** creating ant?
05:49bsteuberI think most use cases will be calling java from clojure from java
05:49djpowelli heard that, he must be more polite than the maven creator
05:49bsteuberso once back and forth
05:50djpowellyeah 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
05:50neotykdjpowell: that takes some guts to admit, true
05:51djpowellat 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.
05:51neotykbsteuber: you could create your own plugin for lein it is as
05:51neotyk*** simple as putting thinkgs in proper packages
05:52neotykbsteuber: so you would like to build first-part-java, clojure
05:52neotyk*** aot, second-part-java?
05:52bsteuberbut no matter which tool I use, I guess I have to give it the right compilation order, right?
05:52bsteuberso compile standalone java classes, then clojure stuff, then dependent java classes
05:53neotykbsteuber: my usecase for lein-java was simple wrapper in java
05:53neotyk*** that clj depended upon
05:53neotykI was thinking of it
05:53bsteuberwould be nice to have an automatic resolution of this
05:54djpowellat 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
05:54neotykthat should be no biggie to do with lein-javac
05:54neotykbsteuber: automatic resolution is asking a lot :P
05:54neotykbut agree, it would be very nice
05:55djpowellit 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
05:55bsteubersure, always asking for much :)
05:55djpowellspose that would work for gen-class, but not for deftype tho
05:56bsteuberhow about trying to parse import statements from all clj and java files, building a dependency graph and then doint the compilation?
05:56bsteuberthis could even resolve cyclic deps by inserting dummy methods at first
05:56neotykin java there I ways to include w/o including
05:56neotykClass.forName and alike
05:56bsteuberhrmpf
05:57djpowellneotyk: that wouldn't matter tho would it
05:57djpowellneotyk: if it isn't a compile-time dependency, then you don't need to compile it first
05:57neotykdjpowell: true, true
05:57djpowellbut it isn't just include - explicitly qualified references in code too
05:59djpowelleasiest 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
05:59bsteuberso I guess automatic dependency resolution will never work then, right?
05:59bsteuberdjpowell: I like that
06:00bsteuberwould that always work?
06:00djpowellno idea
06:01bsteuberso how would I implement this, say as a lein plugin
06:02bsteuberI guess I'd have to macroexpand the clj files completely to make sure I'll get all gen-class etc.
06:03bsteuberand then replace it by dummy defs
06:04djpowellI suspect it would be hard
06:04djpowellWhat if the classes corresponding to the parameter types are in the java?
06:05djpowellwas only a vague idea - probably not practical without some hacking of the compiler, and even then, I haven't thought it through
06:06bsteuberdjpowell: I agree, too bad
06:06bsteuberso I'll have to give the order by hand
06:07djpowellwould it be practical to avoid using gen-class for linkage and dynamically look up the function from java using RT
06:13bsteuberdjpowell: maybe, I'll think that over
06:17robtp?paste
06:17robtphi - can anyone tell me why http://gist.github.com/473695
06:18robtpresults in clojure.lang.PersistentArrayMap cannot be cast to java.lang.String
06:20robtpokay - then my problem actually is that clojure-http.resourcefully/get is somehow being referred in the namespace
06:20robtpwhich i don't want, and i thought i had worked my way around
06:23esjrobtp: if that's the case then an :exclude clause in the (ns ...) should work around ?
06:24robtpesj: but i'm referreing resourcefully as :res, so why does it still trample on clojure.core/get?
06:25esjrobtp: i haven't a clue :)
06:25robtpi can (:refer-clojure :exclude [get]), and then use clojure.core/get
06:25robtpi was also wondering why i variously see :use and use, :require and require
06:27esjrobtp: I might have this wrong but I think its to do with (ns ...) being a macro and (use ...) etc being functions.
06:38robtpwhen does one use binding vs let?
06:41esjbinding is for dynamic binding, let for lexical
06:41Chousukerobtp: they both do binding, but the semantics are very different.
06:41robtpif 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?
06:42Chousukeright.
06:42esjyup
06:42Chousukelexical means code that's "textually" within the scope
06:43Chousukedynamic affects code that's executed within the scope at runtime.
06:43Chousukethough note that binding only establishes thread-local dynamic bindings.
06:43robtpChousuke, esj: thanks
06:44robtpChousuke: i think that's all i'm looking for
06:44Chousukealso laziness can bite you if you're not careful :)
06:44Chousukealtogether dynamic binding can be useful sometimes but it's easy to make mistakes :P
06:45robtphmmm, http://gist.github.com/473714 is not right then
06:45robtp*connect-timeout* is used in res/post
06:46robtpbut i get an error complaining "cannot resolve var ... in this context"
06:46robtpand then my second question is why referring resourcefully as res still causes its get to trample on clojure.core/get
06:46Chousuke*connect-timeout* is in the res-namespace isn't it?
06:46Chousukewithout the -
06:46Chousukeso you need to do (binding [res/*connect-timeout*] ...)
06:47Chousukerobtp: because of :use. you want :require
06:47Chousukerobtp: the ns macro is kind of confusing :P
06:48robtpwhy can i write both :use and use, :require and reuqire?
06:48Chousukethe :keywords are part of ns structure, use and require are the macros/functions it actually uses to do the work
06:48robtpwhich is preferable to use?
06:49robtphmm (:require [clojure-http.resourcefully :as res] still results in an error?
06:49ChousukeIt shouldn't. :/
06:49Chousukeare you sure you properly re-evaluated everything?
06:49robtpno
06:49Chousukeif you're in a repl maybe the old stuff is still there
06:50Chousukehappens often with slime
07:13r2q2Can I generate xml with hiccup?
07:21robtpi 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
07:33Chousukerobtp: call seq on body-seq
07:37Chousukerobtp: btw, your annotate function has weird use of assoc
07:37robtpwhat ought i do?
07:37robtpthis code is probably very un-idiomatic :)
07:38Chousukeyou're doing (do (assoc options :ontologiesToExpand ontologies) (assoc options :ontologiesToKeepInResult ontologies))
07:38Chousukewhich doesn't even work
07:38Chousukeoptions never changes.
07:38Chousukeit's immutable
07:39robtphow can i accomplish that which i'm trying?
07:39ChousukeI'm not sure what your intention is
07:40robtpset default values
07:40robtpso i should probably just merge another map, huh?
07:40Chousukehm
07:41robtpwait, no, sorry, i misspoke
07:41Chousukeyou need to restructure the code first so that you actually capture the new options map
07:41robtpif an :ontologies option is given, i want to set those two keys :ontologiesToExpand, ... in options
07:41Chousukeright. options is immutable so the way you're doing it does exactly nothing :)
07:42Chousukewhat you need to do is (let [new-options (assoc options :ontologiesToExpand ontologies, :ontologiesToKeepInResult ontologies)] ...)
07:42robtpso if :ontologies is in the options map, i want to set those two keys, otherwise continue as normal
07:43Chousuke"set" is kind of imperative terminology
07:43Chousukewhat you mean is you want a new map with those keys
07:43robtpexactly
07:44Chousukethe key names are pretty unidiomatic btw. Camelcase is generally avoided.
07:45robtpnot my choice on that :)
07:45ChousukeI'd make a new function for dealing with the defaults
07:46Chousukesomething like (defn ensure-defaults [options] (if whatever (assoc options :key 'default) options))
07:47Chousukethen you can just skip the when-let in annotate and do (let [parameters (select-keys (ensure-defaults options) ...)] ...)
07:49Chousukealso 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] ...) :)
07:52robtpso the doseq part is also ineffective, right?
07:52Chousukeah, yeah
07:52robtpthe idea there is to join a sequence by commas (this is a web service, some params are comma-delimited lists)
07:53robtpi really need to be going, but i'd appreciate if you could leave a suggestion :)
07:53robtpthanks for all of your help
07:54Chousukeyou want (into {} (map (fn [[k v]] (if (vector? v) ...) [k (str-join ...)]) parameters))
07:54robtpcool - thanks again
07:54robtpthis is on tomorrow's todo list...
07:54Chousukeie. for all key-value pairs in the map, return a new key-value pair, and stuff those into an empty map
07:55Chousukeremember, maps can be treated as a sequence of [k v] vectors
07:55robtpright, i vaguely recalled reading that
07:55robtpi'm outta here
07:56robtpthanks!
07:56Chousukeyou're welcome
07:56Chousukeit takes a while to get used to doing things the functional way, but you'll get there :P
08:42kib2Hi. I have a problem with a macro: http://paste.lisp.org/display/112423
09:01dnolenkib2: 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.
09:19bsteuberkib2: use another macro! (defmacro html-regions [[names] ...] `(do ,@(for [name names] ...
09:21kib2In fact I've translated this article to Clojure: http://cybertiggyr.com/lh/
10:19AWizzArdHow can set! operate on *warn-on-reflection* on toplevel?
10:19AWizzArdIs *warn-on-reflection* not an ordinary Var?
10:33ChousukeAWizzArd: in a repl?
10:34AWizzArdChousuke: yes, in a repl or file.
10:34ChousukeAWizzArd: *warn-on-reflection* is dynamically bound to false by the repl function before the main loop
10:34AWizzArd(I typically always set this to true.)
10:48AWizzArdChousuke: thanks for the tip, makes sense.
10:54LajlaChousuke, olet matelijanen
12:00mattreplanyone ever implement a pack/unpack capability for Clojure similar to Python's `struct` module?
12:04rbxbxmattrepl: http://snipplr.com/view/13559/serializing-clojure-data-structures/ perhaps?
12:05mattreplrbxbx: thanks, I should've been more specific. I'd like to be able to (de)serialize between byte streams and primitive types
12:07cschreinerI'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:09rbxbxmattrepl: 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:09rbxbxcschreiner: how is random-color implemented?
12:09mattreplyeah, I recall it being mentioned. think I have an opportunity to scratch the itch. =)
12:10rbxbxmattrepl: good on you :)
12:10wlangstrothcschreiner: what format are the colors taking?
12:10cschreinerrbxbx: (defn random-color [] (Color. (n! 255) (n! 255) (n! 255))) and (defn n! [x] (. rnd nextInt x))
12:11cschreiner(def rnd (new java.util.Random)
12:11cschreinerColor is the java.awt.Color
12:12rbxbxhm
12:13mattreplyou want repeatedly
12:13mattrepl(repeatedly 10 random-color)
12:13mattreplrepeat just returns a value n times
12:13cschreinermattrepl: indeed I do, thanks
13:58robtpChousuke: hey, if you're still there question re your suggestion yesterday
13:58Chousukerobtp: sure.
13:58robtp; 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:59robtpi don't understand what that does? the first element of the vector does not even have a name?
14:00Chousukeit's map destructuring
14:01Chousukethe :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:01Chousukeand the :or supplies a "defaults" map that is merged with the actual map that is destructured
14:01Chousukeso if a key isn't specified, it's taken from the defaults
14:02dsantiagoHow does one import or typehint nested Java classes?
14:02lancepantzdsantiago: you import them like java.lang.Class$Inner
14:02dsantiagoAh, OK, thanks.
14:02Chousuke,(let [{:keys [foo bar] :or {:foo 1}} {:bar 5}] [foo bar]) like this
14:02clojurebot[nil 5]
14:03Chousukehmm, wait.
14:03duncanmdum de dum
14:03Chousukeoh, damn, :or is only used if the map is not specified at all it seems :(
14:04robtpoh wowo, i missed all of that
14:06robtpChousuke: so :keys is a special reserved keyword in destructuring maps?
14:06Chousukerobtp: yeah
14:06robtpChousuke: i can just merge the defaults first
14:06Chousukerobtp: there's a similar keyword for :syms and :strs
14:06robtpto address the :or doesn't work problem
14:06Chousukeyep
14:07qbg,(let [{:keys [foo bar] :or {foo 1}} {:bar 5}] [foo bar])
14:07clojurebot[1 5]
14:07dpritchettthanks for the tip on registering, Chousuke
14:07Chousukehuh
14:07Chousukeoh! I just remembered wrong how the thing works.
14:08Chousukedpritchett: I suppose it should be more prominent in the topic
14:08Chousukeor a chanserv notice or something maybe
14:12robtpChousuke: are there docs for :keys :syms :strs anywhere?
14:12qbghttp://clojure.org/special_forms#Special%20Forms--%28let%20[bindings*%20]%20exprs*%29
14:13robtpqbg: just found that, thanks
14:13robtpshould've been obvious?
14:30dpritchettI 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:31qbgYou have a trailing )
14:32qbgAnd with the cond forms being that small, I would put matching pairs on the same line
14:33qbgIndentation for the contents of defn is also larger than normal
14:35dpritchetti'm wrestling with some auto-indenting in vim
14:35dpritchetti don't remember where i got it
14:35dpritchettthanks for the tips!
14:40robtpChousuke: in the :or part of the form, i have to use symbols, and not keywords, as the keys
14:40robtpmeaning i can't define that default-options map earlier
14:43Chousukeright. So just use merge?
14:44robtpChousuke: did so, but could i do it the other way?
14:45Chousukeif you want to separately define the defaults, then no
15:08dpritchettbhenry: 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:08dpritchett^examples
15:09bhenryi agree? did i accidentally remove something of yours?
15:10bhenryi don't know why i agree questionably...
15:10dpritchettWhoops - looks like I accidentally removed it myself and then you edited something else.
15:10dpritchettMy bad, thanks for improving the example I posted.
15:11bhenryyes i like your style of posting the user=> stuff. i just displayed my output in a comment in the code sample.
15:28bhenrydpritchett your example for bound? isn't a good example of how you'd use it http://clojuredocs.org/v/1947
15:29dpritchettI am an FP neophyte, feel free to replace it with something better
15:29dpritchettI'm just stubbing out some of the functions I don't know very well by testing them at the REPL
15:30bhenryi just lost my terminal and it seems as though only a restart will bring it back. i will try it in a bit.
15:32RaynesWhy does clojure.java.shell/sh print out "{:out UTF-8, :dir nil, :env nil}" every time it'se called?
15:32Raynesit's*
15:33technomancyRaynes: bugzors
15:33technomancyclojurebot: ticket #398
15:33Raynesclojure.java.anything seems to be buggy. :\
15:33clojurebot{: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:34Raynesraek: Did you ever create an issue for that bug you found in clojure.java.io?
15:34RaynesWhoa, there is a clojure.string now? :o!
15:44TimMcRaynes: Link?
15:45ataggartclojure.string shows up in clojuredocs but not the official api docs
15:47RaynesTimMc: Link to what?
15:47TimMcRaynes: clojure.string
15:49Rayneshttp://github.com/clojure/clojure/blob/master/src/clj/clojure/string.clj
15:49dpritchettJust finished adding simple explanations to all of the boolean functions I could find on clojuredocs.org
15:50dpritchettthe ones ending in ? anyway
15:50TimMcRaynes: Ah, much obliged.
15:53TimMcMan, how come I never heard of this site?
15:53TimMc(Clojuredocs)
15:53rbxbxIt's about 3 days old, for starters ;)
15:53RaynesBecause it came out about 3 days ago.
15:53ataggartimpressive for being so new
15:54dpritchettWarning: built with Rails ;)
15:54technomancythat's a shame; it means they can't use the reader to verify that the examples are syntactically correct.
15:55jkkramerthere's also http://clojure-examples.appspot.com/ written in clojure ;)
15:56jkkramernot as featureful though
16:05pjstadigmaybe if it's run on jruby there's a chance to clojurify
16:12rbxbxDoes anyone have Conjure up and running on mysql with 0.7(RC1 or RC2) ?
16:19eevar_random question: if you wander off the beaten path and use clojure; why stick with mysql as your rdbms?
16:20qbgWhy not?
16:20rbxbxagreed.
16:20rbxbxperhaps for relational data? ;)
16:20lpetiteevar_: maybe because mysql is not your current rdbms :-p
16:21rbxbxah
16:21eevar_because it's a crappy non-standard toy-db retrofitted to something nearly-acid-compliant?
16:21rbxbxtouche. the default one conjure uses is h2, and I don't want to use their heinous web interface for database management
16:22rbxbxand I was being lazy because it offers support for mysql out of the box (or at least it does in theory)
16:23bozhidarrbxbx: you don't have to use the web interface
16:23rbxbxha! I wonder who dirtmcgirt is, anyone that likes FP and ODB is a friend of mine.
16:23bozhidarI use H2 heavily
16:23bozhidarand love it
16:23rbxbxno?
16:23rbxbxhm
16:23bozhidarbut hate the interface also
16:23bozhidarso I use it from my IDE
16:23rbxbxI did a cursory glance of the docs and didn't see connecting via other means.
16:23bozhidar(insert here Eclipse/NetBeans/IntelliJ)
16:24bozhidareverything that has jdbc support
16:24rbxbxah. is there a cli client?
16:24bozhidarcan be used to work with h2
16:24rbxbxI don't use an ide :\
16:24bozhidaryou can use http://squirrel-sql.sourceforge.net/ I guess
16:24bozhidarI use Emacs most of the time
16:25bozhidarbut for Java development I find myself forced to use an IDE
16:26rbxbxperhaps I'll give an IDE another chance, have heard that eclipse has decent support for Vi bindings :\
16:26bozhidarI wish every language had some good mode like slime, cperl, ccmode, but unfortunately that is not the case...
16:26rbxbxor learn emacs ;_;
16:26bozhidarIntelliJ has decent support as well
16:27bozhidarand an open source edition
16:27rbxbxfantastic :)
16:27bozhidarsince several months
16:27rbxbxsorry for the newbish questions, the java ecosystem is still very o_O to me though.
16:27bozhidarand Emacs has viper-mode for hardcore vi users ;-)
16:27rbxbxand google just doesn't cut it sometimes.
16:27rbxbxI've tried emacs in viper-mode
16:27rbxbxit went OK-ish.
16:28bozhidarnothing can replace the human interaction :-)
16:28rbxbx:D
16:29rbxbxperhaps the better clojure tooling is worth taking another stab though, last time I had no real reason for trying it.
16:31nickikI used eclipse but the startuptime and some otherthings where bad. So I went headfirst into emacs ....
16:31nickikstill hard
16:32nickikhave to trie that viper-mode so I don't have to learn to mutch new stuff at once :)
16:32rbxbxaye.
16:32rbxbxI've even started learning some java in support of this clojure addiction :(
16:33mattreplnickik: have you read yegge's bit on emacs? http://sites.google.com/site/steveyegge2/effective-emacs
16:36nickik@mattrepl "The tips in this little document are geared towards Emacs power-users"
16:37mattreplnickik: heh, I never noticed that. it was one of the articles that convinced me to learn emacs
16:37nickikbut thx I will read if as soon i have some basics. I can't even copy or cut stuff jet
16:39rbxbxthat's actually what caused me to pursue emacs the first time (now clojure)
16:39nickikCan you help me with that? What are these shortcuts <cut> <copy>
16:39mattreplnickik: have you become famliiar with EmacsWiki? http://www.emacswiki.com.org
16:40mattreplnickik: sure
16:40rbxbxalt+d and ctrl+y aye?
16:41rbxbxer.
16:41mattreplC-w (ctrl + w) is kill-region. this is roughly equivalent to "cut"
16:42mattreplM-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:43mattreplif you want to paste, C-y
16:43nickikmattrepl: 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:44nickikBut I going to do the tutorial stuff that is in emacs eventully
16:44mattrepland, 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:45mattreplyeah, that's a lot to learn at once. Lisp does seem to bring many to Emacs
16:47nickikI never liked the IDE stuff to mutch
16:48nickikNot to mention swank, paredit, slime ....
16:55dpritchettI'm playing in emacs with clojure-mode and viper-mode
16:56dpritchettI 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:20TimMcCan clojure.core/for do filtering? I see :when, but I can't get it to affect anything.
17:21kotarak,(for [x [:Tim :Mc] :when (not= x :Mc)] x)
17:21clojurebot(:Tim)
17:21qbg,(for [x (range 3) :when (even? x) y (range 3)] [x y])
17:21clojurebot([0 0] [0 1] [0 2] [2 0] [2 1] [2 2])
17:23alexykhow do I find out teh number of CPUs avaiable for the JVM?
17:23TimMcOh, so :when takes a test, not a function.
17:23qbg(.. Runtime getRuntime availableProcessors)
17:23TimMcI was using a function, which of course was always "true". :-P
17:24alexykqbg: thx
17:25qbg(stole that from the source of pmap)
17:31anonymouse89anyone a vimclojure user? I'm trying to install and am confused by gradle/clojuresque etc.
17:33dpritchettI've tried vimclojure a few times but didn't get too far. It
17:33dpritchett's worth noting the stable release is nearly a year old
17:44dakroneanonymouse89: are you installing from a zip, or from source/hgclone?
17:46anonymouse89dakrone: source seems very old so I was trying source/hg but was running into trouble with clojuresque/gradle
17:46anonymouse89sorry zip seems old
17:47dakroneanonymouse89: I'd recommend trying the snapshots, they're very recent: http://groups.google.com/group/vimclojure/msg/ce3fe24b57372799
17:48dakronethat way you don't have to mess with gradle
17:55anonymouse89dakrone: that's perfect. he should update his site.
17:56dakroneyea, that build is an RC, so hopefully we'll see the actual release on the site soon.
17:56anonymouse89ah, so he just picked up work on it again (?)
17:57dakroneyea, check out the mailing list if you have any problems or questions
18:12neotykHi *
18:13neotykdo you know if aleph can be used to stream?
18:29alexykI'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:29alexykalso, on twitter?
18:34TimMcalexyk: 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:35alexykTimMc: so far I found many who have the whole three. Which makes me ponder various data mining schemes.
18:36TimMcI tend to use TimMc/timmc for more professional accounts (code publishing, e.g.) and phyzome for personal stuff.
18:36TimMcHowever, both are public nicks.
18:37alexykTimMc: ok
18:37alexykTimMc: why no twitter yet? :)
18:37TimMcTechnically, I have one, but don't use it. I find it utterly useless.
18:38Raynesalexyk: I has a github account.
18:38RaynesAnd a Twitter account.
18:38RaynesGithub account is the same as my nick here.
18:38RaynesIORaynes on Twitter, because Raynes is taken.
18:38alexykRaynes: as a Haskell man, you're a superior being and are not to be overunderestimated
18:39Rayneso.o
18:39TimMcalexyk: You should grab the /who list and check it against GitHub and Twitter.
18:39TimMcPerhaps you could even use clojure for that... ;-)
18:40alexykTimMc: 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:40alexykTimMc: yeah, clojure is good for this kind of stuff
18:40TimMcThat will make your program even easier to write. :-)
18:42Raynesalexyk: You could use gotmilk to look for accounts. ;) $#google gotmilk github#$
18:42sexpbotFirst out of 11 results is: jfkw's Profile - GitHub
18:42sexpbothttp://github.com/jfkw
18:42RaynesAw.
18:42RaynesI figured it would be the first result.
18:42Raynesalexyk: http://github.com/Raynes/gotmilk
18:42Raynes:p
18:43alexyksee, he got milk first or what
18:43alexykRaynes: is it a repo for facialized ads or what?
18:44alexyk...ah, more boring stuff :)
18:44RaynesHuh? O.o
18:44alexykgot milk ads, mind you! but, command line is very cool too
18:44RaynesHaha.
18:45alexykdnolen: are you a contributor for Incanter?
18:46alexykRaynes: so you suggest to google github nicks by repo name?
18:46dnolenalexyk: no
18:46alexykRaynes: cool
18:46Raynesalexyk: 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:47lancepantzalexyk: i believe rapleaf's service does something along the lines of what you are suggesting
18:47lancepantznot even sure if those guys are still around
18:48lancepantzi use this nick for github, irc, twitter, reddit, digg, facebook, xbox live, psn
18:50RaynesWay to be inconsistent, Github.
18:50RaynesIf searching repos, it returns "username" rather than "owner" which it uses for pretty much everything else repo-related.
18:51alexykRaynes: very very cool.
18:52Raynes:D
19:51TimMcOoh, I think I found a bug in clojure.contrib.sql -- how do I check if one has already been filed?
19:52TeXnomancyclojurebot: assembla?
19:52clojurebotassembla is http://www.assembla.com/spaces/clojure
19:52TeXnomancyclojurebot: botsnack
19:52clojurebotthanks; that was delicious. (nom nom nom)
19:55TimMcAh!
19:55TimMcI did a web search for Clojure bugs and nothing came up.
19:56defnlancepantz: get your jruby + rails + clojure bridge code online yet? :X
19:56lancepantzhaha
19:56lancepantzsaw your message last week, tried to get back, you were gone
19:56defnah, sorry
19:56lancepantzbut it's actually rails + clojure, not jrails
19:57lancepantzgoes through a compojure api
19:59TimMchttp://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:01TimMcLooks like a bug, yeah? Or is there some JDBC/MySQL/etc. nonsense that I'm not aware of?
20:43map_reduce,(range 10)
20:43clojurebot(0 1 2 3 4 5 6 7 8 9)
20:44map_reducehey, 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:50tomoj,(contains? clojure.lang.Compiler/specials 'fn*)
20:50clojurebottrue
20:52map_reduceah, thanks :)
20:52tomojit's just a primitive special form, you'd never use it I think
20:54tomojnot sure why lazy-seq uses it when fn is available
20:54map_reducefair nuff, i'm just trying to learn by going through the source code
20:54tomojI believe you should be safe pretending that the fn* there is fn, as far as understanding lazy-seq
20:54tomoj,((fn* [x] x) 3)
20:54clojurebot3
20:54tomojjust missing some features of fn I guess
20:55map_reducegotcha, cool
20:57tomojI wonder what that ^{:once true} stuff is
20:58TeXnomancyit's for futures and delays IIRC
20:58TeXnomancykind of a low-level memoization
21:00tomoj,(meta (first (nth (macroexpand-1 '(lazy-seq nil)) 2)))
21:00clojurebot{:once true}
21:00tomoj,(first (nth (macroexpand-1 '(lazy-seq nil)) 2))
21:00clojurebotfn*
21:04map_reducehmph, fn* is a Symbol, weird
21:06tomojweird why?
21:09map_reduceI would have expected to see someting like clojure.core$fn*
21:09map_reducewith my limited 2 week experience of clojure.... :)
21:15TimMcmap_reduce: I am also a beginner, but...
21:15TimMcfn* is a "special form", meaning it is defined by the compiler, not by calls to other Clojure code.
21:17map_reduceI gather so, tomoj just introduced me to clojure.core.Compiler so I'm largely talking out of my a** right now...
21:17TimMcUnlike "when" and "repeatedly" and such, it is one of the true primitives of the language.
21:17map_reducesorry, clojure.lang.Compiler
21:18map_reducestill, 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:20TimMcWhat I'm gathering is that all "names" are symbols, just that some are at the compile-time level and others at run-time.
21:20TimMc(Experts, please jump in to correct my educated wild-ass guesses.)
21:23map_reducecrud, 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:24TimMcEach symbol has a name and a namespace.
21:25tomojhmm
21:26tomojI wonder if map_reduce would have also been surprised that + is a symbol, given:
21:26tomoj,+
21:26clojurebot#<core$_PLUS_ clojure.core$_PLUS_@1643de1>
21:26TimMcHah.
21:26stuarthalloway,(.getNamespace 'plain-symbol)
21:26clojurebotnil
21:27stuarthalloway,(.getNamespace 'org.clojure/foo)
21:27clojurebot"org.clojure"
21:27TimMcHrm.
21:27TimMcSo, fully-qualified symbols have a namespace.
21:28stuarthallowaywhat was the original question?
21:28TimMc"Why is fn* a Symbol in clojure.lang.Compiler?"
21:29stuarthallowayimplementation detail
21:30stuarthallowayno deep conceptual significance
21:30TimMcI had claimed that it was a compiler primitive, instead of being definable in terms of further Clojure.
21:31TimMc...but I'm a newb with just enough compiler education to confuse other newbs. :-P
21:34tomojoh, he meant FN?
21:35TimMctomoj: I believe so.
21:35alexykis there a "flip" function to splice ->> / -> arguments into front or back as needed?
21:36clojayGuys, 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:36clojaybudget 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:36alexyk(-> "x" (apply flip get mymap))
21:36defnthere's one that's escaping my brain right now clojay
21:36alexykor something
21:36defnit's a book on FP algorithms IIRC
21:37clojaydefn: purely functional data structures?
21:37defnyes!
21:37defndefinitely worth a buy
21:37alexykclojay: Real World Haskell
21:37TimMcclojay: I learned Scheme with HTDP: http://htdp.org/
21:37tomojalexyk: it wouldn't work anyway
21:37alexyktomoj: well how 'bout a macro?
21:38tomoj(-> "x" (apply flip get mymap)) is (apply "x" flip get mymap)
21:38alexyktomoj true
21:38clojayalexyk: I'm afraid Real World Haskell would be a little too far from Clojure
21:38tomojalexyk: don't ask for a macro that generalizes -> and ->> :P
21:38alexykclojay: well if you want FP, than it's FP
21:38TimMcclojay: HtDP helps you think in terms of algebraic data structures. I suspect SICP does that too, but I haven't read it.
21:39alexyktomoj: all I ask is to move the damn arg into front dammit! :)
21:39TimMcHDP is free to read online, though. :-P
21:39clojayTimMc: so is SICP
21:39TimMcYay!
21:39alexykclojay: and RWH too :)
21:39clojayTimMc: but yes, SICP and HDTP are two possible candidates
21:40TimMcPLT Scheme was very friendly to learn.
21:40alexykclojay: skip it all and get TheJoyofClojure.com by our very own Chouser-san
21:40TimMcThat's what they use in the freshman Fundamentals of Computer Science course at my university.
21:40mikemanyone mentioned Practical Common Lisp? http://gigamonkeys.com/book/
21:40tomojreally?
21:41clojaymikem: apparently CL is not very functional
21:41tomojoh, I had missed that idiomatic lisp was also part of the question
21:41clojayalexyk: I'm planning to get The Joy of Clojure when it's finished
21:42alexykclojay: or you can get the MEAP PDF and read it on screen or kindle
21:42mikemyeah, 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:42qbgPCL is good for CL; not so much for Clojure
21:43clojayI 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:43alexykso, a macro to move an arg to the front, going 1...
21:44TimMcclojay: I think the answer will partly depend on whether existing Clojure books assume you are already familiar with FP.
21:45tomojI think reading scheme books is an excellent idea
21:45alexykthe little schemer
21:45chouserOn Lisp is great
21:45alexykor lisper
21:46qbgThe SICP lecture videos are classics
21:46alexykPCL makes for good toilet reading, pardon my French
21:46chouserYou 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:47alexykin about 53 sittings you can finish PCL, and it's what it deserves as it's not very fun.
21:47clojaychouser: How about this progression? Programming Clojure + Little Schemer + SICP + The Joy of Clojure?
21:48chouserHaven't read the middle two, but from what I know that doesn't sound too bad.
21:48stuarthallowayand if you get tired before you are done at least you started well :-)
21:48alexykclojay: just cut from PC to TJoC! :)
21:49clojaystuarthalloway: haha
21:49stuarthallowayclojar: I liked Little Schemer, but it will be redundant with the others
21:49alexykstuarthalloway: when's the 1.2 edition?
21:49stuarthallowayalexyk: of what?
21:49alexykstuarthalloway: of your one! :)
21:50stuarthallowayI am working on this 1.2 edition: http://clojure.org/downloads
21:50TimMcstuarthalloway: I found what I believe is a bug in clojure.contrib.sql. Do I simply file a ticket on Assembla?
21:50stuarthallowayTimMc: please discuss on mailing list first
21:50TimMcClojure-dev?
21:50clojurebotclojure-dev is the eclipse plugin http://code.google.com/p/clojure-dev/
21:50alexykstuarthalloway: I'll buy the 1.2-synced book of yours in 2 copies at once, paper and kindle!
21:51stuarthallowayTimMc: main list is fine
21:51TimMcAh, OK.
21:51stuarthallowaymain list can help rally support, if others are also feeling the pain
21:51alexykstuarthalloway: 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:52clojaystuarthalloway: when will the new edition of your book be released?
21:52alexyk(even before prims are settled)
21:52stuarthallowaywell, gosh
21:52TimMcstuarthalloway: The Clojure-dev page said scary things about Contributor Agreements. :-P
21:52chouserstuarthalloway: how can you say no?
21:52stuarthallowaythere is no new edition in the works
21:52clojaystuarthalloway: oh, sorry
21:52alexykstuarthalloway: until now! :) clojay: don't weaken your flank
21:52stuarthallowaybut I have done extensive slide decks (free!) and a video
21:53stuarthallowayMost of the 1.2 stuff is covered at http://github.com/stuarthalloway/clojure-presentations/downloads
21:53clojaystuarthalloway: can you tell me how your book differs from Practical Clojure (the Apress one)
21:53stuarthallowayand protocols are at http://vimeo.com/11236603
21:53alexykok! cool. Still printed book feels like The Truth.
21:54stuarthallowayclojay: I sit next to the author of PracCloj, but I haven't read it yet :-)
21:54clojaystuarthalloway: Is it a parallel universe where all Clojure saints are sent to?
21:55stuarthallowayclojay: kind of :-) http://clojure.com/about.html
21:56tomojdata encapsulation is folly, huh
21:57alexykhow do we diff two maps?
21:57alexyksubtract
21:57clojayhas anyone tried The Joy of Clojure on Kindle? Does it look good?
21:58alexykclojay: reasonable
21:58alexyk(on teh old DX)
21:58tomojalexyk: you mean take two maps, throw out the keys they share (and the associated values), and merge the rest?
21:59alexyktomoj: even simpler, throw out the keys from m2 whihc are in m2
21:59alexykdissoc I guess
21:59clojayalexyk: i may go for the ebook version then
21:59tomojthrow out the keys from m1 which are in m2, you mean?
21:59alexyktomoj: yeah
22:00alexykclojay: you'll enjoy it
22:00clojayIf 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:00stuarthallowayqbg: let me know if you have questions
22:02stuarthallowayif anybody wants to download the 1.2 beta and tell me if they see any problems, that would be great
22:02qbgstuarthalloway: It says the docs are at http://richhickey.github.com/clojure/
22:02qbgGiven the move of the repos, shouldn't that be updated?
22:03stuarthallowayyeah
22:03alexykstuarthalloway: how are the prims settled then?
22:03stuarthallowayalexyk: Release.next
22:04mikemstuarthalloway: I had some issues with adding metadata to functions: http://groups.google.com/group/clojure/browse_thread/thread/f2594a96860f4f91#
22:04alexykok
22:04mikemmaybe I was doing it wrong?
22:05stuarthalloway,(let [f ^{:awesome true} (fn [])] (meta f))
22:05clojurebot{:awesome true}
22:05qbgstuarthalloway: get is listed twice at the end
22:05qbg(section 4)
22:05stuarthallowaythanks, fixed
22:05qbgSo is count
22:05stuarthallowaymikem: that was a trivial example of doing it right
22:06mikemstuarthalloway: i'm not sure how to translate that properly when using defn
22:06stuarthallowaymikem: and yes, there are issues with fn metadata. Consider it alpha
22:07mikemstuarthalloway: ah, noted :) at least it's coming
22:08clojayHow oudated is programming clojure now that 1.2 is coming out?
22:09clojayoudated -> outdated
22:11stuarthallowayclojay: almost nothing is *wrong*
22:11stuarthallowaybut more could now be said
22:11clojaystuarthalloway: got it
22:12stuarthallowaythe only significant chance since the book is the metadata reader macro, formerly #^ and now ^
22:16alexykstuarthalloway: were you in Philly before and in Durham now?
22:16stuarthallowayalexyk: for some values of before :-)
22:16stuarthallowaybut i have not lived in Philly
22:16alexykstuarthalloway: I thought you were there for some reason
22:17alexyk(I used to live there)
22:17alexykso Durham is far from anything, I bet you guys move to SF in 1 year
22:17stuarthallowayalexyk; not likely :-)
22:17alexykstuarthalloway: Seattle then :)
22:19alexykor, let's say you'll have to open an office in the Bay Area. Just a bet.
22:20clojayok, 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:22alexykclojay: 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:23alexyk(and treats ebook just as a paper book for now in terms of one-off-ness)
22:23clojayalexyk: I thought Amazon would give you a significantly better version though (when read on a Kindle dx)
22:24alexykclojay: I bought some very crappy PDF versions for DX. They get them from publishers anyways
22:24clojay(in terms of layout, etc)
22:24alexykclojay: the best is mobi converted by publisher
22:24alexyki.e. from PragProg, .mobi is better than PDF on the Kindle
22:24alexykPDF is for the computer and search
22:26clojayalexyk: too bad Manning doesn't offer a .mobi
22:26alexykclojay: they were talking about offering it somewhere/at some point IIRC
22:26alexykand/or we can bug them
22:30robtpwhat does the "*" denote: ([f args* argseq])?
22:33robtpahh, okay, varargs
22:34robtpso & name is end-defn varargs, name* is middle of defn? or is that completely wrong?
22:34rhudsonWhere are you seeing arg* ?
22:35robtp,(doc apply)
22:35clojurebot"([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."
22:36clojayhow 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:36rhudsonOK, that's notation for the usual 0-or-more meaning of * . It's not part of Clojure syntax per se.
22:36robtpclojay: that's what apply is for
22:36robtprhudson: ahh, got it
22:36robtpclojay: which is exactly what i was just looking at
22:37clojayrobtp: oh we had a similar problem then
22:37robtprhudson: so the definition of apply is actually like (defn apply [fn & more]), and the seq is taken as the last element of more?
22:37robtpand the args are any remaining elements
22:38clojay(apply max my-list)
22:38robtpclojay: looks right to me?
22:38clojayrobtp: it works
22:38Raynesapply is a macro.
22:38rhudson(apply f a b [c d e f]) is equivalent to (f a b c d e f)
22:39tomoj,apply
22:39clojurebot#<core$apply clojure.core$apply@1b55ca5>
22:39RaynesIsn't it?
22:39RaynesOh. It isn't.
22:41rhudson,(apply map + [[1 2 3], [10 20 30]])
22:41clojurebot(11 22 33)
22:43robtprhudson: whoa, i thought map took one fn argument, *args, and an argseq
22:43robtphow is having that + in there legit?
22:44tomoj*args can be [+]
22:44rhudsonmap takes 1 or more seq arguments, and applies the function to elements in the same position until the shortest seq is exhausted
22:44rhudson(map + [1 2 3] [10 20 30])
22:46clojayso apply basically removes one set of parenthesis?
22:46rhudson(map vector [:a :b :c] [1 2 3] [4 5])
22:46rhudsonThat's one way to think of it.
22:47rhudson,(apply max [3 1 4 1 5 9])
22:47clojurebot9
22:47cemerickclojay: that sort of shorthand is going to trip you up eventually
22:48robtprhudson: that (apply map + double-vec) is still freaky
22:48cemerickapply invokes the provided fn with the provided arguments
22:49clojaycemerick: 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:50robtprhudson: so behind the scenes, what does (apply map + [[etc] [etc2]]) look like
22:50robtpclojay: the provided arguments are + and [[vec] [vec2]]
22:50tomojno, +, [1 2 3], and [10 20 30]
22:50cemerickclojay: that's functionally equivalent to (map + [1 2 3] [10 20 30])
22:51robtpwhich i think becomes (+ (1 2 3) (10 20 30))
22:51tomojeh?
22:51robtptomoj: apply doesn't seem to give any special treatment to a + in that pesition
22:51tomojthere is no special treatment indeed
22:51tomoj+ is just passed to map the same way apply passes args to any function
22:51cemerickThe point is, the fn *and* the arguments are data that do not need to be coincident with the apply usage.
22:51robtptomoj: oh, i think we agree, i read "no, +, [1 2 3] and [10 20 30]" wrong
22:52robtpcool, thanks all
22:53cemericke.g.:
22:53cemerick,(let [some-data [(range 10) (range 30 50)]] (apply map + some-data))
22:53clojurebot(30 32 34 36 38 40 42 44 46 48)
22:54robtpcemerick: so (range a b) attempts to match the other given range?
22:54cemerick,(doc range)
22:54clojurebot"([] [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:54robtpwait, nevermind
22:54cemerick,(range 5 10)
22:54robtpmath issues
22:54clojurebot(5 6 7 8 9)
22:56rhudsonNote that the first range has 10 elements, the second 20, and the result (using map) has 10
22:56robtpyeah, i got that now. math is tough!
22:56cemerickThis might help, insofar as it is very clear about the args going into apply having nothing to do with literals:
22:57cemerick,(apply + (take 10 (repeatedly rand)))
22:57clojurebot4.596899040906102
22:59clojaywtf... we have a repeatedly function?
22:59cemerickremarkably useful
22:59clojayfantastic
22:59scgilardioh yes, it's very nice
23:00cemerickscgilardi: hi Stephen, long time no chat :-)
23:00scgilardiheya chas. good to see you too.
23:00cemerickwhat are you up to these days?
23:01scgilardiworking on fun stuff at Sonian... (avengers and all that)
23:01clojayI know it's a Lisp but to be honest Clojure looks a bit like Haskell to me
23:02cemerickright, right; forgot you were there, sorry. You're the quiet one. ;-)
23:02defnThen you don't know Haskell ;)
23:02scgilardifell behind on mailing list and chat, but trying to catch up
23:02danlarkinit's impossible
23:02danlarkinthere's too much
23:03scgilardi6000 message backlogs are daunting
23:03cemerickclojay: there's lots of influences
23:03defnyou could probably finish it all in a few days
23:03cemerickI manage to keep up for a while, fall behind for around 5K, and then just dump and start over.
23:03defnlots of it you wont care to read anyway
23:03danlarkinmy clojure ML backlog is 22445 :)
23:03scgilardidan wins again!
23:04danlarkinlazy execution wins again!
23:06wdouglasIs there an idiomatic way of getting for with two seqs to return a dot product instead of all combinations of the seqs?
23:08qbgIf it doesn't need to be in for, you could use map
23:08clojayby 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:08wdouglasI was having a tough time making map work for my case
23:09rhudsonwdouglas: (map dot seq1 seq2) didn't do it for you?
23:09wdouglasI think I can do it but goodness it'd be really easy with for
23:09qbg,(for [x (map vector [:a :b :c] [:do :re :mi])] x)
23:09clojurebot([:a :do] [:b :re] [:c :mi])
23:10wdouglasqbg: oh
23:10cemerickclojay: Joy of Clojure is more my style, but YMMV.
23:10wdouglasqbg: Very nice
23:11clojaycemerick: I was thinking AND more than OR
23:11cemerick*shrug* :-)
23:12clojaycemerick: got it
23:12tomojjust use (map vector ..) unless you need the for for some other reason
23:47BahmanHi all!
23:47qbgHello Bahman
23:47BahmanHi qbg!
23:52miltondsilvaok... 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:53tomojwhat is the whole "the right tool for the right job" thing?
23:53jhawk28use a hammer when you need a hammer or a screwdriver when you need a screwdriver
23:53jhawk28makes you more productive
23:54tomojso miltondsilva wants to prove that you would be more productive using a screwdriver when you need a hammer?
23:54tomojseems unlikely..
23:54miltondsilvahmmm...
23:55miltondsilvaok so... I think that there is a better programming language... something like a silver bullet
23:55miltondsilvayes yes.. ridicule
23:55miltondsilvabut
23:55miltondsilvathe think is.. I can't find any paper.. study or something like that... that studies this
23:56miltondsilvathe thing*
23:56technomancyyou don't need a study to tell you that you can't use a language with a 2MB runtime for embedded work.
23:56technomancynor a language that relies on persistent data structures in an environment without a good GC
23:57jhawk28sometimes its a good sales technique to get your management to let you use a bunch of different tools
23:57miltondsilvabut why can't you use a common descriptor to express your ideas? and have it compile to whatever you want?
23:59jhawk28different dynamics of languages produce vastly different results
23:59jhawk28and everyone has their opinion about each one
23:59jhawk28after all, text editors all to the same thing, but try convince someone that emacs is better than vim or vice versa
23:59miltondsilvayes! it's all about opinion.. so I would like to get some facts...