Question: Please use Ocaml (* infinite precision natural numbers can be represented as lists of ints between 0 and 9 Write a function that takes an

Please use 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 0 = Some []

toDec -1234 = None

*)

(* Hint use

mod 10

/ 10

*)

let rec toDec (i : int) : int list option =

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!