systems 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 | Caml Weekly news http://pauillac.inria.fr/~aschmitt/cwn/
pnou has quit ["Lost terminal"]
docelic has quit [Excess Flood]
docelic has joined #ocaml
docelic has quit [Read error: 110 (Connection timed out)]
Vincenz has quit ["SLEEP"]
docelic has joined #ocaml
docelic is now known as docelic|sleepo
Kinners has joined #ocaml
Smerdyakov has quit ["smear campaign against the desert rain"]
Smerdyakov has joined #ocaml
lament has joined #ocaml
async has joined #ocaml
lowks has joined #ocaml
<lowks> type 'a btree
<lowks> what does the " ' " mean ?
<Kinners> it's a type variable, it means that any type can be used
<lowks> hi Kinners i am actually archie_sihir
<lowks> Kinners: so then it would mean that a union like this :
<lowks> type 'a btree=
<lowks> Node of 'a*'a btree*'a btree
<lowks> | Leaf;;;
<lowks> when i do a 'Node('foobar',Leaf,Leaf);;
<lowks> it is correct ?
<lowks> from this code what is 'a ?
<Kinners> string
<lowks> Kinners: 'Node('foobar',Leaf,Leaf);;
<lowks> is correct ?
<Kinners> yes
<Kinners> if it compiles it's correct :)
<lowks> Kinners: funny thing is ... 'Node('foobar',Leaf,Leaf);;' gives a syntax error
<lowks> Kinners: but 'Node("foobar",Leaf,Leaf);;' compiles file
<lowks> s/file/fine/
<lowks> Kinners: what is the 'rec' keyword for ?
<Kinners> ah woops, ' is for characters, " is for strings
<lowks> oh
<lowks> let rec cardinality=function ...
<lowks> what is that 'rec' for ?
<Kinners> rec says that the function is recursive
<lowks> can you explain what is meant by a 'recursive function' ??
<Kinners> a function that can call itself
<lowks> ok ...
<lowks> this one : Node(_,left,right) --> what does the '_' mean ?
<Kinners> it will match anything, and it's used when you don't need the value that is matched
<lowks> Kinners: when i want pattern matching do i have to put the key word 'match' ?
<Kinners> that's not the only way of doing it, pattern matching is used in a few different ways
<Kinners> such as, let (x,_,z) = (1,2,3), or let foo = function ... or let foo l = match l with ...
<lowks> how does the 'let foo=function ..' work ?
<lowks> # let rec cardinality=function
<lowks> Leaf ->0
<lowks> | Node(_,left,right)->cardinality left+cardinality right+1;;
<lowks> val cardinality : 'a btree -> int = <fun>
<lowks> does the 'Leaf->0' means it setting the Leaf variable to 0 ?
<Kinners> function pat1 -> expr1 | pat2 -> expr2 | ... patn -> exprn, evaluates to a function that takes one argument and does the matching
<lowks> so in that function what does the 'Leaf->0' do ?
<Kinners> if that argument is a Leaf, the result is 0
<lowks> so if it meets up with a Leaf argument it will give a result of 0 ?
<lowks> okay ..
<lowks> i see how the program works ... but then i dunno how they map real life on to this program =(
<lowks> that has been my problem all along =((
<Kinners> let rec fact = function 0 -> 1 | n -> n * fact (n - 1);;
<Kinners> put that into the toplevel
<lowks> done
<Kinners> #trace fact;;
<lowks> the funny thing about ocaml is that if i write a function like that
<lowks> trace fact;;
<lowks> Unbound value trace
<Kinners> #trace fact is a toplevel directive, trace fact is a function call
<Kinners> then, fact 10;;
<lowks> # trace fact;;
<lowks> Unbound value trace
<lowks> # fact 10;;
<lowks> - : int = 90
<lowks> #
<Kinners> I mean literally type "#trace fact;;" :)
<lowks> with the "#" ?
<Kinners> yes
<lowks> # fact 10;;
<lowks> fact <-- 10
<lowks> fact <-- 9
<lowks> fact <-- 8
<lowks> fact <-- 7
<lowks> fact <-- 6
<lowks> fact <-- 5
<lowks> fact <-- 4
<lowks> fact <-- 3
<lowks> fact <-- 2
<lowks> fact <-- 1
<lowks> fact <-- 0
<lowks> fact --> 1
<lowks> fact --> 1
<lowks> fact --> 2
<lowks> fact --> 6
<lowks> fact --> 24
<Kinners> yeah I know what it prints :)
<lowks> fact --> 120
<lowks> fact --> 720
<lowks> fact --> 5040
<lowks> fact --> 40320
<lowks> fact --> 362880
<lowks> fact --> 3628800
<lowks> hehe
<lowks> what does that mean now ?
<lowks> dun understand it =(
<Kinners> that's showing the recursion, a left arrow shows the function being called with a value, right arrow is the function returning a value
<lowks> why does trace need a "#" infront of it ?
<lowks> what other commands are there ?
<Kinners> look at the ocaml docs (for the ocaml command)
<lowks> okay
<lowks> i really like the way ocaml does recursion
<lowks> confusing at first
<lowks> but cool once understood
<Kinners> now if you try fact (-1);; you'll get an error
<lowks> stack overflow
<lowks> # type 'a btree=
<lowks> Node of 'a*'a btree*'a btree
<lowks> | Leaf;;
<lowks> what does that '*' denote here ?
<Kinners> that's the type for tuples, ("foobar",Leaf,Leaf)
<lowks> so if it's a list it will be something like :
<lowks> #type 'a btree=
<lowks> Node of 'a::'a btree::'a btree ??
<Kinners> no..
<Kinners> type in 1, [1,2;3,4];;
<lowks> ?
<Kinners> type it in, and see the type it prints
<lowks> oh
<lowks> # 1, [1,2;3,4];;
<lowks> - : int * (int * int) list = (1, [(1, 2); (3, 4)])
<lowks> why is it int*(int*int) ??
<lowks> i remember '::' is for deconstructing a list tho
<lowks> hmmm
<Kinners> :: is for constructing lists, and a comma for constructing tuples
<Kinners> maybe operator is a better term than constructor for :: and ',', I dunno
<lowks> then how come i can't write 'Node of 'a::'a btree ..' ?
<Kinners> firstly, all elements in a list must be of the same type
<lowks> oh
<lowks> so can't do stuff like 'a ... 'b
<Kinners> and the type expression is seperate from how you make a value of that type
<lowks> okay ...
<Kinners> so if you have an int list, you can make it with [1;2;3], [1] @ [2;3], 1 :: 2 :: 3 :: [], etc.
<lowks> how do i write the type constructor for it ?
<Kinners> for what?
<lowks> i mean a type that creates a list
<Kinners> type ilist = int list and illist = ilist list;;
<Kinners> let foo:illist = [[1];[2];[3;4]];;
<lowks> what is that 'and' key word for anyway ?
<Kinners> you have the two type expressions, then you bind the value to foo and tell it that you want it as the illist type (without the :illist the type of foo would be an int list list)
<Kinners> for recursive type definitions, if they were to reference each other, in this case it's just so it can be on one line :)
polin8 has quit ["Now _that's_ a good cup of coffee."]
polin8 has joined #ocaml
<lowks> Kinners: for functions in functions .... what exactly does the keyword
<lowks> 'in' do ?
<Kinners> let this name be bound to that value in this scope
<lowks> so the 'in' is for scope ?
async has quit ["Lost terminal"]
walters has joined #ocaml
<Kinners> basically
<walters> hi. is there an easy way to push back a character onto a standard stream?
<walters> i wrote my own little thing which looks like type buffered_inchannel = (in_channel * char option ref);;
<walters> but as i copy this from project to project i just think there must be an easier way
<walters> or...any suggestions for an easier way to parse a data stream which looks like <int> <string to newline>\n[<float> <float> .... <float>] ?
<Kinners> use peeking maybe?
wax has quit [Remote closed the connection]
<walters> how do i peek?
<walters> oh, i see, Stream.peek
<walters> hm, no...
wax has joined #ocaml
lament has quit ["LOOSE TEETH DON'T NEED MY HELP"]
Kinners has left #ocaml []
<lowks> wow
<lowks> the for loops have 'to' and 'down to'
<lowks> cool !!
lament has joined #ocaml
<lowks> what is the 'sig' keyword for ?
<lowks> what does a 'let function=...' mean ??
<walters> let function x = ... creates a new function
<walters> Objective Caml version 3.06
<walters> # Str.regexp;;
<walters> Reference to undefined global `Str'
<walters> any ideas?
<walters> oh, i have to make a new toplevel.
<walters> hm.
lament has quit ["MUD IS NOT ONE OF THE 4 FOOD GROUPS"]
walters has quit ["I like core dumps"]
pnou has joined #ocaml
giedi has joined #ocaml
<giedi> hey
two-face has joined #ocaml
two-face has quit ["Client exiting"]
giedi has quit ["Client Exiting"]
docelic|sleepo is now known as docelic
Kinners has joined #ocaml
malc_ has joined #ocaml
malc_ has left #ocaml []
malc_ has joined #ocaml
two-face has joined #ocaml
two-face has quit ["Client exiting"]
Vincenz has joined #ocaml
two-face has joined #ocaml
Vincenz_ has joined #ocaml
Vincenz has quit [Read error: 104 (Connection reset by peer)]
foxster has quit [Read error: 104 (Connection reset by peer)]
Vincenz_ is now known as Vincenz
xmkl is now known as smkl
<Vincenz> hmm
<Vincenz> ocamllex seems to be missing some things that sml-lex has
<Vincenz> (not that I know shit about sml)
<Vincenz> does ocamlyacc support the %change directive?
<two-face> don't know
Kinners has left #ocaml []
malc_ has quit ["malc_ has no reason"]
two-face has left #ocaml []
mattam has quit [Read error: 60 (Operation timed out)]
mattam has joined #ocaml
__DL__ has joined #ocaml
_DL_ has quit [Read error: 110 (Connection timed out)]
archie_sihir has quit [Remote closed the connection]
TachYon26 has joined #ocaml
two-face has joined #ocaml
<Vincenz> hmm
<Vincenz> in ocamlyacc can you use something like...
<Vincenz> LPAREN (exp SEMICOLON)* RPAREN ?
<Vincenz> or is that too complex?
<Vincenz> or wait
<Vincenz> LPAREN exp (SEMICOLON exp)* RPAREN ?
two-face has left #ocaml []
<Vincenz> question about ocamlyacc
<Vincenz> how do you define custome types
<Vincenz> like...for example pos
mattam has quit [Read error: 104 (Connection reset by peer)]
mattam has joined #ocaml
platypus has joined #ocaml
TachYon26 has quit [Remote closed the connection]
axolotl has joined #ocaml
lowks has quit [Read error: 104 (Connection reset by peer)]
lowks has joined #ocaml
wax has quit [Read error: 113 (No route to host)]
stefp has quit [Remote closed the connection]
stefp has joined #ocaml
foxster has joined #ocaml
wax- has joined #ocaml
two-face has joined #ocaml
two-face has left #ocaml []
axolotl has quit [Read error: 110 (Connection timed out)]
wax- has quit [Read error: 60 (Operation timed out)]
wax- has joined #ocaml
cbcbcb has joined #ocaml
<cbcbcb> can anybody tell me the ocaml equivalent of SML "fun hd x::xs = x"?
mattam has quit [Remote closed the connection]
mattam has joined #ocaml
<cbcbcb> or can anybody suggest a good online ocaml tutorial?
* Riastradh points at ocaml.org -> the O'Caml Manual -> the first section.
<Riastradh> fun hd x::xs = x
<Riastradh> can be translated to OCaml as:
<Riastradh> let hd (x :: xs) = x;;
<cbcbcb> thanks
polin8 has quit ["Lost terminal"]
<Riastradh> Is there a multidimensional array module?
<Riastradh> Oh, matrices in the Array module.
<Smerdyakov> Do you just want this as a runtime optimization?
<Riastradh> No, I just wanted to see if there was already a library of operations on multidimensional arrays so I wouldn't have to write my own.
<Riastradh> Of course, there aren't many matrix operations in the Array module, I suppose.
Smerdyakov has quit []
stefp has quit [Read error: 110 (Connection timed out)]
stefp has joined #ocaml
foxster has quit [Read error: 104 (Connection reset by peer)]
foxster has joined #ocaml
foxster has quit [Read error: 104 (Connection reset by peer)]
polin8 has joined #ocaml
<Riastradh> Can constructors take records? -- like: type foo = Foo of { a : b; c : d };;
foxster has joined #ocaml
cbcbcb has quit []
docelic has quit [Read error: 104 (Connection reset by peer)]
polin8 has quit ["Lost terminal"]
polin8 has joined #ocaml
polin8 has quit [Client Quit]
polin8 has joined #ocaml
docelic has joined #ocaml
Vincenz has quit []
jao has joined #ocaml
__DL__ has quit [Remote closed the connection]
Smerdyakov has joined #ocaml
polin8 has quit [Read error: 104 (Connection reset by peer)]
docelic is now known as docelic|sleepo
polin8 has joined #ocaml
docelic|sleepo is now known as docelic
polin8 has quit [Read error: 54 (Connection reset by peer)]
docelic is now known as docelic|sleepo
polin8 has joined #ocaml
jao is now known as jao|zZzZ