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