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

Version Path
trackler-2.2.1.78 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.77 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.76 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.75 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.74 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.73 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.72 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.71 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.70 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.69 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.68 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.67 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.66 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.65 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.64 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.63 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.62 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.61 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.60 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.59 tracks/fsharp/exercises/clock/Example.fs