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.180 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.179 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.178 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.177 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.176 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.175 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.174 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.173 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.172 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.171 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.170 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.169 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.167 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.166 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.165 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.164 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.163 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.162 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.161 tracks/fsharp/exercises/clock/Example.fs
trackler-2.2.1.160 tracks/fsharp/exercises/clock/Example.fs