Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -0,0 +1,5 @@
|
|||
type Grade is range 0..100;
|
||||
subtype Lower_Case is Character range 'a'..'z';
|
||||
subtype Natural is Integer range 0..Integer'Last;
|
||||
subtype Positive is Integer range 1..Integer'Last;
|
||||
type Deflection is range -180..180;
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
Mat1 : Matrix;
|
||||
Mat2 : Matrix;
|
||||
...
|
||||
Mat1 := Mat2;
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
V1 : Vector := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
|
||||
V2 : Vector := (2, 2, 2, 2, 2, 2, 2, 2, 2, 2);
|
||||
...
|
||||
V2(3..6) := V1(7..10);
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
function "*" (Left : Vector; Right : Integer) return Vector is
|
||||
Result : Vector;
|
||||
begin
|
||||
for I in Vector'Range loop
|
||||
Result(I) := Left(I) * Right;
|
||||
end loop;
|
||||
return Result;
|
||||
end "*"
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
type Unconstrained_Vector is array (Positive range <>) of Integer;
|
||||
U1 : Unconstrained_Vector := (1,2,3,4,5,6,7,8,9,10);
|
||||
U2 : Unconstrained_Vector := (10,11,12,13);
|
||||
...
|
||||
function "*" (Left : Unconstrained_Vector; Right : Integer) return Unconstrained_Vector is
|
||||
Result : Unconstrained_Vector(Left'Range);
|
||||
begin
|
||||
for I in Left'Range loop
|
||||
Result(I) := Left(I) * Right;
|
||||
end loop;
|
||||
return Result;
|
||||
end "*";
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
type Char_Array is array (0..9) of Character; -- A constrained array of characters
|
||||
type String is array (Positive range <>) of Character; -- An unconstrained array of characters
|
||||
|
|
@ -0,0 +1 @@
|
|||
subtype Positive is Integer range 1..Integer'Last;
|
||||
|
|
@ -0,0 +1 @@
|
|||
Name : String := "Rosetta Code";
|
||||
|
|
@ -0,0 +1 @@
|
|||
Num_Elements : Natural := Char_Array'Length;
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
type Vector is array (1..10) of Integer;
|
||||
type Table is array (0..99) of Vector;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
V : Vector;
|
||||
...
|
||||
V(2) := 10;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
T : Table;
|
||||
...
|
||||
T(1)(2) := 10;
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
type Matrix is array (0..99, 1..10) of Integer;
|
||||
M : Matrix;
|
||||
...
|
||||
M(1,2) := 10;
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
CL-USER> ;; create a 4-dimensional array
|
||||
(make-array '(5 4 3 2) :initial-element 0)
|
||||
#4A((((0 0) (0 0) (0 0))
|
||||
((0 0) (0 0) (0 0))
|
||||
((0 0) (0 0) (0 0))
|
||||
((0 0) (0 0) (0 0)))
|
||||
(((0 0) (0 0) (0 0))
|
||||
((0 0) (0 0) (0 0))
|
||||
((0 0) (0 0) (0 0))
|
||||
((0 0) (0 0) (0 0)))
|
||||
(((0 0) (0 0) (0 0))
|
||||
((0 0) (0 0) (0 0))
|
||||
((0 0) (0 0) (0 0))
|
||||
((0 0) (0 0) (0 0)))
|
||||
(((0 0) (0 0) (0 0))
|
||||
((0 0) (0 0) (0 0))
|
||||
((0 0) (0 0) (0 0))
|
||||
((0 0) (0 0) (0 0)))
|
||||
(((0 0) (0 0) (0 0))
|
||||
((0 0) (0 0) (0 0))
|
||||
((0 0) (0 0) (0 0))
|
||||
((0 0) (0 0) (0 0))))
|
||||
CL-USER> ;; bind it to a variable (in the REPL, '*' is the value of the last evaluated form)
|
||||
(defparameter arr *)
|
||||
ARR
|
||||
CL-USER> ;; query array rank (number of dimensions) and dimensions
|
||||
(array-rank arr)
|
||||
4
|
||||
CL-USER> (array-dimensions arr)
|
||||
(5 4 3 2)
|
||||
CL-USER> ;; access, set, and access again element
|
||||
(aref arr 3 2 1 1)
|
||||
0
|
||||
CL-USER> (setf (aref arr 3 2 1 1) 2)
|
||||
2
|
||||
CL-USER> (aref arr 3 2 1 1)
|
||||
2
|
||||
CL-USER> ;; arrays are stored row-major order and elements can be accessed (and set) that way
|
||||
;; first let's get the row-major index
|
||||
(array-row-major-index arr 3 2 1 1)
|
||||
87
|
||||
CL-USER> (setf (row-major-aref arr 87) 3)
|
||||
3
|
||||
CL-USER> (aref arr 3 2 1 1)
|
||||
3
|
||||
CL-USER> ;; adjustable arrays can be reshaped
|
||||
(make-array '(3 3 3) :adjustable t :initial-element 0)
|
||||
#3A(((0 0 0) (0 0 0) (0 0 0))
|
||||
((0 0 0) (0 0 0) (0 0 0))
|
||||
((0 0 0) (0 0 0) (0 0 0)))
|
||||
CL-USER> (adjust-array * '(4 4 4) :initial-element 1)
|
||||
#3A(((0 0 0 1) (0 0 0 1) (0 0 0 1) (1 1 1 1))
|
||||
((0 0 0 1) (0 0 0 1) (0 0 0 1) (1 1 1 1))
|
||||
((0 0 0 1) (0 0 0 1) (0 0 0 1) (1 1 1 1))
|
||||
((1 1 1 1) (1 1 1 1) (1 1 1 1) (1 1 1 1)))
|
||||
CL-USER> ;; some built-in limits for arrays (they seem to be memory bound):
|
||||
(list array-rank-limit array-dimension-limit array-total-size-limit)
|
||||
(129 35184372088832 35184372088832)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
let d4=Array4D.init 3 4 5 6 (fun n i g l->n,i,g,l)
|
||||
printfn "%A %A" d4[1,2,3,4] d4[2,3,4,5]
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
//
|
||||
// Multi-Dimensional Array
|
||||
// Using FutureBasic 7.0.34, August 2025 R.W
|
||||
|
||||
window 1
|
||||
|
||||
Int my2DArray(2, 3) // traditional 2 x 3
|
||||
|
||||
// myArray: 0,0 - 0,1 - 0,2 - 0,3
|
||||
// 1,0 - 1,1 - 1,2 - 1,3
|
||||
// 2,0 - 2,1 - 2,2 - 2,3
|
||||
|
||||
// This is like a theater seating chart
|
||||
// of three rows with four seats in each row
|
||||
|
||||
// to index or point to each position, you
|
||||
// need two numbers to address the row and seat (column)
|
||||
|
||||
Int rowIndex, colIndex
|
||||
|
||||
for rowIndex = 0 to 2 // three rows
|
||||
for colIndex = 0 to 3 // of four seats
|
||||
my2DArray(rowIndex, colIndex) = rnd(6) //assign random number 1-6
|
||||
print my2DArray(rowIndex, colIndex);" "; //see the contents
|
||||
next colIndex
|
||||
print
|
||||
next rowIndex
|
||||
|
||||
// The elements of my2DArray(2,3) are stored in row-major-order
|
||||
// in contiguous locations in memory:
|
||||
|
||||
// my2DArray (0,0)
|
||||
// my2DArray (0,1)
|
||||
// my2DArray (0,2)
|
||||
// my2DArray (0,3)
|
||||
// my2DArray (1,0)
|
||||
// my2DArray (1,1)
|
||||
// my2DArray (1,2)
|
||||
// my2DArray (1,3)
|
||||
// my2DArray (2,0)
|
||||
// my2DArray (2,1)
|
||||
// my2DArray (2,2)
|
||||
// my2DArray (2,2)
|
||||
|
||||
// Here is a 4 dimansional array
|
||||
|
||||
Double my4DArray(2,3,3,3) // A traditional 4 dimensional array
|
||||
my4DArray(0,0,0,1) = 4 // asigning value into the array
|
||||
|
||||
|
||||
print@
|
||||
|
||||
// Non traditional MDA array, does not need to be declared.
|
||||
// MDA arrays are mutable, single or multi-dimensional, always
|
||||
// global in scope and are zero-based.
|
||||
//
|
||||
// MDA arrays are identified by a tag (if omitted mda 0 is used).
|
||||
// To help identify the MDA arrays (if you're using more than one)
|
||||
// you can assign constants to the tag, for example:
|
||||
//
|
||||
// _cardDeck = 1
|
||||
// _Lights = 2
|
||||
//
|
||||
// You can then identify the MDA array as such
|
||||
//
|
||||
// mda _cardDeck(0) = @"AC"
|
||||
// mda _cardDeck(1) = @"1C"
|
||||
//
|
||||
// mda _Lights(0) = LEDseq1
|
||||
// etc.
|
||||
//
|
||||
// Which will help you identify in your code which array you
|
||||
// are dealing with (instead of remembering numerical values).
|
||||
//
|
||||
// In the example below, the mda has a tag of 1 to identify it.
|
||||
// While MDA stands for Multi Dimensional Array, it can also
|
||||
// be used for a single dimensional use.
|
||||
|
||||
// What makes MDA versatile is the fact that you can assign
|
||||
// anything.
|
||||
|
||||
// In a traditional array where you defined the variable
|
||||
// type, you are committed to that type. For example, if
|
||||
// you declared Int my2DArray(2, 3), you are committed to
|
||||
// assign only integer values into the array. With an MDA
|
||||
// array you can place whatever value, as this example
|
||||
// below
|
||||
|
||||
mda 1(0,0) = 1.5 // it can have a number
|
||||
mda 1(1,0) = @"Charlie" // it can have a string
|
||||
mda 1(2,0) = PI // it can have constant
|
||||
|
||||
print@ mda 1(0,0), mda 1(1,0), mda 1 (2,0)
|
||||
CGRect r // declare r to be a rectangle record
|
||||
r.origin.x = 10 // x = 10
|
||||
r.origin.y = 20 // y = 20
|
||||
r.size.width = 300 // width = 300
|
||||
r.size.height = 150 // height = 150
|
||||
|
||||
// Stuff this record/structure into an mda array element
|
||||
|
||||
mda 1(0,1) = r
|
||||
|
||||
print @"Contents of mda 1(0,1) = "; mda 1(0,1) // see if it's there
|
||||
print@
|
||||
|
||||
// you can also transfer the record in its entirety
|
||||
|
||||
CGRect newRect
|
||||
newRect = mda 1(0,1)
|
||||
|
||||
// see if it transfers
|
||||
print @"Contents of newRect = mda 1(0,1)"
|
||||
print @" x = ";newRect.origin.x
|
||||
print @" y = ";newRect.origin.y
|
||||
print @"width = ";newRect.size.width
|
||||
print @"height= ";newRect.size.height
|
||||
|
||||
// MDA type array also has built in helper which doesn't exist
|
||||
// in traditional arrays such as sort ability.
|
||||
|
||||
mda 2(0) = @"Zulu"
|
||||
mda 2(1) = @"Charlie"
|
||||
mda 2(2) = @"Alpha"
|
||||
|
||||
print@
|
||||
print @"Contents of mda 2"
|
||||
Int x
|
||||
for x = 0 to 2:print@ x;@" = "; mda 2(x): next x
|
||||
print @
|
||||
|
||||
mda_sort 2 // sort the array
|
||||
|
||||
print @"Sorted:"
|
||||
for x = 0 to 2:print@ x;@" = "; mda 2(x): next x
|
||||
|
||||
// Another helper example
|
||||
|
||||
print@
|
||||
print @"mda 2 array has ";mda_count 2;@" elements"
|
||||
//
|
||||
// For more info see documentation of mda arrays at
|
||||
// https://www.brilorsoftware.com/fb/documentation/FBHelp/pgs/mda.html
|
||||
|
||||
handleEvents
|
||||
|
|
@ -1,3 +1 @@
|
|||
-->
|
||||
<span style="color: #004080;">sequence</span> <span style="color: #000000;">xyz</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">x</span><span style="color: #0000FF;">),</span><span style="color: #000000;">y</span><span style="color: #0000FF;">),</span><span style="color: #000000;">z</span><span style="color: #0000FF;">)</span>
|
||||
<!--
|
||||
sequence xyz = repeat(repeat(repeat(0,x),y),z)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
-->
|
||||
<span style="color: #004080;">sequence</span> <span style="color: #000000;">line</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">x</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #004080;">sequence</span> <span style="color: #000000;">plane</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #000000;">line</span><span style="color: #0000FF;">,</span><span style="color: #000000;">y</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #004080;">sequence</span> <span style="color: #000000;">space</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #000000;">plane</span><span style="color: #0000FF;">,</span><span style="color: #000000;">z</span><span style="color: #0000FF;">)</span>
|
||||
<!--
|
||||
sequence line = repeat(0,x)
|
||||
sequence plane = repeat(line,y)
|
||||
sequence space = repeat(plane,z)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,6 @@
|
|||
-->
|
||||
<span style="color: #004080;">sequence</span> <span style="color: #000000;">rqd</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">),</span><span style="color: #000000;">3</span><span style="color: #0000FF;">),</span><span style="color: #000000;">4</span><span style="color: #0000FF;">),</span><span style="color: #000000;">5</span><span style="color: #0000FF;">),</span>
|
||||
<span style="color: #000000;">row</span> <span style="color: #000080;font-style:italic;">-- scratch var</span>
|
||||
sequence rqd = repeat(repeat(repeat(repeat(0,2),3),4),5)
|
||||
|
||||
<span style="color: #000000;">rqd</span><span style="color: #0000FF;">[</span><span style="color: #000000;">5</span><span style="color: #0000FF;">][</span><span style="color: #000000;">4</span><span style="color: #0000FF;">][</span><span style="color: #000000;">3</span><span style="color: #0000FF;">][</span><span style="color: #000000;">2</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">:=</span> <span style="color: #000000;">5432</span>
|
||||
<span style="color: #0000FF;">?</span><span style="color: #000000;">rqd</span><span style="color: #0000FF;">[</span><span style="color: #000000;">5</span><span style="color: #0000FF;">][</span><span style="color: #000000;">4</span><span style="color: #0000FF;">][</span><span style="color: #000000;">3</span><span style="color: #0000FF;">][</span><span style="color: #000000;">2</span><span style="color: #0000FF;">]</span>
|
||||
|
||||
<span style="color: #000000;">row</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">rqd</span><span style="color: #0000FF;">[</span><span style="color: #000000;">5</span><span style="color: #0000FF;">][</span><span style="color: #000000;">4</span><span style="color: #0000FF;">][</span><span style="color: #000000;">3</span><span style="color: #0000FF;">]</span> <span style="color: #000080;font-style:italic;">-- row is now [0,5432]</span>
|
||||
<span style="color: #000000;">row</span><span style="color: #0000FF;">[</span><span style="color: #000000;">1</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span> <span style="color: #000080;font-style:italic;">-- rqd remains unchanged</span>
|
||||
<span style="color: #000000;">rqd</span><span style="color: #0000FF;">[</span><span style="color: #000000;">5</span><span style="color: #0000FF;">][</span><span style="color: #000000;">4</span><span style="color: #0000FF;">][</span><span style="color: #000000;">3</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">row</span> <span style="color: #000080;font-style:italic;">-- rqd[5][4][3][1] is now 1</span>
|
||||
<span style="color: #000000;">rqd</span><span style="color: #0000FF;">[</span><span style="color: #000000;">5</span><span style="color: #0000FF;">][</span><span style="color: #000000;">4</span><span style="color: #0000FF;">][</span><span style="color: #000000;">2</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">10</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- middle element of rqd[5][4] is now longer than the other two</span>
|
||||
<span style="color: #0000FF;">?</span><span style="color: #000000;">rqd</span><span style="color: #0000FF;">[</span><span style="color: #000000;">5</span><span style="color: #0000FF;">][</span><span style="color: #000000;">4</span><span style="color: #0000FF;">]</span>
|
||||
<!--
|
||||
rqd[5][4][3][2] := 5432
|
||||
rqd[5][4][3][1] = 1
|
||||
rqd[5][4][2] = repeat(0,10)
|
||||
?rqd[5][4]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,3 @@
|
|||
-->
|
||||
<span style="color: #0000FF;">?</span><span style="color: #008000;">"==1=="</span>
|
||||
<span style="color: #7060A8;">pp</span><span style="color: #0000FF;">(</span><span style="color: #000000;">rqd</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">pp_Nest</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">})</span>
|
||||
<span style="color: #0000FF;">?</span><span style="color: #008000;">"==2=="</span>
|
||||
<span style="color: #7060A8;">pp</span><span style="color: #0000FF;">(</span><span style="color: #000000;">rqd</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">pp_Nest</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">})</span>
|
||||
<span style="color: #0000FF;">?</span><span style="color: #008000;">"==3=="</span>
|
||||
<span style="color: #7060A8;">pp</span><span style="color: #0000FF;">(</span><span style="color: #000000;">rqd</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">pp_Nest</span><span style="color: #0000FF;">,</span><span style="color: #000000;">3</span><span style="color: #0000FF;">})</span>
|
||||
<!--
|
||||
?"==1==" pp(rqd,{pp_Nest,1})
|
||||
?"==2==" pp(rqd,{pp_Nest,2})
|
||||
?"==3==" pp(rqd,{pp_Nest,3})
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
local fmt = require "fmt"
|
||||
|
||||
-- Create a 4 dimensional list of the required size and
|
||||
-- initialize successive elements to the values 1 to 120.
|
||||
local m = 1
|
||||
local a4 = table.create(5)
|
||||
for i = 1, 5 do
|
||||
a4[i] = table.create(4)
|
||||
for j = 1, 4 do
|
||||
a4[i][j] = table.create(3)
|
||||
for k = 1, 3 do
|
||||
a4[i][j][k] = table.create(2)
|
||||
for l = 1, 2 do
|
||||
a4[i][j][k][l] = m
|
||||
m += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
print($"First element = {a4[1][1][1][1]}") -- access and print value of first element
|
||||
a4[1][1][1][1] = 121 -- change value of first element
|
||||
print()
|
||||
|
||||
-- Access and print values of all elements in 12 x 10 tabular format.
|
||||
local c = 0
|
||||
for i = 1, 5 do
|
||||
for j = 1, 4 do
|
||||
for k = 1, 3 do
|
||||
for l = 1, 2 do
|
||||
fmt.write("%4d", a4[i][j][k][l])
|
||||
c += 1
|
||||
if c % 10 == 0 then print() end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
12
Task/Multi-dimensional-array/R/multi-dimensional-array.r
Normal file
12
Task/Multi-dimensional-array/R/multi-dimensional-array.r
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#Creating an array
|
||||
arr <- array(1:120, dim=c(5, 4, 3, 2))
|
||||
#Setting and accessing a single element
|
||||
arr[1, 1, 1, 1] <- 1000
|
||||
arr[1, 1, 1, 1]
|
||||
#Accessing a range of elements (leaving an index blank means you access all elements in that dimension)
|
||||
arr[3:5,1,2,]
|
||||
#Reshaping
|
||||
dim(arr) <- c(2, 3, 4, 5)
|
||||
#Adding dimensions to a vector
|
||||
x <- 1:16
|
||||
dim(x) <- rep(2, 4)
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
-- 21 Feb 2026
|
||||
include Setting
|
||||
|
||||
say 'MULTI-DIMENSIONAL ARRAY'
|
||||
say version
|
||||
say
|
||||
-- Default value
|
||||
stem1.=0
|
||||
-- Incomplete multiplication table
|
||||
do i = 1 to 5
|
||||
do j = 1 to 5
|
||||
stem1.i.j=i*j
|
||||
end
|
||||
end
|
||||
-- Show some results
|
||||
say 'Multiplication table'
|
||||
say '2 x 3 =' stem1.2.3
|
||||
say '5 x 2 =' stem1.5.2
|
||||
say '3 x 3 =' stem1.3.3
|
||||
say '4 x 6 =' stem1.4.6
|
||||
say
|
||||
-- Indices may have any value, not just numeric.
|
||||
a="~"; b=" "; c="'"
|
||||
stem2.a.b.c="Special indices"
|
||||
say "stem2.~. .' =" stem2.a.b.c
|
||||
say
|
||||
-- Dump variable pool
|
||||
call Showvars
|
||||
exit
|
||||
|
||||
-- Showvars
|
||||
include Math
|
||||
|
|
@ -1,13 +1,16 @@
|
|||
smd := [][]string{len: 4, init: []string{len:2, init: 'Hello'}}
|
||||
imd := [][]int{len: 3, init: []int{len:4, init: it}}
|
||||
smd := [][]string{len: 4, init: []string{len:2, init: 'Hello'}} // `{len: , cap: , init: }` can be adjusted
|
||||
imd := [][]int{len: 3, init: []int{len:4, init: index}}
|
||||
mut mmd := [][]f64{len: 5, init: []f64{len: 5}}
|
||||
mmd[0][2] = 2.0
|
||||
mmd[1][3] = 4.2
|
||||
mmd[2][4] = 1.8
|
||||
mmd[3][0] = 5.0
|
||||
mut omd := [][]bool{} // initialize without defining size
|
||||
omd << [true, false, true]
|
||||
omd << [true, false, true] // appended using push operator `<<`
|
||||
mut emd := [2][3]int{} // easy and quick initialization of fixed-size
|
||||
emd[0][1] = 2
|
||||
println(smd)
|
||||
println(imd)
|
||||
println(mmd)
|
||||
println(omd)
|
||||
println(emd)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue