pattern has quit [Read error: 60 (Operation timed out)]
pattern has joined #ocaml
det_ has quit [Read error: 110 (Connection timed out)]
jdmarshall has quit ["ChatZilla 0.9.52B [Mozilla rv:1.6/20040113]"]
housetier has quit ["#breaks @ irc.highteq.de"]
skylan has quit [Read error: 104 (Connection reset by peer)]
skylan has joined #ocaml
pattern has quit [Read error: 60 (Operation timed out)]
pattern has joined #ocaml
Defcon7` is now known as Defcon7
bk_ has quit [kornbluth.freenode.net irc.freenode.net]
srv has quit [kornbluth.freenode.net irc.freenode.net]
Hadaka has quit [kornbluth.freenode.net irc.freenode.net]
teratorn has quit [kornbluth.freenode.net irc.freenode.net]
bk_ has joined #ocaml
srv has joined #ocaml
Hadaka has joined #ocaml
teratorn has joined #ocaml
buggs^z has joined #ocaml
buggs has quit [Connection timed out]
buggs^z is now known as buggs
pattern has quit [Read error: 110 (Connection timed out)]
bk_ has quit ["I'll be back"]
jdmarshall has joined #ocaml
Nutssh has joined #ocaml
blueshoe has joined #ocaml
blueshoe has quit [Read error: 104 (Connection reset by peer)]
blueshoe has joined #ocaml
blueshoe has quit [Client Quit]
blueshoe has joined #ocaml
jdmarshall has quit ["ChatZilla 0.9.52B [Mozilla rv:1.6/20040113]"]
blueshoe has quit [Read error: 104 (Connection reset by peer)]
Nutssh has quit ["Client exiting"]
pattern has joined #ocaml
gim has joined #ocaml
mimosa has joined #ocaml
det has joined #ocaml
riffraff has joined #ocaml
<riffraff>
hi
<riffraff>
i'm a newbie with ocaml, and I wonder what is the ocaml-ish way to do pattern matching a-la perl (regexp or something like that). Some tutorial online ?
<pattern>
also, if you want to stick to the standard ocaml library, have a look in the Str module
<riffraff>
pattern, yes, just found that
<riffraff>
tnx anyway
<riffraff>
now, I have a little problem trying to build ocmla w/o tk
tvainika has joined #ocaml
<riffraff>
it seem It wont consider -no-tk
<riffraff>
oh, no, it works
srv has quit [Read error: 104 (Connection reset by peer)]
srv has joined #ocaml
riffraff has quit [Remote closed the connection]
bruce_ has joined #ocaml
whiskas has joined #ocaml
bruce_ has quit [Read error: 104 (Connection reset by peer)]
whiskas has quit [Client Quit]
wazze has joined #ocaml
Hadaka has quit [kornbluth.freenode.net irc.freenode.net]
teratorn has quit [kornbluth.freenode.net irc.freenode.net]
Hadaka has joined #ocaml
teratorn has joined #ocaml
Naked has joined #ocaml
bruce_ has joined #ocaml
gim has quit [kornbluth.freenode.net irc.freenode.net]
shawn has quit [kornbluth.freenode.net irc.freenode.net]
shawn has joined #ocaml
gim has joined #ocaml
bruce_ has quit [Read error: 54 (Connection reset by peer)]
\rff has joined #ocaml
<\rff>
hi
<\rff>
a little problem for a newbie: how do I escape a '.' in Str.regexp ?
<\rff>
let item = Str.regexp "\." in gives me an error saying that \ is not allowed
<Riastradh>
\rff, you have to escape the backslash, too, because it's in a string literal.
<\rff>
so it becames '\\.', thanks
<\rff>
another question: if I'm using the interactive shell, how do I load a library ? I mean, when I compile I add it to the command line, but how I do it in the shell ?
Hadaka has quit [kornbluth.freenode.net irc.freenode.net]
teratorn has quit [kornbluth.freenode.net irc.freenode.net]
Naked is now known as Hadaka
teratorn has joined #ocaml
teratorn has quit [kornbluth.freenode.net irc.freenode.net]
teratorn has joined #ocaml
<pattern>
rff, try something like "ocaml -I /usr/lib/ocaml/3.06 str.cma" or just "ocaml str.cma"
<\rff>
pattern: yes, I know, but I wondered if I could load a module *after* I started the interpreter
<Riastradh>
#load "foo.cma" or something.
<\rff>
oh, tnx
karryall has joined #ocaml
\rff has quit [Read error: 104 (Connection reset by peer)]
The-Fixer has quit ["Goodbye"]
mattam_ has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
_shawn has joined #ocaml
shawn has quit [Connection timed out]
owll has joined #ocaml
owll has quit [Client Quit]
cjohnson has quit ["Drawn beyond the lines of reason"]
Potasso has joined #ocaml
Potasso has left #ocaml []
drworm has quit [Remote closed the connection]
drworm has joined #ocaml
riffraff has joined #ocaml
<riffraff>
hi gurus
<karryall>
hi
<riffraff>
mh.. what's wrong if I try to read a file in a list with: let rec f chan = try input_line chan :: f chan with End_of_file -> []
<karryall>
it's not tail recursive
<karryall>
thus it fails if there's many lines in the file
<riffraff>
karryall: sorry if I'm dumb, but I supposed ":: f chan" was the recursion
<karryall>
it is
<riffraff>
but it's not tail recursive because it's not the very last expression in the let rec ?
<karryall>
yes, it's not the last exporession (there's the :: after)
<karryall>
AND there's the exception handler that's also preventing the tail recursion
<pattern>
riffraff, first the "f chan" (right before the "with") is evaluated, and then that value is consed to the head of the list with ::
<pattern>
so the last thing that happens is the ::, not the recursive call to f
<riffraff>
I see
<pattern>
there is an idiomatic way to make a function tail recursive, and that is to use an accumulator
<pattern>
so that instead of first evaluating "f chan" and then consing that value to the head of the list, you instead pass the tail of the list in an accumulator to f, so that f can cons that value before calling itself recursively with the new value
<pattern>
sounds kind of complicated, but once you see it a few times it becomes pretty natural
<karryall>
pattern: except it won't work here because of the exn handler
<pattern>
yeah, once you've added the accumulator you'll need to deal with the exception
<pattern>
or vice versa, if you prefer
<riffraff>
I see, thanks
<pattern>
the key is to deal with the exception within the function itself, rather than have the function wrapped in an exception handler
<pattern>
because a function wrapped in an exception handler is not tail recursive, as karryall mentioned above
<pattern>
usually you could just catch the exception one or more levels up from the function itself... but with EOF it needs to be caught within the function, for obvious reasons
<riffraff>
intersting, thanks
<riffraff>
thanks pattern, karryall, bye
riffraff has quit []
karryall has quit ["home"]
maihem has joined #ocaml
lordjim has joined #ocaml
cjohnson has joined #ocaml
wazze has quit ["Ein Dieb ist jemand, der die Angewohnheit hat, Dinge zu finden, bevor andere Leute sie verlieren"]