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!)
setog3 has quit ["WeeChat 0.2.4"]
buluca has joined #ocaml
bzzbzz has joined #ocaml
mr_pengy has quit [Remote closed the connection]
smimou has quit ["bli"]
piggybox has quit []
thesoko has joined #ocaml
twobitsprite has quit ["Lost terminal"]
zarvok has quit ["BitchX-1.1-final -- just do it."]
db4n has joined #ocaml
fy__ has joined #ocaml
<db4n> Hello, anybody home?
<fy__> Hello.
<db4n> Do you know anything|much about camlp4?
<fy__> No, unfortunately. I've only just picked up the language.
Smerdyakov has quit ["Leaving"]
Smerdyakov has joined #ocaml
db4n has left #ocaml []
fy__ has quit [Read error: 110 (Connection timed out)]
fy__ has joined #ocaml
buluca has quit [Read error: 113 (No route to host)]
TFKv2 is now known as TFK
bluestorm_ has joined #ocaml
Submarine has quit ["in Soviet Russia, Céline Dion owns you"]
rwmjones_ has joined #ocaml
rwmjones_ has quit ["Leaving"]
buluca has joined #ocaml
<G> rwmjones: you still here?
smimou has joined #ocaml
mnemonic has quit ["leaving"]
slipstream has joined #ocaml
<rwmjones> G morning
Mr_Awesome has quit ["time to impregnate a moth"]
<G> rwmjones: actually, don't worry
<rwmjones> ok
slipstream-- has quit [Read error: 110 (Connection timed out)]
<G> rwmjones: but morning anyway ;)
leo037 has joined #ocaml
buluca has quit [Read error: 113 (No route to host)]
thesoko has quit [Remote closed the connection]
screwt8 has quit [Remote closed the connection]
thesoko has joined #ocaml
TFK has quit []
screwt8 has joined #ocaml
noteventime has joined #ocaml
db4n has joined #ocaml
Lena has joined #ocaml
buluca has joined #ocaml
<db4n> Hello, I have a camlp4 question.
<db4n> Trying to syntax extension including: "{"; seq = sequence; "}"
<db4n> Compiling with: ocamlc -pp "camlp4r pa_extend.cmo q_MLast.cmo" -I +camlp4 -c stdlibr.ml
<db4n> => Unbound value sequence
<db4n> How do you capture the sequence between the braces?
buluca has quit [Read error: 113 (No route to host)]
buluca has joined #ocaml
noteventime has quit [Remote closed the connection]
noteventime has joined #ocaml
Lena has quit ["Leaving."]
db4n_ has joined #ocaml
Alleria has joined #ocaml
pango has quit [Remote closed the connection]
pango has joined #ocaml
db4n has quit [Read error: 110 (Connection timed out)]
Nucleo has joined #ocaml
buluc1 has joined #ocaml
buluca has quit [Nick collision from services.]
buluc1 is now known as buluca
thesoko has quit [Remote closed the connection]
mnemonic has joined #ocaml
buluca has quit [Excess Flood]
buluca has joined #ocaml
thesoko has joined #ocaml
malc_ has joined #ocaml
db4n_ has left #ocaml []
noteventime has quit [Remote closed the connection]
noteventime has joined #ocaml
shawn has quit ["Leaving"]
Lena has joined #ocaml
Submarine has joined #ocaml
Lena has quit ["Leaving."]
shawn has joined #ocaml
buluc1 has joined #ocaml
buluca has quit [Nick collision from services.]
buluc1 is now known as buluca
Alleria has quit [Read error: 110 (Connection timed out)]
Lena has joined #ocaml
love-pingoo has joined #ocaml
shawn has quit [Success]
love-pingoo has quit ["Connection reset by pear"]
Lena_2 has joined #ocaml
noteventime has quit [Remote closed the connection]
tty56 has joined #ocaml
noteventime has joined #ocaml
shawn has joined #ocaml
root` has joined #ocaml
tty56_ has quit [Read error: 110 (Connection timed out)]
noteventime has quit [Remote closed the connection]
noteventime has joined #ocaml
shawn has quit ["This computer has gone to sleep"]
noteventime has quit [Remote closed the connection]
noteventime has joined #ocaml
Mr_Awesome has joined #ocaml
shawn has joined #ocaml
malc_ has quit ["leaving"]
leo037 has quit ["Leaving"]
fy__ has quit [Remote closed the connection]
thorat has joined #ocaml
thorat has left #ocaml []
hsfb has joined #ocaml
<hsfb> hello folks.. i'd appreciate some hlep
<hsfb> *help.. see i have this function that uses List.map to apply fy to each element, and it works, returning me a list
<Smerdyakov> We're all out of hlep! :D
<hsfb> hehe... beer then!
<hsfb> Now i'm trying to use fold_right instead, so I get not the list but the sum of its elements
<hsfb> but somehow i'm messing things up
<hsfb> the version that works is let entropy l = List.map entr_elem l;;
<hsfb>
<xavierbot> Characters 0-3:
<xavierbot> the version that works is let entropy l = List.map entr_elem l;;
<xavierbot> ^^^
<xavierbot> Unbound value the
<hsfb> and the one that does not is
<hsfb> let entropy l = List.fold_right (fun x y -> (entr_elem x) +. (entr_elem y)) l 0.0;;
<hsfb>
<xavierbot> Characters 26-29:
<xavierbot> Parse error: [binding] expected after [opt_rec] (in [str_item])
<xavierbot> let entropy l = List.fold_right (fun x y -> (entr_elem x) +. (entr_elem y)) l 0.0;;
<xavierbot> ^^^
<hsfb> with is returning me 'nan'
<Smerdyakov> BTW, if 'entropy' doesn't have a polymorphic type, you could shorten that first definition to: let entropy = List.map entr_elem
<hsfb> makes sens
<hsfb> yeah, that works, nic
<hsfb> nice
<Smerdyakov> I don't think there's any general answer to your question. The sequence of calculations just does result in NaN...
<hsfb> but see, using the map version for entropy [0.05; 0.1; 0.4; 0.4; 0.3; 0.04];; gets me - : float list =
<hsfb> [-0.216096404744368142; -0.332192809488736251; -0.52877123795494485;
<hsfb> -0.52877123795494485; -0.521089678249861854; -0.185754247590989]
<hsfb>
<Smerdyakov> So? You are calling entr_elem on the accumulator, too, and no one but you can have any idea what result that will produce.
<hsfb> oh, i see.. i'm doing entr_elem "as i go"
<hsfb> not on each element first, then summing
<Smerdyakov> I'm not sure what you mean, but it sounds like your code is doing something more complicated than you want.
<Smerdyakov> Also, the parentheses around the operands of +. are superfluous.
<hsfb> ok...
<hsfb> yeah, this solves the problem.. let entropy l = sum (List.map entr_elem l);; but it seems that i _should_ be able to use fold to solve it in just one pass
<hsfb> tks anyway
<Smerdyakov> Of course you can.
<Smerdyakov> Just try evaluating your old definition on short lists manually, and you'll see the problem.
<Smerdyakov> (You should do this in general whenever you get stuck, before asking for help.)
<hsfb> Ok, i'll do that... are you brazilian or portuguese speaking ?
<Smerdyakov> No.
foucault has joined #ocaml
pantsd has joined #ocaml
<hsfb> Smerdyakov: let entropy l = List.fold_right (fun x y -> (entr_elem x) +. y) l 0.0;;
<hsfb>
<xavierbot> Characters 5-12:
<xavierbot> Smerdyakov: let entropy l = List.fold_right (fun x y -> (entr_elem x) +. y) l 0.0;;
<xavierbot> ^^^^^^^
<xavierbot> Unbound value entropy
<xavierbot> Characters 11-12:
<xavierbot> Parse error: illegal begin of top_phrase
<pango> xavierbox, sleep
<hsfb> is there a shortcut for writing this type of definition ? its probably a common pattern
<pango> xavierbot, sleep
<xavierbot> xavierbot goes to sleep (do 'xavierbot wake' to wake)
<hsfb> pango: tks, that was my next question
<Smerdyakov> hsfb, try to write your own "shortcut" as an exercise. :)
<hsfb> you mean camlp4?
bluestorm_ has quit [Remote closed the connection]
<Smerdyakov> hsfb, no, I mean by writing your own higher-order function.
<Smerdyakov> hsfb, and, don't forget, you are still using extraneous parentheses around the first +, operand there....
<hsfb> i'll watch that.. too much elisp is bad for your camel
<hsfb> Tks again!
foucault has quit [Remote closed the connection]
<pango> hsfb: have you a special reason for using fold_right? Only fold_left implementation is tail recursive...
<hsfb> swapping
<hsfb> i remember one of you is the author from m3ga blog