+
+private class PipeSelect[E]
+ super Iterator[E]
+
+ var source: Iterator[E]
+
+ var predicate: Function[E, Bool]
+
+ init(source: Iterator[E], predicate: Function[E, Bool])
+ do
+ self.source = source
+ self.predicate = predicate
+
+ do_skip
+ end
+
+ fun do_skip
+ do
+ while source.is_ok and not predicate.apply(source.item) do source.next
+ end
+
+ redef fun is_ok do return source.is_ok
+
+ redef fun item do return source.item
+
+ redef fun next
+ do
+ source.next
+ do_skip
+ end
+end
+
+private class PipeMap[E, F]
+ super Iterator[F]
+
+ var source: Iterator[E]
+ var function: Function[E, F]
+
+ var item_cache: nullable F = null
+ var item_cached = false
+
+ redef fun is_ok do return source.is_ok
+
+ redef fun item do
+ if item_cached then return item_cache
+ item_cache = function.apply(source.item)
+ item_cached = true
+ return item_cache
+ end
+
+ redef fun next do
+ source.next
+ item_cached = false
+ end
+end
+
+# Stateless singleton that reify to the `to_s` method.
+#
+# assert fun_to_s.apply(5) == "5"
+fun fun_to_s: Function[Object, String] do return once new FunctionToS