Skip to content

Instantly share code, notes, and snippets.

@scvalex
Created April 3, 2010 19:21
Show Gist options
  • Save scvalex/354770 to your computer and use it in GitHub Desktop.
Save scvalex/354770 to your computer and use it in GitHub Desktop.
Gaussian elimination on lists
-- PRE: xs is sorted and not null
-- POST: r is xs without the elements that vary by
-- more than err from the median
gausselim ∷ (Num a, Ord a) ⇒ a → [a] → [a]
gausselim err xs = filter good xs
where
middle = xs ‼ (length xs `div` 2)
good x = abs (x - middle) < err
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment