Created
August 17, 2020 17:56
-
-
Save crclark96/d2b79bf0f091343e35d49583497efa70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*Main> moveZeros [1, 2, 0, 1, 0, 0, 3, 6] | |
[1,2,1,3,6,0,0,0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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