thedark has quit [Read error: 60 (Operation timed out)]
foxster has quit [Connection timed out]
mattam has quit [Read error: 113 (No route to host)]
stefp has quit [Remote closed the connection]
stefp has joined #ocaml
asqui has joined #ocaml
asquii has joined #ocaml
asqui has quit [Read error: 60 (Operation timed out)]
asquii is now known as asqui
__DL__ has quit [Remote closed the connection]
__DL__ has joined #ocaml
lament has joined #ocaml
__DL__ has quit [Remote closed the connection]
__DL__ has joined #ocaml
__DL__ has quit [Remote closed the connection]
asqui has quit [Connection timed out]
Vincenz has quit []
Kinners has joined #ocaml
Smerdyakov has quit ["sleep"]
Kinners has quit [Read error: 54 (Connection reset by peer)]
foxster has joined #ocaml
stepcut has joined #ocaml
mattam has joined #ocaml
reltuk has quit [Read error: 104 (Connection reset by peer)]
reltuk has joined #ocaml
jdrake has quit ["Oops. This machine just fell asleep"]
Yurik has quit ["Client exiting"]
stefp has quit [Read error: 60 (Operation timed out)]
Yurik has joined #ocaml
stefp has joined #ocaml
axolotl is now known as wax
lament has quit ["I WILL NOT DEMAND WHAT I'M WORTH"]
d-charlie has joined #ocaml
reltuk has quit [Read error: 54 (Connection reset by peer)]
reltuk has joined #ocaml
__DL__ has joined #ocaml
systems has joined #ocaml
systems has quit [Client Quit]
exa has quit [Read error: 104 (Connection reset by peer)]
examachine has joined #ocaml
TachYon26 has joined #ocaml
docelic|sleepo is now known as docelic
asqui has joined #ocaml
d-charlie is now known as d-bug
wax has quit [Remote closed the connection]
wax has joined #ocaml
wats`8| has joined #ocaml
wats`8| is now known as lus|wazze
mattam_ has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
Smerdyakov has joined #ocaml
Smerdyakov has quit [Client Quit]
stefp has quit [Read error: 110 (Connection timed out)]
Smerdyakov has joined #ocaml
Smerdyakov has quit [Client Quit]
Smerdyakov has joined #ocaml
lus|wazze has quit ["Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Univ]
lus|wazze has joined #ocaml
d-bug has left #ocaml []
<async>
can you specify the type in a Hash table?
<async>
when i do let clients = Hashtbl.create 10 I get a "contains type variables that cannot be generalized" error
<__DL__>
you can allways specify the type of anything :
<__DL__>
let (lcients : bla Hashtbl.t) = ....
Smerdyakov has quit [Read error: 113 (No route to host)]
stefp has joined #ocaml
polin8_ has quit [Remote closed the connection]
Smerdyakov has joined #ocaml
pattern_ has quit ["..."]
Smerdyakov has quit ["why you break, internet?"]
Smerdyakov has joined #ocaml
giedi has joined #ocaml
TachYon26 has quit [Remote closed the connection]
Smerdyakov has quit ["shopping"]
TachYon has joined #ocaml
stefp has quit [Read error: 110 (Connection timed out)]
wax has quit [Remote closed the connection]
stefp has joined #ocaml
stepcut has quit ["work"]
pattern_ has joined #ocaml
rpw has joined #ocaml
rpw has quit [Remote closed the connection]
Smerdyakov has joined #ocaml
TachYon has quit [Remote closed the connection]
rpw has joined #ocaml
Smerdyakov has quit [Read error: 113 (No route to host)]
Smerdyakov has joined #ocaml
rpw has quit [Remote closed the connection]
<Smerdyakov>
Brief ad: People who code for fun might want to check out #hprog and http://www.hprog.org/ . Thank you. :-)
rpw has joined #ocaml
thedark has joined #ocaml
rpw_ has joined #ocaml
rpw has quit [Remote closed the connection]
emu has joined #ocaml
taw has joined #ocaml
<taw>
hello ^^
<taw>
anybody tried to use ocaml for server-side www programming ?
<Smerdyakov>
No, but SML.
<taw>
can it be linked with apache somehow ?
<taw>
something more efficient than naive cgi ?
<taw>
mostly database connection reuse
<Smerdyakov>
I made a separate server and communicated with it via mod_proxy.
<taw>
mmm
<taw>
is this efficient way ?
<Smerdyakov>
I don't know, but I had a working system with a cool SML-based web template language. :-)
<Smerdyakov>
And then I decided to switch to using existing CGI Wiki software.
<taw>
i'm trying to get really extreme performance ^^
<Smerdyakov>
I don't think anyone's invested in making such a system yet, though of course it would be superior to most things in use today with a little effort.
<taw>
yes
<taw>
ocaml would be much faster than php/perl/etc if it had database connection reuse and a few other tricks
<Smerdyakov>
I made my system in a pretty funny way. I compiled the dynamic pages into SML modules and had the daemon recompile itself and hand off the listening socket to a new version that it started. :-)
<taw>
hmm
<taw>
linking it with php/perl would work too
<taw>
they would take care of database connections
<taw>
and ocaml would do heavy stuff
<taw>
is it possible to use ocaml like that ?
<Smerdyakov>
Statically typed functional languages would be better for all web stuff, though :P
<taw>
better than c, that's sure ;)
<Riastradh>
If OCaml or SML had a syntax for XML representation similar to s-expressions I'd use 'em for web development.
<taw>
tried camlp4 ?
<Smerdyakov>
Tried the stuff that Benjamin Pierce works on?
<Riastradh>
No, but from what I've seen of it it's really ugly.
<Riastradh>
And kind of hard to understand.
<Riastradh>
No, Smerdyakov.
<Smerdyakov>
Well, his group has been working on XML processing languages for a while now.
<Smerdyakov>
You ought to check it out, if you're into that stuff.
<Riastradh>
Where can I find out about it
<Riastradh>
?
<Smerdyakov>
Search for Benjamin Pierce :-)
<thedark>
can someone have a look at a short (15 lines) function i wrote, i cant figure out what is bugging :(
<taw>
sure, flood it here
<thedark>
let table_representants c =
<thedark>
let rep:representant = {rep= vecteur_of_ints (Array.make (longueur c) 0);poidsmin=0 }in
<thedark>
let table= Array.make (1 lsl (longueur c)) rep in
<thedark>
let temp = (vecteur_of_ints(Array.make (longueur c) 0)) in
<thedark>
let j = ref 0 in
<thedark>
for i = 1 to (1 lsl (longueur c)) do
<thedark>
while (get temp !j)=F2.one do
<thedark>
set temp !j F2.zero;
<thedark>
j:=!j+1
<thedark>
done;
<thedark>
set temp !j F2.one;
<thedark>
table.(i).rep = temp;
<thedark>
table.(i).poidsmin = poids temp
<thedark>
done;
<thedark>
table;;
<thedark>
this function aims to create an array, containing binary representations of ints, and the number of '1' used for each representation
<taw>
mmm
<taw>
that's french ;)
<thedark>
basically, in the 7th field of the array there should be '0000111' and '3'
<thedark>
well that is, but i can translate things in english:)
<taw>
more serious problem is that i don't know what are these french functions you use
<taw>
like vecteur_of_ints, longueur
<thedark>
well i can explain it too
<thedark>
val vecteur_of_ints : int array -> vecteur
<thedark>
longueur = length
<taw>
of Array ?
<thedark>
nope, of a vecteur
<taw>
i don't like this "1 to (1 lsl (longueur c))"
<taw>
it's going to grow real fast, not ?
<thedark>
taw; yes
<thedark>
oh, and last thing : the function is failing with "Exception: Invalid_argument "Array.get"."
<taw>
oh
<taw>
is it off by one maybe ?
<taw>
of course ^^
<thedark>
the only array.get i'm doing is "while (get temp !j)=F2.one do "
<taw>
for i = 0 to ((1 lsl (longueur c))-1) do
<taw>
mmm
<taw>
table.(i).
<taw>
looks quite like that
<thedark>
hmm u'r right.. i'm trying it with the '-1'
<thedark>
still the same problem
<taw>
does it fail on get temp !j ?
<taw>
replace code you suspect with (try X with _->failwith "I'm here !") ;)
<taw>
where X is suspected code
<thedark>
ok
<taw>
does it really fail there
<taw>
temp has size (longueur c), you increase j (1 lsl (longueur)) times
<taw>
why should it work ;) ?
<thedark>
Exception: Failure "i'm here".
<thedark>
so it fails on the (get temp !j)
<taw>
yeah ^^
<taw>
but why do you think it could possibly work ?
<thedark>
well i designed it too work:)
<taw>
you increase j at least once per iteration
<taw>
with exception of maybe first one
<thedark>
whoops, what an idiot
<taw>
anyway, try being more functional next time
<taw>
coding ocaml as if it was c++ gets you as many bugs as with c++ ;)
<Riastradh>
I told him to be more functional yesterday and he didn't change anything.
<taw>
relax, it takes some time ;-)
<thedark>
well i cant figure out how to do this in a functional way :(
jao has joined #ocaml
<taw>
and what is it that you want to do ?
<Riastradh>
Why don't you use lists?
<thedark>
taw: i want an array, and at the nth case of the array, i want the binary representation of n, and the number of 1's in this representation
<taw>
mmm
<thedark>
Riastradh: i've tried, and failed :( but maybe i should try again
<taw>
what ;) ?
<taw>
you want to take an integer
<taw>
and convert it to binary representation ?
<mellum>
In which way is the binary representation of n different from n?
<taw>
you want to get array of bits of n ?
<thedark>
mellum: what i call binary representation is an array of 0's and 1's
<thedark>
taw: yes
<mellum>
Hmm. Seems pretty useless. Recalculating the nth bit on the fly is much cheaper.
<thedark>
mellum: thats what my function is doing .. or at least should be doing
<taw>
let get_bit_nr n s = (n lsr s) land 1
<taw>
not ?
<thedark>
what for?
<thedark>
i cant understand it, let me find the 'land' keyword :)
<taw>
that function get s-th bit of n
<taw>
land = logical and
<thedark>
ok:)
<taw>
lsr = logical shift right
<Riastradh>
Is there an arithmetic shift operator?
<mellum>
n and s are bad parameter name choices... everybody would bet it gets the nth bit of s
<mellum>
Riastradh: yes
<Riastradh>
What is it? >>? asl? ...heh, asl.
<mellum>
Riastradh: well, asl wouldn't make a lot of sense
<taw>
let int_to_bitarray c = Array.mapi (fun a _ -> get_bit_nr c a) (Array.create 32 0);;
<taw>
this function will do the same as yours ;)
<taw>
mellum: whatever ^^
<thedark>
taw: i'll hit u back in 10 minuts when i'll have understound ur function :)
<taw>
using mapi is probably not the most efficient way ^^
<mellum>
I think there's also an array constructor that directly takes an initializing function, which might be easier
<taw>
probably, but i'm ruby guy and i think in terms of .each_with_index ^^
<Riastradh>
let int_to_bitarray c = Array.init 32 (fun a -> get_bit_nr c a)
<mellum>
let int_to_bitarray c = Array.init 32 (get_bit_nr c);;
<Riastradh>
...and you're not suppoed to use Array.create, anyways.
<Riastradh>
Oh, yeah, eta-reduction.
* Smerdyakov
laughs at Riastradh for his long version.
* Riastradh
has been programming in Scheme for a while!
* Smerdyakov
laughs at mellum for not doing the whole thing with function composition ;-)
<mellum>
Scheme isn't spicey enough.
<Riastradh>
And Objective-C, even worse.
<mellum>
Smerdyakov: with what?
<Riastradh>
let int_to_bitarray = compose (Array.init 32) get_bit_nr
<Riastradh>
Take that!
<taw>
mmm
<taw>
i don't like that
<mellum>
Doesn't look better to me than my version... oh well
<Riastradh>
let compose f g = fun x -> f (g x)
<taw>
mellum's version looks much saner
<Riastradh>
There must be another combinator to reduce 'compose (Array.init 32) get_bit_nr' even more...
<mellum>
Riastradh: Hey, this is not Perl :)
<Riastradh>
mellum, heh.
<thedark>
well i'm learning a lot of things tonight:) thx all
<thedark>
hmm now my function is working, but not the way i excepted :( if table is an array table.(i) = foo will affect it, right?
<Riastradh>
table.(i) <- foo (* that's how you assign values in the array *)
<taw>
why do you want to do that anyway ;) ?
<taw>
be functional
<Riastradh>
Indeed. Be thou more functional, knave!
<thedark>
i need a function returning an array..
<Riastradh>
Array.make.
<thedark>
do u mean i should use a function to initialize my array?
<Riastradh>
Array.make size init (* makes an array of 'size' with all cells filled with 'init' *)
<taw>
try keeping all non-functional elements contained inside functional functions
<__DL__>
Array.init is inteersting to
<Riastradh>
If you want cell-specific initialization, use Array.init -- Array.init size f (* makes an array of 'size,' whose cells are filled by calling 'f' on the index of each cell *)
<thedark>
oh:) array.init seems to be what i want:) thx :)
TachYon has joined #ocaml
<thedark>
whats wrong with this :
<thedark>
let tableinit i =
<thedark>
let temp = vecteur_of_ints(int_to_bit_array i (longueur c)) in
<thedark>
let r:representant = {rep= temp;poidsmin=poids temp }in
<thedark>
r
<thedark>
i want it to return a representant, and it returns a function
<taw>
mmm
<thedark>
val tableinit : int -> representant = <fun>
<Riastradh>
Um, yeah, you have to call tableinit to return a representant.
<thedark>
table= Array.make (1 lsl (longueur c)) tableinit returns me an array of functions ...
jao has left #ocaml []
lus|wazze has quit ["Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Univ]
lus|wazze has joined #ocaml
Smerdyakov has quit ["eating"]
rpw has joined #ocaml
rpw_ has quit [Remote closed the connection]
<taw>
bye
taw has left #ocaml []
pnou has quit [Read error: 54 (Connection reset by peer)]
<thedark>
Riastradh: theres still something i dont understand there : tableinit returns a function, and with array.make i get an array of functions instead of an array of representants....
rpw has quit [Remote closed the connection]
giedi has quit ["Client Exiting"]
TachYon has quit [Remote closed the connection]
<Riastradh>
thedark, how do you figure that tableinit returns a function?
<lus|wazze>
actually it doesnt, he posted the type of tableinit earlier and it was int -> something where something was the type he wanted it to return ...
<Riastradh>
And also by calling Array.make on tableinit, of course it returns an array of functions -- Array.make size init makes an array with a size of 'size' and whose elements are initialized to the value of 'init' -- you no doubt meant to use Array.init.
<Riastradh>
Zigackly, lus|wazze.
<thedark>
Riastradh: i've found my error, i was using array.make instead of array.init
Smerdyakov has joined #ocaml
examachine is now known as exa
docelic has quit [Read error: 104 (Connection reset by peer)]
docelic has joined #ocaml
docelic has quit [Read error: 104 (Connection reset by peer)]