Convert seconds to compound duration: Difference between revisions

Content added Content deleted
Line 206: Line 206:
on angloDuration(intSeconds)
on angloDuration(intSeconds)
script mf
script mf
-- weekParts Int -> [Int]
on weekParts(intSeconds)
unitParts(intSeconds, [missing value, 7, 24, 60, 60])
end weekParts
-- [String] -> (Int, String) -> [String]
on formatted(a, lstPair)
on formatted(a, lstPair)
set q to item 1 of lstPair
set q to item 1 of lstPair
Line 217: Line 223:
intercalate(", ", ¬
intercalate(", ", ¬
foldr(mf's formatted, [], ¬
foldr(formatted of mf, [], ¬
zip(weekParts(intSeconds), ¬
zip(weekParts(intSeconds) of mf, ¬
["wk", "d", "hr", "min", "sec"])))
["wk", "d", "hr", "min", "sec"])))
end angloDuration
end angloDuration




-- INTEGER DECOMPOSITION
-- weekParts :: Int -> [Int]

on weekParts(intSeconds)
-- unitParts :: Int -> [maybe Int] -> [Int]
on unitParts(intTotal, unitList)
script mf
script mf
-- partList Record -> Int -> Record
-- partList Record -> Int -> Record
Line 242: Line 250:
end script
end script
parts of foldr(mf's partList, ¬
parts of foldr(partList of mf, ¬
{remaining:intSeconds, parts:[]}, [missing value, 7, 24, 60, 60])
{remaining:intTotal, parts:[]}, unitList)
end weekParts
end unitParts




Line 313: Line 321:
property lambda : f
property lambda : f
end script
end script
end mClosure</lang>
end mClosure
</lang>