>>109039981
I still don't get how that is so different from
(defun transform (stream)
(and-let* ((filtered (seq-filter #'numberp stream))
(mapped (seq-map #'number-to-string filtered)))))
(let* ((list-stream (stream '("a" "b" 0 1 2 3))))
(seq-into (transform list-stream) 'vector))
(let* ((vector-stream (stream (vector "a" "b" 0 1 2 3))))
(seq-into (transform vector-stream) 'list))
(using stream.el)
or in Rust using iterators:
fn transform<I: IntoIterator<Item=u32>>(iter: I) -> impl Iterator<Item=String> {
iter.into_iter()
.filter(|x| x % 2 == 0)
.map( |x| format!("{}", x))
}
use std::collections::HashSet;
fn main() {
let nums: [u32;4] = [0, 1, 2, 3];
let trans: Vec<String> = transform(nums).collect();
let nums: HashSet<u32> = HashSet::from([0, 1, 2, 3]);
let trans: Vec<String> = transform(nums).collect();
}
They're both lazy so no unnecessary building of intermediary lists or whatever and both can be seamlessly chained with more transformations. Also both examples allow for using different sequence/collection types (or technically anything that can be turned into a stream/iterator) as in and output.