This commit is contained in:
2026-04-26 12:56:37 +07:00
parent 470f7223a5
commit 69cb3ea452
3 changed files with 137 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
{
"worktrees": {},
"sessions": {},
"tabOrder": {
"local": [
"pending:1"
]
}
}

View File

View File

@@ -0,0 +1,128 @@
# ---------------------------------------------- 100 --------------------------------------------- #
# next number is x - 1 +3
function add_next_number(l::AbstractVector)::AbstractVector
next_number = l[end] -1 +3
new_l = deepcopy(l)
push!(new_l, next_number)
return new_l
end
function add_next_number_inplace(l::AbstractVector)
next_number = l[end] -1 +3
push!(l, next_number)
end
function main()
# non-inplace version
v = [1]
n = 5
for i in 1:n
v = add_next_number(v)
end
println("not inplace $v")
# inplace version
v2 = [2]
for i in 1:n
add_next_number_inplace(v2)
end
println("inplace $v2")
end
main()