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/
<walters> __DL__: thanks!
<walters> __DL__: how is the speed?
<__DL__> I've never try it.
<__DL__> don't know
<__DL__> (but it quite similar to buffer)
<walters> k
jdrake has quit ["Read Error 69 (Connect reset by sex)"]
lus|wazze has quit ["Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Unive"]
jdrake has joined #ocaml
docelic is now known as docelic|sleepo
jao has left #ocaml []
mattam has quit ["leaving"]
__DL__ has quit [Read error: 110 (Connection timed out)]
<walters> is there a way i can partially match a record?
<walters> like let {topics=topics,...} = myrecord in...
<walters> or something?
<walters> maybe i am thinking of SML.
<Smerdyakov> That is indeed how you do it in SML.
<walters> no way to do it in ocaml?
<walters> er, wait, i could just do myrecord.topics.
<walters> nevermind :)
__DL__ has joined #ocaml
Kinners has left #ocaml []
Smerdyakov has quit []
giedi has joined #ocaml
reltuk has quit ["reformatin'"]
giedi has quit [Remote closed the connection]
stepcut has joined #ocaml
<stepcut> are there any mmap libraries that work with Ocaml 3.06?
lament has joined #ocaml
Kinners has joined #ocaml
mattam has joined #ocaml
polin8 has quit [Remote closed the connection]
polin8 has joined #ocaml
gene9 has joined #ocaml
polin8_ has joined #ocaml
polin8 has quit [Read error: 110 (Connection timed out)]
d-bug has joined #ocaml
stef_ has joined #ocaml
stefp has quit [Read error: 110 (Connection timed out)]
docelic|sleepo is now known as docelic|away
Kinners has quit [Read error: 104 (Connection reset by peer)]
lament has quit ["I WON'T NOT USE NO DOUBLE NEGATIVES"]
walters has quit ["H-Dog OUT!"]
jdrake is now known as jdrake`bed
foxster has quit [Read error: 104 (Connection reset by peer)]
reltuk has joined #ocaml
Kinners has joined #ocaml
thedark has joined #ocaml
<thedark> can someone have a quick look at one of my function and tell me if its correct ?
<Kinners> I'll accept the challenge
reltuk has quit []
<thedark> in 'if (v.get i) = 1 then p:=!p+1' ocaml says v.get is unbound, and get is val get : vecteur -> int -> F2.carrier .. ideas?
<__DL__> you mean (get v i) not (v.get i)
<__DL__> (if get is what you told us)
<thedark> ok
<thedark> thx :)
<thedark> well it's very weird, my code is
<thedark> let poids v:F2Lin.vecteur = let p = ref 0 in
<thedark> for i = 0 to v.longueur do
<thedark> if (get v i) = 1 then p:=!p+1 done; p
<thedark> ocamp is complaining that v has type codecorrecteur and is used with type F2Lin.vecteur
<Kinners> for the get v i line?
<thedark> yes
<__DL__> does the type codecorrecteur have a fiels named longueur ?
<thedark> __DL__ : yes
<__DL__> so you should try v.F2Lin.longueur
<__DL__> the problem is that ocaml dones't like when two record have the same name for fields
<thedark> it says F2Lin.longueur is unbound
<__DL__> its " v.F2Lin.longueur " not F2Lin.longueur (in place of v.longueur)
<thedark> yes, i've done this, and it says Unbound record field label F2Lin.longueur
<__DL__> can I see the deffinition of the vecteur type ?
<thedark> u cant : i've just been provided with the F2Lin interface file
<__DL__> the one you can have by making module M = F2Lin
<__DL__> (in a top level)
<thedark> sig
<thedark> type vecteur = F2Lin.vecteur
<thedark> val vecteur_of_ints : int array -> vecteur
<thedark> val ints_of_vecteur : vecteur -> int array
<thedark> val vecteur_of_array : F2.carrier array -> vecteur
<thedark> val map_vecteur : (F2.carrier -> F2.carrier) -> vecteur -> vecteur
<thedark> val longueur : vecteur -> int
<thedark> val get : vecteur -> int -> F2.carrier
<thedark> val set : vecteur -> int -> F2.carrier -> unit
<thedark> end
<thedark> (ive removed some functions, so that this is not 50 lines long
<__DL__> ok, It what I think : when you do a v.lounger it mean that v is a record type. It donest seem to be the case Here
<__DL__> to call a function, you should do :
<__DL__> F2Lin.longueur v not v.longeur
<thedark> ok, i give it a try
<thedark> it's working, thx a lot for the hints
<__DL__> by the way, what you have given is the module definition. THe type definition is only the "type vecteur = F2Lin.vecteur" line
<thedark> ok
stef_ is now known as stefp
d-bug has quit ["bbl"]
reltuk has joined #ocaml
gene9 has quit [Read error: 54 (Connection reset by peer)]
systems has joined #ocaml
<thedark> i want to create an array containing lists from " 0 0 0 0" to "1 1 1 1" (so thats a 16 items array) .. how can i do this?
d-bug has joined #ocaml
<__DL__> you have to count in binarys
<thedark> i know, but what's the best way to do that?
<__DL__> frankly, it look like homework, And I don't like to awser to something which look like homework...
<__DL__> (but you have to learn to add one, and then you can count)
<thedark> i'm trying to implement CRC's in ocaml
<__DL__> it is not already done somewhere ?
<thedark> well that's homework... but doing it in ocaml is not homework
<thedark> i could have done this in 1 hour in C... but i want to learn ocaml
<__DL__> then my anser is still : " you have to learn to add one, and then you can coun"
<__DL__> (with the t for count)
<__DL__> (best to learn by trying)
<thedark> so i'll reformulate my question to get the answer i want: would u use imperative or recursive style in order to do this?
systems has quit [Read error: 110 (Connection timed out)]
Kinners has quit [Read error: 60 (Operation timed out)]
<__DL__> Probably recursive, but I do everything recursivly
<thedark> ok
<thedark> another question : is it possible to do grapical things with camel? for example, is there a xlib or a SDL for ocaml?
<__DL__> there is ocamlsdl, lablgtk labtk, lablgl, xlib and some others...
<thedark> ok:)
mattam_ has joined #ocaml
mattam has quit [Read error: 60 (Operation timed out)]
cfork has joined #ocaml
cfork has quit ["doing assignment... I wish"]
<thedark> if i write "let table = Array.make 2^8 0 in", will i be able to put any kind of things in this aray? or just integers?
<__DL__> just integers
<thedark> how do i tell the kind of things i want to put in the array?
<__DL__> by giving one at construction time
<thedark> for example i've defined a type rep = { foo.... }, and want an array of rep.. do i write let table= Array.make n rep ?
<__DL__> you have to give a object of type rep to Array.make
<thedark> so " let r:rep in let table=Array.make n r in" ?
<__DL__> well, for example
<__DL__> (you don't have to explictly give the type of are if it is already known)
<thedark> what?
<__DL__> (stupid program that automaticly trasform "r" into are
<__DL__> )
<thedark> oh ok
mattam_ is now known as mattam
d-bug has quit [Read error: 104 (Connection reset by peer)]
d-bug has joined #ocaml
d-bug has quit [Read error: 104 (Connection reset by peer)]
<thedark> whats wrong with this : "let r: rep in let table = Array.make 50 r in table.1.age=1 table.1.size=2 " ?
<__DL__> oh, well. You have to have an something of type rep. There is nothing there. YOu just say r is of type rep, but you didn't give any value, there have to be one
<__DL__> plus it is table.(1), the ( ) are mandatory
<thedark> i feel like i'm misunderstanding the whole langage :(
<__DL__> well. It s not so easy.
<__DL__> By the way, are you french ?
<thedark> yes
<thedark> is my english so awfull?:)
<__DL__> non, mais je viens de faire un whois et je me suis dis, nerim, tiens ça me dis qqc
<thedark> je vois:)
<thedark> bah ton whois me dit kkc aussi :)
d-bug has joined #ocaml
<thedark> btw, j'ai décidé de me mettre a ocaml, et j'espere que ca va etre payant dans qulques mois parcke pour le moment, c'est pas évident
<__DL__> l'ider, pour un tableu, c'est qu'il doit être initialisé.
<thedark> bah let r: rep in, ca dit que r est de type r
<thedark> et table=array.make 50 r in ca dit que table est un tableau contenant 50 elements du type de r, donc de type rep ... non?
<__DL__> ça ne dis pas ce que vaut r, il faut lui donner une valeur a ce r
<thedark> hum ok
<__DL__> Il n'y a pas de valeur non initialisé en caml
<thedark> donc r.foo = 0 par ex?
<__DL__> non, plutot let r = { foo = 0; bar = 0; kux="tre"}
<__DL__> (j'ai oublier le in)
<thedark> ok
<thedark> a quoi il sert le in au fait? je vois pas de cas ou on le met pas...
<thedark> en fait je suis en maitrise d'info, et le dess que je veux faire l'an prochain est plein de camel, donc il faut que j'aprenne:)
Smerdyakov has joined #ocaml
<__DL__> thedark: on a pas besoin du in pour definir des valeur de toplevel (c'est a dire les valeur qui peuvent êrte utilisé de l'exterieur du module courant (entre autre))
<thedark> par défaut les variables sans in sont globales donc?
<__DL__> oui
<thedark> ok
<__DL__> au fait, a tu regarder ça : http://www.pps.jussieu.fr/Livres/ora/DA-OCAML/index.html ?
<thedark> je suis dessus en ce moment:)
<__DL__> ok :)
smklsmkl is now known as smkl
<thedark> __DL__: can u have a quick look at my code, i cant understand my mistakes ...
<thedark> foo n t = match t with
<thedark> |0 -> []
<thedark> |t -> if n => 2^t then [1]::foo (n - 2^t) (t - 1) else [0@::foo n (t-1)
<karryall> ^ est la concaténation de strings
<karryall> pas ce que tu veux je pense ...
<thedark> mais tout le monde parle francais ici? (en effet, je veux la puissance)
<karryall> ** est l'exponentiation mais c'est pour les flottants
<karryall> 2. ** 3. donne 8.
<thedark> ok:) merci
<karryall> mais là tu peux faire un shift
<karryall> 1 lsl t ;;
<thedark> oki
<thedark> et pour le reste?
<karryall> pour => je pense que tu voulais dire >=
<thedark> oui:)
<karryall> ensuite pour les ::
<karryall> à gauche il faut mettre un élément
<karryall> à droite le reste de la liste
<karryall> donc là ça pas parce que tu mets des listes à droite et à gauche
<thedark> bah non j'en mets qu'a gauche la non?
<karryall> ben justement, faut pas
<karryall> enfin ça depends
<karryall> tu veux quoi comme résultat un "int list" ou in "int list list"
<thedark> 1 lsl t c pareil que 2^t ? ya pas une histoire d'effet de bord (0 lsl t, 2 lsl t ...) ?
<thedark> jveux une liste d'entiers
<karryall> alors c'est 0 :: (foo truc bidule)
<__DL__> je pense que le pb, c'est qu'il afut mettre 1::(foo ...) et non [1]::(foo ...)
<thedark> ok merci:)
<__DL__> je vous laisse a+
<thedark> ++
samx has joined #ocaml
Vincenz has joined #ocaml
giedi has joined #ocaml
systems has joined #ocaml
<thedark> how do i create an array of n ints initalized to 0 ?
<karryall> Array.make n 0
<thedark> thx:)
<systems> hehe
systems has quit ["Client Exiting"]
<thedark> can someone explain me what carrier is ? i have a function val set : vecteur -> int -> F2.carrier -> unit
<thedark> and i cant figure out how to use it :( set v 0 1 will say 1 is not of type F2.carrier
<__DL__> I've no idea. What is this library you use ?
<thedark> its definition (of the library) starts with type carrier = int ..
<samx> it would sound like F2.carrier is an abstract type.. are you sure the "= int" is in the interface, and not just the implementation?
<thedark> its just in the implementation
<thedark> the interface just says "type carrier"
<samx> ok, then you can't constuct it straight, but need to use some function provided by the interface to construct one
<thedark> ok:) i c:) thx
<thedark> set is "val set : vecteur -> int -> F2.carrier -> unit" and when i do " set v 1 F2.zero" it says set has too many args .. ideas?
<samx> you have a semicolon in the end of the line?
<thedark> no . do i need one?
<thedark> i cant figure out where , are needed and where they arent..
<samx> that is "set v 1 F2.zero;".. if you have some expression after it, then yes
<thedark> ok:) thx
<samx> but yeah.. i agree the syntax is a bit of a pain in the ass, but you get used to it after a while
<thedark> this ; (or something else) causes other problems :
<thedark> | t -> if n >= 1 lsl t then set v t F2.one;
<thedark> binary_from_int (n - (1 lsl t)) (t-1)
<thedark> else set v t F2.zero;
<thedark> binary_from_int n (t-1) ;;
<thedark> this will return me a syntax error on the "else"
<samx> put the expression sequences in brackets.. that is, if ... then (.....) else (....)
stepcut has quit []
<thedark> okay, it works:) thx
<thedark> what can causes Exception: Invalid argument "Array.set" ? does it mean i'm trying to access the array out of bound, or that i'm trying to put something of the wrong type in it?
<__DL__> it is an out of bound acces.
<__DL__> tape safety tell us that you can't put something of the wrong type in it, so there is no exception for this
giedi has quit ["Client Exiting"]
<thedark> thats i've thought, but i cant understand why my access is out of bound :(
<thedark> can i flood u a bit with french stuff, maybe my error will sound obvious to you ...
<samx> go ahead
<thedark> let v:F2Lin.vecteur = vecteur_of_ints (Array.make t 0) in
<thedark> set v (t+1) F2.one
<thedark> * vecteur_of_ints prend un tableau OCaml d'entiers et renvoie un
<thedark> * vecteur dont les éléments sont les images modulo 2 de ces entiers
<thedark> * ints_of_vecteur prend un vecteur d'éléments de F2 et renvoie un
<thedark> * tableau OCaml de ces éléments vus comme entiers
<thedark> val vecteur_of_ints : int array -> vecteur
<thedark> * set v i value modifie le vecteur v en place en remplaçant
<thedark> * l'élément d'indice i par la valeur value donnée en paramètre
<thedark> * Les indices commencent à 0.
<thedark> val set : vecteur -> int -> F2.carrier -> unit
<thedark> the first 2 lines are what i'm doing, the other ones are the function definitions ... with t instead of t+1 i've the same bug
<samx> an array of length t has indexes from 0 to t-1
<thedark> i see ...
<samx> so, if you try to access index t, of t + 1, you'll be out of bounds
<thedark> ok
jdrake`bed has quit [Read error: 60 (Operation timed out)]
lus|wazze has joined #ocaml
<thedark> whats wrong with this,ocaml tells me the "p" on the last line is used with type F2Lin.vecteur instead of type int
<thedark> let poids v:F2Lin.vecteur = let p = ref 0 in
<thedark> for i = 0 to F2Lin.longueur v do if (F2Lin.get v i) = F2.one then p:=!p+1 done;
<thedark> p
<lus|wazze> you explicitly declared the return value type of poids as F2Lin.vecteur
<lus|wazze> and then return an int ref
d-bug has quit []
<lus|wazze> i suppose what you WANTED to do was explicitly declare the type of the argument v as F2Lin.vecteur
<lus|wazze> therefore you should make that say
<lus|wazze> let poids (v : F2Lin.vecteur) = etc
<thedark> so i just miss the ( ) for the argument ?
<lus|wazze> yep
karryall has quit ["ERC vVersion 3.0 $Revision: 1.328 $ (IRC client for Emacs)"]
<thedark> another problem looking similar : let aux_distancemin g:F2lin.matrice a b = tells me unbound type constructor F2Lin.matrice .. what have i done wrong ?
__DL__ has quit [Remote closed the connection]
<lus|wazze> i think the module you want to refer to is called F2Lin
<lus|wazze> not F2lin
<thedark> now with let aux_distancemin g:F2Lin.matrice a b = i've got an unbound type constructor b (a and b are intended to be ints)
d-bug has joined #ocaml
gene9 has joined #ocaml
<mattam> use parenthesis...
<thedark> yep i've figured it out..
<thedark> but still i cant understand why :(
gene9 has quit [Read error: 104 (Connection reset by peer)]
<lus|wazze> because when you don't enclose it in parentheses, it thinks the type specification returns to the return type of the function
<thedark> ok
<lus|wazze> refers that is
__DL__ has joined #ocaml
exa has joined #ocaml
<exa> how to access record fields in another module that you haven't opened?
<exa> i always forget this, please help :(
<Riastradh> record_obj.ModuleName.record_field
<exa> ah that easy!
<exa> thanks Riastradh
* exa bows gracefully
docelic|away is now known as docelic
d-bug has quit ["night"]
two-face has joined #ocaml
<two-face> hi
<Riastradh> Hi.
lus|wazze has quit ["Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Univ]
tschuldigungts has joined #ocaml
samx has left #ocaml []
tschuldigungts is now known as lus|wazze
Smerdyakov has quit ["brb"]
Smerdyakov has joined #ocaml
<thedark> do i have to specify the name of the module of a type if this type has been defined in the current file?
<two-face> no
<thedark> so can u explain this :
<thedark> type code_correcteur = | lot of things here |
<thedark> let code (u:F2Lin.vecteur) (C:code_correcteur) = mult_vect_mat u C.generatrice
<thedark> i get a unbound constructor C message
<two-face> because C.generatrice
<two-face> what's the "." ?
<Riastradh> No, because of (C:code_correcteur), if 'type code_correcteur = | ... |' doesn't contain C in the ...
<thedark> ok
<thedark> more funny things follows
<thedark> This expression has type code_correcteur but is here used with type
<thedark> code_correcteur
<Riastradh> That (C:code_correcteur) tries to match C as a constructor for code_correcteur.
<Riastradh> ...er.
<Riastradh> I'm just as confused as you are on that one.
<thedark> Riastradh: it works perectly with 'c' insted of 'C'
<Riastradh> Yes, because C looks like a constructor to OCaml.
<thedark> oh ok, i didnt know that.. what about my "
<thedark> This expression has type code_correcteur but is here used with type code_correcteur
<Riastradh> I haven't the faintest idea.
<thedark> i'm a little piqued :(
<Riastradh> Why are you using type annotations in the function definition?
<Riastradh> Why don't you put them in the module's interface?
<thedark> i shouldnt?
<Riastradh> Generally they're put in the module's interface.
<thedark> ok. it works fine without it
<two-face> bye
two-face has quit ["Client exiting"]
TachYon has joined #ocaml
foxster has joined #ocaml
karryall has joined #ocaml
TachYon has quit [Remote closed the connection]
<thedark> i have a recursive function doing accesses to an array, and i dont know how to return this array. ideas?
<Riastradh> Um, put the array at the place where the function returns.
<thedark> do u want to have a look at my function?
<Riastradh> OK.
<thedark> let rec binary_from_int n t =
<thedark> let v:F2Lin.vecteur = vecteur_of_ints (Array.make t 0) in
<thedark> match t with
<thedark> 1 -> if n = 1 then set v 0 F2.one else set v 0 F2.zero;
<thedark> | t -> if n >= 1 lsl t then (set v (t-1) F2.one;
<thedark> binary_from_int (n - (1 lsl t)) (t-1))
<thedark> else (set v (t-1) F2.zero;
<thedark> binary_from_int n (t-1)) ;;
<thedark> right now it has type unit.. and i want it to return an array of hint
<Riastradh> Remove one semicolon from the last line.
<Riastradh> Er, I think you may have to surround the 'match' with parentheses.
<Riastradh> Then put the last semicolon outside of them, and, on another line, put the array.
<thedark> wont work
<Riastradh> Show me it now as you have made my modifications.
<thedark> says the huge thing (match....) is not a function
<thedark> let rec binary_from_int n t =
<thedark> let v:F2Lin.vecteur = vecteur_of_ints (Array.make t 0) in
<thedark> ( match t with
<thedark> 1 -> if n = 1 then set v 0 F2.one else set v 0 F2.zero;
<thedark> | t -> if n >= 1 lsl t then (set v (t-1) F2.one;
<thedark> binary_from_int (n - (1 lsl t)) (t-1))
<thedark> else (set v (t-1) F2.zero;
<thedark> binary_from_int n (t-1)))
<thedark> v ;;
<Riastradh> Put a semicolon after the last parenthesis after the 'match'.
<thedark> still not working.. i will need an auxiliary function i see
<thedark> i meant i think:)
<Riastradh> There is no reason you should need one.
<Riastradh> Paste your code again.
<thedark> sometimes it returns a unit
<thedark> and sometimes it returns an array
<thedark> let rec binary_from_int n t =
<thedark> let v:F2Lin.vecteur = vecteur_of_ints (Array.make t 0) in
<thedark> ( match t with
<thedark> 1 -> if n = 1 then set v 0 F2.one else set v 0 F2.zero;
<thedark> | t -> if n >= 1 lsl t then (set v (t-1) F2.one;
<thedark> binary_from_int (n - (1 lsl t)) (t-1))
<thedark> else (set v (t-1) F2.zero;
<thedark> binary_from_int n (t-1)));
<thedark> v ;;
<thedark> i need to put the recursivity thing into another function
<Riastradh> No, you don't.
<thedark> This expression has type F2Lin.vecteur but is here used with type unit
<Riastradh> Have you declared it in a signature?
Smerdyakov has quit ["dialup makes me unhappy"]
<thedark> whi should have
<thedark> again, look at what it returns
<thedark> unit at the line 5
<thedark> and an array at the last line
<Riastradh> Perhaps the reader is somewhat indentation-sensitive -- try indenting 'v;;' with two spaces.
<Riastradh> Oh, wait.
<Riastradh> Duh, no, you're using it in the wrong context.
<Riastradh> It -does- return an F2Lin.vecteur.
<Riastradh> But all the calls to binary_from_int allocate new vectors, and those vectors are thrown away.
<thedark> on the last line yes
<thedark> but not on the fifth line
<thedark> on the 4th i mean
<thedark> 1 -> if n = 1 then set v 0 F2.one else set v 0 F2.zero;
<Riastradh> That function doesn't look like it will work anyways.
<Riastradh> The result of every single call to binary_to_int is thrown away.
<thedark> nope
<thedark> i mean yes
<thedark> but the recursive call modifies the result v with the set call...
<thedark> i think this function would work... with an axuilary one.. thats what i'm gonna do:)
<Riastradh> No, it won't, because binary_to_int always makes a new vector.
<thedark> thats why i need an auxiliary function
<Riastradh> Why, though?
<Riastradh> A simple 'for' loop will suffice -- that's why they included 'for'.
<thedark> not a bad idea:)
<thedark> my goal is to generate all the combinations betwwen "000000000" and "1111111111"... or to count in binary in other words.. ideas,
<Riastradh> Why can't you count in base 10?
<thedark> because i want to generate things from "0000000" to "1111111"
<thedark> its for implementing a CRC module
<Riastradh> OK, so write a function that increments or decrements a binary number.
<Riastradh> s/ or decrements//1
<thedark> well i'm trying to do it with ony imperative style now, hold on
<Riastradh> It can be done imperatively.
<Riastradh> ...if you represent binary numbers as arrays.
<thedark> thats what i'm doing
<Riastradh> But you're making it far more complicated than necessary.
<thedark> why?
<Riastradh> To increment, find the first bit from the right that's 0, set it to 1, and set all the bits before it to 0.
<thedark> i know that
<Riastradh> Since you're counting binary numbers, what more do you need to do?
<thedark> i need to stock them somewhere
<Riastradh> 'Stock them' somewhere?
<thedark> at the end of all my stuff, i want an array containing at the indice i the binary representation of i
<thedark> and the binary representation of i is an array of 0 and 1
<Riastradh> OK, that's not hard.
<thedark> well it's hard for me, as i dont know the ocaml langage:(
<Riastradh> Um, maybe you should learn it before trying to write this thing.
<thedark> i'm learning it by trying to write it
lus|wazze has quit ["Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Unive"]
<thedark> but i'm a little confused with the mix of imperative and functional features
<Riastradh> Why aren't you learning with something a bit simpler?
<karryall> thedark: you don't _have_ to mix them
<thedark> well i'm trying to do the whole thing with imperative code now
<karryall> with mutable datastructures (arrays), it's probably better to stay with imperative code
<Riastradh> I would advise you use the functional parts while learning.
<karryall> code is more readable and easier to understand
jdrake has joined #ocaml
Smerdyakov has joined #ocaml
__DL__ has quit [calvino.freenode.net irc.freenode.net]
rhil has quit [calvino.freenode.net irc.freenode.net]
axolotl has quit [calvino.freenode.net irc.freenode.net]
lam has quit [calvino.freenode.net irc.freenode.net]
Riastradh has quit [calvino.freenode.net irc.freenode.net]
themus has quit [calvino.freenode.net irc.freenode.net]
pnou has quit [calvino.freenode.net irc.freenode.net]
lsr has quit [calvino.freenode.net irc.freenode.net]
__DL__ has joined #ocaml
rhil has joined #ocaml
axolotl has joined #ocaml
lam has joined #ocaml
Riastradh has joined #ocaml
themus has joined #ocaml
pnou has joined #ocaml
lsr has joined #ocaml
Riastradh has quit ["Changing server"]
Riastradh has joined #ocaml
asqui has quit [Operation timed out]
<thedark> i've just done my stuff the imperative way, but ocaml says i've an error, can someone have a quick look at my function?
<thedark> Riastradh: can i paste u my function, i dont know why it wont compile :(
<Riastradh> If it's not too long.
<thedark> about 15 lines
<Riastradh> Paste it in five-line chunks, with a gap of a couple seconds in between each chunk.
<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;
<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).poids = poids (temp )
<thedark> done;
<thedark> table;;
<thedark> ocaml says i have a syntax error on the last ;;
<Riastradh> What's the 'let j = ref 0;' about?
<thedark> i use it to read the temp vector
<thedark> for adding 1 to a binary number, i have to find the first 0, and to turn it to 1 (and then to turn those before to 0) ... i'm using j for that
<Riastradh> No, no, why is there a semicolon there and not an ' in' instead?
<thedark> whooops
<thedark> well i think/home i've get it to work
<Riastradh> I continue to really suggest you use functional code, not imperative code, too.
<thedark> well i think it depends on the thing u want to do
<Riastradh> ...and if you're learning OCaml, it is generally better to focus upon the functional bits.
<thedark> well i've already focused on it a lot, so i'm trying to use a few imperative things now
<thedark> how can i get a random float between 0 and 1 ?
<Riastradh> Use the Random module, Luke!
<thedark> well i thought Rand.float 1 was what i needed, but apparently not:-
PsionV has joined #ocaml
Smerdyakov has quit [Killed (NickServ (Nickname Enforcement))]
PsionV is now known as Smerdyakov
docelic is now known as docelic|sleepo