OCaml version 5.4.1 Enter #help;; for help. Findlib has been successfully loaded. Additional directives: #require "package";; to load a package #list;; to list the available packages #camlp4o;; to load camlp4 (standard syntax) #camlp4r;; to load camlp4 (revised syntax) #predicates "p,q,...";; to set these predicates Topfind.reset();; to force that packages will be reloaded #thread;; to enable threads # let x = 5;; val x : int = 5 # 2 + 2 ;; - : int = 4 # 2 + 3 ;; - : int = 5 # let x = 5;; val x : int = 5 # (1 + 3, "banana") ;; - : int * string = (4, "banana") # (1, false, "foo") ;; - : int * bool * string = (1, false, "foo") # ((1, false), "foo") ;; - : (int * bool) * string = ((1, false), "foo") # fst ("foo", false) ;; - : string = "foo" # snd ("foo", false) ;; - : bool = false # fst ("foo", false, 42) ;; Line 1, characters 4-22: 1 | fst ("foo", false, 42) ;; ^^^^^^^^^^^^^^^^^^ Error: This expression has type 'a * 'b * 'c but an expression was expected of type 'd * 'e # let x = 2 ;; val x : int = 2 # let x = 3 ;; val x : int = 3 # let f () = print_endline "jaz sem f" ;; val f : unit -> unit = # let g () = f () ; f () ;; val g : unit -> unit = # f () ;; jaz sem f - : unit = () # g () ;; jaz sem f jaz sem f - : unit = () # let f () = print_endline "jaz sem tudi f" ;; val f : unit -> unit = # g () ;; jaz sem f jaz sem f - : unit = () # f () ;; jaz sem tudi f - : unit = () # x ;; - : int = 3 # (let x = 5 in x + x) * 10 ;; - : int = 100 # x ;; - : int = 3 # (let x = 5 in print_endline "marsikaj"; x + x + 10) * 10 ;; marsikaj - : int = 200 # (let x = 5 in (let y = 10 in (x + y * 10))) * 10 ;; - : int = 1050 # (let x = 5 in let y = 10 in (x + y * 10)) * 10 ;; - : int = 1050 # (let x = 5 and y = 10 in x + y * 10) * 10 ;; - : int = 1050 # let (a, b) = (1 + 2, 3 + 4) ;; val a : int = 3 val b : int = 7 # let thd (_, _, z) = z ;; val thd : 'a * 'b * 'c -> 'c = # thd (1, false, "foo") ;; - : string = "foo" # (1,2,3,4) ;; - : int * int * int * int = (1, 2, 3, 4) # (1,2);; - : int * int = (1, 2) # () ;; - : unit = () # type oseba = { ime : string; priimek : string; } ;; type oseba = { ime : string; priimek : string; } # { ime = "Neza" ; priimek = "Cankar" } ;; - : oseba = {ime = "Neza"; priimek = "Cankar"} # { priimek = "Cankar" ; ime = "Neza" } ;; - : oseba = {ime = "Neza"; priimek = "Cankar"} # let a = { ime = "Neza" ; priimek = "Cankar" } ;; val a : oseba = {ime = "Neza"; priimek = "Cankar"} # let b = { priimek = "Cankar" ; ime = "Neza" } ;; val b : oseba = {ime = "Neza"; priimek = "Cankar"} # a ;; - : oseba = {ime = "Neza"; priimek = "Cankar"} # b ;; - : oseba = {ime = "Neza"; priimek = "Cankar"} # a = b ;; - : bool = true # let {ime=x; priimek=y} = a ;; val x : string = "Neza" val y : string = "Cankar" # let {ime=z; priimek=_} = a ;; val z : string = "Neza" # let {ime=w; _} = a ;; val w : string = "Neza" # let {ime=w} = a ;; val w : string = "Neza" # type zajec = { masa : int } ;; type zajec = { masa : int; } # let boni = { masa = 6 } ;; val boni : zajec = {masa = 6} # boni ;; - : zajec = {masa = 6} # let fluffy = 5 ;; val fluffy : int = 5 # let poki = 60 ;; val poki : int = 60 # a ;; - : oseba = {ime = "Neza"; priimek = "Cankar"} # a.ime ;; - : string = "Neza" # a.priimek ;; - : string = "Cankar" # type papagaj = {ime : string ; masa : float } ;; type papagaj = { ime : string; masa : float; } # type krava = { ime : string ; masa : float } ;; type krava = { ime : string; masa : float; } # { ime = "Piki" ; masa = 40.0 } ;; - : krava = {ime = "Piki"; masa = 40.} # type kaca = { ime : string ; dolzina : float } ;; type kaca = { ime : string; dolzina : float; } # { ime = "Piki" ; dolozina = 42.0 } ;; Line 1, characters 17-25: 1 | { ime = "Piki" ; dolozina = 42.0 } ;; ^^^^^^^^ Error: Unbound record field dolozina Hint: Did you mean dolzina? # { ime = "Piki" ; dolzina = 42.0 } ;; - : kaca = {ime = "Piki"; dolzina = 42.} # { ime = "Piki" ; masa = 40.0 } ;; - : krava = {ime = "Piki"; masa = 40.} # { ime = "Piki" ; masa = 40.0 } : papagaj ;; Line 1, characters 31-32: 1 | { ime = "Piki" ; masa = 40.0 } : papagaj ;; ^ Error: Syntax error # ({ ime = "Piki" ; masa = 40.0 } : papagaj) ;; - : papagaj = {ime = "Piki"; masa = 40.} # let piki = ({ ime = "Piki" ; masa = 40.0 } : papagaj) ;; val piki : papagaj = {ime = "Piki"; masa = 40.} # let liska = ({ ime = "Piki" ; masa = 40.0 }) ;; val liska : krava = {ime = "Piki"; masa = 40.} # piki = liska ;; Line 1, characters 7-12: 1 | piki = liska ;; ^^^^^ Error: The value liska has type krava but an expression was expected of type papagaj # piki = piki ;; - : bool = true # liska = liska ;; - : bool = true # type barva = { red : float; green : float; blue : float } type izdelek = | Cevelj of barva * int | Palica of int | Posoda of int;; type barva = { red : float; green : float; blue : float; } type izdelek = Cevelj of barva * int | Palica of int | Posoda of int # 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 };; type barva = { red : float; green : float; blue : float; } type izdelek = Cevelj of barva * int | Palica of int | Posoda of int val rdeca : barva = {red = 1.; green = 0.; blue = 0.} # 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);; type barva = { red : float; green : float; blue : float; } type izdelek = Cevelj of barva * int | Palica of int | Posoda of int val rdeca : barva = {red = 1.; green = 0.; blue = 0.} val cevelj_obutega_macka : izdelek = Cevelj ({red = 1.; green = 0.; blue = 0.}, 23) # cevelj_obutega_macka ;; - : izdelek = Cevelj ({red = 1.; green = 0.; blue = 0.}, 23) # Palica 7 ;; - : izdelek = Palica 7 # Posoda 10 ;; - : izdelek = Posoda 10 # 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 (red, 37) with | Cevelj (b, v) -> if v < 25 then 15 else 25 | Palica x -> 1 + 2 * x | Posoda y -> 7;; Line 16, characters 17-19: 16 | | Posoda y -> 7;; ^^ Error: Syntax error # 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;; Line 16, characters 17-19: 16 | | Posoda y -> 7;; ^^ Error: Syntax error # 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;; type barva = { red : float; green : float; blue : float; } type izdelek = Cevelj of barva * int | Palica of int | Posoda of int val rdeca : barva = {red = 1.; green = 0.; blue = 0.} val cevelj_obutega_macka : izdelek = Cevelj ({red = 1.; green = 0.; blue = 0.}, 23) val primer1 : int = 25 # match (Palica 7) with | Cevelj (b, v) -> if v < 35 then 15 else 25 | Posoda y -> 7 ;; Lines 1-3, characters 0-24: 1 | match (Palica 7) with 2 | | Cevelj (b, v) -> if v < 35 then 15 else 25 3 | | Posoda y -> 7... Warning 8 [partial-match]: this pattern-matching is not exhaustive. Here is an example of a case that is not matched: Palica _ Exception: Match_failure ("//toplevel//", 1, 0). # match (Posoda 10) with | Cevelj (b, v) -> if v < 35 then 15 else 25 | Posoda y -> 7 ;; Lines 1-3, characters 0-24: 1 | match (Posoda 10) with 2 | | Cevelj (b, v) -> if v < 35 then 15 else 25 3 | | Posoda y -> 7... Warning 8 [partial-match]: this pattern-matching is not exhaustive. Here is an example of a case that is not matched: Palica _ - : int = 7 # 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 | Cevelj (b, v) -> Cevellj (b, 2 * v) | x -> x;; Line 21, characters 21-28: 21 | | Cevelj (b, v) -> Cevellj (b, 2 * v) ^^^^^^^ Error: Unbound constructor Cevellj Hint: Did you mean Cevelj? # 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 | Cevelj (b, v) -> Cevelj (b, 2 * v) | x -> x;; type barva = { red : float; green : float; blue : float; } type izdelek = Cevelj of barva * int | Palica of int | Posoda of int val rdeca : barva = {red = 1.; green = 0.; blue = 0.} val cevelj_obutega_macka : izdelek = Cevelj ({red = 1.; green = 0.; blue = 0.}, 23) val primer1 : int = 25 val podvoji_cevelj : izdelek -> izdelek = # podvoji_cevelj cevelj_obutega_macka ;; - : izdelek = Cevelj ({red = 1.; green = 0.; blue = 0.}, 46) # podvoji_cevelj (Palica 7) ;; - : izdelek = Palica 7 # 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);; Line 22, characters 4-17: 22 | | Cevelj (b, v) -> Cevelj (b, 2 * v);; ^^^^^^^^^^^^^ Warning 11 [redundant-case]: this match case is unused. type barva = { red : float; green : float; blue : float; } type izdelek = Cevelj of barva * int | Palica of int | Posoda of int val rdeca : barva = {red = 1.; green = 0.; blue = 0.} val cevelj_obutega_macka : izdelek = Cevelj ({red = 1.; green = 0.; blue = 0.}, 23) val primer1 : int = 25 val podvoji_cevelj : izdelek -> izdelek = # true ;; - : bool = true # 42 ;; - : int = 42 # 42.0 ;; - : float = 42. # 42 + 42.0 ;; Line 1, characters 5-9: 1 | 42 + 42.0 ;; ^^^^ Error: The constant 42.0 has type float but an expression was expected of type int # 13.7 +. 42.0 ;; - : float = 55.7 # 3.4 *. 1.2 ;; - : float = 4.08 # 3 *. 1 ;; Line 1, characters 0-1: 1 | 3 *. 1 ;; ^ Error: The constant 3 has type int but an expression was expected of type float Hint: Did you mean 3.? # (fun x -> 2 * x + 3) 5 ;; - : int = 13 # fun x -> 2 * x + 3 ;; - : int -> int = # fun x -> (print_endline "ahoy" ; x + 3) ;; - : int -> int = # (fun x -> (print_endline "ahoy" ; x + 3)) 100 ;; ahoy - : int = 103 # 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;; Line 22, characters 4-17: 22 | | Cevelj (b, v) -> Cevelj (b, 2 * v) ^^^^^^^^^^^^^ Warning 11 [redundant-case]: this match case is unused. type barva = { red : float; green : float; blue : float; } type izdelek = Cevelj of barva * int | Palica of int | Posoda of int val rdeca : barva = {red = 1.; green = 0.; blue = 0.} val cevelj_obutega_macka : izdelek = Cevelj ({red = 1.; green = 0.; blue = 0.}, 23) val primer1 : int = 25 val podvoji_cevelj : izdelek -> izdelek = val primer2 : int -> int -> int = val primer3 : int -> int -> int = val primer4 : int -> int -> int = val primer5 : int -> int -> int = # 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 fact n = if n = 0 then 1 else n * fact (n - 1);; Line 22, characters 4-17: 22 | | Cevelj (b, v) -> Cevelj (b, 2 * v) ^^^^^^^^^^^^^ Warning 11 [redundant-case]: this match case is unused. Line 31, characters 38-42: 31 | let fact n = if n = 0 then 1 else n * fact (n - 1);; ^^^^ Error: Unbound value fact Hint: If this is a recursive definition, you should add the rec keyword on line 31 # 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);; Line 22, characters 4-17: 22 | | Cevelj (b, v) -> Cevelj (b, 2 * v) ^^^^^^^^^^^^^ Warning 11 [redundant-case]: this match case is unused. type barva = { red : float; green : float; blue : float; } type izdelek = Cevelj of barva * int | Palica of int | Posoda of int val rdeca : barva = {red = 1.; green = 0.; blue = 0.} val cevelj_obutega_macka : izdelek = Cevelj ({red = 1.; green = 0.; blue = 0.}, 23) val primer1 : int = 25 val podvoji_cevelj : izdelek -> izdelek = val primer2 : int -> int -> int = val primer3 : int -> int -> int = val primer4 : int -> int -> int = val primer5 : int -> int -> int = val fact : int -> int = # fact 5 ;; - : int = 120 # fact 7 ;; - : int = 5040 # 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);; Line 22, characters 4-17: 22 | | Cevelj (b, v) -> Cevelj (b, 2 * v) ^^^^^^^^^^^^^ Warning 11 [redundant-case]: this match case is unused. type barva = { red : float; green : float; blue : float; } type izdelek = Cevelj of barva * int | Palica of int | Posoda of int val rdeca : barva = {red = 1.; green = 0.; blue = 0.} val cevelj_obutega_macka : izdelek = Cevelj ({red = 1.; green = 0.; blue = 0.}, 23) val primer1 : int = 25 val podvoji_cevelj : izdelek -> izdelek = val primer2 : int -> int -> int = val primer3 : int -> int -> int = val primer4 : int -> int -> int = val primer5 : int -> int -> int = val fact : int -> int = val cow : int -> int = # cow 5 ;; - : int = 500 #