Browse thread
Re: [Caml-list] How to find out if a function is tail recursive?
-
Luc Maranget
-
John Max Skaller
- John Max Skaller
-
John Max Skaller
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | John Max Skaller <skaller@o...> |
| Subject: | Re: [Caml-list] How to find out if a function is tail recursive? |
John Max Skaller wrote: > let rec count lst = > match lst with > | [] -> 0 > | h :: t -> 1 + count t > > which isn't tail recursive. BTW: to see the last line spoils the tail recursion, rewrite it in functional notation: | h ::t -> add(1, count(t)) and you can now see that 'add' is the tail call, not count. -- John Max Skaller, mailto:skaller@ozemail.com.au snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia. voice:61-2-9660-0850 ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners