Sha256: ee1a033d6d4f85a7ee3da9a349190cfa006b0b3c4fee548edd7f0b417fa511af
Contents?: true
Size: 583 Bytes
Versions: 126
Compression:
Stored size: 583 Bytes
Contents
module Clock open System type Clock = { hours: int; minutes: int } let modulo x y = (int)(((x % y) + y) % y) let create hours minutes = let totalMinutes = hours * 60 + minutes let normalizedHours = modulo ((double)totalMinutes / 60.0) 24.0 let normalizedMinutes = modulo ((double)minutes) 60.0 { hours = normalizedHours; minutes = normalizedMinutes } let add minutes clock = create clock.hours (clock.minutes + minutes) let subtract minutes clock = create clock.hours (clock.minutes - minutes) let display clock = sprintf "%02i:%02i" clock.hours clock.minutes
Version data entries
126 entries across 126 versions & 1 rubygems