packages feed

edge-0.8.20: Common.hs

module Common where

import Math ( inc
            , isNeg
            )

-- seconds
type Time = Double

-- Radians
type Angle = Double

-- mysterious unit but usually same as pixels
type Velocity = Vector

type Vector = (Double, Double)

-- replaceAt :: Int -> a -> [a] -> [a]
-- replaceAt i a as
--   | isNeg i || i >= length as = as
--   | otherwise = take i as ++ [a] ++ drop (inc i) as

replaceAt a b c
  | isNeg a = c          
  | otherwise = acc 0 c

  where acc _ [] = []
        acc u (v:vs)
          | u == a = b : vs
          | otherwise = v : acc (inc u) vs

allTrue = all id

pairDup x = (x, x)