smimou changed the topic of #ocaml to: OCaml 3.08.3 available! | Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
Gueben has quit ["Leaving"]
cjohnson has quit [Remote closed the connection]
mr_pengy has quit [Remote closed the connection]
cognominal has quit [Remote closed the connection]
cognominal has joined #ocaml
bzzbzz_ has quit ["leaving"]
<araujo> What's wrong:
<araujo> let signum = fun x -> match x with
<araujo> | x > 0 -> 1
<araujo> | x < 0 -> -1
<araujo> | _ -> 0;;
<Nutssh> match only does destructuring and equality. You can't do predicates like 'x > 0'. You could do ' | x when x> 0 -> 1 | x when x < 0 -> -1 ... '
<araujo> i see..
<araujo> thanks
<araujo> Nutssh, so, patter matching only does equeality?
<Nutssh> Effectively, yes. It can also do destructuring. You can do predicates by using the 'when' clause.
<araujo> Good.
<araujo> stupid q: what is the extension of the ocaml files?
<Nutssh> .ml for the modules and .mli for the interfaces (signatures)
ulfdoz__ has joined #ocaml
_shawn has joined #ocaml
<araujo> Nutssh, hah, wait.. and for normal source code...
<Nutssh> You might want to skim the ocaml manual.
<araujo> hah, yeah :-)
<araujo> Nutssh, it is just that ive been working so far with the repl
<Nutssh> It sounds like you know much of what you're doing, but could use a quick overview of the language features.
<araujo> yeah, i just got here open the user manul in my web browser
<araujo> :-)
ulfdoz_ has quit [Read error: 110 (Connection timed out)]
<araujo> Btw, brief comment, O'Caml rules
shawn_ has quit [Read error: 110 (Connection timed out)]
<Nutssh> It does!
<Nutssh> Once you've used higher order functions, it is so painful to go back
<araujo> haha, yeah, they are very addictives
tintin has joined #ocaml
Herrchen has joined #ocaml
abl has quit [Read error: 104 (Connection reset by peer)]
abl has joined #ocaml
<ulfdoz__> re
ulfdoz__ is now known as ulfdoz
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]
<Herrchen> moin
mlh has joined #ocaml
vodka-goo has joined #ocaml
abl has quit []
Sonarman has quit ["leaving"]
Herrchen has quit ["bye"]
smimou has joined #ocaml
Gueben has joined #ocaml
<araujo> question here, reading about pattern matching i see i can do something like:
<araujo> (function x -> match x with | true -> false | false -> true) (3 > 4);;
<araujo> (function | true -> false | false -> true) (8 < 9)
<mflux> yes
<mflux> in the first example you could use fun instead of function, as you are not doing multiple cases
<mflux> function .. is essentially the same as fun x -> match x with ..
<araujo> is it the latter just syntactic sugar for the former, or there is some black magic behind?
<araujo> yeah, seems so.
<mflux> well
<mflux> fun a b c -> could be considered to be syntactic sugar for function a -> function b -> function c-> ..
<araujo> yeah
<araujo> i read that
<araujo> but i ask about the patter matching
<araujo> (function | true -> false | false -> true) takes always a default value right?, the expr to match?
<mflux> btw, the first | isn't necessary, although it is commonly used when indenting and you want to nicely line the cases
<araujo> yeah, i like to write the first |
<mflux> 'takes always a default value'?
<mflux> (function true -> false | false -> true) is a function bool -> bool
<araujo> i mean, it always takes one 'expr' to match?
<mflux> function -keyword creates a function with one parameter, is that what you're referring to?
<araujo> yeah
<araujo> sao, it works like that?...
<mflux> so you cannot write function a b c -> .. as you can write fun a b c -> ..
Gueben has quit [Read error: 60 (Operation timed out)]
<mflux> everything you've written is valid ocaml
<araujo> right, i can't use function like that...
smimram has joined #ocaml
pango_ has quit [Read error: 60 (Operation timed out)]
smimou has quit [Read error: 60 (Operation timed out)]
smimou has joined #ocaml
smimram has quit [Read error: 145 (Connection timed out)]
smimou has quit [Read error: 145 (Connection timed out)]
cjohnson has joined #ocaml
<araujo> mm..
<araujo> is it the pattern match interval notation still allowed?
<mflux> 1..42? I believe it is
<mflux> it's an extension though
<mflux> hmm
<mflux> it apparently works only with characters
<mflux> as you might guess, I haven't used it ;)
<araujo> :-)
<araujo> yeah, it gives me "Syntax error" with numbers...
<araujo> extension means...?
<mflux> something that could be removed from ocaml in a future version
<mflux> personally, I don't mind, although I did hear this definition only a little while back (hi mellum ;))
<araujo> ah
<mflux> I think streams (really cool btw) used to be a language extension, but now they are implemented with the preprocessor, which is ok to me
<araujo> Nice,
<araujo> I don't need to use 'rec' for tail recursion?
<araujo> mm.. i think im sort of confused...
<araujo> pattern matching is recursive by default?
two-face has joined #ocaml
<mflux> that does sound confused
<mflux> can you provide an example?
vodka-goo has quit []
<araujo> mflux, my concern: let list_size = function [] -> 0 | _::tl -> 1 + list_size tl;;
<araujo> why don't i need to use 'rec'?
vodka-goo has joined #ocaml
<mflux> you do need to :)
<mflux> ..maybe you've defined list_size earlier in your ocaml session..
<araujo> geez.. i think it is the second time i made this mistake...
<araujo> s/made/make
Gueben has joined #ocaml
bzzbzz has joined #ocaml
two-face has quit [Read error: 60 (Operation timed out)]
mlh has quit [Client Quit]
two-face has joined #ocaml
two-face has quit [Read error: 60 (Operation timed out)]
smimou has joined #ocaml
Banana has quit [Remote closed the connection]
angagon has quit [Read error: 110 (Connection timed out)]
_JusSx_ has joined #ocaml
_JusSx_ has quit [Client Quit]
_JusSx_ has joined #ocaml
Banana has joined #ocaml
smimou has quit [Read error: 110 (Connection timed out)]
smimou has joined #ocaml
budjet has joined #ocaml
skylan has quit [Read error: 104 (Connection reset by peer)]
skylan has joined #ocaml
budjet has quit [Remote closed the connection]
vodka-goo has quit [Remote closed the connection]
vodka-goo has joined #ocaml
Snark has joined #ocaml
<Snark> slt
two-face has joined #ocaml
mfurr has joined #ocaml
cognominal has quit [Read error: 60 (Operation timed out)]
two-face has quit [Read error: 145 (Connection timed out)]
<ulfdoz> Snark: What means slt?
Snark has quit [Read error: 60 (Operation timed out)]
pnou has joined #ocaml
cognominal has joined #ocaml
Snark has joined #ocaml
two-face has joined #ocaml
angagon has joined #ocaml
TeXitoi has joined #ocaml
two-face has quit ["Leaving"]
pango has joined #ocaml
dan2 has quit [Read error: 131 (Connection reset by peer)]
Snark has quit ["Leaving"]
Sonarman has joined #ocaml
vezenchio has joined #ocaml
cjohnson has quit [Remote closed the connection]
_JusSx_ has quit ["Lost terminal"]
<ulfdoz> cya
cjohnson has joined #ocaml
zwnj has joined #ocaml
vodka-goo has quit [Remote closed the connection]
zwnj has left #ocaml []
Gueben has quit ["Leaving"]