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
willb has quit ["Leaving"]
nuncanada has joined #ocaml
Raynes has joined #ocaml
barismetin has quit [Remote closed the connection]
psnively has quit []
bzzbzz has joined #ocaml
jeddhaberstro has joined #ocaml
Smerdyakov has joined #ocaml
fschwidom has quit [Remote closed the connection]
Amorphous has quit [Read error: 104 (Connection reset by peer)]
Amorphous has joined #ocaml
nuncanada has quit [Remote closed the connection]
Smerdyakov has quit [Read error: 110 (Connection timed out)]
willb has joined #ocaml
mib_nrnl1d has joined #ocaml
jeddhaberstro has quit []
jeremiah has quit [Read error: 104 (Connection reset by peer)]
seafood has joined #ocaml
jeremiah has joined #ocaml
alexyk has joined #ocaml
johnnowak has quit []
rwmjones has quit [Read error: 60 (Operation timed out)]
rwmjones has joined #ocaml
<noon> alternatively you can also use Emacs' inferior-caml mode
seafood has quit []
<Raynes> I use Tuareg mode.
alexyk has quit []
alexyk has joined #ocaml
mib_nrnl1d has quit ["http://www.mibbit.com ajax IRC Client"]
seafood has joined #ocaml
seafood has quit []
itewsh has joined #ocaml
dejj has quit [Read error: 110 (Connection timed out)]
johnnowak has joined #ocaml
dejj has joined #ocaml
alexyk has quit []
shortc|desk has quit [Read error: 110 (Connection timed out)]
seafood has joined #ocaml
dejj has quit [Read error: 110 (Connection timed out)]
ygrek has joined #ocaml
dejj has joined #ocaml
fschwidom has joined #ocaml
fschwidom has quit [Remote closed the connection]
fschwidom has joined #ocaml
Snark has joined #ocaml
seafood has quit [Read error: 110 (Connection timed out)]
shortc|desk has joined #ocaml
_zack has joined #ocaml
dejj has quit [Read error: 110 (Connection timed out)]
dejj has joined #ocaml
_zack has quit ["Leaving."]
dejj has quit [Read error: 145 (Connection timed out)]
snhmib has quit [Remote closed the connection]
dejj has joined #ocaml
_zack has joined #ocaml
johnnowak has quit []
fschwidom has quit [No route to host]
ikaros has joined #ocaml
dejj has quit [Read error: 110 (Connection timed out)]
dejj has joined #ocaml
_zack has quit ["Leaving."]
m3ga has quit ["disappearing into the sunset"]
dejj has quit ["Leaving..."]
kig has left #ocaml []
fschwidom has joined #ocaml
<maxote> is there any link made in Java instead of in C# as it http://sourceforge.net/projects/categorytheory/ ?
mehdid_ has joined #ocaml
mehdid has quit [Read error: 131 (Connection reset by peer)]
seafood has joined #ocaml
itewsh has quit [Read error: 110 (Connection timed out)]
itewsh has joined #ocaml
marmotine has joined #ocaml
slash_ has quit [Client Quit]
nuncanada has joined #ocaml
alexyk has joined #ocaml
vixey has joined #ocaml
seafood has quit [Read error: 113 (No route to host)]
Anarchos has joined #ocaml
alexyk has quit []
alexyk has joined #ocaml
Smerdyakov has joined #ocaml
alexyk has quit [Client Quit]
Stefan_vK1 has joined #ocaml
Stefan_vK has quit [Read error: 110 (Connection timed out)]
smimou has quit ["bli"]
alexyk has joined #ocaml
Associat0r has joined #ocaml
_zack has joined #ocaml
johnnowak has joined #ocaml
johnnowak has quit [Client Quit]
nuncanada has quit [Read error: 110 (Connection timed out)]
nuncanada has joined #ocaml
_zack has quit ["Leaving."]
marmotine has quit ["mv marmotine Laurie"]
smimou has joined #ocaml
ygrek has quit [Remote closed the connection]
_zack has joined #ocaml
blizz2 has joined #ocaml
_zack has quit ["Leaving."]
jeremiah has quit [Read error: 104 (Connection reset by peer)]
blizz2 has quit []
Raynes has quit [Read error: 104 (Connection reset by peer)]
slash__ has joined #ocaml
ygrek has joined #ocaml
slash__ has quit [Read error: 60 (Operation timed out)]
jlouis has joined #ocaml
jeremiah has joined #ocaml
Raynes has joined #ocaml
Anarchos has quit ["Vision[0.8.5-0418]: i've been blurred!"]
ikaros has quit [Read error: 104 (Connection reset by peer)]
ygrek has quit [Remote closed the connection]
ikaros has joined #ocaml
jlouis has quit [Remote closed the connection]
Snark has quit ["Ex-Chat"]
Anarchos has joined #ocaml
ikaros has quit [Remote closed the connection]
ikaros has joined #ocaml
<noon> I have:
<noon> let aux =
<noon> let l = ref [] in
<noon> try
<noon> while true do
<noon> l := (input_line input)::!l
<noon> done
<noon> with
<noon> | End_of_file -> let _ = close_in input in !l
<noon> in
<noon> aux
<noon> however the compiler says that the try block has type unit and thus I cannot return !l
noon was kicked from #ocaml by Smerdyakov [Smerdyakov]
noon has joined #ocaml
<Smerdyakov> Don't paste that much code.
<noon> oh
<noon> is there a limit on the number of lines?
<vixey> yes
<Smerdyakov> I feel like 1 is a good limit. :P
<noon> sorry
<Smerdyakov> There is no programming channel on Freenode where the paste you just made would be appropriate, I think.
<vixey> well there's only one channel about ocaml.. :p
<Smerdyakov> vixey, I meant in terms of length.
<vixey> yeah I was just kidding Smerdyakov
<Smerdyakov> noon, the [try] block indeed does have type [unit]. Why do you think it shouldn't
<noon> it should, but I would like to know what's the Right Thing to do in this case: add a never-reached value after the while?
<Smerdyakov> noon, IMO, you should never use loops in OCaml.
<noon> actually I tried to use a recursive function instead but it raised a Stack_overflow
<Smerdyakov> noon, but, for a quick fix in your case, it looks like you just want to move the [!l] outside of the [try..with].
<vixey> noon, you could do this without any ref cell
<Smerdyakov> noon, that was because you didn't make your function tail-recursive.
<Smerdyakov> noon, pending exception handlers block tail recursion.
<noon> I believe it was not tail-recursive because there was the try-with block around the recursive call
<Smerdyakov> noon, yup, that's a restatement of what I just said. :)
<vixey> like let rec lines input rest = try lines input (input_line input :: rest) with End_of_file -> close_input input; rest
<Smerdyakov> noon, move the [try..with] to a context with no recursive calls, returning an [option] to indicate which case fired. That's the standard idiom.
<Smerdyakov> vixey, that's not tail-recursive.
<Smerdyakov> vixey, also, of course, your version returns different results than the original.
<Smerdyakov> vixey, oops, never mind!
<vixey> sorry I don't know ocaml as well as I thought ..I see why it's not tail recursive now
<vixey> yes a function like input_line except, that returns option seems perfect
<cygnus_> can you write map as a tail recursion?
<Smerdyakov> cygnus_, every OCaml program can be written using no kind of recursion besides tail recursion.
<cygnus_> why is the implementation of map not tail recursive
<noon> ... given sufficient work, in certain cases, probably
<Smerdyakov> Search me.
<cygnus_> google you? or you have no idea
<Smerdyakov> noon, the "in certain cases" and "probably" are unnecessary.
<Smerdyakov> cygnus_, no idea.
<Smerdyakov> noon, there is an automatic transformation of every OCaml program to a version with only tail recursion.
<noon> oh; it adds additional stacks?
<vixey> are you talking about CPS or deforistation?
<Smerdyakov> CPS translation is one possibility.
<Smerdyakov> CPS-translated programs don't need stacks.
<noon> Smerdyakov: I'll try to do my function without loops. Do you think it is a good idea to use a reference nevertheless? I don't feel too comfortable with mixing recursive functions and reference usage...
<Smerdyakov> noon, no, I think you should think long and hard before using any imperative feature of OCaml. Your example doesn't pass my personal admission test.
<noon> hehe
<noon> Well, I have no idea on how to do that. It seems that there is no easy way to know when the stream is at end of file apart from catching the End_of_file exception. And in this case, how can I return a list that has been constructed by a recursive function inside the try block?
<Smerdyakov> Like I said, catch the exception in a sub-expression with no recursive call.
<vixey> ..a function like input_line except, that returns option?
<noon> Smerdyakov: okay, I have found, thank you!
willb has quit ["Leaving"]
<noon> vixey: that's what I have done
<noon> vixey: I hope it passes the admission test :)
<det> Ocaml using exceptions instead of options is a PITA for recursive functions
<det> match
<det> try
<det> Some (Gzip.input_char in_gzip)
<det> with
<det> End_of_file -> None
<det> with
<det> None ->
<det> ...
<det> You have to do crap like that :<
* det is afk now
<noon> is det going to be kicked?
Anarchos has quit ["Vision[0.8.5-0418]: i've been blurred!"]
itewsh has quit ["KTHXBYE"]
itewsh has joined #ocaml
itewsh has quit [Client Quit]
fschwidom has quit [Remote closed the connection]