Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
artoy committed Aug 24, 2023
1 parent ea58b0d commit 881902f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/test/list/nth.imp
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
nth(l, n) {
mklist(n) {
if n = 0 then Nil else {
let h = _ in
let m = n + -1 in
let t = mkref mklist(m) in
Cons h t
}
}

nth(l, n) {
match l with
Nil -> fail
| Cons h t -> {
let m = n + -1 in
if n = 1 then h else nth(*t, m)
}
}

{

let n = ( _ : ~ >= 1) in
let k = ( _ : ~ >= 1 /\ ~ <= n) in
let l = mklist(n) in
nth(l, k)
}

0 comments on commit 881902f

Please sign in to comment.