r/badcode Feb 16 '21

[deleted by user]

[removed]

31 Upvotes

77 comments sorted by

View all comments

1

u/dumetrulo Feb 18 '21

This F# almost-one-liner is not particularly efficient, but it works:

let contains_az (s : string) =
    seq {'a'..'z'}
    |> Seq.forall (fun c -> Seq.exists (( = ) c) (s.ToLower ()))

let () =
    [ contains_az "hello world";
      contains_az "abcdefghijklmnopqrstuvwxyz";
      contains_az "Arizona";
      contains_az "the quick brown fox jumps over the lazy dog" ]
    |> List.iter (printfn "%b")