view tests/fact.ur @ 1524:a71223513c77

Compile self-tail-calls as gotos
author Adam Chlipala <adam@chlipala.net>
date Tue, 02 Aug 2011 17:04:14 -0400
parents
children
line wrap: on
line source
fun fact n = if n <= 1 then 1 else n * fact (n - 1)

fun factTr n acc = if n <= 1 then acc else factTr (n - 1) (n * acc)

fun main () : transaction page = return <xml>{[fact 10]}, {[factTr 10 1]}</xml>