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.98 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.97 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.96 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.95 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.94 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.93 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.92 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.91 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.90 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.89 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.88 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.87 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.86 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.85 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.84 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.83 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.82 tracks/fsharp/exercises/octal/Example.fs
trackler-2.2.1.81 tracks/fsharp/exercises/octal/Example.fs