right-pad

This commit is contained in:
mehbark 2023-02-14 15:34:51 -05:00
parent 1ae5d8eb46
commit ed68082ee0

View file

@ -528,3 +528,8 @@ def left_pad (to : Nat) {n : Nat} (with' : α) (xs : SizedArray α n)
exact left_pad' to with' xs hnle
#eval left_pad 10 413 (from_list [1,2,3,4,5,6,7])
def right_pad (to : Nat) {n : Nat} (with' : α) (xs : SizedArray α n)
: SizedArray α (max to n) := xs |> reverse |> left_pad to with' |> reverse
#eval right_pad 10 413 (from_list [1,2,3,4,5,6,7])