Sha256: bf09889760c1c1865e560e75f1f661cceb07e29b762406b004e27f8e4165ca2e

Contents?: true

Size: 289 Bytes

Versions: 98

Compression:

Stored size: 289 Bytes

Contents

module Octal

let isValid char = char >= '0' && char <= '7'

let charToDecimal char = (int)char - (int)'0'

let toDecimal (input: string) = 
    let chars = input.ToCharArray()
    if Array.forall isValid chars then Array.fold (fun acc c -> acc * 8 + charToDecimal c) 0 chars
    else 0

Version data entries

98 entries across 98 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.179 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.178 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.177 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.176 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.175 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.174 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.173 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.172 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.171 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.170 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.169 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.167 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.166 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.165 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.164 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.163 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.162 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.161 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.160 tracks/fsharp/exercises/octal/Example.fs