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/
mattam has quit ["zZz"]
lament has joined #ocaml
__DL__ has quit [Remote closed the connection]
Kinners has joined #ocaml
gl has quit [sterling.freenode.net irc.freenode.net]
lam has quit [sterling.freenode.net irc.freenode.net]
mellum has quit [sterling.freenode.net irc.freenode.net]
gl has joined #ocaml
lam has joined #ocaml
mellum has joined #ocaml
polin8 has quit [Read error: 104 (Connection reset by peer)]
polin8 has joined #ocaml
GabeW has joined #ocaml
lament is now known as lameAFK
lameAFK has quit ["heh"]
GabeW has quit ["leaving"]
mattam has joined #ocaml
lament has joined #ocaml
Kinners has quit [sterling.freenode.net irc.freenode.net]
asqui has quit [sterling.freenode.net irc.freenode.net]
polin8 has quit [Dead socket]
asqui has joined #ocaml
asqui has quit [Excess Flood]
polin8_ has joined #ocaml
asqui has joined #ocaml
lament has quit ["My pineal gland says i should sleep"]
Zadeh has joined #ocaml
__DL__ has joined #ocaml
mattam_ has joined #ocaml
__DL__ has quit [Remote closed the connection]
mattam has quit [Read error: 110 (Connection timed out)]
__DL__ has joined #ocaml
Vincenz has joined #ocaml
<Vincenz> Hmm, hello
<Vincenz> why doesn't the following work?
Zadeh has quit [Read error: 104 (Connection reset by peer)]
<Vincenz> it complains on line 11
<Vincenz> inside the function
<Vincenz> ah, you can't have functions with more than one param?
<Vincenz> how would I solve that then?
<Vincenz> (I mean, how do I make a nameless function that accepts two params without resorting to 'function a -> function b')
<Vincenz> got it, it's 'fun'
<Vincenz> how do I type a function?
<mellum> vincez: let f x: int->int = succ
<Vincenz> aha, thnx
<Vincenz> what if I have
<Vincenz> let f x = function
<mellum> vincenz: but there is rarely a reason to do that
<Vincenz> | ..y...stuff.. ->
<Vincenz> mellum; why? I think if I restrict my types it clarifies the usage
<mellum> If the program is that complicated, you usually create an .mli file that contains function signatures
<mellum> Also, types can sometimes get pretty verbose
<Vincenz> ah, i see
<mellum> Hm, the best I have in my program is val edge_fold : (Graph.graph -> int -> int -> bool) -> ('a -> Branch.obj -> 'a) -> 'a -> Graph.graph -> 'a :-)
<Vincenz> what's it do?
<Vincenz> like a list fold but for graphs?
<Vincenz> I'm trying to study this compiler book on my own
<Vincenz> I'm at chapter 1
<Vincenz> straightline interpreter :)
<mellum> It's actually not that complicated, it's like list.fold, only it takes an additional filter, and iterates over edges of a graph
<Vincenz> I followed the course last year, but it was in based on a C book, and we didn't get much practice. So I ordered the same book but the ML version and I'm trying to do it all now :)
<Vincenz> hmm
<Vincenz> how do I get the last element of a list?
<mellum> You don't, since that is an expensive operation :)
<Vincenz> I have to
<Vincenz> I've got a list of expressions
<Vincenz> each has to be executed and I want the value from the last
<Vincenz> but since the other ones might have sideeffects..
<Vincenz> hmm
<Vincenz> perhaps a list.fold_right
<mellum> Sounds like a job for fold.
<Vincenz> fold_left or right?
<mellum> Uh, I always confuse those two...
<Vincenz> yeah, me too
<Vincenz> I want the head to be executed first
<Vincenz> heh
<Vincenz> easy to test
<Vincenz> just use a ref
<Vincenz> ah!
<Vincenz> List.fold_left
<Vincenz> List.fold_left (fun r v-> r:=v;r) a [1; 2; 3];;
<Vincenz> List.fold_right (fun v r-> r:=v;r) [1; 2; 3] a;;
<Vincenz> :)
<Vincenz> fold_left gives me a {contents = 3}
<Vincenz> fold_right gives me a {contents = 1}
<Vincenz> :))
<Vincenz> almost done with my first interpreter
<Vincenz> I'll put it on nopaste if you want to see it
<mellum> What does it interpret?
<Vincenz> this custom code that they use as an example
<Vincenz> it's just chapter 1
<Vincenz> an intro
<Vincenz> but I want to do everything in this book
* Vincenz is at page 11 of 520
<mellum> You got a lot of time? :)
<Vincenz> nope
<Vincenz> I work
<Vincenz> but not this week anymore
<Vincenz> vacation until sunday
<Vincenz> hmm
<Vincenz> could you help me with a fold statement?
<mellum> maybe
<Vincenz> ok
<Vincenz> as output I want a pair (int, list)
<Vincenz> where the list is a lookuptable (don't worry about the construction of that)
Kinners has joined #ocaml
<Vincenz> as input I have a list of expressions
<Vincenz> and I have the function
<Vincenz> interpExp : expression -> list -> (int, list)
<Vincenz> where this list is a lookuptable too
<Vincenz> ah, I might have it :)
<Vincenz> List.fold_right (fun v r-> r:=v;r) [1; 2; 3] a;;
<Vincenz> shit
<Vincenz> let (n2, l2) = List.fold_left (fun (n1, l1) e -> interpExp e l) (0, l) l
<Vincenz> heh
<Vincenz> of course...I finish programming and I have errors
<Vincenz> Yay!
<Vincenz> Wahoo, it works :)
<Vincenz> want me to paste it online?
<mellum> Vincenz: Well, then just quickly write an optimizing C++ compiler, and it is enough for today ;)
<Vincenz> uhu
<Vincenz> right...
<Vincenz> I'm new to ocaml, I'm new to compilers
<Vincenz> anyways
<Vincenz> this interpreter interprets an AST :)
<mellum> Ah, it doesn't parse yet
<Vincenz> nope
<Vincenz> but parsing should be easy with ocamlyac
<Vincenz> ..c
<mellum> Your lookup is basically List.assoc from the standard lib
<Vincenz> oh, thnx :)
<mellum> It might not really be ideal, since each assignment only shadows the previous assignment, so the list always gets longer
<Vincenz> I know
<Vincenz> that's what they said to use
<Vincenz> it's good tho
<mellum> It has the advantage of being very easy :)
<Vincenz> if you want to work with environments
<Vincenz> not only that
<Vincenz> let's take java
<Vincenz> {
<Vincenz> int a = 1;
<Vincenz> {
<Vincenz> int a = 2;
<Vincenz> }
<Vincenz> System.out.println(a);
<Vincenz> }
<mellum> Well, you must not do that in Java...
<Vincenz> you want it to print 1, not 2
<Vincenz> you know what I mean...environments...
<mellum> C allows it, though
<Vincenz> by using non-destructive stuff
<Vincenz> you can get your previous environment back
<Vincenz> just shadow when you enter a new block, and remove the shadow when you come back out
<Vincenz> :)
<Vincenz> chapter 2, lexical analysis, this should be a breeze
<Vincenz> what'd you think of it for the rest?
<Vincenz> I'm always open to constructive criticism :)
<mellum> You should probably use Printf.printf for printing
<mellum> Generally, it looks good to me
<Vincenz> :)
<Vincenz> odd
<Vincenz> Printf.printf (2, stdout, ()) "%d";; doesn't work
<Vincenz> ^^^^^^^^^^^^^
<Vincenz> This expression has type int * out_channel * unit but is here used with type
<Vincenz> ('a -> 'b, out_channel, unit) format
<Vincenz> hmm Printf.printf "%d" 2;; works, but the signature of the function Printf.printf states: ('a, out_channel, unit) format -> 'a = <fun>
<Kinners> formatting uses some special voodoo
<Vincenz> apparently :)
systems has joined #ocaml
Kinners has left #ocaml []
systems has quit [Read error: 110 (Connection timed out)]
Vincenz has quit ["Booting to Gentoo"]
vincenz_ has quit ["leaving"]
polin8_ is now known as polin8
systems has joined #ocaml
systems has quit [Read error: 110 (Connection timed out)]
lus|wazze has joined #ocaml
foxster has joined #ocaml
async has quit ["Lost terminal"]
async has joined #ocaml
<async> how do you make X calls in an ocaml program?
<Smerdyakov> Wazzat?
<Riastradh> async - Rephrase, please.
<Riastradh> Oh, X11 protocol calls?
lus|wazze has quit ["Das ist die antri-depri-quit-msg... der anti-depri-quit-msgen-blues!"]
foxen has joined #ocaml
foxster has quit [Read error: 110 (Connection timed out)]
jao has joined #ocaml
taw has joined #ocaml
<taw> hi
<taw> how do you usually debug programs in ocaml ?
<taw> problem is like that - they create very complex structure
<taw> it would be nice if it just printed it
mattam_ has quit ["zZz"]
taw has left #ocaml []
foxen has quit [Connection timed out]