On Jan 23, 7:34 am, "Stephen C. Gilardi" <squee...@mac.com> wrote:
> There was a recent suggestion here:
>
>        http://groups.google.com/group/clojure/msg/32d323e15f8ce624
>
> about the proper value of:
>
>         (clojure.contrib.lazy-seqs/combinations)
>
> (and perhaps by extension (clojure.contrib.lazy-seqs/combinations '())  
> (or any number of empty seq arguments))

No no no :).  (combinations '()) should be nil/empty coll, but
(combinations) should be a [[]] (or any coll/seq containing only an
nil/empty coll, I don't care which types).

This can be argued several ways, but the clearest is to think about
the length of the sequence returned by combinations.  It should be the
product of the lengths of the input sequences.  Thus, if any of the
inputs to combinations are empty lists, (* ? 0 ? ?) ==> 0, the return
value should be nil.  But, if the input is *no lists at all*, then we
have (*) ==> 1 and the output should be a list containing the empty
list.


> Does a decision to use empty collections in the powerset case fit well  
> with the suggestion that
>
>         (clojure.contrib.lazy-seqs/combinations) return ([])
>
> or are they in conflict or unrelated?

Well, you can reason in the same way about power-set; if the input has
n elements, the output should have 2^n elements.  Thus, (power-set
nil) should return [[]] as well (or, again, any coll/seq containing
only an empty coll/seq, I don't care which type).

Or, you could just look at Wiki: "the power set of the empty set is
the set containing the empty set"

http://en.wikipedia.org/wiki/Power_set

-Jason
--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to