Why aren't lists callable?

2009-01-11 Thread Ethan Herdrick
Why aren't all sequences callable, i.e. why don't they all implement IFn? I'd like to use lists like this sometimes. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email

Re: Why aren't lists callable?

2009-01-11 Thread Chouser
On Sun, Jan 11, 2009 at 9:38 PM, Ethan Herdrick wrote: > > Why aren't all sequences callable, i.e. why don't they all implement > IFn? I'd like to use lists like this sometimes. When you call maps and vectors, it acts as if you're calling 'get'. But 'get' doesn't do anything useful for lists.

Re: Why aren't lists callable?

2009-01-11 Thread Mark Fredrickson
I can't imagine this idea will be met warmly, but I have a suggestion. It requires ending maps and vectors as functions of keys. Instead, make the first argument to a collection be a function which is mapped to across the collection. Any additional arguments are passed to the function on e

Re: Why aren't lists callable?

2009-01-12 Thread Stuart Sierra
On Jan 12, 12:11 am, Mark Fredrickson wrote: > I can't imagine this idea will be met warmly, but I have a suggestion.   > It requires ending maps and vectors as functions of keys. Instead,   > make the first argument to a collection be a function which is mapped   > to across the collection. Any

Re: Why aren't lists callable?

2009-01-12 Thread Rich Hickey
On Jan 12, 10:31 am, Stuart Sierra wrote: > On Jan 12, 12:11 am, Mark Fredrickson > wrote: > > > I can't imagine this idea will be met warmly, but I have a suggestion. > > It requires ending maps and vectors as functions of keys. Instead, > > make the first argument to a collection be a functi

Re: Why aren't lists callable?

2009-01-12 Thread Jason Wolfe
For mapping across maps I often find the following utility helpful: (defn map-map "Like map, but expects f to produce pairs that are combined to produce a map output." [f & maps] (reduce #(conj %1 %2) {} (apply map f maps))) 1:1 user=> (map-map (fn [[k v]] [k (str v " Mark")]) {:greet "hello"

Re: Why aren't lists callable?

2009-01-12 Thread Ethan Herdrick
Then why are sets callable? Not that I'm complaining - I found it handy, then came to wonder why lists aren't. -Ethan > I'd just like to add to this discussion that maps and vectors are > functions not just because it's neat or possible, with the > implementation one of many possibilities, but

Re: Why aren't lists callable?

2009-01-12 Thread Chouser
On Mon, Jan 12, 2009 at 5:56 PM, Jason Wolfe wrote: > > For mapping across maps I often find the following utility helpful: > > (defn map-map "Like map, but expects f to produce pairs that are > combined to produce a map output." > [f & maps] (reduce #(conj %1 %2) {} (apply map f maps))) > > 1:

Re: Why aren't lists callable?

2009-01-12 Thread Stuart Sierra
A set is, in a sense, a function mapping from arbitrary objects to Boolean values. If the object is in the set, it returns true. A list, in the Lisp world at least, only has two elements, first and rest (car and cdr in older Lisps). A list object isn't really a "complete" collection the way vector

Re: Why aren't lists callable?

2009-01-14 Thread Ethan Herdrick
Makes sense, but (#{:a :b :c} :b) doesn't return 'true', it returns :b. So it's not really acting like an object to boolean mapping. Doesn't much matter, though. By the way, I'd like to see map-map in the core. -Ethan On Jan 12, 5:30 pm, Stuart Sierra wrote: > A set is, in a sense, a functio

Re: Why aren't lists callable?

2009-01-14 Thread Chouser
On Wed, Jan 14, 2009 at 10:23 PM, Ethan Herdrick wrote: > > By the way, I'd like to see map-map in the core. If you're referring to Jason Wolfe's suggested function, I think you may be pretty satisfied with (into {} (map ...)) instead. --Chouser --~--~-~--~~~---~--~