Function generator

Report a typo

Implement a function generator.

It returns the function by the name given. Support three functions:

  • "identity" (returns its argument).
  • "half" (returns its argument divided by 2).
  • "zero" (returns 0).

If the name is unknown, return the "zero" function.

Write a program in Kotlin
// TODO: provide three functions here

fun generate(functionName: String): (Int) -> Int {
// TODO: provide implementation here
}
___

Create a free account to access the full topic