annotate tests/tail.ur @ 954:2a50da66ffd8

Basic tail recursion introduction seems to be working
author Adam Chlipala <adamc@hcoop.net>
date Thu, 17 Sep 2009 16:35:11 -0400
parents
children d80734855790
rev   line source
adamc@954 1 fun one () = return 1
adamc@954 2
adamc@954 3 fun addEm n =
adamc@954 4 if n = 0 then
adamc@954 5 return 0
adamc@954 6 else
adamc@954 7 n1 <- rpc (one ());
adamc@954 8 n2 <- addEm (n - 1);
adamc@954 9 return (n1 + n2)
adamc@954 10
adamc@954 11 fun main () =
adamc@954 12 s <- source 0;
adamc@954 13 return <xml><body onload={n <- addEm 3; set s n}>
adamc@954 14 <dyn signal={n <- signal s; return (txt n)}/>
adamc@954 15 </body></xml>