Convert seconds to compound duration: Difference between revisions

→‎{{header|Haskell}}: Additionally parameterised separators.
m (→‎{{header|Haskell}}: Adjusted a pair of bound names.)
(→‎{{header|Haskell}}: Additionally parameterised separators.)
Line 1,789:
translation local daysPerWeek hoursPerDay n =
intercalate " -> " $
[show, durationString ", " " " daysPerWeek hoursPerDay (words local)] <*> [n]
 
durationString :: String -> String -> Int -> Int -> [String] -> Int -> String
durationString componentGap numberLabelGap daysPerWeek hoursPerDay xs n =
intercalate
", "componentGap
(foldr
(foldr timeTags [] (zip (weekParts daysPerWeek hoursPerDay n) xs))
(timeTags numberLabelGap)
[]
(foldr timeTags [] (zip (weekParts daysPerWeek hoursPerDay n) xs))
 
timeTags :: String -> (Int, String) -> [String] -> [String]
timeTags numberLabelGap (n, s) xs
| 0 < n = unwordsintercalate numberLabelGap [show n, s] : xs
| otherwise = xs
 
9,659

edits