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
__DL__ has quit [Remote closed the connection]
systems has joined #ocaml
systems has quit ["Client Exiting"]
<thedark> i need a random int, how can i get it?
<Riastradh> I think there's a Random structure or something.
<thedark> ok, i'll search
<thedark> where can i find help on this random module ??
<Riastradh> http://www.ocaml.org/ -> The O'Caml Manual
<thedark> well i've finally found it on http://caml.inria.fr/ocaml/htmlman/libref/Random.html
<thedark> but as i've never used any module, i'm not that happy :)
<Riastradh> It's simple.
<Riastradh> open Random;;
<Riastradh> random_integer 4;; (* or whatever the function is and arguments it takes *)
<thedark> random_integer ??
<Riastradh> I don't know exactly what the function is. RTFM.
<Riastradh> Or you might just want to do:
<Riastradh> Random.int 4;; (* the function is called 'int,' so you might want to use the fully qualified name *)
<thedark> my problem is that i want a random int lower than a big_int ...
Kinners has joined #ocaml
<Riastradh> Random.int big_int
<thedark> wont work
<Riastradh> Why not?
<thedark> Random.int waits for an int
<thedark> This expression has type Big_int.big_int but is here used with type int
<thedark> let k= Random.int n in
<thedark> ...
* Riastradh doesn't know, in that case.
<thedark> well i'm having a very hard time trying to implement rsa in a langage i dont even know :( those teachers are mad ...
<Kinners> thedark: what's the problem?
<Kinners> want a random big_int?
<thedark> exactly
Smerdyakov has quit ["brb"]
<Kinners> thedark: can it be any number or within a range?
<thedark> it needs to be lower than a big_int n
<thedark> in fact i'm implementing the rabin miller test (i know it sounds like chinese)
<thedark> an idea i have is to take a random int, to * it with another random int, and to keep doing so till i'm bigger than my bound
mattam_ is now known as mattam
<Kinners> wouldn't be very random though? I thought about using Random.bits somehow but keeping it within a bound might make that more complicated
<thedark> well it would be random, but bigger than n/max size of int
palomer has joined #ocaml
<palomer> anyone know how to get lablgtk2 from cvs?
<mattam> Kinners: :)
thedark has quit [Connection timed out]
lament has joined #ocaml
docelic has quit [No route to host]
palomer has quit [Remote closed the connection]
palomer has joined #ocaml
<palomer> what does let _ = do?
<Kinners> I 'spose you could say the result of the binding is discarded, it's similar to ignore (expr)
docelic has joined #ocaml
docelic is now known as docelic|sleepo
palomer has quit [Remote closed the connection]
xtrm_ has joined #ocaml
xtrm has quit [Read error: 54 (Connection reset by peer)]
Sonarman has joined #ocaml
Sonarman has quit ["bye"]
<pattern_> well, i think i've finally gotten to the point where i officially like ocaml more than any other language i know
<emu> did you fill out the appropriate forms?
<emu> and submit them to the Ministry of Languages?
<pattern_> oh, i hope i'll be able to make it by the deadline
<pattern_> i wouldn't want them to put down that c is my favorite language, by default
<pattern_> ;)
<pattern_> but it's good to finally see for myself the ease, speed and reliability of ocaml
<pattern_> it has lived up to the hype, for me... as i expected it to... but it's nice to finally be familiar enough with the language to start to really appreciate it
Kinners has left #ocaml []
lament has quit ["Did you know that God's name is ERIS, and that He is a girl?"]
debug has quit [Excess Flood]
debug has joined #ocaml
mrvn has joined #ocaml
polin8_ has joined #ocaml
polin8 has quit [Connection reset by peer]
mrvn_ has quit [Dead socket]
_cm has joined #ocaml
cm has quit [Dead socket]
_cm is now known as cm
skylan has quit [Excess Flood]
skylan has joined #ocaml
Kinners has joined #ocaml
mrvn has quit [Read error: 110 (Connection timed out)]
<Kinners> I've found a site with benchmarks of a few programs, one of the programs joins a list of strings with a tab character
<Kinners> (amongst other things), which slows it down in ocaml
<Kinners> so what's a faster way of doing that? skipping the join and just iterating over the list with a function to print a tab and a string makes it faster than the perl program
<Kinners> not as consise of course :)
mellum has quit [Read error: 60 (Operation timed out)]
Smerdyakov has joined #ocaml
mellum has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
systems has joined #ocaml
<pattern_> when i print a value in ocamldebug sometimes i see something like "Foo <poly>", a polymorphous type
<pattern_> how can i look in to the values of that type?
<pattern_> from within the debugger, that is
mrvn has joined #ocaml
<pattern_> hey, mrvn... can i ask you a question?
<Smerdyakov> What is an example of such a type?
<mrvn> you can allways ask
<Krystof> after all, it looks like you just did
<pattern_> smerdyakov, type 'a tree = Leaf of 'a | Node of 'a tree * 'a tree
<mrvn> Bad choice.
<pattern_> this is just for practice, mrvn
<mrvn> How do you represent an empty tree with that?
<pattern_> not a real program
<pattern_> there are no empty trees
<pattern_> why would i want an empty tree, anyway?
<mrvn> type 'a tree = Leaf | Node of 'a tree * 'a tree
<mrvn> Thats usually whats used.
<pattern_> but then the leaf has not contents
<mrvn> yes.
<pattern_> i want the leaf to store values
<mrvn> type 'a tree = Leaf | Node of 'a tree * 'a * 'a tree I mean
<systems> leaf can't store a value
<pattern_> systems, sure it can
<mrvn> Usually values are stored in the nodes.
<pattern_> well, they're not here
<systems> leaf are there because a node must have a left side and a right side ... even if not yet used
<pattern_> i'm only interested in the leaves
<mrvn> Otherwise whats the point of having a tree if all values are in the leafes?
<systems> when used they become nodes
<pattern_> mrvn huffman encoding
<pattern_> i store symbols in the leaves
<systems> you replace Leaf with Nothing i think, or what?
<mrvn> Ok, then you have implicity 0 and 1 bits inside the trees path.
<mrvn> -y
<Smerdyakov> I think you fellas are arguing about something worthless at the moment....
<pattern_> http://www.cs.duke.edu/csed/poop/huff/info/gopher8.jpg is an example of a tree i'm looking to make
<pattern_> only there will be no values in the nodes
<pattern_> there'll be just the values in the leaves
<mrvn> Ok, I'm on track now. Whats your problem then?
<systems> like in, Node(Nothin_on_my_left, value, Nothing_on_my_right)
<pattern_> smerdyakov, yes, we have gotten off on a tangent... i'm still interested in how to print <poly> values from the debugger
<mrvn> Can't you call a function "print_poly poly" from the debugger?
<pattern_> yeah, i guess... i just thought that there was a simple way to just look inside
<mrvn> I'm a printf debugger myself.
<pattern_> :)
<mrvn> never used ocaml-debug
systems has quit ["Client Exiting"]
docelic|sleepo is now known as docelic|away
Smerdyakov has quit []
Kinners has left #ocaml []
Krystof is now known as K_Oxford
docelic|away is now known as docelic
TachYon26 has joined #ocaml
docelic is now known as docelic|away
systems has joined #ocaml
Smerdyakov has joined #ocaml
systems has left #ocaml []
karryall has joined #ocaml
palomer has joined #ocaml
<palomer> ls
<palomer> oops
<palomer> anyone know what object(self) does?
<mrvn> bind the object you create to self
<palomer> class colored_point (x,y) c =
<palomer> object (self)
<palomer> what does that do?
<mrvn> bind the object you create to self
<palomer> doesn't let x = new colored point (1,2) "yellow" do that for you?
<mrvn> no, that would actually create that object
<palomer> how can you bind something if it's not created?
docelic|away is now known as docelic
<mrvn> it will be bound to the object when its created.
<palomer> so when you create the object with new, it will be bound to self...
<palomer> I fail to see what that does
<mrvn> palomer: Sometimes you need to call self#bla
<palomer> ahh
<palomer> so I could've bound it to object(this)
<palomer> or object(countchocula)
<mrvn> sure
<palomer> me is starting to like the OO in ocaml
mattam has joined #ocaml
<palomer> and can all objects belonging to a class access the private methods/members of all the objects of that class?
docelic has quit ["fixing"]
<mrvn> You mean call a private method of another instance of the same class?
<palomer> yes
<mrvn> I guess they can. just try it
<palomer> oh, and what does something like this mean: external keyval : t -> keysym = "ml_GdkEventKey_keyval"
<palomer> im confused about the keysym= "blah" part
<mrvn> Thats a binding to a c function
<palomer> ahh
<mrvn> (t->keysym) is the type and it calls "ml_GdkEventKey_keyval" when used
mattam_ has joined #ocaml
<palomer> yay! got it to trap my keys
* palomer is making progress
Smerdyakov has quit []
docelic has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
Smerdyakov has joined #ocaml
TachYon26 has quit ["bez ki³y nie ma zaliczenia (z prawd studentek AM)"]
liyang has quit ["leaving"]
karryall has quit ["tcho"]
liyang has joined #ocaml
Smerdyakov has quit ["go on a trip to far off land"]
liyang has quit [Remote closed the connection]
liyang has joined #ocaml
liyang has quit [Remote closed the connection]
liyang has joined #ocaml
Rapiere has joined #ocaml
TachYon has joined #ocaml
TachYon has quit [Remote closed the connection]
Vincenz has joined #ocaml
<Vincenz> hmm
<Vincenz> Hi!
<Riastradh> Hi!
TachYon has joined #ocaml
debug has quit [Remote closed the connection]
* Vincenz is learning Ocaml
<mellum> How do I read a line from a file into a string?
<Vincenz> if I knew I'd be a genious :P
Rapiere has left #ocaml []
<mrvn> read_line
clam has joined #ocaml
Kinners has joined #ocaml
<Vincenz> I have a question: I have this tutorial and they keep using "prefix"
<Vincenz> but that doesn't exist in the Objective Caml I'm using
<Vincenz> (prefix +)
<clam> a bit more context
<Vincenz> it's a function that turns an infix operator into a prefix one
<Vincenz> so I can do
<Vincenz> (+ 1 2)
<Kinners> (+) 1 2
<Vincenz> yes....but....
<Vincenz> I don't know beforehand which operator it will be
<Vincenz> I'll try that
<Vincenz> ah it works :)
<Vincenz> thnx
<Vincenz> damn (*) starts a comment
<Kinners> put some spaces in
<Kinners> ( * )
<Vincenz> ah, thank you
<Vincenz> Neato :)
<Vincenz> I just got an iterator to run over a tree, look at the first parameter of it, check which operator the string stands for and apply it to the subtrees...
<Vincenz> I guess writing an interpreter for an AST should be a breeze in Ocaml :)
<Kinners> that's what it was designed for I think (well not *just* that)
* Vincenz goes back to studying the tutorial
<Kinners> (what the ML language was designed for I mean, not just ocaml :)
<Vincenz> does this mean it's less good for other target domains?
<mellum> Vincenz: Always depends on what you compare it to. It is probably not as good as FORTRAN for matrix calculations, for example.
<Vincenz> I'm coming from a Java/c++ background
<Vincenz> and I admit I was hoping to use it for math thingies...
<Vincenz> (too)
<mellum> Well, I'd say it's better than Java for pretty much everything, and better than C++ for everything but system and low level programming
<Vincenz> alright :)
<Vincenz> well better than Java for GUI...not sure about that one
<mellum> Hm, maybe not, haven't done much there in either
<Kinners> raw ocaml math speed is ok, the ocaml cvs version has some improvements in that area, there are bindings to various math libraries too
<Vincenz> well then it's just like I envisioned it :)
<Vincenz> ocaml cvs version?
<Kinners> Vincenz: the development version
<Vincenz> ah...
<Vincenz> I prefer a stable version, preferably in compiled in an .exe :P
<mrvn> Kinners: with math libraries your basically back to C speed for large enough matrixes/numbers.
<Vincenz> what do you mean by "ok": passable?
<Vincenz> or ...ok :good?
<mellum> Well, if it turns out to be to slow, you can always do some functions in C...
<Vincenz> I mean it gets compiled to assembly right? should be pretty fast, no?
<mellum> Vincenz: floating point numbers are allocated on the heap ("boxed"), which incurs some overhead
<Vincenz> ah
<mellum> The compiler does local unboxing in loops and other tricks, though.
<Vincenz> by on the heap you mean in RAM, or is there an extra processing step?
<mellum> heap is dynamically allocated RAM, as opposed to the stack
<Vincenz> so...basically it's a load of the pointer and then a load of the float?
<Kinners> Vincenz: there was a benchmark that seemed to trip up the ocaml compiler and it produced less than optimal code, but I think once they sorted that out it was within 20% of the C code
<Vincenz> instead of just a load of the lfoat?
<mrvn> using registers for temporary floats would be much faster
<mellum> Vincenz: yes
<Vincenz> mrvn: can't use registers directly...still need to load it from ram once
<mrvn> Vincenz: not neccessarily.
<mrvn> temps are usually created from somewhere, used and forgotten. Thus the name temp.
<Vincenz> yes, temps...but I was referring to the original constants you create somewhere, because as for temps, I assume ocaml is smart enough to put those into registers, no?
<mrvn> let a = 1. +. 1. in let b = a +. 1. in let c = b +. 1. in c +. 1.
<mrvn> Where is my ocaml compiler when I need it?
<mrvn> Need to get 14.6MB of archives. After unpacking 56.1MB will be used.
<mrvn> urgs
<mellum> Ocaml does register allocation for that. It does not do constant folding or CSE though, so it still generates crappy code.
<mellum> I wonder why it doesn't do constant folding? That's pretty trivial for a native compiler
systems has joined #ocaml
<Vincenz> constant folding?
<Vincenz> as in...all constants the same memory?
<mellum> Vincenz: no, as in immediately return 11
<Vincenz> oh..
<Vincenz> you mean...execute at compiletime
<mellum> For integer code, the compiler does that...
<Vincenz> could you paste the assembly in private?
<mrvn> fstpl 0x0(%esp,1)
<mrvn> Does that store a float register on the stack?
<mellum> Vincenz: do you know Alpha assembly? :)
<Vincenz> no idea, I'm not that good at advanced assembly, just some basic x86
<Vincenz> and TI microcontroller
<mrvn> thats x86
<Vincenz> like I said...basic x86 :P
<mellum> Well, it basically loads six different 1's from memory, and does the calculations
<mrvn> 8049385: d9 e8 fld1
<Vincenz> hmm....does it save temps in registers?
<mrvn> 1.0 is an optcode on i386 it seems.
<mellum> Mixed with some magic to check whether the minor heap needs a garbage collection
<mrvn> Even on i386 it seems to store the temps on the stack needlessly.
<Vincenz> damn
<mrvn> Its unboxed on i386 but still far from optimal.
<mellum> mrvn: it doesn't store temps on the stack on Alpha...
<mellum> mrvn: on i386, you *must* store temps on Alpha. The FPU doesn't have registers :)
<mellum> erm, s,Alpha,the stack,
<Vincenz> heh...if the ocaml compiler was written in ocaml, perhaps it'd be easy for someone to do those kind of stransforms
<mrvn> mellum: no, int stack and not fpu stack.
<mellum> mrvn: Well, then it is probably running out of registers...
<mrvn> faddp %st,%st(1) <- thats the fpu stack
<mrvn> fstpl 0x0(%esp,1) <- thats the normal stack
<mrvn> or not?
<Kinners> Vincenz: the compiler is written in ocaml
<Vincenz> wow
<Vincenz> I really need to learn ocaml quick
<mrvn> mellum: no. its the example code from above.
<mrvn> It actually should fold the consts anyway.
<mellum> mrvn: indeed. And merge the constants in the pool.
<mrvn> mellum: That might be because on i386 there exists a "fld1" opcode.
<mellum> One could simply disable constant folding for cross compiles, since that is messy, but no reason for native compiles
<mrvn> Might be some emulation code on alpha to do fld1
<mellum> mrvn: well, on Alpha, the only constants you can generate immediately are 0 and 2
<mrvn> mellum: one wonders why 2
<mrvn> you get a 1 by comparing 2 with 0?
<mellum> because it's 1 when considered as VAX float :)
<mellum> mrvn: no, comparing 0 == 0 yields 2
<mrvn> and 0 and 2?
<mellum> And with just 2 and 0, you cannot even generate other useful constants quickly...
<mellum> 0 == 2 is 0, of course.
<mellum> Well, except -2.
<mrvn> mellum: Den sx164 wieder zum laufen bekommen?
<mellum> mrvn: noch nicht versucht, hab ja kein serielles Kabel
<mrvn> Wo liegt denn ne NE2000 Netzwerkkarte so normal (IO und irq)?
<mrvn> ups
<Vincenz> vect_assign...it's used in the tutorial but apparently it doesn't exist
<Vincenz> (it's to assign a new value to a certain index in a vector...where vector is defined as [| 10;20|])
<Kinners> Vincenz: arry.(idx) <- 42;;
<Kinners> Vincenz: the index is 0 based
* Vincenz nods
<Vincenz> alright I'll use that