On Jun 13, 4:11 pm, Jarkko Oranen <chous...@gmail.com> wrote: > Also, try using (find-doc "foo") and (doc foo) in a repl for > documentation searches. For this function, you might want to check out > if-let.
Find-doc seems to give about the same results as searching through the API page, only also cluttering up the REPL transcript. :) > > (defmacro with-stack-trace [& body] > > `(try (eval (quote (do ~...@body))) > > (catch Throwable ex# > > (. (get-ultimate-cause ex#) printStackTrace)))) > > The golden rule: eval is almost always wrong. > > Why not simply `(try ~...@body > (catch ...))? Doesn't catch exceptions thrown by the compiler, only ones thrown by the evaluator. The code I wrote nabs both. > maps also are sequenceable into a seq of [k v] pairs so instead of > explicitly looping it's possible to do > (into {} (map (fn [[k v]] [(if keys? (f k) k) (f v)]) coll) Yeah, that might work well. > I don't see why you do (apply f [k])... That's equivalent to (f k) Sometimes I forget the first item in a function-call form can be anything that evaluates to a function, and not just a symbol bound to one. :) > I also personally dislike functions that take a boolean parameter; if > you must, at least make it optional, with default to false The -raw ending is one I use on functions that tend to have ugly call semantics, and are mainly used to implement other more specialized functions. I had a map-preserve that called map-preserve-raw with keys? false, in particular, which would be the function usually used. > > (defn map-preserve [f coll] > > (map-preserve-raw f coll false)) There it is. > > (defn map-code [f code] > > (if (coll? code) > > (map-preserve-raw #(map-code f %) code true) > > (apply f [code]))) > > > This makes with-derefs (part of super-lazy-seq) simpler: > > I didn't quite get your super-lazy-seq, but then again I didn't look > at it in detail yet. It seems like it > might make constructing lazy seqs easier, but I'd need more examples. > The use of atoms feels dubious. > It seems to me that you're emulating mutability with them. I might be > wrong, but if there's any way to get rid of the atoms, it's worth the > effort :) Yeah, it's a little bit dodgy-seeming, but making any form of "lazy loop/recur" pretty much demands some sort of mutable bindings. > Not to mention file-seq already exists in core Eh. There's no files section in the navigation pane at the site. A complete category-page based version of the api docs would be useful, with all the file-interaction stuff on one page, all the atom-stuff on another, and so on, with nothing omitted (and maybe some things in two or more places). --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---