def stack_sum := fun (n : Int) ↦
Id.run
(do
let mut st : List Int := []
for i in (PastaLean.pyRange n)do
st := PastaLean.pyAppend st i
let mut total : Int := (0 : Int)
while (PastaLean.pyTruthy st) do
let mut p'_popv_1 := PastaLean.pyPopValue st
st := PastaLean.pyPopRest st
total := total +ₚ p'_popv_1
return total)
def stack_sum'rn := fun (n : Int) ↦
Id.run
(do
let mut st : Array Int := #[]
for i in (PastaLean.pyRange n)do
st := PastaLean.pyArrayAppend st i
let mut total : Int := (0 : Int)
while (PastaLean.pyTruthy st) do
let mut p'_popv_1 := PastaLean.pyArrayPopValue st
st := PastaLean.pyArrayPopRest st
total := total +ₚ p'_popv_1
return total)