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.139 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.138 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.137 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.136 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.135 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.134 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.133 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.132 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.131 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.130 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.129 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.128 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.127 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.126 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.125 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.124 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.123 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.122 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.121 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.120 tracks/fsharp/exercises/clock/Example.fs