flux changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | 3.11.0 out now! Get yours from http://caml.inria.fr/ocaml/release.html
<Yoric[DT]> Time to call this a night.
Yoric[DT] has quit ["Ex-Chat"]
Amorphous has joined #ocaml
<vuln> How can I solve the problems of atribution once I can't atribute none of the vars inside a function ?
<Alpounet> gn all
Alpounet has quit ["Quitte"]
delamarche has joined #ocaml
Ched has quit ["Ex-Chat"]
<kaustuv> vuln: allocation and de-allocation of memory is done for you by the OCaml runtime system, so just don't worry about it.
<vuln> kaustuv: I mean. I want to change the value of a variable inside a while loop
<vuln> Is it possible?
<vuln> I have to put it outside with the keyword 'in' ?
<totom> vuln: you can't change the values of variables in ocaml (bis)
<totom> unless they are references
Ariens_Hyperion has quit []
<totom> variables are just bindings -- another name for a value
<totom> try to stick to functional programming - no affectations
<vuln> totom: it's not a memory abstraction layer as C or something like this..
<vuln> right?
<totom> ??
<vuln> totom: hum..
<vuln> May you write a code in OCaml to give me the first 10 numbers starting from 0?
<vuln> The rest I do.
<totom> let toZero = function 0 -> [0] | n -> n :: (toZero (n-1))
<vuln> totom: Do you recommend other sites to learn Ocaml besides of ocaml-tutorial and the official one?
<totom> I don't know any, sorry
<vuln> Thanks
<vuln> :)
<totom> oops, starting from zero, sorry
<vuln> you forgot the rec key word on let toZero
<totom> I did the reverse
<totom> let rec toNine = function 10 -> [] | n -> n::(toNine (n+1))
<vuln> thanks :)
<vuln> What | mean?
<vuln> and n -> n?
<totom> it's a match case
<totom> for ten, return []
<totom> for n, return n::(toNine (n+1))
<totom> | is a separator
<vuln> hum.. got it
<vuln> :) thanks again
<totom> good night (1:30 AM here)
<vuln> night
<kaustuv> vuln: until you have got the hang of pattern matching, try expressing it in simple if-then-else forms. For example,
<kaustuv> let rec range low high =
<kaustuv> if low = high then []
<kaustuv> else low :: (range (low + 1) high) ;;
<kaustuv> let first_ten = range 0 10 ;;
<totom> (btw, range should really be a built-in function :-)
<totom> I think every project has these three lines of code hidden somewhere
<kaustuv> (It is in batteries, I believe. Also, List.init in ExtLib is strictly better.)
jonasb has quit [Remote closed the connection]
delamarche has quit []
<vuln> kaustuv: thanks :)
<vuln> pattern matching you mean ->, ::, etc right?
Palace_Chan has joined #ocaml
Waleee has quit [Connection timed out]
Waleee has joined #ocaml
vuln has quit [Read error: 104 (Connection reset by peer)]
kaustuv has left #ocaml []
vuln has joined #ocaml
vuln has quit ["leaving"]
r0bby has joined #ocaml
r0bby has quit [Client Quit]
thelema has joined #ocaml
r0bby has joined #ocaml
seafood has quit []
seafood has joined #ocaml
schme has quit ["leaving"]
jeddhaberstro has joined #ocaml
Waleee has quit []
Palace_Chan has quit ["Palace goes to sleep"]
sporkmonger has quit []
vovkaii has quit ["Leaving"]
jeddhaberstro has quit []
palomer has joined #ocaml
<palomer> hello
<palomer> is type inference done with an inorder traversal in ocaml?
verte has quit [Read error: 110 (Connection timed out)]
verte has joined #ocaml
_zack has joined #ocaml
ttamtta1 has joined #ocaml
palomer has quit ["Leaving"]
seafood has quit []
Ched has joined #ocaml
jknick has joined #ocaml
s4tan has joined #ocaml
flx_ has joined #ocaml
flux has quit [Read error: 104 (Connection reset by peer)]
mr_uggla_ has joined #ocaml
kaustuv has joined #ocaml
mr_uggla has quit [Read error: 104 (Connection reset by peer)]
ikaros has joined #ocaml
verte has quit ["http://coyotos.org/"]
ikaros has quit ["Leave the magic to Houdini"]
Camarade_Tux has quit [Read error: 110 (Connection timed out)]
Camarade_Tux has joined #ocaml
rwmjones_ has joined #ocaml
ttamtta1 has left #ocaml []
theIdeaMen has joined #ocaml
Yoric[DT] has joined #ocaml
hkBst has joined #ocaml
<Yoric[DT]> hi
Alpounet has joined #ocaml
<kaustuv> mfp: I just asked Damien, and he says that the X86 backend uses SSE2 to get floating point registers
<mfp> huh? never observed that in the past, a new 3.11 thing?
* mfp checks the .s
<kaustuv> Well, he says he isn't sure.
<mfp> it doesn't
<mfp> fldl 20(%esp)
<mfp> fmull 12(%esp)
<mfp> fstpl 28(%esp) etc
<Camarade_Tux> iirc only x86-64 uses sse2 (and only sse2)
<mfp> compare to the x86-64 code:
<mfp> movsd %xmm1, %xmm4
<mfp> mulsd %xmm0, %xmm4
<mfp> mulsd %xmm1, %xmm1
<mfp> mulsd %xmm0, %xmm0
<kaustuv> the trivial port to SML and compiled with MLton is about three times faster than ocamlopt on x86, fwiw
<mfp> the 64-bit binary is nearly 5X faster than the 32-bit one with ocamlopt
<mfp> if MLton is using SSE2, that would explain the difference amply
<kaustuv> MLton is not using SSE2.
<mfp> then it's just better with the FP stack
<kaustuv> well, I think. I'm not an x86 assembly expert. You can see for yourself what mlton produces: http://www.msr-inria.inria.fr/~kaustuv/misc/mandy.0.S
<munga> is there a way to generate the interface of a ml file with ocamlbuild (directly) in the same way I can with ocamlfind ocamlc -i ... ?
<mfp> unlike ocamlopt x86, which uses memory operands, MLton uses the FP stack for real: fld %st(1) fmul %st, %st fld %st(1) fmul %st, %st
rwmjones_ has quit ["Closed connection"]
<kaustuv> 2.370s (mlton) vs. 4.112s (ocamlopt) on this x86-64 laptop
<kaustuv> http://www.msr-inria.inria.fr/~kaustuv/misc/{mandy.sml,mandy-64.0.S} for the source and the x86-64 assembly from mlton.
ttamttam1 has joined #ocaml
<mfp> kaustuv: which OCaml code are you using, the one with the recursive function (uses unboxed floats), or the one with refs (2X faster on my box). Also, is it 3.11?
<kaustuv> mfp: I didn't change the source code from the c.l.f post referenced in the reddit post. I did compile with -nodynlink and -fno-PIC. Yes, 3.11
<mfp> I get 2.4s vs 1.25s with 3.11 x86-64, recursive function vs. imperative
<mfp> 3.11 is a bit better than 3.10 at float unboxing, but clearly not enough
<kaustuv> Can you run MLton on the .sml file to compare? I suspect your processor is much faster than my laptop's.
<kaustuv> Heh, I love this from that clf thread.
<kaustuv> > The imperative features of OCaml and F# are there to be used.
<kaustuv> > They are not there not to be used.
Ariens_Hyperion has joined #ocaml
verte has joined #ocaml
Ariens_Hyperion has quit []
Associat0r has joined #ocaml
Alpounet has quit ["Ex-Chat"]
sporkmonger_ has joined #ocaml
verte has quit ["http://coyotos.org/"]
Waleee has joined #ocaml
Associat0r has quit [Read error: 110 (Connection timed out)]
bzzbzz has joined #ocaml
Cheshire has joined #ocaml
ttamttam1 has left #ocaml []
mishok13 has quit [Read error: 60 (Operation timed out)]
kaustuv has left #ocaml []
mishok13 has joined #ocaml
slash_ has joined #ocaml
s4tan has quit []
kaustuv has joined #ocaml
thelema_ has quit ["ChatZilla 0.9.84 [Firefox 3.0.6/2009011913]"]
<Yoric[DT]> thelema: rewriting your [Enum.reduce] -- it was raising the wrong exception.
schme has joined #ocaml
<mfp> kaustuv: the mlton version runs in 1.37s here (mlton -codegen amd64 -output mandy2 mandy.sml), 1.25s for the imperative OCaml one
ttamttam1 has joined #ocaml
ttamttam1 has left #ocaml []
willb has joined #ocaml
<hcarty> munga: ocamlbuild foo.inferred.mli -- "man ocamlbuild" should give you that information under the Target Names section
<hcarty> munga: It may require some extra steps in myocamlbuild.ml or _tags, depending on the build process you use
<munga> hcarty: thanks !!
<kaustuv> mfp: thanks. It seems to support my general impression that MLton's optimizer is still the best in class for ML-like languages.
<mfp> http://www.reddit.com/r/programming/comments/7yyk7/phantom_types_to_prevent_bugs_in_the_ocaml/ <- going a bit beyond the classic `Read | `Write examples :)
<mfp> kaustuv: I thought it was (amongst?) the best in absolute terms, not only for MLs?
<mfp> or is GHC's better nowadays?
<hcarty> munga: You're welcome - even after finding that, it frustrated the heck out of me because I didn't realize I had to change my myocamlbuild.ml to take proper advantage of it
<kaustuv> mfp: I have no idea what amazing claims the GHC people make these days. It always seems to me that GHC is an exercise in compiler contortionism to support their lazy-by-default paradigm. But this is not a scientific statement.
Cheshire has quit [No route to host]
Cheshire has joined #ocaml
bluestorm has joined #ocaml
kaustuv has left #ocaml []
<mfp> the GHC ppl often come up with impressive examples where GHC auto-vectorizes or turns complex stream processing into a tight N-instruction loop
<mfp> but it remains to be seen whether you'd hit the honey pot in real programs --- it always feels very hit-or-miss
Ariens_Hyperion has joined #ocaml
Waleee has quit ["http://www.mibbit.com ajax IRC Client"]
<bluestorm> mfp: and sometimes you have (because of lazyness, not deficiencies in GHC) impressive examples where your innocent code turns out to leak quite a lot
<mfp> yeah, I remember when somebody replied to my saying on reddit that fold (+) was laziness biting you in the ass w/ "no, it's an inappropriate use of laziness"
<mfp> not worrying about when things are eval'ed is the point of being non-strict (the same way the GC frees you from knowing who's responsible for which mem),
<mfp> oops foldl (+) above, of course
Asmadeus has quit [Read error: 54 (Connection reset by peer)]
<mfp> so having to use foldl' instead of foldl _is_ a case of laziness getting in the way, from my POV
Asmadeus has joined #ocaml
vuln has joined #ocaml
theIdeaMen has quit [Remote closed the connection]
Alpounet has joined #ocaml
Ariens_Hyperion has quit []
<mfp> WTH it's the 2nd time somebody posts to proggit dymically typed [some lisp] beats OCaml and then it turns out it's not actually faster & type annotations are being used
<mfp> maybe because OCaml is the seen as the generic statically typed, fast thing
<mfp> s/dymically/dynamically/
<mfp> so they wouldn't say ... beats GHC as it would weaken the statement? (oh, you're not using -fbang-patterns/strict whatever ?)
<mfp> -the
<mfp> damn I cannot write today, that floated boxes thing was really shameful
<Camarade_Tux> because they're jumping on the first thing that says ocaml is slower than X
Ched has quit [Read error: 104 (Connection reset by peer)]
Ched has joined #ocaml
<Camarade_Tux> http://thinkingdigitally.com/archive/the-case-for-replacing-java-with-python-in-education/ : "Dynamic Typing - [...] as nearly everyone who programs dynamically typed language for a while finds out that the type safety provided by static typing is unnecessary and more often gets in your way than it helps you (ex. Casting)."
<Cheshire> it is a shame that python is popular
<Cheshire> if you program in python .. it turns you into a sales person
<Cheshire> "The language is mature with comprehensive library support, pleasant to use and a much more likely language to inspire students to explore outside the school curriculum."
<Cheshire> "Buy now! before this great deal runs out"
<bluestorm> that wasn't constructive criticism :-'
<Alpounet> so what would you say about Python ? :-p
_zack has quit ["Leaving."]
<bluestorm> Alpounet: I haven't used Python in a while (and only a few weeks long), but I didn't like the default data structures
<bluestorm> you've got hashtables or a list-array-blah thing
<Alpounet> hehe, yep
<Alpounet> and everything is variant
<bluestorm> and people have no sense of algorithmic complexity
<bluestorm> wich is not so good for beginners
<Alpounet> indeed... or that becomes <troll>Windows</troll>
<bluestorm> there are specialized datastructures with decent algorithmic behavior in the stdlib, but nobody advertize them
Narrenschiff has joined #ocaml
<Alpounet> brb
kaustuv has joined #ocaml
mishok13 has quit ["Stopping IRC chat... [OK]"]
Camarade_Tux has quit ["Leaving"]
Camarade_Tux has joined #ocaml
Camarade_Tux has quit [Client Quit]
Yoric[DT] has quit ["Ex-Chat"]
Narrenschiff has quit []
mlh has joined #ocaml
petchema has joined #ocaml
<vuln> What means the keyword 'ref' and what matters if I put ! before a variable?
Ariens_Hyperion has joined #ocaml
<petchema> type 'a ref = { mutable contents: 'a } let ref v = { contents = v } let ( ! ) r = r.contents let ( := ) r v = r.contents <- v
<petchema> that's enough to redefine references
<Alpounet> ref enables having mutable values in your OCaml code
<Alpounet> ! permit to access this value
<vuln> thanks :)
Cheshire has quit [Read error: 113 (No route to host)]
Cheshire has joined #ocaml
Associ8or has joined #ocaml
thelema has quit [Read error: 60 (Operation timed out)]
prime2 has joined #ocaml
prime2 has quit ["leaving"]
_zack has joined #ocaml
<Alpounet> where is the |> operator defined in Batteries ?
chupiq has joined #ocaml
Ariens_Hyperion has left #ocaml []
Associ8or has quit []
<mfp> Alpounet: src/core/extlib/std.ml
sporkmonger_ has quit []
sporkmonger has joined #ocaml
prime2 has joined #ocaml
<Alpounet> thanks :)
thelema has joined #ocaml
Associat0r has joined #ocaml
<Alpounet> Does the toplevel give you the type of (**>) ?
<Alpounet> (even if I know it, I'm still waiting the answer of the toplevel :-p)
Pliskin has joined #ocaml
Pliskin has left #ocaml []
marteo has joined #ocaml
sporkmonger has quit ["Get Colloquy for iPhone! http://mobile.colloquy.info/"]
Cheshire has quit [No route to host]
<marteo> hi
<marteo> i'm doing a exponentiation program (for school)
<marteo> and I get the 'out of memory' error
<marteo> let rec puiss x n =match n with| 0 -> 1| _ -> if n = 2*(n/2)then (puiss (puiss x (n/2)) 2)else x*(puiss (puiss x ((n-1)/2)) 2) ;;
<marteo> (is there anywhere to paste ?)
<bluestorm> marteo: use "if n mod 2 = 0"
<marteo> ok
<bluestorm> and "(n-1)/2"is useless, "n/2" will return the same result (and is in that situation clearer imho)
<bluestorm> hum
<bluestorm> the "out of memory" error comes from a flaw in your impl.
<bluestorm> you use "puiss ... 2", without any special case for 2 or 1
<bluestorm> puiss ... 2 would loop
<marteo> don't understand (same result with mod)
<bluestorm> puiss x 2 = puiss (puiss x 1) 2 = puiss (x * puiss x 0) 2 = puiss x 2
<bluestorm> you have to do instead
<marteo> ooh ok
<bluestorm> puiss (x * x) (n/2)
<bluestorm> (ie. hardcode the "puiss 2")
<marteo> right, thanks.
<marteo> it works.
chupiq has quit ["http://www.mibbit.com ajax IRC Client"]
Associat0r has quit [Read error: 104 (Connection reset by peer)]
Associat0r has joined #ocaml
jonasb has joined #ocaml
Ariens_Hyperion has joined #ocaml
slash_ has quit ["Lost terminal"]
bartiosze has joined #ocaml
_zack has quit ["Leaving."]
bartiosze has left #ocaml []
Camarade_Tux has joined #ocaml
Ariens_Hyperion has quit []
tripwyre has joined #ocaml
marteo has quit [Remote closed the connection]
bluestorm has quit [Remote closed the connection]
seafood has joined #ocaml
hkBst has quit [Read error: 104 (Connection reset by peer)]
Ariens_Hyperion has joined #ocaml
Ariens_Hyperion has quit [Connection timed out]
vuln has quit [Read error: 104 (Connection reset by peer)]
vuln has joined #ocaml
prime2 has quit ["leaving"]
tripwyre has quit []
willb has quit [Read error: 110 (Connection timed out)]