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.180 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.179 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.178 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.177 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.176 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.175 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.174 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.173 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.172 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.171 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.170 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.169 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.167 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.166 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.165 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.164 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.163 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.162 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.161 tracks/fsharp/exercises/bracket-push/Example.fs
trackler-2.2.1.160 tracks/fsharp/exercises/bracket-push/Example.fs