-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
In the Unit1 reader, you have the following code example:
let getDivisors =
fun n ->
let rec mkDivisors =
fun n i ->
if i > n then
""
else
if (n % i = 0) then
i + " " + (getDivisors n (i + 1))
else
getDivisors n (i + 1)
mkDivisors n 1However this code will not compile. Calling getDevisors within mkDivisors will result in a compile error about getDivisor not being defined in the body of mkDivisor. I believe the correct thing is to call mkDevisor instead of getDevisor.
My IDE also complained about i + " " + (mkDivisors n (i + 1)) resulting in a type error. I would need to do i.ToString() + " " + (mkDivisors n (i + 1)) instead
So the correct version would be:
let getDevisors =
fun n ->
let rec mkDevisors =
fun n i ->
if i > n then
""
else
if (n % i = 0) then
i.ToString() + " " + (mkDevisors n (i + 1))
else
mkDevisors n (i + 1)
mkDevisors n 1Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels