mbishop changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | Grab Ocaml 3.10.0 from http://caml.inria.fr/ocaml/release.html (featuring new camlp4 and more!)
<maayhem> pango_, translate_program is of type (a,b) -> (c list, a)
<maayhem> a is "indices"
<maayhem> well, the type of indices
<maayhem> elist is of type b list
<maayhem> so (List.map (translate_program indices) (rev elist)) returns type (c list, a) list
<maayhem> and I just want the c list list
<pango_> List.map (fun b -> fst (translate_program (indices, b))) (rev elist) ?
<maayhem> pango_, excellent, it seems to be what I want :)
<bluestorm> i guess reasoning only on type equalities would have given you the desired function
<bluestorm> List.map : ('a -> 'b) -> 'a list -> 'b list
<bluestorm> so elist : 'a list
<bluestorm> translate_program : 'idx * 'a -> ('c list * 'idx)
<bluestorm> you want the 'c list part, so 'b = 'c list
<bluestorm> so you want your map function to be 'a -> 'c list, given a var indices : 'idx
<bluestorm> (fun a -> translate_program (indices, a)) is 'a -> 'c list * 'idx
<bluestorm> so (fun a -> fst (translate_program (indices, a))) is the only solution
<pango_> let's say it's the simplest correctly typed expression. it could still be wrong ;) (it's much like checking unit's consistency in physics: it can be helpful to detect mistakes, but not to prove that some formula is correct)
<bluestorm> hm pango_
<maayhem> bluestorm, I am still quite novice in ocaml syntax, thats why I asked for some help ..
<bluestorm> i'm not sure with the very few variables involved here
<bluestorm> that you can come up with a wrong good-typed non-obvious solution
<bluestorm> hm
<bluestorm> even obvious
<bluestorm> if you constrain the return type to be that 'c list
<bluestorm> then fst (...) is your only solution (no other 'c producing function known), and then you have to use the only 'idx value
<bluestorm> seems the function part of the List.map is uniquely determined
<maayhem> yea I knew fst had to be involved, but I didnt know the syntax fun c -> ... inside a Map
<maayhem> never used as such in the past, but now I know
buluca has quit [Read error: 113 (No route to host)]
Anarchos has quit ["went to bed"]
<bluestorm> maayhem: (fun e -> ...) are lambda expressions
<bluestorm> you can use them anywhere, not just inside Map
<bluestorm> in the toplevel for example :
<bluestorm> # fun x -> x + 1;;
<bluestorm> - : int -> int = <fun>
<maayhem> yea, just never had to use them inside Map until now ..
<bluestorm> ah
<maayhem> thanks ! bye
maayhem has left #ocaml []
dbueno has joined #ocaml
dbueno has quit ["This computer has gone to sleep"]
dbueno has joined #ocaml
postalchris has joined #ocaml
postalchris has quit [Client Quit]
nashdj has quit [Read error: 110 (Connection timed out)]
bluestorm has quit [Remote closed the connection]
middayc_ has joined #ocaml
middayc has quit [Read error: 110 (Connection timed out)]
kmeyer has joined #ocaml
thesoko has joined #ocaml
thesoko has quit [Remote closed the connection]
seafood_ has joined #ocaml
ygrek has joined #ocaml
ita has quit [Read error: 104 (Connection reset by peer)]
seafood_ has quit [Read error: 110 (Connection timed out)]
Associat0r has quit []
Associat0r has joined #ocaml
Associat0r has quit [Client Quit]
Associat0r has joined #ocaml
dbueno has quit ["Leaving"]
AxleLonghorn has joined #ocaml
__suri_ has joined #ocaml
middayc_ has quit []
__suri__ has joined #ocaml
Associat0r has quit [Success]
__suri has quit [Read error: 110 (Connection timed out)]
__suri_ has quit [Read error: 110 (Connection timed out)]
__suri__ has quit [Connection timed out]
thermoplyae has joined #ocaml
mordaunt has joined #ocaml
buluca has joined #ocaml
__suri has joined #ocaml
ygrek has quit [Remote closed the connection]
kmeyer has quit [Remote closed the connection]
kmeyer has joined #ocaml
AxleLonghorn has left #ocaml []
jderque has joined #ocaml
thermoplyae has quit ["daddy's in space"]
ygrek has joined #ocaml
Snark has joined #ocaml
ttamttam has joined #ocaml
asmanur has joined #ocaml
jderque has quit [Read error: 110 (Connection timed out)]
asmanur_ has joined #ocaml
asmanur has quit [Read error: 110 (Connection timed out)]
asmanur__ has joined #ocaml
asmanur_ has quit [Read error: 110 (Connection timed out)]
asmanur_ has joined #ocaml
_asmanur has joined #ocaml
asmanur__ has quit [Read error: 110 (Connection timed out)]
_asmanur is now known as asmanur
asmanur_ has quit [Read error: 110 (Connection timed out)]
leo037 has joined #ocaml
filp has joined #ocaml
Tetsuo has joined #ocaml
seafood_ has joined #ocaml
seafood_ has quit [Read error: 104 (Connection reset by peer)]
l_a_m has joined #ocaml
seafood_ has joined #ocaml
seafood_ has quit [Read error: 104 (Connection reset by peer)]
seafood_ has joined #ocaml
seafood__ has joined #ocaml
hkBst has joined #ocaml
seafood__ has quit [Read error: 104 (Connection reset by peer)]
seafood__ has joined #ocaml
seafood___ has joined #ocaml
pippijn_ is now known as pippijn
seafood_ has quit [Read error: 110 (Connection timed out)]
seafood__ has quit [Read error: 110 (Connection timed out)]
seafood___ has quit [Read error: 110 (Connection timed out)]
seafood_ has joined #ocaml
S1ugg0 has joined #ocaml
S1ugg0 has left #ocaml []
seafood__ has joined #ocaml
jderque has joined #ocaml
seafood__ has quit [Read error: 104 (Connection reset by peer)]
seafood_ has quit [Connection timed out]
seafood_ has joined #ocaml
bluestorm has joined #ocaml
netx has quit [Remote closed the connection]
seafood__ has joined #ocaml
leo037 has quit ["ici, de la neige. Voir photo sur mon blog :)"]
seafood_ has quit [Read error: 110 (Connection timed out)]
netx has joined #ocaml
buluca has quit [Read error: 113 (No route to host)]
Sp4rKy has joined #ocaml
<Sp4rKy> hi
<Sp4rKy> does anyone can help me with this error ?
<Sp4rKy> hmm, i found :)
<pango_> f (x,y) is not the same thing as f x y in OCaml
<pango_> f (x,y) really means send it the tuple (x,y)
asmanur has quit [Read error: 110 (Connection timed out)]
<pippijn> f x y means f(x)(y)?
<Sp4rKy> yep
<Sp4rKy> it's what i found :)
<pango_> (x) is the same as x, since there's no comma it's not a tuple
<pango_> # (5) ;;
<pango_> - : int = 5
<Sp4rKy> mhhh
<pango_> but yes, f x y is the same as (f x) y
* Sp4rKy doesn't like caml syntax ;o
* pippijn does
<Sp4rKy> ^^
<pango_> if f is a function of n arguments, n >=2, then f x is a function of (n-1) arguments
<Sp4rKy> it what it's pretty difficult to understand/apply
<Sp4rKy> (for me :)
<Sp4rKy> is there a function to compute the sum of a intl ist ?
<pango_> Sp4rKy: that's probably why you're learning it
<Sp4rKy> (mafunc [1;3;4;5]) = 13
<Sp4rKy> pango_: i'm learning it becaue i've to
<Sp4rKy> it's one of my class :)
<pango_> Sp4rKy: exactly what I'm saying, you're being taught OCaml to expand your knowledge beyond what you already know
<Snark> Sp4rKy, use List.fold_left ...
<Sp4rKy> and maybe a function to get the size of a list ? :D
<pango_> man List, or go read List.mli in libraries directory
<Sp4rKy> ok :)à
<Sp4rKy> thanks !
<pango_> s/List.mli/list.mli/ even (no capital)
<pango_> np
<pango_> and if you don't know where the library lives, 'ocamlc -where' will tell you
<Sp4rKy> I use camllight
<pango_> ah, sorry, no experience with camllight
<Sp4rKy> np, i'll search :)
<Sp4rKy> another question
<Sp4rKy> let rec moy = function l -> somme(l) / list_length(l);;
<Sp4rKy> both sommme and list_length return int
<Sp4rKy> how cani cast the result to float ?
<flux> (I wonder what makes people dive into camllight.. it's introed at some uni?-o)
<Snark> Sp4rKy, CPGE ?
<Sp4rKy> Snark: sorry ?
<Snark> Classes Préparatoires aux Grandes Écoles ?
<Sp4rKy> don't know what CPGE is
<flux> ocaml has functions float_of_int and float (which do the same thing)
<Sp4rKy> Snark: ohh , no :)
<Snark> Sp4rKy, then the answer is "no" :-)
<Sp4rKy> flux: i want the result to be real float
<Sp4rKy> ie 1/2 will return me 0
<flux> sp4rky, I suppose you want to divide floats with floats then
<flux> 0.0 is a float :)
<flux> in ocaml you would use operator /. to divide floating point values
<pango_> Sp4rKy: yes, casting the _result_ of the division won't help
<Sp4rKy> flux: yep, to cast each member to float
<Sp4rKy> my mistake
<Sp4rKy> Snark: i'm in engineer school
<Sp4rKy> flux: /. fails as members are int
* pango_ used to be in CPGE, but they were teaching Pascal at the time ;)
<flux> sp4rky, exactly, why you would convert the integers to float before division
<Sp4rKy> flux: if my functions reutrn 1 and 2
<Sp4rKy> the result will be 0
<flux> 1.0 /. 2.0 will be 0.5
<Sp4rKy> but i want 0.5
<Sp4rKy> flux: yes, but they return 1 and 2
<flux> think how you would make 1 to be 1.0 and 2 to be 2.0.. ;-)
<Sp4rKy> how can i do this ?
<flux> as I mentioned, ocaml provides you with functions to convert integers to floats
<Sp4rKy> (float_of_int fun1) /. (float_of_int fun2) ?
<Sp4rKy> l -> (float_of_int (somme l)) /. (float_of_int (list_length l));; works :)
<Sp4rKy> how can i define a type which is a list of (string, int) ?
<Sp4rKy> type foo = (string, int) list;; fails
<Snark> Sp4rKy, in which engineer school is camllight used ?
<Sp4rKy> Snark: IFSIC one
<Sp4rKy> Snark: IFSIC is linked with irisa & inria labs
<pango_> use * for tuple types (it's the cartesian product of its members' types)
<jderque> Sp4rKy: type foo = (string * int) list
<flux> sp4rky, did you notice what value definitions echo after you enter them?
<flux> well, atleast in ocaml..
<Sp4rKy> jderque: fails too
<flux> makes that "values echo"
<flux> wish xavierbot was around
<jderque> Sp4rKy: it works for me :-/
<bluestorm> Sparkles:
<bluestorm> type foo == (string * int) list ?
<bluestorm> if you're using caml light you need two = here
<Sp4rKy> bluestorm: oh yes :)
<jderque> ha, yeah, i'm using ocaml, not caml light. sorry
<Sp4rKy> jderque: np
<bluestorm> i found it useful to have a quick look at caml light
<bluestorm> for example there are some languages feature wich are quite nice to use, and we haven't anymore in OCaml
<bluestorm> +that
<bluestorm> "where", the multi-argument "fun", and the constructor/function automatic binding
<Snark> Sp4rKy, oh, in Rennes
<Sp4rKy> Snark: yes :)
<Sp4rKy> are you leaving in Rennes ?
<bluestorm> living ?
<Sp4rKy> yep :)
<Sp4rKy> s/leaving/living/
ita has joined #ocaml
buluca has joined #ocaml
<Sp4rKy> Snark: ?
<bluestorm> there have been some interesting patches concerning the toplevel recently
<Sp4rKy> This expression has type (string * float) list,
<Sp4rKy> but is used with type (string * resul) list.
<Sp4rKy> :(
<bluestorm> Sp4rKy: if you want to show some code
<bluestorm> use http://pastebin.be (or whatever)
<Sp4rKy> bluestorm: i'm pasting it :)
<bluestorm> ok
<Sp4rKy> m1 is a (string * float) list
<Sp4rKy> etu1 a string
<bluestorm> side note : "let rec consulter_note = function etu ->" = "let rec consulter_note = fun etu ->" = "let rec consulter_note etu ="
<bluestorm> | (a, b)::l -> if (a = etu) then b
<bluestorm> you return a float there
<bluestorm> but your first case return Absent, wich is "resul"
<bluestorm> Moy (int_of_float b) maybe ?
jderque has quit ["leaving"]
<bluestorm> (that would make a "resul" value more-or-less equivalent to your "b")
<pango_> is there no List.assoc in camllight library?
<bluestorm> hm
<Sp4rKy> pango_: don't know
<bluestorm> must be
<pango_> that code looks like standard assoc list lookup...
<bluestorm> but it's still a good idea to help him have the code right first :p
<bluestorm> Sp4rKy: see, you have an "assoc"
<bluestorm> try Moy (int_of_float (assoc etu your_list)) with Not_found -> Absent
<Sp4rKy> hmm
<bluestorm> or if mem_assoc etu your_list then Moy (int_of_float (assoc etu your_list)) else absent
<bluestorm> depending on how much you like exceptions
<Sp4rKy> don't like:p
<Sp4rKy> we don't use it a lot during clases
<bluestorm> (i personally prefer the first one, as the second has a slight feeling of "duplicated work", but i'd understand the other choice)
<Sp4rKy> so i guess we shouldn't use them a lot during exam :)
<bluestorm> hm
<bluestorm> exceptions may be useful
<bluestorm> even for control flow handling
<bluestorm> caml doesn't have "return", "break" or "continue"
<bluestorm> in some cases, using exceptions for that is handy
<bluestorm> (of course this is not good functional programming style, but sometimes you just write ugly for loops)
<Sp4rKy> oh, works :d
<Sp4rKy> I didn't care about Moy type
<Sp4rKy> as it's an int, i don't need to force the previous function to float :)
<pango_> My is a constructor, not a type
<pango_> s/My/Moy/
<Sp4rKy> yes yes
<Sp4rKy> but ihave a moy function :)
asmanur has joined #ocaml
ttamttam has left #ocaml []
seafood__ has quit []
seafood_ has joined #ocaml
marmottine has joined #ocaml
seafood_ has quit []
jderque has joined #ocaml
AxleLonghorn has joined #ocaml
buluca has quit [Read error: 113 (No route to host)]
nashdj has joined #ocaml
AxleLonghorn has quit ["Leaving."]
ita is now known as ita|off
pango__ has joined #ocaml
pango__ is now known as pango
smimou has quit ["bli"]
smimou has joined #ocaml
pango_ has quit [Remote closed the connection]
pango has quit [Remote closed the connection]
ygrek has quit [Remote closed the connection]
ygrek has joined #ocaml
pango has joined #ocaml
Morphous has joined #ocaml
asmanur has quit [Read error: 110 (Connection timed out)]
filp has quit [Read error: 104 (Connection reset by peer)]
middayc has joined #ocaml
nashdj has quit [Read error: 110 (Connection timed out)]
Amorphous has quit [Read error: 110 (Connection timed out)]
love-pingoo has joined #ocaml
Associat0r has joined #ocaml
Tetsuo has quit [Read error: 110 (Connection timed out)]
Tetsuo has joined #ocaml
filp has joined #ocaml
filp has quit [Remote closed the connection]
mordaunt has quit [Read error: 104 (Connection reset by peer)]
jderque has quit [Read error: 113 (No route to host)]
jderque has joined #ocaml
hkBst has quit ["Konversation terminated!"]
ita|off is now known as ita
Sp4rKy has quit [Read error: 110 (Connection timed out)]
pango has quit [Remote closed the connection]
pango has joined #ocaml
buluca has joined #ocaml
asmanur has joined #ocaml
Yoric[DT] has joined #ocaml
<Yoric[DT]> hi
<middayc> h i
ita has quit ["Hasta luego!"]
ttamttam has joined #ocaml
jderque has quit ["leaving"]
ttamttam has left #ocaml []
Snark has quit ["Quitte"]
ttamttam has joined #ocaml
ttamttam has left #ocaml []
ttamttam has joined #ocaml
ttamttam has quit [Client Quit]
l_a_m has quit [Remote closed the connection]
asmanur has quit [Remote closed the connection]
middayc has quit []
kelaouch1 has joined #ocaml
pango has quit [Remote closed the connection]
pants1 has joined #ocaml
kelaouchi has quit [Read error: 110 (Connection timed out)]
pants1 has quit [Client Quit]
Mr_Awesome has joined #ocaml
pango has joined #ocaml
pants1 has joined #ocaml
buluca has quit [Read error: 113 (No route to host)]
AxleLonghorn has joined #ocaml
AxleLonghorn has left #ocaml []
middayc has joined #ocaml
<middayc> hi
<pippijn> hi
<flux> hi
<pippijn> :D
<middayc> :) basically I just said hi to show I am present
<middayc> (I have some time so I am continuing to play with ocaml and sdlcaml)
jlouis_ has joined #ocaml
ygrek has quit [Remote closed the connection]
jlouis has quit [Read error: 110 (Connection timed out)]
elliottt has joined #ocaml
<elliottt> would anyone be able to help me with a library install problem?
<elliottt> i'm attempting to install col from funlinks.camlcity.org, and getting a compile error that i don't understand.
elliottt has left #ocaml []
Tetsuo has quit ["Leaving"]
<flux> I haven't used it, but if you're using ocaml 3.10.x, it might be because 3.10.x has an incompatible syntax extension layer
<flux> there's camlp5 that brings the old system back to ocaml 3.10.x, but I haven't tried that either
<bluestorm> flux: iirc camlp5 isn't totally backward-compatible either
<flux> bluestorm, oh.. well, as said, I haven't used it :)
<bluestorm> (you were right, camlp4 is the problem here : http://martin.jambon.free.fr/ocaml.html#col )
bluestorm has quit ["Konversation terminated!"]
AxleLonghorn has joined #ocaml
love-pingoo has quit ["Connection reset by pear"]
AxleLonghorn has left #ocaml []
middayc has quit [Read error: 110 (Connection timed out)]
Yoric[DT] has quit ["Ex-Chat"]
leo037 has joined #ocaml
seafood_ has joined #ocaml
seafood_ has quit [Client Quit]