Converting math notation to kotlin

Posted: 21 Jun 2022. Last modified on 01-Jul-22.

This article will take about 1 minute to read.


object M
fun M.Sigma(from: Int, to: Int, each: (x: Int) -> Double): Double = (from..to).sumOf(each)
val M.Σ get() = M::Sigma
fun main{
    println(M.Σ(0, 6) { (it * it).toDouble() })
}