<pattern_>
i'm trying to do an exercise in my "functional approach to programming book", but i can't for the life of me understand the question
<pattern_>
"Use the provided it_list function to write a function that takes a comparison predicate (of the type ( a' -> a' -> bool )) and a list of values of the type a' as its arguments and provides a maximal element of the list for the comparison operation."
<pattern_>
what do they mean by "provides a maximal element of the list for the comparison operation"?
<pattern_>
doesn't a comparison operator require two elements?
<pattern_>
and if we know it's the maximum, what use is comparing it?
<Kinners>
find the maximum element in the list as defined by the comparison operator I guess
<Kinners>
you don't know what the maximum is, that's why you need to compare
<pattern_>
hmm.. so what he means is: apply a comparison operator to this list
<Kinners>
yes
<pattern_>
ok, that makes more sense :)
<mrvn>
Unles its an empty list (throw up) or a single list (return singleton)
<mrvn>
usually thats a job for fold_left
<mrvn>
Wow, my ftp client now can connect to a fixed host/port, login as a fixed user with fixed pass and then kill the connect.
<pattern_>
i think the it_list function he talks about is like fold_left or fold_right
<mellum>
mrvn: are you going to implement active or passive?
<pattern_>
the book actually teaches caml light
<mrvn>
purely passive.
<mrvn>
mellum: But with a splitter/proxy at university.
<mellum>
mrvn: i see
<mrvn>
The n-way splitter was easy. getting all the data conncts ready for it is the hard part.
<mrvn>
But the ocaml IO realy sucks for this stuff.
<mellum>
Had a look at ocamlnet or whats it called
<mellum>
?
<mrvn>
For example how do I read in a data stream in 1K chunks?
<mrvn>
input reads only as much as present and really_input throws away the last incomplete chunk with an End_of_file exception.
mattam has joined #ocaml
<mellum>
well, going to bed now... n8
<mrvn>
n8
<Kinners>
you could build a function on top of input that read in 1K chunks couldn't you?
<mrvn>
No, that would still read in bytewise.
<mrvn>
I want to block
<mrvn>
Its realy inefficient to read a 1MB/s stream bytewise.
<mrvn>
really_input should say how many chars it read before getting an End_of_file upon failure and I would be happy.
<Kinners>
bytewise as in len = 1?
<mrvn>
Kinners: On local connects it read between 1 and 8 chars with each loop.
<Kinners>
strange
<mrvn>
The doc says that input reads some chars until it feels like it read enough.
<mrvn>
Probably thinks reading a 0 byte is a good position to end
<mrvn>
I'm also missing functions to make channels non blocking and to do a select on channels.
<mrvn>
The IO is realy loosing a lot compared to Unix.file_descr.
systems has joined #ocaml
<mrvn>
urgs, in 7 1/2 hours I have to be up because i get visitors. Bet catch some zzzZZZ
<Kinners>
night mrvn
<stepcut>
lets say I make a sum data type: type sum_type = A of string | B of char | C of int
<stepcut>
and later I do a pattern match on the type: match v with A -> do_something | other -> print_constructor_for_other
<stepcut>
err: match v with A s -> do_something | other -> print_constructor_for_other
<stepcut>
anyway, if the 'A' matched, I want to do sothing, otherwise I want to print the constructor. Is there some way to do that without hard coding it for each case?
<whee>
no
<whee>
it's possible to automate it with camlp4, though
<whee>
althoughI can't remember how complex that solution was
<stepcut>
hrm, I will just hard code it for now then.
<stepcut>
I am not ready to learn camlp4 yet
<stepcut>
and there are only two cases :)
<whee>
heh
TachYon has quit [Remote closed the connection]
<stepcut>
but in theory, it code grow to several cases
<whee>
someone went and wrote a camlp4 extension that can do what you want, I remember seeing it on the mailing list
<whee>
or maybe c.l.functional
<stepcut>
alright, I made a function so I only have to change one place if I add more constructors :)
<stepcut>
is there a function composition builtin to ocaml? so I can do ((f . g . h) x) instead of (f (g (h x))) ?
<whee>
nope
<whee>
also a quick fix with camlp4, though :)
<stepcut>
I should learn camlp4 sometime
<whee>
it's not too hard to pick up, and it's worth it
<stepcut>
excellent
<Riastradh>
Can't you just do: let (.) f g = function x -> f (g x) ?
<Riastradh>
Oh...I see you can't.
<Riastradh>
Of course, you could always just use another syntax for function composition.
systems has quit ["Client Exiting"]
<stepcut>
I just wanted to know if there was a builtin one -- it would confuse people if there was a builtin and I was using a homebrew instead ...
stepcut has quit ["home."]
<Smerdyakov>
SML has o as an infix operator for composition :P
<Kinners>
is the byte code compiler written entirely in C?
lament has joined #ocaml
mattam has quit ["zZz"]
palomer has joined #ocaml
<palomer>
:o
<palomer>
where do I got gtk for ocaml?
<palomer>
gtk2 that is
<palomer>
my first foray into gtk:o
<Kinners>
same place that has gtk1 for ocaml :)
<palomer>
:o
<palomer>
it's beta!
Kinners has left #ocaml []
TachYon has joined #ocaml
mattam has joined #ocaml
usander has joined #ocaml
TachYon has quit [Remote closed the connection]
lament has quit [Remote closed the connection]
foxster has joined #ocaml
xtrm has quit [Read error: 60 (Operation timed out)]
lam_ has joined #ocaml
xtrm has joined #ocaml
<mrvn>
Debian unstable has lablgtk2 packages for most archs already.
systems has joined #ocaml
Kinners has joined #ocaml
Kinners has left #ocaml []
systems has quit [Read error: 60 (Operation timed out)]
Kinners has joined #ocaml
systems has joined #ocaml
TachYon26 has joined #ocaml
systems has quit [Read error: 110 (Connection timed out)]
mrvn_ has joined #ocaml
mrvn has quit [Read error: 110 (Connection timed out)]
systems has joined #ocaml
lam has quit [Ping timeout: 14400 seconds]
TachYon26 has quit [Read error: 60 (Operation timed out)]
systems has quit ["Client Exiting"]
Kinners has left #ocaml []
usander has quit ["using sirc version 2.211+KSIRC/1.2.1"]
systems has joined #ocaml
TachYon26 has joined #ocaml
systems has quit ["Client Exiting"]
mattam has quit ["leaving"]
TachYon26 has quit ["bez ki³y nie ma zaliczenia (z prawd studentek AM)"]
karryall has quit ["tcho!"]
mattam has joined #ocaml
Krystof is now known as K_feast
systems has joined #ocaml
mattam has quit [brunner.freenode.net irc.freenode.net]
mrvn_ has quit [brunner.freenode.net irc.freenode.net]
lam_ has quit [brunner.freenode.net irc.freenode.net]
mattam has joined #ocaml
mrvn_ has joined #ocaml
lam_ has joined #ocaml
systems has quit ["Client Exiting"]
polin8 has quit ["Lost terminal"]
polin8 has joined #ocaml
Smerdyakov has quit []
mellum has quit [Read error: 110 (Connection timed out)]