fun f x y let val a x1 fun g 0 o let val a xy fun h 0 0 I h

fun f x y let val a x+1 fun g (0 o let val a x+y fun h 0 0 I h k a n (n-1) h (n-1) end if (x 0) then g y else a g (f (x-1) y end

Solution

fun f x y = // function f is defined taking x and y as input
let // Let in this case is to assume or take few variable or fuction required for the function \"f\"
val a = x+1 // INITIALIZATION of \"a\" as \"x+1\" where x was taken as input in function \"f\"
fun g 0 = 0 // another function \"g\" is defined inside function \"f\" in which when 0 is taken as input it returns 0
| g n = // there is another case of same function \"g\" here input is n (not 0)
let // Let in this case is to assume or take few variable or fuction required for the function \"g\"
val a = x+y //INITIALIZATION of \"a\" as \"x+1\" where x and y was taken as input in function \"f\"
fun h 0 = 0 // now again another function is defined inside the function g in which when 0 is taken as input it returns 0
| h k = a + n + g(n+1) // in another case of same function \"g\" here input is k (not 0) and if h takes k as input it returns a + n + g(n+1)
in // now the above value of a and function \"h\" is used in the function \"g\"
h (n-1) // here function h is taking the input \"n-1\"
end //end of function \"g\"
in // now the above value of a and function \"g\" is used in the function \"f\"
if (x=0) then g y // in function \"f\" if x is equal to 0 then function \"f\" with input x and y is equal to function \"g\" with input y
else a + g (f (x-1) y) // if x is not equal to 0 then function \"f\" with input x and y is equal to a + g (f (x-1) y)
end; // end of function \"f\"

 fun f x y let val a x+1 fun g (0 o let val a x+y fun h 0 0 I h k a n (n-1) h (n-1) end if (x 0) then g y else a g (f (x-1) y end Solutionfun f x y = // functio

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site