sponge45 changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/
pango_ has joined #ocaml
smimou has quit ["bli"]
pango has quit [Remote closed the connection]
Aradorn has joined #ocaml
hedos has left #ocaml []
MisterC has joined #ocaml
malc_ has joined #ocaml
Skal has quit [Connection timed out]
<SolarBear>
Hey, anyone available for a simple question
<malc_>
yes
<SolarBear>
I'm new to ocaml and I'm trying this :
<SolarBear>
let merge_i list1 list2 = List.sort (list1 @ list2)
<SolarBear>
I get : This expression has type 'a list but is here used with type 'b -> 'b -> int
<malc_>
List.sort has two parameters
<malc_>
first comparision function
<malc_>
and the second the list to be sorted
<malc_>
List.sort compare (list1 @ list2) - should work
<SolarBear>
ah
<malc_>
comparison even
<SolarBear>
Ah! many thanks
<malc_>
np
Axioplase has quit ["leaving"]
mbishop has joined #ocaml
lmbdwr has joined #ocaml
<lmbdwr>
hi.
<lmbdwr>
anyone for a coq question ?
Aradorn has quit ["Leaving"]
solarbear_ has joined #ocaml
SolarBear has quit [Read error: 110 (Connection timed out)]
solarbear_ has quit [Remote closed the connection]
sheets has joined #ocaml
<sheets>
In what cases does OCaml iterize tail-recursive functions? I have a function with a simple nested if-then conditional with three branches: base case, recursive case 1, recursive case 2. I get stack overflows. What gives?
<malc_>
despite what you think your function is not tail-recursive (for whatever reason)
<sheets>
yes... that has become quite obvious. Do you know what OCaml requires for tail-recursion?
<sheets>
I can't imagine that my other code is giving me stack overflows...
<sheets>
unless List.map uses a call that's not tail recursive
<malc_>
List.map is a non tail-recursive function all by itself
<malc_>
val map : ('a -> 'b) -> 'a list -> 'b list
<malc_>
(** [List.map f [a1; ...; an]] applies function [f] to [a1, ..., an], and builds the list [[f a1; ...; f an]] with the results returned by [f]. Not tail-recursive. *)
<sheets>
so... if I have a list that is > MAX_STACK_SIZE, List.map will overflow?
<tsuyoshi>
the extlib replacement is tail recursive though
<sheets>
!?
<malc_>
sheets: use rev_map
<sheets>
Why the hell would you implement List.map not tail-recursively?! #$&*#
<sheets>
rev_map?
<malc_>
mailing-list had witnessed long debates on the subject in the past
<sheets>
>_<
<malc_>
val rev_map : ('a -> 'b) -> 'a list -> 'b list
<malc_>
(** [List.rev_map f l] gives the same result as {!List.rev}[ (]{!List.map}[ f l)], but is tail-recursive and more efficient. *)
<sheets>
how are you getting this doc?
<malc_>
well `man List' and or cat $prefix/lib/ocaml/Module.mli get's me by nicely
<malc_>
in otherwords i practice rtfm
<sheets>
wow... i had no idea that the distribution installed man pages
<sheets>
that will be helpful...
<sheets>
additionally, do you know a good, syntactic tutorial? I have functional programming down but the ocaml syntax trips me up sometimes.
<malc_>
not really. there are a few sites on the net that describe the differences between sml/ocaml and or revised/orignal syntax
<malc_>
those might be handy
<tsuyoshi>
I found the "developing applications with ocaml" book pretty useful