| Copyright | (C) 2025 Alexey Tochin |
|---|---|
| License | BSD3 (see the file LICENSE) |
| Maintainer | Alexey Tochin <Alexey.Tochin@gmail.com> |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Numeric.InfBackprop.Utils.Tuple
Description
Utility functions for working with tuples.
Synopsis
- cross :: (a -> b) -> (c -> d) -> (a, c) -> (b, d)
- cross3 :: (a0 -> b0) -> (a1 -> b1) -> (a2 -> b2) -> (a0, a1, a2) -> (b0, b1, b2)
- fork :: (t -> a) -> (t -> b) -> t -> (a, b)
- fork3 :: (t -> a0) -> (t -> a1) -> (t -> a2) -> t -> (a0, a1, a2)
- curry3 :: ((a, b, c) -> d) -> a -> b -> c -> d
- uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d
- biCross :: (a -> b -> c) -> (d -> e -> f) -> (a, d) -> (b, e) -> (c, f)
- biCross3 :: (a -> b -> c) -> (d -> e -> f) -> (g -> h -> l) -> (a, d, g) -> (b, e, h) -> (c, f, l)
Documentation
cross :: (a -> b) -> (c -> d) -> (a, c) -> (b, d) Source #
Applies two functions to the components of a tuple.
cross3 :: (a0 -> b0) -> (a1 -> b1) -> (a2 -> b2) -> (a0, a1, a2) -> (b0, b1, b2) Source #
Applies three functions to the components of a triple.
Examples
>>>import GHC.Num ((+), (-), (*))
>>>cross3 (+1) (*2) (\x -> x - 3) (3, 4, 10)(4,8,7)
fork :: (t -> a) -> (t -> b) -> t -> (a, b) Source #
Applies two functions to the same argument and returns a tuple of results.
Examples
>>>import GHC.Num ((+), (*))
>>>fork (+1) (*2) 3(4,6)
fork3 :: (t -> a0) -> (t -> a1) -> (t -> a2) -> t -> (a0, a1, a2) Source #
Applies three functions to the same argument and returns a triple of results.
>>>import GHC.Num ((+), (-), (*))
Examples
>>>fork3 (+1) (*2) (\x -> x - 3) 5(6,10,2)
curry3 :: ((a, b, c) -> d) -> a -> b -> c -> d Source #
Curries a function on triples.
Examples
>>>import GHC.Num ((+))
>>>f (x, y, z) = x + y + z>>>g = curry3 f>>>g 1 2 36
uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d Source #
Uncurries a function on triples.
Examples
>>>import GHC.Num ((+))
>>>f x y z = x + y + z>>>g = uncurry3 f>>>g (1, 2, 3)6