Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,29 @@
|
|||
" Create a two-dimensional array with r rows and c columns.
|
||||
" The optional third argument specifies the initial value
|
||||
" (default is 0).
|
||||
function MakeArray(r, c, ...)
|
||||
if a:0
|
||||
let init = a:1
|
||||
else
|
||||
let init = 0
|
||||
endif
|
||||
|
||||
let temp = []
|
||||
for c in range(a:c)
|
||||
call add(temp, init)
|
||||
endfor
|
||||
|
||||
let array = []
|
||||
for r in range(a:r)
|
||||
call add(array, temp[:])
|
||||
endfor
|
||||
return array
|
||||
endfunction
|
||||
|
||||
let rows = input("Enter number of rows: ")
|
||||
let cols = input("Enter number of columns: ")
|
||||
echo "\n"
|
||||
let array = MakeArray(rows, cols)
|
||||
let array[rows - 1][cols - 1] = rows * cols
|
||||
echo array[rows - 1][cols - 1]
|
||||
unlet array
|
||||
Loading…
Add table
Add a link
Reference in a new issue