Question
OCAML! (* infinite precision natural numbers can be represented as lists of ints between 0 and 9 Write a function that takes an integer and
OCAML! (*
infinite precision natural numbers can be represented as lists of ints between 0 and 9
Write a function that takes an integer and represents it with a list of integers between 0 and 9 where the head
of the list holds the least signifigant digit and the very last element of the list represents the most significant digit.
If the input is negative return None. We provide you with some use cases:
For example:
toDec 1234 = Some [4; 3; 2; 1]
toDec 20 = Some []
toDec -1234 = None
*)
(* Hint use
mod 10
/ 10
*)
let rec toDec (i : int) : int list option = failwith "unimplemented"
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started