Add basic vector functions to Util
This commit is contained in:
parent
5b91c3815c
commit
061c733688
23
src/Util.md
23
src/Util.md
|
@ -22,3 +22,26 @@ Applies a function to the contents of a `Left` if the value of the given `Either
|
|||
mapLeft f (Left x) = Left (f x)
|
||||
mapLeft f (Right x) = Right x
|
||||
```
|
||||
## Vectors
|
||||
|
||||
Define some operations for pairs of numbers, treating them roughly like vectors
|
||||
|
||||
### Addition and Subtraction
|
||||
|
||||
<!-- idris
|
||||
export infixl 8 >+<
|
||||
export infixl 8 >-<
|
||||
|
||||
namespace Pair
|
||||
-->
|
||||
|
||||
```idris
|
||||
public export
|
||||
(>+<) : Num a => (x, y : (a, a)) -> (a, a)
|
||||
(x_1, x_2) >+< (y_1, y_2) = (x_1 + y_1, x_2 + y_2)
|
||||
|
||||
public export
|
||||
(>-<) : Neg a => (x, y : (a, a)) -> (a, a)
|
||||
(x_1, x_2) >-< (y_1, y_2) = (x_1 - y_1, x_2 - y_2)
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in a new issue