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.119 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.118 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.117 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.116 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.115 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.114 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.113 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.111 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.110 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.109 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.108 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.107 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.106 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.105 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.104 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.103 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.102 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.101 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.100 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.99 tracks/fsharp/exercises/grains/Example.fs