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
palomer has quit [Remote closed the connection]
palomer has joined #ocaml
Kinners has joined #ocaml
docelic is now known as docelic|sleepo
mattam has quit [Read error: 110 (Connection timed out)]
systems has joined #ocaml
systems has left #ocaml []
palomer has quit [Remote closed the connection]
mrvn has joined #ocaml
mrvn__ has quit [Read error: 110 (Connection timed out)]
palomer has joined #ocaml
palomer has quit [Remote closed the connection]
OQHCV has joined #ocaml
OQHCV has left #ocaml []
Kinners has left #ocaml []
palomer has joined #ocaml
<palomer> how would you guys represent a binary tree in ocaml?
<palomer> I thought of using records, but then how would I tell it when there is no right branch?
<palomer> hrm, I made some progress
<palomer> type value = int;;type element = Null | Node of node;; type node = {right: element;left: element; key: value};;
<palomer> though this gives me a syntax error:
<palomer> let a = {right = Node of {right = Null; left = Null; key = 4} ; left = Null ; value = 5};;
<palomer> any ideas?
<palomer> hrm, got it
<palomer> arggh
foxster has quit [Read error: 104 (Connection reset by peer)]
mattam has joined #ocaml
<palomer> anyone know what's wrong with this?
<palomer> let rec insert = fun a tree-> match tree with
<palomer> Empty -> Node (Empty, a , Empty)
<palomer> | Node ( ln , v , rn ) -> if a < v then Node (insert a ln, v , rn) else
<palomer> Node ( ln, v , insert a rn) ;;
<palomer> it does some weird stuff
Yurik has joined #ocaml
<Yurik> re
asqui has quit [Read error: 110 (Connection timed out)]
Kinners has joined #ocaml
listener has joined #ocaml
listener has quit ["ERC v2.0 (IRC client for Emacs)"]
_gene9 has joined #ocaml
_gene9 is now known as gene9
<gene9> Yurik: hi
karryall has joined #ocaml
mattam_ has joined #ocaml
docelic|sleepo is now known as docelic
<Yurik> gene9: hi
mattam has quit [Read error: 110 (Connection timed out)]
Kinners has left #ocaml []
gene9 has quit []
systems has joined #ocaml
<systems> hi
<systems> I am reading jason hickey intro to ocaml, and in chapter 3 he talks about mutually recursive function and the use of keyword 'and'
<systems> what does 'and' do really, i dont get it
<mellum> systems: it allows mutually recursive functions :)
<systems> :(
<systems> in another example he goes like let (+) = (-) and ( * ) = (/)
<mellum> That seems like a pretty silly example
<systems> yea, it was an example to show prefix operators
<systems> but i still dont get what and adds!!
<mellum> in this case, it saves a few keystrokes only.
<systems> how is that different from let (+) = (-) ; let ( * ) = (/)
<mellum> let (+) = (-) ;; let ( * ) = (/) you mean
<mellum> and it's not different at all.
<mellum> The *real* use is for mutually recirsive functions, but it's often abused as abbreviation.
<mellum> So you write let a=1 and b=5 and x=23 in... instead of let a=1 in let b=5 in...
<systems> you recommend the second style!
<mellum> Well, it's a common idiom to use "and" that way, so I wouldn't recommend against it
<systems> :)
systems has quit [Read error: 60 (Operation timed out)]
<palomer> :o
smkl has joined #ocaml
docelic is now known as docelic|away
foxster has joined #ocaml
foxster has quit []
foxster has joined #ocaml
asqui has joined #ocaml
systems has joined #ocaml
docelic|away is now known as docelic
systems has quit [Killed (NickServ (Nickname Enforcement))]
systems has joined #ocaml
systems has quit [Killed (NickServ (Nickname Enforcement))]
systems has joined #ocaml
mattam_ is now known as mattam
systems has quit [Connection reset by peer]
Yurik_ has joined #ocaml
Yurik has quit [Read error: 104 (Connection reset by peer)]
mellum has quit [Read error: 110 (Connection timed out)]
mellum has joined #ocaml
palomer has quit [Connection reset by peer]
systems has joined #ocaml
<systems> wussup
stepcut has joined #ocaml
systems has quit ["Client Exiting"]
<stepcut> is there a way to call a normal function in infix form. Or can you only do that with specially defined functions.
<stepcut> aka: let add x y = x + y in 1 `add` 2;;
<stepcut> it's confusing to name everything @@ and /> and stuff...
* stepcut waits for someone to say 'camlp4....'
<pattern_> # let (++) x y = x + y ;;
<pattern_> val ( ++ ) : int -> int -> int = <fun>
<pattern_> # 1 ++ 2 ;;
<pattern_> - : int = 3
<stepcut> yeah, but I you can't do # let ( irish ) f g = function x -> (f (g x));;
<pattern_> # let (++) f g = function x -> (f (g x));;
<pattern_> val ( ++ ) : ('a -> 'b) -> ('c -> 'a) -> 'c -> 'b = <fun>
<pattern_> # let inc x = x + 1 ;;
<pattern_> val inc : int -> int = <fun>
<pattern_> # (inc ++ inc) 1 ;;
<pattern_> - : int = 3
<pattern_> :D
<pattern_> but you can't call it irish :(
<pattern_> or so i'm told
<pattern_> it seems that caml light has an #infix directive that would make any function infix
<pattern_> ocaml does not seem to have that feature
<pattern_> infix functions have to be called stupid things like "+" or "++" or "+++", etc
<stepcut> i need to define a lot of infix operators, things will get confusing if they are all called stupid things
<stepcut> :)
<pattern_> i totally agree
<pattern_> but i didn't write the language, i just use it :P
<pattern_> :)
<stepcut> in haskell, you can take any function, stick it between `backticks` and use it as infix
<pattern_> makes perfect sense to me
<stepcut> I thought ocaml might have something similar
<pattern_> caml light did... but ocaml apparently does not
<stepcut> hrm
<pattern_> but i'm just a beginner, and am only passing on what others wiser than myself have told me on the topic
<pattern_> so i could well be wrong
<stepcut> well, I have not found anything different than you, and I looked....
<pattern_> i feel your pain :)
<stepcut> it hurrrrrts...
<pattern_> hehe
<stepcut> I like ocaml, but I find the ommisions interesting
<stepcut> omittions?
<stepcut> hrm, I have never spelled this word before
<pattern_> ommisions, i think
<Riastradh> Omissions.
<stepcut> m-w.com agrees, omissions
<Riastradh> Omit -> one m. emit <-> omit. Emission -> two 's's.
<pattern_> at least that word wasn't omitted from the dictionary ;)
<pattern_> ocaml's omissions don't bother me as much... since this is my first functional language the features it does have are keeping my hands quite full
<stepcut> hehe
<stepcut> I program in ocaml, haskell, and elisp. Its interesting to see the different paths you can go down
<stepcut> the difference between static and dynamic typing, or pure functional vs functional w/side effects
<pattern_> learning some of the other functional languages would be cool too
<stepcut> i thing you mean "will be cool too" :p
<stepcut> err, s/thing/think/ :)
<pattern_> not if ocaml is my last language, as everyone says ;)
<stepcut> hehe
<stepcut> i like the haskell syntax a lot
<pattern_> there was a thread on the ocaml list about adding a haskell syntax to ocaml
<pattern_> just recently
<stepcut> interesting...
<pattern_> just search on that page for "haskell"
<stepcut> I really need to learn camlp4