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
-
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: | [Caml-list] This is so nice .. |
I can hardly believe this works.
I copied this trick from Jacque's code
http://wwwfun.kurims.kyoto-u.ac.jp/~garrigue/papers/mixev3.04.ml.txt
Thanks! This is really great stuff.
I feel like a dill: its exactly the same
as the parameterised class trick I already
knew about.
------------------------------------------
type 'a s1 = [`A | `B of 'a]
type 'a s2 = ['a s1 | `C]
type ss1 = 'a s1 as 'a
type ss2 = 'a s2 as 'a
let rec reduce : ss2 -> ss1 = function
| `A -> `A
| `B z -> `B (reduce z)
| `C -> raise Not_found
;;
reduce (`B `C);;
--
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