Multi-dimensional array: Difference between revisions

Content added Content deleted
(Added FreeBASIC)
(Added Quackery.)
Line 2,304: Line 2,304:
[ 0, 0, 0, 0, 0]]]], dtype=int8)
[ 0, 0, 0, 0, 0]]]], dtype=int8)
>>> </syntaxhighlight>
>>> </syntaxhighlight>

=={{header|Quackery}}==

Quackery does not come supplied with multi-dimensional arrays. This is an idiomatic implementation using nests of nests.

Row or column major implementations are also possible. Quackery is not based on a contiguous static memory model.

<syntaxhighlight lang="Quackery"> [ this ] is null ( --> [ )

[ dip nested
reverse
witheach
[ of i if nested ] ] is array ( [ --> a )

[ witheach peek ] is [peek] ( [ a --> x )

[ dup dip
[ rot dip
[ -1 split drop
witheach
[ dip dup peek ] ] ]
reverse
witheach
[ dip swap poke ] ] is [poke] ( x a [ --> a )

null ' [ 5 4 3 2 ] array
say "[ 5 4 3 2 ] array created, initialised with nulls."
cr
cr
2 swap ' [ 3 2 1 0 ] [poke]
say "2 stored in [ 3 2 1 0 ]."
cr
4 swap ' [ 4 3 2 1 ] [poke]
say "4 stored in [ 4 3 2 1 ]."
cr
8 swap ' [ 4 3 2 1 ] [poke]
say "8 stored in [ 4 3 2 1 ]."
cr
cr
dup ' [ 0 0 0 0 ] [peek] echo
say " copied from [ 0 0 0 0 ]."
cr
dup ' [ 3 2 1 0 ] [peek] echo
say " copied from [ 3 2 1 0 ]."
cr
' [ 4 3 2 1 ] [peek] echo
say " copied from [ 4 3 2 1 ]."
cr</syntaxhighlight>

{{out}}

<pre>[ 5 4 3 2 ] array created, initialised with nulls.

2 stored in [ 3 2 1 0 ].
4 stored in [ 4 3 2 1 ].
8 stored in [ 4 3 2 1 ].

null copied from [ 0 0 0 0 ].
2 copied from [ 3 2 1 0 ].
8 copied from [ 4 3 2 1 ].

</pre>


=={{header|Racket}}==
=={{header|Racket}}==