DEV Community

Discussion on: Daily Challenge #135 - The Wide Mouthed Frog!

Collapse
 
nickholmesde profile image
Nick Holmes • Edited

F#:

let mouth_size = function
    | IgnoreCase "alligator" -> "small"
    | _ -> "wide"

But that uses an active pattern to make it case insensitive, like this;

let (|IgnoreCase|_|) a b = 
    match String.Equals(a, b, StringComparison.OrdinalIgnoreCase) with
    | true -> Some()
    | false -> None

Active Patterns provide a real nice way to move the ugly details of the case insensitive comparison out the the way.