diff options
author | Chloe Brown <chloe.brown.00@outlook.com> | 2025-06-26 13:56:26 +0100 |
---|---|---|
committer | Chloe Brown <chloe.brown.00@outlook.com> | 2025-06-26 13:56:26 +0100 |
commit | a5178bb076a21b9ffbf4236683d89c8a6cd2258c (patch) | |
tree | 0d6e59f79d2b12be24ff7f33ada96c51a70b47b7 /sec/encoding.ltx | |
parent | c880808d0e1ac239603c2b7a1ecb339426fe23a6 (diff) |
Fix 620--635.
Diffstat (limited to 'sec/encoding.ltx')
-rw-r--r-- | sec/encoding.ltx | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/sec/encoding.ltx b/sec/encoding.ltx index c5a311b..1078597 100644 --- a/sec/encoding.ltx +++ b/sec/encoding.ltx @@ -349,21 +349,20 @@ lists passed to \roll*{} have a static length making the \(\mathsf{max}\) operator easy to partially evaluate. After phase three, our example for \systemtinline{balanced} beta -reduces to the following: +reduces to the below. This example demonstrates both pattern matching +and indexing lists. In the \systemtinline{Suc} branch, the variable +\systemtinline{dh} stores the result of indexing the single list +\systemtinline{[(depth, heap)]}. \begin{listing}[H] \begin{systemt} let balanced n f = primrec n with - Zero => (1 , fun (length, idxs) => + Zero => (Suc Zero , fun (length, idxs) => if length == 0 then Leaf f else snd arb (length - 1, fun i => idxs (Suc i))) -| Suc (depth, heap) => (Suc ((depth - depth) + depth), fun (length, idxs) => - if length == 0 then Branch (0, 1) else - let x = idxs 0 in - let dh = - if x == 0 then (depth, heap) else - if x - 1 == 0 then (depth, heap) else - arb - in snd dh (length - 1, fun i => idxs (Suc i))) +| Suc (depth, heap) => (Suc depth, fun (length, idxs) => + if length == 0 then Branch (0, 0) else + let dh = if idxs 0 == 0 then (depth, heap) else arb in + snd dh (length - 1, fun i => idxs (Suc i))) \end{systemt} \vspace{-\baselineskip} \end{listing} |