Sha256: 799c7e43835c2c280c786d78b158fd939a0e61406869ae72b11be21f2a6c859d

Contents?: true

Size: 490 Bytes

Versions: 132

Compression:

Stored size: 490 Bytes

Contents

module PhoneNumber

open System

let private validate (input: string) =
    let isStartDigit digit = List.contains digit ['2'..'9']

    if isStartDigit input.[0] && isStartDigit input.[3] then
        Some input
    else 
        None

let clean (input: string) = 
    let digits = input.ToCharArray() |> Array.filter (Char.IsDigit) |> String

    match digits.Length with
    | 10 -> validate digits
    | 11 when digits.Chars 0 = '1' ->  validate (digits.Substring(1))
    | _ -> None

Version data entries

132 entries across 132 versions & 1 rubygems

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