Skip to content

Instantly share code, notes, and snippets.

@nicuveo
Created December 8, 2025 22:06
Show Gist options
  • Select an option

  • Save nicuveo/12733334bde8b4a8cea3a9a27d83b297 to your computer and use it in GitHub Desktop.

Select an option

Save nicuveo/12733334bde8b4a8cea3a9a27d83b297 to your computer and use it in GitHub Desktop.
Circular programmin in Haskell
distanceFromAverage :: [Int] -> [Int]
distanceFromAverage values =
let (result, mean) = go 0 0 [] mean values
in result
where
go total amount result _ [] = (result, total `div` amount)
go total amount result mean (x:xs) =
go (total + x) (amount + 1) (result ++ [abs $ x - mean]) mean xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment