diff --git a/srcgen2/xats2js/srcgen1/DATS/js1emit_dynexp.dats b/srcgen2/xats2js/srcgen1/DATS/js1emit_dynexp.dats index f5b1f1e14..81912c471 100644 --- a/srcgen2/xats2js/srcgen1/DATS/js1emit_dynexp.dats +++ b/srcgen2/xats2js/srcgen1/DATS/js1emit_dynexp.dats @@ -1838,10 +1838,10 @@ i1tnmfpr(filr, itnm);strnfpr(filr, " // try\n")) // val () = ( -nindfpr(filr, nind); -strnfpr(filr, "try {\n"); -f0_i1tnmcmp(env0, itnm, icmp); -strnfpr(filr, "} catch(");i1valjs1(filr, iexn);strnfpr(filr, ") {\n")) +nindstrnfpr +(filr, nind, "try {\n");f0_i1tnmcmp(env0, itnm, icmp); +nindstrnfpr +(filr, nind, "} catch(");i1valjs1(filr, iexn);strnfpr(filr, ") {\n")) // val () = // enter envx2js_incnind(env0,2(*++*)) diff --git a/srcgen2/xats2js/srcgen1/TEST/JS/DATA/mytest11.dats b/srcgen2/xats2js/srcgen1/TEST/JS/DATA/mytest11.dats index 1a012b4e9..b4b410e58 100644 --- a/srcgen2/xats2js/srcgen1/TEST/JS/DATA/mytest11.dats +++ b/srcgen2/xats2js/srcgen1/TEST/JS/DATA/mytest11.dats @@ -1,4 +1,4 @@ -(* ****** ****** *) +* ****** ****** *) (* ****** ****** *) #staload UN = "prelude/SATS/unsfx00.sats" @@ -25,6 +25,7 @@ (* ****** ****** *) (* ****** ****** *) // +(* val fact = fix f(x: sint): sint => @@ -32,10 +33,59 @@ if x > 0 then x * f(x-1) else 1 // val ( ) = println("fact(10) = ", fact(10)) // +*) +// (* ****** ****** *) (* ****** ****** *) - -val () = $raise ErrorExn() +// +datatype +tree(a:type+) = +| tree_nil of () +| tree_cons of (tree(a), a, tree(a)) +// +fun + +tree_isAVL +(xs: tree(a)): bool = +( +try +let +val _ = +auxlst(xs) in true +end +with ~NotAVL() => false) +where +{ +// +excptcon NotAVL +// +fun +max +( x: sint +, y: sint): sint = +(if x >= y then x else y) +// +fun +auxlst(xs) = +( +case+ xs of +| +tree_nil +((*void*)) => 0 +| +tree_cons +(xs1, _, xs3) => +let +val h1 = auxlst(xs1) +val h3 = auxlst(xs3) +in + if + abs(h1-h3) <= 1 + then 1 + max(h1, h3) else $raise NotAVL() +end +) +// +} (*where*) // end of [tree_isAVL(xs)] (* ****** ****** *) (* ****** ****** *)