Sha256: fe29cb7db6ed7af03aff733c7b594e883ca41c89ef355d03465fb1836c3b80d0

Contents?: true

Size: 622 Bytes

Versions: 134

Compression:

Stored size: 622 Bytes

Contents

module BracketPush

open System

let isPaired (input: string) =
    let brackets = "[]{}()" |> Set.ofSeq
    let filtered = input.ToCharArray() |> Array.filter brackets.Contains |> String
    let replaceMatchingBrackets (str: string) = str.Replace("[]", "").Replace("{}", "").Replace("()", "")
    
    let rec loop (remaining: string) =
        match remaining.Length with
        | 0 -> true
        | _  -> 
            let updated = replaceMatchingBrackets remaining
            match updated.Length = remaining.Length with
            | true -> false
            | false -> loop updated
        
    loop filtered

Version data entries

134 entries across 134 versions & 1 rubygems

Version Path
trackler-2.2.1.78 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.77 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.76 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.75 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.74 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.73 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.72 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.71 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.70 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.69 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.68 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.67 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.66 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.65 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.64 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.63 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.62 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.61 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.60 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.59 tracks/fsharp/exercises/bracket-push/Example.fs