@@ -57,14 +57,26 @@ index (S k) (x::xs) = index k xs
5757zipWith : (a -> b -> c) -> Stream a -> Stream b -> Stream c
5858zipWith f (x::xs) (y::ys) = f x y :: zipWith f xs ys
5959
60+||| Combine three streams by applying a function element-wise along them
61+zipWith3 : (a -> b -> c -> d) -> Stream a -> Stream b -> Stream c -> Stream d
62+zipWith3 f (x::xs) (y::ys) (z::zs) = f x y z :: zipWith3 f xs ys zs
63+
6064||| Create a stream of pairs from two streams
6165zip : Stream a -> Stream b -> Stream (a, b)
6266zip = zipWith (\x,y => (x,y))
6367
68+||| Combine three streams into a stream of tuples elementwise
69+zip3 : Stream a -> Stream b -> Stream c -> Stream (a, b, c)
70+zip3 = zipWith3 (\x,y,z => (x,y,z))
71+
6472||| Create a pair of streams from a stream of pairs
6573unzip : Stream (a, b) -> (Stream a, Stream b)
6674unzip xs = (map fst xs, map snd xs)
6775
76+||| Split a stream of three-element tuples into three streams
77+unzip3 : Stream (a, b, c) -> (Stream a, Stream b, Stream c)
78+unzip3 xs = (map (\(x,_,_) => x) xs, map (\(_,x,_) => x) xs, map (\(_,_,x) => x) xs)
79+
6880||| Return the diagonal elements of a stream of streams
6981diag : Stream (Stream a) -> Stream a
7082diag ((x::xs)::xss) = x :: diag (map tail xss)