toy-lib-0.1.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

ToyLib.Prelude

Synopsis

Documentation

square :: Num a => a -> a #

\(O(1)\)

isqrt :: Int -> Int #

\(O(1)\) Inaccurate, but fast Int square root. TODO: Fast and accurate implementation

(.:) :: (b -> c) -> (a1 -> a2 -> b) -> a1 -> a2 -> c #

\(O(1)\) Two-variable function compositon.

swapDupeU :: Vector (Int, Int) -> Vector (Int, Int) #

\(O(E)\) Edge duplication.

swapDupeW :: Unbox w => Vector (Int, Int, w) -> Vector (Int, Int, w) #

\(O(E)\) Converts undirected edges into directed edges.

ortho4' :: ((Int, Int), (Int, Int)) -> (Int, Int) -> Vector (Int, Int) #

orthoWith :: ((Int, Int), (Int, Int)) -> ((Int, Int) -> Bool) -> Int -> Vector Int #

Specifically for grids with generic search functions.

slice :: Vector v a => Int -> Int -> v a -> v a #

\(O(1)\) slice via inclusive range [l, r].

zero2 :: Int -> Int -> ((Int, Int), (Int, Int)) #

zero3 :: Int -> Int -> Int -> ((Int, Int, Int), (Int, Int, Int)) #

rangeG :: Vector v Int => Int -> Int -> v Int #

\(O(N)\) List-like range syntax for vector.

>>> rangeG @U.Vector 3 5
[3,4,5]

rangeV :: Int -> Int -> Vector Int #

\(O(N)\) Type-constrained rangeG.

rangeU :: Int -> Int -> Vector Int #

\(O(N)\) Type-constrained rangeG.

rangeGR :: Vector v Int => Int -> Int -> v Int #

\(O(N)\) Easier reverse range syntax for vector.

>>> rangeGR @U.Vector 3 5
[5,4,3]

rangeVR :: Int -> Int -> Vector Int #

\(O(N)\) Type-constrained rangeGR.

rangeUR :: Int -> Int -> Vector Int #

\(O(N)\) Type-constrained rangeGR.

times :: Int -> (a -> a) -> a -> a #

\(O(N)\) Applies the given function n times. >>> -- 2 ^ 3 >>> times 3 (* 2) (1 :: Int) 8

interleave :: [a] -> [a] -> [a] #

\(O(N+M)\)

swapDupe :: (a, a) -> [(a, a)] #

\(O(E)\)

add2 :: (Int, Int) -> (Int, Int) -> (Int, Int) #

\(O(1)\)

sub2 :: (Int, Int) -> (Int, Int) -> (Int, Int) #

\(O(1)\)

mul2 :: Int -> (Int, Int) -> (Int, Int) #

\(O(1)\)

add3 :: (Int, Int, Int) -> (Int, Int, Int) -> (Int, Int, Int) #

\(O(1)\)

sub3 :: (Int, Int, Int) -> (Int, Int, Int) -> (Int, Int, Int) #

\(O(1)\)

mul3 :: (Int, Int, Int) -> (Int, Int, Int) -> (Int, Int, Int) #

\(O(1)\)

toRadian :: Double -> Double #

\(O(1)\) 180.0 degree = p radian.

toDegree :: Double -> Double #

\(O(1)\)

fst4 :: (a, b, c, d) -> a #

\(O(1)\)

snd4 :: (a, b, c, d) -> b #

\(O(1)\)

thd4 :: (a, b, c, d) -> c #

\(O(1)\)

fth4 :: (a, b, c, d) -> d #

\(O(1)\)

first4 :: (a -> x) -> (a, b, c, d) -> (x, b, c, d) #

\(O(1)\)

second4 :: (b -> x) -> (a, b, c, d) -> (a, x, c, d) #

\(O(1)\)

third4 :: (c -> x) -> (a, b, c, d) -> (a, b, x, d) #

\(O(1)\)

fourth4 :: (d -> x) -> (a, b, c, d) -> (a, b, c, x) #

\(O(1)\)

fix1 :: a -> ((a -> b) -> a -> b) -> b #

\(O(1)\)

fix2 :: a -> b -> ((a -> b -> c) -> a -> b -> c) -> c #

\(O(1)\)

fix3 :: a -> b -> c -> ((a -> b -> c -> d) -> a -> b -> c -> d) -> d #

\(O(1)\)