Skip to content

Commit

Permalink
Updating: very very minorly
Browse files Browse the repository at this point in the history
  • Loading branch information
githwxi committed Oct 23, 2024
1 parent 7f85cf6 commit d4a009c
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 7 deletions.
8 changes: 4 additions & 4 deletions srcgen2/xats2js/srcgen1/DATS/js1emit_dynexp.dats
Original file line number Diff line number Diff line change
Expand Up @@ -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(*++*))
Expand Down
56 changes: 53 additions & 3 deletions srcgen2/xats2js/srcgen1/TEST/JS/DATA/mytest11.dats
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(* ****** ****** *)
* ****** ****** *)
(* ****** ****** *)
#staload UN =
"prelude/SATS/unsfx00.sats"
Expand All @@ -25,17 +25,67 @@
(* ****** ****** *)
(* ****** ****** *)
//
(*
val fact =
fix
f(x: sint): sint =>
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
<a:type>
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)]

(* ****** ****** *)
(* ****** ****** *)
Expand Down

0 comments on commit d4a009c

Please sign in to comment.