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!)
Mr_Awesome has joined #ocaml
screwt820 has joined #ocaml
smimram has quit ["bli"]
mr_hugo has quit ["iiiiiiiiiii"]
seafoodX has joined #ocaml
drice has joined #ocaml
drice is now known as [azoic]
pants1 has joined #ocaml
ita has quit [Remote closed the connection]
seafoodX has quit []
l_a_m has quit [Remote closed the connection]
piggybox has joined #ocaml
mvitale has quit ["Leaving"]
piggybox_ has quit [Read error: 110 (Connection timed out)]
Abo-Marwan67 has joined #ocaml
pango has quit [Remote closed the connection]
pango has joined #ocaml
CRathman has joined #ocaml
gaja has quit ["leaving"]
Tetsuo has joined #ocaml
gaja has joined #ocaml
pants1 has quit [Read error: 110 (Connection timed out)]
pantsd has joined #ocaml
[azoic] has quit [Read error: 110 (Connection timed out)]
ygrek has joined #ocaml
pants1 has joined #ocaml
schme has quit [Remote closed the connection]
schme has joined #ocaml
pantsd has quit [Read error: 110 (Connection timed out)]
pants1 has quit [Read error: 110 (Connection timed out)]
seafoodX has joined #ocaml
pantsd has joined #ocaml
mordaunt has quit ["Konversation terminated!"]
screwt820 has quit [Remote closed the connection]
Abo-Marwan67 has quit [Read error: 104 (Connection reset by peer)]
Abo-Marwan67 has joined #ocaml
CRathman has quit [Read error: 110 (Connection timed out)]
aij_ has joined #ocaml
aij has quit [Read error: 104 (Connection reset by peer)]
screwt820 has joined #ocaml
Mr_Awesome has quit [Read error: 110 (Connection timed out)]
slipstream-- has joined #ocaml
Smerdyakov has quit [Read error: 110 (Connection timed out)]
aij_ has quit [Remote closed the connection]
slipstream has quit [Read error: 110 (Connection timed out)]
Shammah has joined #ocaml
Shammah has quit ["This computer has gone to sleep"]
olegfink has quit [Read error: 104 (Connection reset by peer)]
olegfink has joined #ocaml
aij has joined #ocaml
crabstick has joined #ocaml
l_a_m has joined #ocaml
_JusSx_ has joined #ocaml
aij has quit [Read error: 104 (Connection reset by peer)]
aij has joined #ocaml
mr_hugo has joined #ocaml
<mr_hugo> hello
piggybox_ has joined #ocaml
<mr_hugo> can someone help me with this code: http://pastebin.com/d134eac20 it is supposed to get all the lines of a file in a list, except for the commented ones, i tested in /etc/ld.so.conf but it didn't work properly
<mr_hugo> an empty list was returned
<pango> correct, the value you return is final_list, defined line 11
<mr_hugo> wasn't it supposed to change ?
<mr_hugo> im adding elements to it
<pango> where ?
<pango> you're not
<mr_hugo> line 6 ?
<pango> line 6 you're building lists, yes, that get passed recursively to list_aux... How does that affect final_list?
<mr_hugo> because in line 13 i'm passing final_list as argument to the function ?
<pango> so ? It gives the initial list value to the function
<mr_hugo> so how do i change its contents ?
<pango> you don't, lists are immutable
<mr_hugo> change as in add contents to it...
<mr_hugo> :/
<pango> and final_list is a let binding, not a variable, so it's incorrect to talk about its "content", much less try to change it
<pango> it's like trying to change the content of 2, or the content of the empty list
Abo-Marwan67 has quit [Read error: 104 (Connection reset by peer)]
screwt820 has quit [Read error: 104 (Connection reset by peer)]
<pango> your problem is that when the End_of_file exception happens, control goes directly to line 14 and you loose the value of your painstakenly build list
<mr_hugo> ok
<mr_hugo> now it works
<mr_hugo> :P
<pango> exception handling must happen within the recursive function, so that when it happens you can return the current list value
<pango> the usual (newbie) trap being to keep the function calls tail recursive, so it doesn't blow up on larger files (around 40k lines)
<mr_hugo> :)
<mr_hugo> yes
<mr_hugo> its the stop case
<mr_hugo> hmm
<mr_hugo> tail recursive
<mr_hugo> ..now i can proceed to a "find_lib" function of some sort...
piggybox has quit [Connection timed out]
<mr_hugo> thank you
<pango> np
<pango> # let inf = open_in "/usr/share/dict/american-english" ;;
<pango> val inf : in_channel = <abstr>
<pango> # list_all_lines inf () ;;
<pango> Stack overflow during evaluation (looping recursion?).
<mr_hugo> this will probably smash the stack because it happens inside the try catch
<mr_hugo> oh yes
<mr_hugo> :/
<pango> your analysis is correct
<mr_hugo> hmmf :/
<pango> they're several way around, discussed periodically in OCaml mailing lists and forums ;)
<mr_hugo> where is the main ocaml forum ?
<rwmjones> mr_hugo, it's the caml-list mailing list, go to the site
<rwmjones> caml.inria.fr
<rwmjones> and you'll see it
screwt820 has joined #ocaml
ygrek has quit [Remote closed the connection]
schme has quit [Remote closed the connection]
<mr_hugo> this is cool :D
<mr_hugo> lots of information in there
<mr_hugo> i didn't knew ocaml had such a strong community...
<mr_hugo> sweet
<pango> there's another bug with the code you posted:
<pango> # let inf = open_in "/dev/null" ;;
<pango> val inf : in_channel = <abstr>
<pango> # list_all_lines inf () ;;
<pango> Exception: End_of_file.
<pango> for empty files, the End_of_file exception escapes out of list_all_lines
<mr_hugo> ahh yes
<mr_hugo> niceee i wasn't thinking of that
<mr_hugo> :D
<mr_hugo> thank you very much
Abo-Marwan67 has joined #ocaml
Demitar has quit [Read error: 104 (Connection reset by peer)]
Shammah has joined #ocaml
<mr_hugo> well, when im coding OCaml, i'm always thinking to myself "its probably possible to do this in 2 lines using a much elegant solution"...
schme has joined #ocaml
CRathman has joined #ocaml
ygrek has joined #ocaml
Demitar has joined #ocaml
Demitar has quit [Read error: 113 (No route to host)]
<mr_hugo> im leaving now
<mr_hugo> if anyone is interested, here is the final solution that i reached: http://pastebin.com/m3f58f902
CRathman has quit [Read error: 110 (Connection timed out)]
Demitar has joined #ocaml
<pango> mr_hugo: I suggest http://pastebin.com/d46bbe882 (but it's only slight modifications)
<mr_hugo> ahh yes :)
<mr_hugo> much better and easier to read
<mr_hugo> thank you
<mr_hugo> and i can add more functions to parse different things
<mr_hugo> this is great yes
<mr_hugo> ill be going now, thanks for everything ;)
mr_hugo has left #ocaml []
<pango> bye!
CRathman has joined #ocaml
Demitar has quit [Read error: 113 (No route to host)]
schme has quit [Remote closed the connection]
Shammah has quit ["This computer has gone to sleep"]
<flux> io is one part in ocaml that doesn't seen always very elegant to use - I blame using exceptions
<pango> yup
<pango> turn out not to mix well with functional style
<flux> if you have a function to convert exceptions to values it's a bit better
<flux> I wonder what's the performance hit, though.. (not enough for me to benchmark it ;-))
schme has joined #ocaml
<pango> given how much cycles must be used in operating system bowel, I guess it's way below radar level
<flux> well, a read might never go the OS, so that depends on the buffer sizes
<pango> maybe it matters if you read a character at once
<pango> (that's why C's getc() is a macro, for example)
Demitar has joined #ocaml
schme has quit [Remote closed the connection]
lord_sesshomaru has joined #ocaml
schme has joined #ocaml
Demitar_ has joined #ocaml
Demitar has quit [Connection timed out]
CRathman has quit [Read error: 110 (Connection timed out)]
schme has quit [Read error: 104 (Connection reset by peer)]
Demitar_ has quit [Read error: 110 (Connection timed out)]
schme has joined #ocaml
bluestorm_ has joined #ocaml
kelaouchi has joined #ocaml
seafoodX has quit []
ygrek has quit [Remote closed the connection]
ygrek has joined #ocaml
pango has quit [Remote closed the connection]
pango has joined #ocaml
Demitar has joined #ocaml
lord_sesshomaru has left #ocaml []
kelaouch1 has joined #ocaml
drice has joined #ocaml
kelaouchi has quit [Read error: 110 (Connection timed out)]
Demitar has quit [Read error: 110 (Connection timed out)]
Demitar has joined #ocaml
bluestorm_ has quit [Remote closed the connection]
mordaunt has joined #ocaml
dbueno has joined #ocaml
Mr_Awesome has joined #ocaml
CRathman has joined #ocaml
pango has quit [Excess Flood]
pango has joined #ocaml
leo037 has joined #ocaml
danderson has left #ocaml []
schme has quit [Read error: 104 (Connection reset by peer)]
schme has joined #ocaml
Abo-Marwan95 has joined #ocaml
screwt820 has quit [Read error: 104 (Connection reset by peer)]
Abo-Marwan67 has quit [Read error: 104 (Connection reset by peer)]
screwt862 has joined #ocaml
ygrek has quit [Remote closed the connection]
ygrek has joined #ocaml
crabstick_ has joined #ocaml
kelaouch1 has quit [Read error: 104 (Connection reset by peer)]
crabstick has quit [Read error: 110 (Connection timed out)]
pantsd has quit [Read error: 110 (Connection timed out)]
ygrek has quit [Remote closed the connection]
schme has quit [Read error: 104 (Connection reset by peer)]
schme has joined #ocaml
schme` has joined #ocaml
ita has joined #ocaml
schme has quit [Read error: 110 (Connection timed out)]
pantsd has joined #ocaml
schme` is now known as schme
EliasAmaral has joined #ocaml
Tetsuo has quit ["Leaving"]
bogdano has joined #ocaml
<hcarty> What is the method for building a custom toplevel with ocamlbuild?
<hcarty> The documentation seems to indicate that it's possible, but "ocamlbuild foo.top" says that there are no rules to build that target
_JusSx_ has quit ["leaving"]
Shammah has joined #ocaml
Shammah has quit [Remote closed the connection]
bkudria has joined #ocaml
<bkudria> can i ask an sml question here, no one seems to be alive in #sml ?
<ita> bkudria: ask and see
<ita> if it is enough ml-related
<bkudria> i have this powerset function: http://pastebin.ca/698956 but this way, power(tl(L)) is computed twice. should i put it into a temp. variable, or what is the correct way to ensure it is computed only once?
<ita> use a declaration just above ? ("let" ?)
<ita> temp variable yes
<bkudria> aah, i'm having a bit of touble with the let syntax. is it "let y = f(x) in dosomething(y) end;" ?
<ita> let is ocaml
<ita> it would be almost possible to write a sml-to-ocaml preprocessor
<bkudria> aah. any idea how to do it in sml?
<bkudria> val y = f(x); dosomething(y); ?
<bkudria> that doesn't work for me either
<bkudria> i'd love to do it in ocaml, but i have to do it in sml :)
<ita> bkudria: let val y=2 in ... end
<ita> bkudria: why sml ?
<bkudria> aah, lemme try that
<bkudria> cause the prof assigned it in sml :) he nglected to show us how to do this bit, though
<ita> bah, write it in caml first, then translate the program
<bkudria> uh oh: powerset.sml:7.3-7.6 Error: syntax error: replacing END with EQUALOP
<bkudria> would you like me to repost my function?
<ita> no :-)
<bkudria> well, not in the channel, of course
<bkudria> any idea what is wrong, then?
<ita> learning the sml syntax
<bkudria> i'm googline like mad
<bkudria> googling*
<bkudria> can't seem to find anything helpful, though
<bkudria> same problem, but the solutions doesn't explain what the problem was
xavierbot has quit [Read error: 110 (Connection timed out)]
<bkudria> ok, i give up
<bkudria> thanks for all the help, ita
bkudria has quit [Remote closed the connection]
leo037 has quit ["Leaving"]
CRathman has quit [Read error: 110 (Connection timed out)]
_PenPen_ has joined #ocaml