diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2022-12-03 02:18:25 -0700 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2022-12-03 02:18:25 -0700 |
| commit | ecf90db5ffada1890e759c5a7e91c13ec15a02bd (patch) | |
| tree | bb102d9d8aeeecdb6d36b63a5b5ec0623d2d8f4d /Graphics/Glyph/Util.hs | |
| parent | d7fb5d4551a93b4756db62f494b761c0cef2fda7 (diff) | |
| parent | a60702dd882768e7f5b7fcadd39253ac8de9114f (diff) | |
| download | terralloc-ecf90db5ffada1890e759c5a7e91c13ec15a02bd.tar.gz terralloc-ecf90db5ffada1890e759c5a7e91c13ec15a02bd.tar.bz2 terralloc-ecf90db5ffada1890e759c5a7e91c13ec15a02bd.zip | |
Merge remote-tracking branch 'origin/snow'
Diffstat (limited to 'Graphics/Glyph/Util.hs')
| -rw-r--r-- | Graphics/Glyph/Util.hs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Graphics/Glyph/Util.hs b/Graphics/Glyph/Util.hs index 1c1269d..90640a4 100644 --- a/Graphics/Glyph/Util.hs +++ b/Graphics/Glyph/Util.hs @@ -329,3 +329,18 @@ mix a b c = a * c + b * (1 - c) fpart :: (RealFrac a) => a -> a fpart x = x - (fromIntegral (floor x::Int)) +ifNaN :: (RealFloat a) => a -> a -> a +ifNaN reg def = if' (isNaN reg) def reg + +everyN :: Int -> [a] -> [a] +everyN _ [] = [] +everyN n (x : xs) = x : (everyN n $ drop n xs) + +chunkList :: [a] -> [(a,a)] +chunkList l = zip [x | x <- everyN 1 l] [x | x <- everyN 1 (tail l)] + +chunkList3 :: [a] -> [(a,a,a)] +chunkList3 l = zip3 + [x | x <- everyN 2 l] + [x | x <- everyN 2 (tail l)] + [x | x <- everyN 2 (tail $ tail l)] |