Skip to content

Commit

Permalink
Add Vec API (#876)
Browse files Browse the repository at this point in the history
  • Loading branch information
shazqadeer authored Apr 25, 2024
1 parent ba61f31 commit 443683c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Source/Core/base.bpl
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,17 @@ function {:inline} Vec_Swap<T>(v: Vec T, i: int, j: int): Vec T
)
}

function {:inline} Vec_Remove<T>(v: Vec T): Vec T {
(
var cond, new_len := 0 < v->len, v->len - 1;
Vec(v->contents[new_len := if (cond) then Default() else v->contents[new_len]], if (cond) then new_len else v->len)
)
function {:inline} Vec_Remove<T>(v: Vec T): Vec T
{
(
var cond, new_len := 0 < v->len, v->len - 1;
Vec(v->contents[new_len := if (cond) then Default() else v->contents[new_len]], if (cond) then new_len else v->len)
)
}

function {:inline} Vec_Contains<T>(v: Vec T, i: int): bool
{
0 <= i && i < Vec_Len(v)
}

// extensionality lemma to be used explicitly by the programmer
Expand Down

0 comments on commit 443683c

Please sign in to comment.