mbishop changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | Grab Ocaml 3.10.0 from http://caml.inria.fr/ocaml/release.html (featuring new camlp4 and more!)
jlouis_ has joined #ocaml
jlouis has quit [Connection timed out]
smimou has quit ["bli"]
yminsky has joined #ocaml
krumms has joined #ocaml
<krumms> hi all
yminsky has quit []
buluca has quit [Read error: 113 (No route to host)]
jlouis has joined #ocaml
mrsolo has joined #ocaml
seafoodX has quit []
jlouis_ has quit [Connection timed out]
nuncanada has joined #ocaml
seafoodX has joined #ocaml
Mr_Awesome has joined #ocaml
carm has joined #ocaml
seafoodX has quit [Read error: 104 (Connection reset by peer)]
seafoodX has joined #ocaml
yminsky has joined #ocaml
jlouis_ has joined #ocaml
jlouis has quit [Connection timed out]
mrsolo_ has joined #ocaml
yminsky has quit []
mrsolo has quit [Connection timed out]
jlouis has joined #ocaml
jlouis_ has quit [Success]
jlouis_ has joined #ocaml
jlouis has quit [Connection timed out]
nuncanada has quit ["Leaving"]
Abo-Marwan14 has quit [Remote closed the connection]
screwt840 has quit [Remote closed the connection]
thermoplyae has joined #ocaml
kelaouchi has quit ["leaving"]
jlouis has joined #ocaml
jlouis_ has quit [Connection timed out]
screwt840 has joined #ocaml
Abo-Marwan14 has joined #ocaml
rwmjones has joined #ocaml
ramki has joined #ocaml
replore has joined #ocaml
jlouis_ has joined #ocaml
replore_ has joined #ocaml
jlouis has quit [Connection timed out]
thermoplyae has left #ocaml []
[azoic] has quit ["Leaving."]
ygrek has joined #ocaml
replore has quit [Read error: 110 (Connection timed out)]
seafoodX_ has joined #ocaml
replore_ has quit [Read error: 113 (No route to host)]
seafoodX has quit [Read error: 110 (Connection timed out)]
seafoodX_ has quit [Read error: 110 (Connection timed out)]
krumms has left #ocaml []
ygrek has quit [Remote closed the connection]
ygrek has joined #ocaml
leo037 has joined #ocaml
mrsolo_ has quit [Client Quit]
univac_ is now known as univac
Demitar has quit [Read error: 110 (Connection timed out)]
Demitar has joined #ocaml
buluca has joined #ocaml
m3ga has joined #ocaml
Demitar has quit [Read error: 110 (Connection timed out)]
replore has joined #ocaml
piggybox_ has quit [Read error: 110 (Connection timed out)]
Jedai has joined #ocaml
piggybox_ has joined #ocaml
MoeD has joined #ocaml
schme` has joined #ocaml
buluca has quit [Read error: 113 (No route to host)]
buluca has joined #ocaml
m3ga has quit ["disappearing into the sunset"]
schme has quit [Read error: 110 (Connection timed out)]
jlouis has joined #ocaml
Demitar has joined #ocaml
jlouis_ has quit [Read error: 110 (Connection timed out)]
mordaunt has quit [Read error: 104 (Connection reset by peer)]
rfischer has joined #ocaml
rfischer has quit [Client Quit]
bluestorm_ has joined #ocaml
sioraiocht has quit []
sioraiocht has joined #ocaml
screwt840 has quit [Remote closed the connection]
Abo-Marwan14 has quit [Remote closed the connection]
sioraiocht has quit [Read error: 104 (Connection reset by peer)]
sioraiocht has joined #ocaml
Abo-Marwan14 has joined #ocaml
screwt840 has joined #ocaml
eroyf has quit [Remote closed the connection]
eroyf has joined #ocaml
[azoic] has joined #ocaml
replore has quit ["Leaving..."]
pango has quit [Remote closed the connection]
claudiotainen has joined #ocaml
<claudiotainen> hi I'm an ocaml newbie, I'm trying to do an inorder visit of a binary tree, but have a problem ... could you take a look please ? let inorder x = match x with
<claudiotainen> | Leaf z -> print_endline z
<claudiotainen> | Node (a,b,c) -> print_endline a ^ inorder(b) ^ inorder(c) ;;
Abo-Marwan14 has quit [Remote closed the connection]
screwt840 has quit [Remote closed the connection]
<claudiotainen> sorry I didn't mean to do that
<flux> for recursive functions you want to use let rec inorder x = ..
<claudiotainen> yes i did it , what you see in this window is not what I mean to show you
<flux> well, another problem is that inorder returns unit (that is: nothing)
<flux> yet you attempt to concatenate like it returned a string
<flux> so you need to decide if you want to return a unit or a string
<claudiotainen> does print_endline takes a unit ?
<claudiotainen> *take
<flux> print_endline takes a string, returns a unit
<flux> ah, perhaps it's a precedency problem, I didn't think of it that way
<flux> so the second expression would look like: print_endline (a ^ inorder b ^ inorder c)
<flux> what you have there is interpreted like (print_endline a) ^ (inorder b) ^ (inorder c)
<bluestorm_> inorder would style have a wrong type however
<claudiotainen> [ by the way I realized this is a preorder visit ...]
<bluestorm_> s/style/still/ -__-
<flux> bluestorm_, nope?
crathman has joined #ocaml
<flux> ah, right
<flux> I wonder what I was still thinking
<flux> but perhaps the code wants to replace ^ with ;
<claudiotainen> oh GREAT flux ;)
<bluestorm_> or just remove then "print_endline" part
<claudiotainen> it works now
<claudiotainen> no it was the ;
<bluestorm_> yes, but it depends on what you want to get from that function
<bluestorm_> for now you're printing elements of the tree
<bluestorm_> you may want to actually get a list of them, for example
<claudiotainen> sure that's what I meant to do
<bluestorm_> or just a string
<claudiotainen> no no just wanted to print elements values
<bluestorm_> i think using i/o in an auxiliary function is not a very good thing, design-wise
<bluestorm_> but if you just wanted to do that, that's fine
<bluestorm_> you'll want more genericity once you'll have done sliglithly different versions of that code ten times :p
<claudiotainen> well this is the first time I use ocaml
pango has joined #ocaml
<MoeD> Not to derail the conversation here, but is this an appropriate venue for a complete ocaml neophyte? I am gonig to start trying to learn it and wondered if I should be asking questions here, or somewhere else.
<claudiotainen> bluestorm what would you suggest to make that a more generic function ?
<bluestorm_> MoeD: i think here is ok
<MoeD> thanks
<bluestorm_> claudiotainen: hm
<claudiotainen> I wonder if a method like String.valueOf exists in ocaml
<bluestorm_> i see two possibilities claudiotainen
leo037 has quit ["Leaving"]
<bluestorm_> you may just want to "get a string" instead of printing it
<bluestorm_> (for printing it later for example, dunno)
<bluestorm_> you would remove the print_endline (to return the string) and use ^ (concatenation)
<bluestorm_> but the other (and better idea) is to get a list of the items of your tree
<bluestorm_> so you can use them for whatever you want later
<bluestorm_> _and_ that's type-agnostic : the type of the items of the tree is not important
<bluestorm_> (if your tree definition were polymorphic, that function would be polymorphic too, wich is a big win to genericity)
<bluestorm_> the first idea (getting a string from lots of ^) is not that good performance-wise, because ^ is costly
MoeD has quit ["Going to play with Gutsy Gibbon ..."]
<claudiotainen> so I should
<claudiotainen> 1) use a generic type in my tree definition
<claudiotainen> 2) use a list to collect the values rather than printing them
<claudiotainen> right ?
<bluestorm_> hm
<bluestorm_> i think that would be a good idea
<bluestorm_> but of course all is in the compromise : if you're sure you won't need something more general, your function might be enough
<bluestorm_> but if you're trying to learn ocaml, that would be a good thing :p
<bluestorm_> claudiotainen: the tree-to-list traversal is interesting because it's composable
<bluestorm_> for example if you want to print the items afterwards, you just use List.iter print_endline your_list
<bluestorm_> and you basically have your previous function
jonathanv has quit [Read error: 104 (Connection reset by peer)]
<claudiotainen> great that's perfect
sioraiocht has quit [Read error: 104 (Connection reset by peer)]
sioraiocht has joined #ocaml
claudiotainen has quit ["leafChat IRC client: http://www.leafdigital.com/Software/leafChat/"]
screwt840 has joined #ocaml
crathman has quit ["ChatZilla 0.9.78.1 [Firefox 2.0.0.7/2007091417]"]
[azoic] has quit ["Leaving."]
zbrown has joined #ocaml
pango has quit [Remote closed the connection]
buluca has quit [Remote closed the connection]
leo037 has joined #ocaml
pango has joined #ocaml
jonathanv has joined #ocaml
LenaR has joined #ocaml
bluestorm_ has quit ["Konversation terminated!"]
Mr_Awesome has quit [Read error: 110 (Connection timed out)]
david_koontz has joined #ocaml
smimou has joined #ocaml
bluestorm_ has joined #ocaml
Torment has joined #ocaml
Jedai has quit [Read error: 110 (Connection timed out)]
Tetsuo has joined #ocaml
carm has quit [Read error: 113 (No route to host)]
nuncanada has joined #ocaml
bluestorm_ has quit ["Konversation terminated!"]
buluca has joined #ocaml
jlouis_ has joined #ocaml
jlouis has quit [Read error: 110 (Connection timed out)]
piggybox_ has quit [Read error: 110 (Connection timed out)]
pango_ has joined #ocaml
Mr_Awesome has joined #ocaml
pango has quit [Remote closed the connection]
kelaouchi has joined #ocaml
Tetsuo has quit ["Leaving"]
LenaR has quit ["Leaving."]
ygrek has quit [Remote closed the connection]
piggybox_ has joined #ocaml
Mr_Awesome has quit [Read error: 110 (Connection timed out)]
ednarofi has joined #ocaml
rwmjones has quit [Read error: 104 (Connection reset by peer)]
rwmjones has joined #ocaml
leo037 has quit ["Please, have a good night"]
yminsky has joined #ocaml
yminsky has quit []
thermoplyae has joined #ocaml