Skip to content

Latest commit

 

History

History
17 lines (15 loc) · 412 Bytes

README.md

File metadata and controls

17 lines (15 loc) · 412 Bytes

Has One

Write a function with type:

has_one : int -> bool

For a positive integer n, has_one n returns true if n contains a 1 digit. If n is negative, then the function must fail.

Here are some unit tests:

assert(has_one 10 = true);;
assert(has_one 220 = false);;
assert(has_one 911 = true);;
assert(has_one 451 = true);;
assert(try has_one (-1) |> fun _ -> false with _ -> true);;