Convert seconds to compound duration: Difference between revisions

m
→‎{{header|Haskell}}: Flipped the type of one function.
(→‎{{header|Factor}}: factor out some repetition, style tweaks)
m (→‎{{header|Haskell}}: Flipped the type of one function.)
Line 1,774:
translation :: Int -> String -> String
translation n local =
intercalate " -> " $ [show, flip timePhrase (words local)] <*> [n]
 
timePhrase :: Int[String] -> [String]Int -> String
timePhrase n xs n = intercalate ", " (foldr timeTags [] (zip (weekParts n) xs))
 
timeTags :: (Int, String) -> [String] -> [String]
timeTags (n, s) xs
| n0 >< 0n = unwords [show n, s] : xs
| otherwise = xs
 
Line 1,788:
 
byUnits :: Int -> Int -> (Int, Int)
byUnits rest x = (quot (rest - m) u, m)
where
let (u, m)
| x > 0 = (xu, rem rest xm)
| 0 |< otherwisex = (1x, rem rest x)
in (quot (rest - m)| uotherwise = (1, mrest)
 
-- TEST ------------------------------------------TEST----------------------------
main :: IO ()
main =
9,659

edits