Functions

Lean 4 Scala 3
def isZero (n: Nat) := n == 0 def isZero (n: Int) = n == 0
Parameter ommited def isZero₁ n := n == 0
Anonymous function fun n => n == 0 (n: Int) => n == 0
Shord hand (· == 0) (_ == 0)
Using pattern matching
def isZero₄ n :=
match n with
0 => true
_ => false
def isZero4 (n: Int) =
n match
case 0 => true
case _ => false
Short hand for pattern matching
def isZero₅: Nat -> Bool 
0 => true
_ => false
def isZero5: Int => Boolean =
case 0 => true
case _ => false

Profile picture

Personal blog of Juan Pablo Romero Méndez.