type barva = { red : float; green : float; blue : float } type izdelek = | Cevelj of barva * int | Palica of int | Posoda of int let rdeca = { red = 1.0 ; green = 0.0 ; blue = 0.0 } let cevelj_obutega_macka = Cevelj (rdeca, 23) let primer1 = match Cevelj (rdeca, 37) with | Cevelj (b, v) -> if v < 25 then 15 else 25 | Palica x -> 1 + 2 * x | Posoda y -> 7 (* velikost čevlja podvojim in ostalo pustimo *) let podvoji_cevelj z = match z with | x -> x | Cevelj (b, v) -> Cevelj (b, 2 * v) (* kako pišemo funkcije *) let primer2 = fun x -> (fun y -> 2 * y + x) (* λ x . λ y . 2 y + x *) let primer3 = fun x y -> 2 * y + x (* λ x y . 2 y + x *) let primer4 x y = 2 * y + x let primer5 x = fun y -> 2 * y + x (* rekurzivna definicija *) let rec fact n = if n = 0 then 1 else n * fact (n - 1) (* pozor! *) let cow x = 100 (* tu si zamislite 20000 vrstic kode, ki jo ne napisal Claude *) let cow n = if n = 0 then 1 else n * cow (n - 1)