dark_light changed the topic of #ocaml to: OCaml 3.09.2 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/
smimou has quit ["bli"]
jcreigh has joined #ocaml
<youknow365> pango: oh man
<youknow365> i must be really stupid
<youknow365> i cant figure this out dammit
<youknow365> yes i used php for 4 years
<youknow365> but with php you would use IF statements
pango_ has joined #ocaml
<youknow365> pango_: did you get my last messsage ?
shekmalhen has quit [Remote closed the connection]
shekmalhen has joined #ocaml
youknow365 has quit ["Konversation terminated!"]
pango has quit [Remote closed the connection]
jcreigh has quit ["Cuius rei demonstrationem mirabilem sane detexi. Hanc marginis exiguitas non caperet."]
cratuki has left #ocaml []
dark_light has joined #ocaml
Smerdyakov has quit ["Leaving"]
Snark has joined #ocaml
shekmalhen has quit ["sérieux là, je part, genre... pu là."]
_jol_ has joined #ocaml
youknow365 has joined #ocaml
<youknow365> anybody up
slipstream has joined #ocaml
shans_home has joined #ocaml
slipstream-- has quit [Connection reset by peer]
_jol_ has quit ["leaving"]
sponge45 has joined #ocaml
<TSC> youknow365: Just ask your question
<youknow365> what exactly are hashes
<youknow365> a form of a list ?
<TSC> Pretty much any introductory computer science book will cover hash tables
<youknow365> i never used them
<youknow365> i know what hashes are but hmm lemme do some reading
Schmurtz has joined #ocaml
_jol_ has joined #ocaml
<pango_> youknow365: so it's not with exceptions that you have a problem, but with pattern matching
_jol_ has quit ["leaving"]
Schmurtz has quit [Read error: 104 (Connection reset by peer)]
Schmurtz has joined #ocaml
Schmurtz is now known as Schmurtz_
Schmurtz_ is now known as Schmurtz
sponge45 has quit ["zzzzzzzz"]
<pango_> it's not explained in exception's chapter, because it's used in several constructs (match ... with, let, function, try ... with, do I miss any ?) and explained (briefly !) in data types chapter
smimou has joined #ocaml
Schmurtz has quit ["L'énergie semble manquer : dodo !"]
finelemon has joined #ocaml
love-pingoo has joined #ocaml
finelemo1 has quit [Read error: 113 (No route to host)]
_JusSx_ has joined #ocaml
Schmurtz has joined #ocaml
Schmurtz has quit [Read error: 104 (Connection reset by peer)]
<flux__> well, I didn't realize at first that try.. with was pattern matching
mnemonic has joined #ocaml
Snark has quit [Read error: 110 (Connection timed out)]
Snark has joined #ocaml
kral has joined #ocaml
<WiSmErHi|> i must play with vector in a fonctionnal algo ( not imperative forms) , can i use pattern matching or i must use recursive function ?
scriptdevil has joined #ocaml
<scriptdevil> can anyone help me.. i am a newbie and i tried this
<scriptdevil> what is the error in the if statement?
<scriptdevil> zmdkrbou: u there?
<scriptdevil> anyone?
<scriptdevil> any help?
<scriptdevil> youknow365 do u know?
scriptdevil has left #ocaml []
scriptdevil has joined #ocaml
<zmdkrbou> scriptdevil: what does the compiler say ?
<scriptdevil> it says syntax error in the line where if is there
<scriptdevil> does it look ok to u zmdkrbou
<scriptdevil> ??
<zmdkrbou> there are several "if" ...
<scriptdevil> the first if
marcelino has joined #ocaml
<zmdkrbou> mmh Printf.printf (bla) if bli then ...
<zmdkrbou> you have to write either let () = Printf.printf (bla) in if bli ...
<zmdkrbou> or Printf.printf (bla) ; if bli ...
<scriptdevil> yeah
<scriptdevil> line 12
<pango_> you need "in" after each local declaration
<scriptdevil> even functions?
<pango_> functions are no different
<pango_> they're values too
<scriptdevil> how do i demarcate a block of code?
<scriptdevil> ok
<scriptdevil> ill try
<zmdkrbou> the only place where you don't have to use "in" is at toplevel
<pango_> line 15, 23... At that point, you can drop the useless else ()
<zmdkrbou> if you define something inside another expression, then you have to use "in"
<scriptdevil> zmdkrbou: i'll see
_jol_ has joined #ocaml
<pango_> the parenthesis in your ifs are superfluous... So are the one in printf's (I'm even surprized that it does work, but it does)
<scriptdevil> pango_: i did not use them originally.. i thought not using paranthesis may be the fault.. it turned out that itr wasnt so
<pango_> I think you miss ;s after printf's however
<zmdkrbou> moreover, you don't need printf to print plain strings
<pango_> zmdkrbou: I'm guilty of overusing printf myself ;)
<zmdkrbou> rhooo :)
<scriptdevil> hmm.. am i supposed tro make thr function let rec lineCounter i in =
<scriptdevil> blah balah
<scriptdevil> sorry for the typos.. new keyboard
<scriptdevil> pango_: do i make it let rec Funcname Arguments in = or = in?
<pango_> construct is let [rec] identifier = expression in expression
<pango_> so the in goes between definition and use
<scriptdevil> pango looks like i am never using it separately...
<pango_> scriptdevil: if functions are never called outside their declaration, they'll never be used... I assumed you just pasted part of your code...
<scriptdevil> ok..
<pango_> declaring j and k the way you did was useless too... because inside printBlank and printStar, they're shadowed by the respective function arguments of the same name...
<scriptdevil> pango_: i guess it is a long way to go for functional programming and me.. i wont give up
<pango_> I'm not sure what's the best way to write your code... I think you should go bottom up
<pango_> write the small functions to print spaces and stars, test them, then build next functions from them
<scriptdevil> pango_: one last thing.. how do i use an argument from a value in an outer funtcion
<pango_> unless they shadowed by another declaration, they're just available
<pango_> your inequality tests against "i", for example, are ok
<scriptdevil> ok..
<scriptdevil> is indentation a problem?
<scriptdevil> is indentation like in python
<zmdkrbou> nope
<scriptdevil> ok
<zmdkrbou> but a good indentation is *really* useful :)
<zmdkrbou> for reading
<scriptdevil> let rec printBlank j =
<scriptdevil> Printf.printf( " " )
<scriptdevil> if (j-1 > i) then
<scriptdevil> printBlank (j-1)
<scriptdevil> else
<scriptdevil> now whats wrong?
<zmdkrbou> printf( " " ) ;
<pango_> ocaml doesn't care about indentation, but someone wrote some preprocessor so that indentation matters (for the "hard indentation" addicts ;) )
<zmdkrbou> since indentation doesn't matter, you're writing "printf (bla) if bli then ..."
<scriptdevil> ok same error after printf " "... compiler is saying syntax error at if..
kral has quit ["Live fast, die young."]
<scriptdevil> # let rec printBlank j =
<scriptdevil> Printf.printf " "
<scriptdevil> if j-1 > i then
<scriptdevil> printBlank (j-1)
<scriptdevil> else
<scriptdevil> ();;
<pango_> scriptdevil: forgot the ; too
<scriptdevil> Characters 48-50:
<scriptdevil> if j-1 > i then
<scriptdevil> ^^
<scriptdevil> ;? where?
marcelino has quit ["Ex-Chat"]
<pango_> scriptdevil: at the end of print's line
<scriptdevil> ok..
<scriptdevil> at last its working
descender has quit [Read error: 54 (Connection reset by peer)]
descender has joined #ocaml
<scriptdevil> hmmm... how did u folks realise a ; was to come after printf?? any general rule for ;
<zmdkrbou> yes : "don't use it" :p
<pango_> ; is the separator in sequences
<zmdkrbou> more seriously, ';' is used to separate two "statements", as in C
<scriptdevil> ok.... so if i use 2 different if then else conditions one after another, do i put a ; after the first else clause?
<zmdkrbou> no
<pango_> since all but the last expression's value is kept, previous statements must return unit, and be used for their side-effects; So ';' is associated with imperative programming
<zmdkrbou> when you write "a ; b ; c", a and b should have type unit
<zmdkrbou> and the value for "a ; b ; c" is c
<scriptdevil> ok...
<scriptdevil> thats neat
_jol_ has quit ["leaving"]
<pango_> scriptdevil: problem with your code is that defining a function doesn't evaluate it
<pango_> scriptdevil: so instead of let i = 0 in let rec lineCounter i = ..., you want something like let rec lineCounter i = ... in lineCounter 2
<pango_> sorry, let rec lineCounter i = ... in lineCounter 0
datrus has joined #ocaml
<datrus> anyone knows if there is a print function that takes a value of any type and prints it for debugging?
<flux__> datrus, check out caml humps
<datrus> ok
<flux__> I think there's a library that might approximate that
<flux__> by using the tag info
<flux__> realistically that's not an easy task to accomplish in ocaml, because the type information is really not in there during runtime
Smerdyakov has joined #ocaml
<datrus> the type information must be there during runtime no? otherwhise how would pattern matching work
<pango_> datrus: it's all done at compile time
<datrus> but i suppose not everything can be done at compile time. in the case of pattern matching it's probably not even decidable
<flux__> datrus, something match a with A -> .. | B i -> .. | C -> .. is compiled into something match tag(a) with 0 -> .. | 1 -> .. | 2 -> ..
<flux__> well, that's actually not the kind of tag I referred to earlier
<pango_> program is statically checked at compile time, so type is known. No need to check it again at run time
<Smerdyakov> datrus, pattern matching is statically typed like everything else, and (as it seems you haven't learned yet) patterns fall into a very restricted syntactic class.
<flux__> given a value, at run time it is impossible to inspect its type, even if you had the whole memory dump of the program
<pango_> s/checked/typed/ (oops!)
<datrus> ok
<pango_> datrus: gcaml can do pattern matching on types, but not ocaml
<flux__> gcaml is seriously cool, too bad it doesn't appear to be worked on
<pango_> flux__: it's in official ocaml cvs repository
<flux__> yeah, I'm just browsing it to find the most recent change
<flux__> but yes, that's promising
<flux__> the best I'm getting is two months
<Smerdyakov> Use Coq if you want to do pattern matching on reflected types. Much more principled approach. ;)
<flux__> but I guess that still means it's not dead
* pango_ .oO( "bring up your deads!" )
mnemonic_ has joined #ocaml
<scriptdevil> a silly question... how do u create a main function in ocaml?
<Smerdyakov> There is no such concept in OCaml.
<scriptdevil> Smerdyakov: then how do u write an executable program ?
<Smerdyakov> The runtime semantics of your program is that every definition is evaluated in linking order.
<Smerdyakov> Include a final definition that does more than define a function.
mnemonic_ has quit [Client Quit]
<scriptdevil> Smerdyakov: in simple terms write something like call a function
<scriptdevil> ?
<Smerdyakov> let _ = print_endline "Hello, world!"
<scriptdevil> ok..
<scriptdevil> i got it working. thanks
mnemonic has quit [Connection timed out]
scriptdevil has quit [""Ocaml is cool""]
<flux__> I've ended up using a convention let main () = .. let _ = main () or even let main args = .. let _ = main (List.tl (Array.to_list Sys.argv))
<Smerdyakov> It's much nicer in Haskell with main :: IO ().
love-pingoo has quit [Read error: 110 (Connection timed out)]
<flux__> well, ocaml allows doing module-specific initialization nicely*. (* it is arguable whether it's nice or not ;))
raavana has joined #ocaml
mnemonic has joined #ocaml
mnemonic has quit [Read error: 110 (Connection timed out)]
mnemonic has joined #ocaml
<youknow365> pango_: pattern matching sint expalined all to well
<pango_> "As with most Caml data structures, inspecting and destructuring lists is performed by pattern-matching." above, on same page
<pango_> admittedly, it's very dry. I don't think the user manual is the easiest way to learn the language
<WiSmErHi|> someone have this probleme when i install the eclipse plugin for ocaml , it's turn off my subversion plugin ?
cmeme has quit ["Client terminated by server"]
cmeme has joined #ocaml
raavana has quit ["Leaving"]
mnemonic has quit ["leaving"]
_JusSx_ has quit ["leaving"]
EsotericMoniker has joined #ocaml
jcreigh has joined #ocaml
sponge45 has joined #ocaml
bzzbzz has joined #ocaml
bzzbzz has quit [Client Quit]
jcreigh has quit ["Cuius rei demonstrationem mirabilem sane detexi. Hanc marginis exiguitas non caperet."]
Snark has quit ["Leaving"]
smimou has quit ["bli"]
Smerdyakov has quit ["Leaving"]