Skip to content

Instantly share code, notes, and snippets.

@crclark96
Created August 17, 2020 17:56
*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