view 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
line wrap: on
line source
fun one () = return 1

fun addEm n =
    if n = 0 then
        return 0
    else
        n1 <- rpc (one ());
        n2 <- addEm (n - 1);
        return (n1 + n2)

fun main () =
    s <- source 0;
    return <xml><body onload={n <- addEm 3; set s n}>
      <dyn signal={n <- signal s; return (txt n)}/>
    </body></xml>