Skal has quit [Read error: 131 (Connection reset by peer)]
<araujo>
mm.. i can't do : (float_of_int 7) + 56;; ?
<Sonarman>
should that be +. maybe?
<araujo>
you right, thanks
<araujo>
And it is something like 56.
cjohnson has quit [""We live like penguins in the desert...""]
vezenchio has quit [""Under democracy one party always devotes its chief energies to trying to prove that the other party is unfit to rule—and bot]
<mflux>
kv
<mflux>
vincenz, pong
ulfdoz has joined #ocaml
ulfdoz_ has quit [Read error: 145 (Connection timed out)]
CLxyz has quit []
Demitar has quit [Read error: 60 (Operation timed out)]
CLxyz has joined #ocaml
Demitar has joined #ocaml
<ulfdoz>
remorning
<araujo>
Hello..
<araujo>
When i got something like: val my_func : int -> int = <fun>
<araujo>
It means that the function takes an int and returns an int among a function?
<mflux>
the function takes an integer and returns an integer, nothing else
<mflux>
such a function could be written like let my_func i = i + 1
<mflux>
or let my_func = function i -> i + 1, or let my_func = fun i -> i + 1
<mflux>
or let my_func (i:int) : int = i + 1 or let my_func : (int -> int) = fun (i:int) -> i + 1 if you want to go difficult..
<araujo>
hah, get it
<araujo>
And what the <func> exactly means?
<mflux>
just that it's a function
<araujo>
That im declaring a function?
<mflux>
the value of the entry is a function
<mflux>
for example integers it would show the value
<araujo>
Oh get it
<mflux>
for functions it can only show that it's a function
<araujo>
Thaks mflux
<mflux>
happy to help
Sonarman has quit ["Lost terminal"]
smimou has joined #ocaml
pango has joined #ocaml
nlv11757_ has joined #ocaml
abl has joined #ocaml
<araujo>
# let rec list_even l = function
<araujo>
| [] -> []
<araujo>
| x :: l -> if (x mod 2) = 0 then (x :: list_even l) else list_even l ;;
<araujo>
It doesn't work.. according to the message, list_even returns "a' list" , but im trying to return "int list" , ideas?
<araujo>
Seems to me like i need to cast the returning value
<solarwind>
Well.. function means that it implcitely 'grabs' an argument. So, let rec list_even l = shoud be let rec list_even =.
<solarwind>
You're actually passing two parameters. A list and 'l'.
<solarwind>
To be even more confusing, you called the tail of your list 'l'.
<solarwind>
(that's why I always use something like a::tl when I patter match a list)
<solarwind>
pattern, too.
<solarwind>
You could have written that as: let rec list_even l = match l with | [] -> [] | ...
<araujo>
oh, i see
<solarwind>
araujo: To be more clear, 'function' is a pattern matching on the first argument passed to that function.
<araujo>
solarwind, oh, i thought it was because of the | [] -> [] , | x :: l -> , respectively
<araujo>
that it was taking just an argument
<solarwind>
Well, if you make something like match l with | [] -> [] | a::tl -> ... both [] and a::tl are actually 'patterns' of l.
<araujo>
Right.
<solarwind>
If you pattern match a function argument (and I mean function not 'function') you shouldn't try to 'access' the argument inside the pattern match.
<araujo>
i see, makes sense.
<araujo>
Can i do this:
<araujo>
# let x = 3
<araujo>
and y = x
<araujo>
and z = y;;
<araujo>
?
<mflux>
no
<mflux>
and not even 'let rec' even though that's what you're attempting
<mflux>
just do let x = 3 let y = x let z = y;;
<araujo>
i ask 'cause, i think i read somewhere in a book that you can't, but i apparently can here...
<araujo>
mm...
<araujo>
mflux, i don't get it, it works here
<mflux>
you've propably defined x earlier
<mflux>
start a new ocaml session
<mflux>
(I assume that's what you're doing)
<araujo>
hah, yeah, you are right
<araujo>
i see ... so if i have x defined before, the others variables will take that value
<araujo>
# let x = 9
<araujo>
and y = x;;
<araujo>
val x : int = 9
<araujo>
val y : int = 3
<araujo>
:-)
<mflux>
things you refer to in a let statement will always refer to previous bindings
<araujo>
Good to know.
<mellum>
# let x = 9 and y = x;;
<mellum>
Unbound value x
<mellum>
doesn't work for me
<mflux>
so let foo n = if n > 1 then (foo n - 1) * 2 else 42 will not compile either; 'let rec foo' needs to be used
<araujo>
mellum, yes, it doesn't, i had x defined previously
<mellum>
Ah, OK.
<araujo>
mflux, that clarifies me a bit the 'rec' keyword
<mflux>
araujo, it's the same thing with non-function definitions too; for example let rec infinite_123 = [1; 2; 3] :: infinite_123
<mellum>
mflux: that's a language extension, though.
<mflux>
mellum, hm, infinite lists or such constructs? it could be used for trees etc?
<mflux>
besides, extension to what? ocaml is ocaml?-)