Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] looping recursion
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: briand@a...
Subject: Re: [Caml-list] looping recursion
After sufficient googling I finally found a post which yields the answer :

let readfile chan =
  let rec loop rlst =
    let line, eof = 
        (input_line chan), false
        | End_of_file -> "", true
      if not eof then
        loop (line :: rlst)
        List.rev rlst
    loop []

but then it gets better.  Imagine my surprise when the following failed:

let data = readfile (open_in "data") in
let split_lines =
                    (fun line ->
  print_string "Done.\n";;

That's just not good !  I can't even use standard map without the
stack blowing up ?  This is a Bad Thing (TM).

Oh but wait. I peruse the manual.  map_rev is what I want.

So I'm going to make a bold statement that .map which blows up
shouldn't even exist and .rev_map should be renamed to .map.

Naturally someone will be telling me very shortly why you can't do this...


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: