|
Empty Iterators: msg#00420lang.scala
What's the canonical way of getting an empty Iterator[A]? Iterator.empty only wants to give me an Iterator[Nothing], which isn't quite what I'm after. The context is as the zero for a fold, class DisjointUnion[A](family : List[Set[A]]) extends Set[A] { val size = ... def contains(elem: A) = ... def elements = family.foldLeft(???)( (i : Iterator[A], s : Set[A]) => i ++ s.elements) } It feels like the '???' should be replaced by something like, def elements = family.foldLeft(Iterator.empty[A])( (i : Iterator[A], s : Set[A]) => i ++ s.elements) where Iterator.empty[A] has the obvious definition, def empty[A] : Iterator[A] = /* old Iterator.empty renamed */ Could this be done without too much breakage elsewhere in the Scala libraries? Cheers, Miles |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: two things about defs: 00420, Burak Emir |
|---|---|
| Next by Date: | Re: How do I pattern match the following: 00420, Burak Emir |
| Previous by Thread: | Tail recursion elimination and logical shortcut operatorsi: 00420, Miles Sabin |
| Next by Thread: | Re: Empty Iterators: 00420, Burak Emir |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |