@@ -57,14 +57,26 @@ index (S k) (x::xs) = index k xs
57zipWith : (a -> b -> c) -> Stream a -> Stream b -> Stream c
57zipWith : (a -> b -> c) -> Stream a -> Stream b -> Stream c
58zipWith f (x::xs) (y::ys) = f x y :: zipWith f xs ys
58zipWith f (x::xs) (y::ys) = f x y :: zipWith f xs ys
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
60||| Create a stream of pairs from two streams
64||| Create a stream of pairs from two streams
61zip : Stream a -> Stream b -> Stream (a, b)
65zip : Stream a -> Stream b -> Stream (a, b)
62zip = zipWith (\x,y => (x,y))
66zip = zipWith (\x,y => (x,y))
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))
64||| Create a pair of streams from a stream of pairs
72||| Create a pair of streams from a stream of pairs
65unzip : Stream (a, b) -> (Stream a, Stream b)
73unzip : Stream (a, b) -> (Stream a, Stream b)
66unzip xs = (map fst xs, map snd xs)
74unzip xs = (map fst xs, map snd xs)
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)
68||| Return the diagonal elements of a stream of streams
80||| Return the diagonal elements of a stream of streams
69diag : Stream (Stream a) -> Stream a
81diag : Stream (Stream a) -> Stream a
70diag ((x::xs)::xss) = x :: diag (map tail xss)
82diag ((x::xs)::xss) = x :: diag (map tail xss)