New paste Repaste Download
removeTrailing0s :: String -> String
removeTrailing0s s =
    let (_, f) = foldr maybeSkip0 (False, id) s
        s' = f ""
    -- If a component is completely stripped (due to being all '0's)
    -- this will return "0".
    in if null s' then "0" else s'
-- Does not skip if any non-zero char has been reached
maybeSkip0 c   (True , f) = (True , (c:) . f)
maybeSkip0 '0' (False, f) = (False,        f)
maybeSkip0 c   (False, f) = (True , (c:) . f)
Filename: stdin. Size: 463b. View raw, , hex, or download this file.

This paste expires on 2025-03-09 09:19:07.205757. Pasted through web.