Sha256: 4a463a940b250257631de51ac9119c81e50bf17c26bf0fcb8f7fd0c370019444

Contents?: true

Size: 319 Bytes

Versions: 132

Compression:

Stored size: 319 Bytes

Contents

module Grains

open System.Numerics

let square (n:int) = 
    if n <= 0 || n > 64 then 
        Error "Invalid input"
    else
        Ok (2I ** (n - 1) |> uint64)

let total = 
    [1..64] 
    |> List.map square
    |> List.reduce (fun x y -> match x, y with Ok a, Ok b -> Ok (a + b) | _ -> Error "Invalid input")

Version data entries

132 entries across 132 versions & 1 rubygems

Version Path
trackler-2.2.1.58 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.57 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.56 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.55 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.54 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.53 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.52 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.51 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.50 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.49 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.48 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.47 tracks/fsharp/exercises/grains/Example.fs