Hi, I am wanting to replicate a python feature ```...
# getting-started
a
Hi, I am wanting to replicate a python feature
Copy code
def myFunction(a,b,c): 
    return lambda x: a * x ** 2 + b * x + c
however I am not understanding what is wrong with
Copy code
fun potentialEnergy(charge1, charge2, k){
    val x = {position: Double -> k * charge1 * charge2 / position / position} // creating lambda function
    return x
}
What is wrong with this lambda function expression.
1
I am doing this in jupyter
Example7.2
m
you need to specify types for your function parameters. That code should not compile at all
m
an equivalent of the python function above would be (assuming all parameters are `Double`s:
Copy code
import kotlin.math.pow

fun myFunction(a: Double, b: Double, c: Double) = { x: Double -> a * x.pow(2.0) + b * x + c }
👍 1
a
can you explain the "=" notation?
n
https://kotlinlang.org/docs/reference/basic-syntax.html#defining-functions expression syntax. it looks a little weird because this function is itself returning a function (well, a lambda)