packages feed

edge-0.9.1.0: Common.hs

{-|
Module      : Common
Description : Some very generic functions and definitions
Copyright   : (c) Christopher Howard, 2016
License     : GPL-3
Maintainer  : ch.howard@zoho.com
-}

module Common where

import Math

-- 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)