Skip to content

Instantly share code, notes, and snippets.

@crclark96
Created August 17, 2020 17:56
Show Gist options
  • Save crclark96/d2b79bf0f091343e35d49583497efa70 to your computer and use it in GitHub Desktop.
Save crclark96/d2b79bf0f091343e35d49583497efa70 to your computer and use it in GitHub Desktop.
*Main> moveZeros [1, 2, 0, 1, 0, 0, 3, 6]
[1,2,1,3,6,0,0,0]
import Data.List
moveZeros :: [Int] -> [Int]
moveZeros xs = xs' ++ replicate (length xs - length xs') 0
where xs' = filter (/= 0) xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment