Yurik changed the topic of #ocaml to: http://icfpcontest.cse.ogi.edu/ -- OCaml wins | http://www.ocaml.org/ | http://caml.inria.fr/oreilly-book/ | http://icfp2002.cs.brown.edu/ | SWIG now supports OCaml| Early releases of OCamlBDB and OCamlGettext are available
lindril has joined #ocaml
lindril has quit [Remote closed the connection]
mrvn_ has joined #ocaml
docelic is now known as docelic|sleepo
jao has joined #ocaml
mrvn has quit [Read error: 110 (Connection timed out)]
mrvn_ has quit [Read error: 60 (Operation timed out)]
mrvn has joined #ocaml
graydon has joined #ocaml
mattam_ has quit ["zZz"]
simon- has joined #ocaml
<simon-> good evening. I'm pretty new to functional programming, and after reading the advantages over imperative programming, would any of you know URLs explaining the strong sides of O'Caml over Haskell and others in particular?
<simon-> oh, and why was the icfp judges so certain that it would be a functional programming language that would run off with the price? :-)
<whee> simon: I don't think of either one (ocaml or haskell) being better than the other
<whee> haskell's great if you want to plunge yourself into FP. it's a fun language
<simon-> like brainf*ck is fun? :)
<whee> ocaml is a little less research-oriented, but still neat
<whee> you really can't go wrong with either one of them
<whee> personally I have more fun with haskell, though
* whee ducks
<simon-> hehe. well, I'm going to give haskell a go, since that was the language I was introduced to first
polin8 has joined #ocaml
<lament> Ocaml is less ivory-towery.
<whee> if you learn haskell, you'll have no problems picking up ocaml later
<lament> And faster.
<lament> And it has ugly syntax.
<whee> yes, I dislike ocaml syntax
<whee> I doubt it's going to change either :\
<lament> camlp4 exists.
<whee> lament: development on camlp4 is over
<whee> if noone continues, it'll likely stop functioning once the AST changes.
<whee> it's likely that it might be maintained, but it doesn't make the ocaml team look too good
polin8 has quit [Read error: 110 (Connection timed out)]
<simon-> hehehe
* simon- is reading an entry page for ICFP
<simon-> "So I added a couple of features, fixed one bug (my lightening entry avoids standing on the graves of dead robots, which was entirely an accounting error, not a religious statement)"
Zadeh_ has joined #ocaml
Zadeh has quit [Read error: 113 (No route to host)]
skylan has quit [Killed (NickServ (Ghost: skylan_!sjh@207.164.213.82))]
polin8 has joined #ocaml
polin8 has quit [Client Quit]
polin8 has joined #ocaml
lament has quit ["Did you know that God's name is ERIS, and that He is a girl?"]
polin8 has quit ["Lost terminal"]
Yurik has joined #ocaml
<Yurik> re
Yurik has quit ["÷ÙÛÅÌ ÉÚ XChat"]
skylan has joined #ocaml
polin8 has joined #ocaml
mattam has joined #ocaml
polin8 has quit ["Now _that's_ a good cup of coffee."]
polin8 has joined #ocaml
polin8 has quit ["Lost terminal"]
* jao is back
jao is now known as jao_away
skylan has quit [Remote closed the connection]
skylan has joined #ocaml
docelic|sleepo is now known as docelic
Yurik has joined #ocaml
Kinners has joined #ocaml
<Yurik> Kinners: hi
<Kinners> hey Yurik
Yurik_ has joined #ocaml
Yurik has quit [Read error: 104 (Connection reset by peer)]
skylan has quit [Read error: 104 (Connection reset by peer)]
skylan has joined #ocaml
<Yurik_> skylan: hi
Yurik__ has joined #ocaml
Yurik_ has quit [Read error: 104 (Connection reset by peer)]
skylan has quit [Read error: 104 (Connection reset by peer)]
skylan has joined #ocaml
Yurik__ has quit [Read error: 104 (Connection reset by peer)]
intero has joined #ocaml
<intero> hi people
<Kinners> hi intero
<intero> hi there Kinners
<intero> i have a boring problem about n-tree
<intero> heh
<intero> a function of mine looks the same of one of a friend of mine
<intero> but of course mine is not working
<intero> :P
<intero> found it
<intero> i am a real moron heh
<Kinners> you probably still know more than me :)
<intero> lol
<intero> i am not sure heh
smklsmkl has joined #ocaml
smkl has quit [Read error: 104 (Connection reset by peer)]
mattam_ has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
Kinners has left #ocaml []
xkb_ has quit [Read error: 104 (Connection reset by peer)]
nkoza has quit [Read error: 113 (No route to host)]
smklsmkl is now known as smkl
Dalroth has joined #ocaml
graydon has quit ["xchat exiting.."]
rox is now known as rox|poisoned
lament has joined #ocaml
Dalroth has quit []
mrvn_ has joined #ocaml
mrvn has quit [Read error: 60 (Operation timed out)]
matkor has joined #ocaml
Dalroth has joined #ocaml
matkor has quit [Client Quit]
polin8 has joined #ocaml
skylan has quit [Read error: 54 (Connection reset by peer)]
skylan has joined #ocaml
<intero> anyone?
<mattam_> yup
<intero> hi
<mattam_> hi intero
<intero> can i bother with a type problem?
mattam_ is now known as mattam
<mattam> why not ?
<intero> heh
<intero> n-tree
<mrvn_> You will never know unless you try
<intero> type 'a ntree = Tr of 'a * 'a ntree list;;
mrvn_ is now known as mrvn
<intero> i need a function that
<intero> finds all the 'granfathers' in a tree
<intero> so i guess, i am just visiting the tree, and check a propriety p i pass to the search function
<intero> like
<intero> let rec preorder p = function
<intero> Tr(h,tlist) -> (h,(p h)) :: prel p tlist
<intero> and prel p = function
<intero> [] -> []
<intero> | y::ys -> preorder p y @ prel p ys;;
<intero> should return [(node,true)..]
<mattam> it doesn't ?
<intero> heh
<intero> course not :P
<intero> # val preorder : ('a -> 'b) -> 'a ntree -> ('a * 'b) list = <fun>
<intero> val prel : ('a -> 'b) -> 'a ntree list -> ('a * 'b) list = <fun>
<intero> should be correct
<mrvn> # let foo _ = true;;
<mrvn> # let tree = Tr (0, [Tr(1,[]),Tr(2,[Tr(3,[])])]);;
<mrvn> # let tree = Tr (0, [Tr(1,[]);Tr(2,[Tr(3,[])])]);;
<mrvn> # preorder foo tree;;
<mrvn> - : (int * bool) list = [(0, true); (1, true); (2, true); (3, true)]
<mrvn> works fine.
<mattam> so it's your p
<intero> maybe the p function?
<intero> let gf = is_gf;;
<intero> let is_gf t =
<intero> let rec aux d = function
<intero> Tr(h,(tlist) ->
<intero> if d<2
<intero> then auxl (d+1) tlist
<intero> else true
<intero> and auxl d = function
<intero> [] -> false
<intero> | y::ys -> aux d y or auxl d ys
<intero> in aux 0 t;;
<intero> emm
<intero> maybe you need some explanation
<intero> any node is a grandfather exept leaves and
<intero> fathers of leaves
<mattam> are you sure your tree is high enough ?
<intero> yes
<intero> you want one long enough to try?
<intero> anyway the problem is
<intero> # preorder gf t;;
<intero> Characters 12-13:
<intero> preorder gf t;;
<intero> ^
<intero> This expression has type int ntree but is here used with type 'a ntree ntree
<mrvn> Got that too with my is_grandfather function.
<intero> same problem?
<intero> tell me if you want a long tree
<mrvn> let is_father = function Tr(_,[]) -> false | _ -> true;;
<mrvn> let is_grandfather = function Tr(_,[]) -> false
<mrvn> | Tr(_,l) -> List.fold_left (fun x l -> if x then true else is_father l) false l;;
<mrvn> let is_grandfather = function Tr(_,[]) -> false
<mrvn> | Tr(_,l) -> List.fold_left (fun x l -> x || is_father l) false l;;
<mrvn> That looks like the right predicate?
<mrvn> let tree = Tr (0, [Tr(1,[]);Tr(2,[Tr(3,[])])]);;
<mrvn> val tree : int ntree = Tr (0, [Tr (1, []); Tr (2, [Tr (3, [])])])
<mrvn> is_grandfather tree;;
<mrvn> - : bool = true
<intero> does preorder is_grandfather tree work?
<mrvn> val preorder : ('a -> 'b) -> 'a ntree -> ('a * 'b) list = <fun>
<mrvn> shold be: val preorder : ('a ntree -> 'b) -> 'a ntree -> ('a * 'b) list = <fun>
<mrvn> let rec preorder p = function
<mrvn> Tr(h,tlist) as t -> (h,(p t)) :: prel p tlist
<mrvn> and prel p = function
<mrvn> [] -> []
<mrvn> | y::ys -> preorder p y @ prel p ys;;
<mrvn> preorder is_grandfather tree;;
<mrvn> - : (int * bool) list = [(0, true); (1, false); (2, false); (3, false)]
<mrvn> And you might want to return the tree instead of their value:
<intero> mmm
<mrvn> let rec preorder p = function
<mrvn> Tr(h,tlist) as t -> (t,(p t)) :: prel p tlist
<mrvn> and prel p = function
<mrvn> [] -> []
<mrvn> | y::ys -> preorder p y @ prel p ys;;
<mrvn> preorder is_grandfather tree;;
<mrvn> - : (int ntree * bool) list =
<mrvn> [(Tr (0, [Tr (1, []); Tr (2, [Tr (3, [])])]), true); (Tr (1, []), false);
<mrvn> (Tr (2, [Tr (3, [])]), false); (Tr (3, []), false)]
systems has joined #ocaml
<intero> i take it my is_gf is pretty wrong
<mattam> intero: change Tr(h,tlist) as t -> (h,(__h -> p t__)) :: prel p tlist
<mattam> your predicate is on the node, not the node's value
<mrvn> # preorder is_gf tree;;
<mrvn> - : (int * bool) list = [(0, true); (1, false); (2, false); (3, false)]
<mattam> same here
<mrvn> Your is_gf is fine.
<intero> ¿?
<mrvn> Its just your preorder thats wrong.
<intero> ah
<intero> mattam: that thing doesnt work with me :( maybe i copied it wrong?
<mrvn> let rec preorder p = function
<mrvn> Tr(h,tlist) as t -> (h,(p t)) :: prel p tlist
<mrvn> and prel p = function
<mrvn> [] -> []
<mrvn> | y::ys -> preorder p y @ prel p ys;;
<mrvn> that?
<intero> yes i mean i did that change
<intero> Tr(h,tlist) as t -> (h,(__h -> p t__)) :: prel p tlist
<intero> nah
<intero> ok
<intero> got it :P
<intero> <mattam> your predicate is on the node, not the node's value
<mattam> :)
<intero> i am still very slow in functional :P
<intero> thanks alot you both
systems has left #ocaml []
<mrvn> Your is_gf is also overly complicated:
<mrvn> let is_gf t = let rec aux d = function
<mrvn> Tr(h,tlist) -> List.fold_left
<mrvn> (fun res elem -> res || aux (d+1) elem) (d>=2) tlist
<mrvn> in aux 0 t;;
<intero> :P
<intero> tomorrow i have ocaml test at uni :/
<mrvn> Even better would be to traverse the tree to each leave, then recurse back two levels and output that node as being grandfather.
<mrvn> You would only look at each node/leafe once.
<intero> that's too much i guess :P
<intero> i can't do that in ocaml :(
<intero> how would you do a is_uncle?
<mrvn> you can't since you don't know the father.
<intero> i mean, actually i find a path from root to node, then search again if h=grandfather then tlist and remove father from that list
<intero> is_uncle x?
<intero> night all
<intero> thanks for the help mattam and mrvn
<intero> pray for me tomorrow :P
intero has left #ocaml []
Dalroth has quit []
lament has quit [Remote closed the connection]
mrvn has quit [leguin.freenode.net irc.freenode.net]
merriam has quit [leguin.freenode.net irc.freenode.net]
mrvn has joined #ocaml
merriam has joined #ocaml
polin8 has quit [leguin.freenode.net irc.freenode.net]
mattam has quit [leguin.freenode.net irc.freenode.net]
jao_away has quit [leguin.freenode.net irc.freenode.net]
simon- has quit [leguin.freenode.net irc.freenode.net]
polin8 has joined #ocaml
mattam has joined #ocaml
simon- has joined #ocaml
jao_away has joined #ocaml
asqui has quit [Excess Flood]
asqui has joined #ocaml
mrvn_ has joined #ocaml
rox|poisoned is now known as rox
TimFreeman has joined #ocaml