Skip to content

Latest commit

 

History

History
 
 

has-one

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

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.

For instance, the following asserts must pass:

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);;