Matrix transposition: Difference between revisions

m (→‎{{header|OCaml}}: Example didn't work when copy pasted because last binding was missing closing ';;' required in the toplevel.)
(→‎{{header|Wren}}: Minor tidy)
 
(6 intermediate revisions by 3 users not shown)
Line 1,371:
=={{header|Delphi}}==
See [[#Pascal]];
=={{header|EasyLang}}==
<syntaxhighlight lang="easylang">
proc transpose . m[][] .
len n[][] len m[1][]
for i to len n[][]
for j to len m[][]
n[i][] &= m[j][i]
.
.
swap n[][] m[][]
.
m[][] = [ [ 1 2 3 4 ] [ 5 6 7 8 ] [ 9 10 11 12 ] ]
print m[][]
print ""
transpose m[][]
print m[][]
</syntaxhighlight>
{{out}}
<pre>
[
[ 1 2 3 4 ]
[ 5 6 7 8 ]
[ 9 10 11 12 ]
]
 
[
[ 1 5 9 ]
[ 2 6 10 ]
[ 3 7 11 ]
[ 4 8 12 ]
]
</pre>
 
=={{header|EchoLisp}}==
<syntaxhighlight lang="scheme">
Line 2,009 ⟶ 2,042:
=={{header|Fōrmulæ}}==
 
{{FormulaeEntry|page=https://formulae.org/?script=examples/Matrix_transposition}}
Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text. Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation &mdash;i.e. XML, JSON&mdash; they are intended for storage and transfer purposes more than visualization and edition.
 
'''Solution'''
Programs in Fōrmulæ are created/edited online in its [https://formulae.org website], However they run on execution servers. By default remote servers are used, but they are limited in memory and processing power, since they are intended for demonstration and casual use. A local server can be downloaded and installed, it has no limitations (it runs in your own computer). Because of that, example programs can be fully visualized and edited, but some of them will not run if they require a moderate or heavy computation/memory resources, and no local server is being used.
 
Matrix transposition is an intrsinec operation in Fōrmulæ, through the Transpose expression:
In '''[https://formulae.org/?example=Matrix_transposition this]''' page you can see the program(s) related to this task and their results.
 
[[File:Fōrmulæ - Matrix transposition 01.png]]
 
[[File:Fōrmulæ - Matrix transposition 02.png]]
 
However, a matrix transposition can be coded:
 
[[File:Fōrmulæ - Matrix transposition 03.png]]
 
[[File:Fōrmulæ - Matrix transposition 04.png]]
 
[[File:Fōrmulæ - Matrix transposition 02.png]]
 
=={{header|GAP}}==
Line 2,445 ⟶ 2,490:
<syntaxhighlight lang="idris">Idris> transpose [[1,2],[3,4],[5,6]]
[[1, 3, 5], [2, 4, 6]] : List (List Integer)</syntaxhighlight>
 
=={{Header|Insitux}}==
 
<syntaxhighlight lang="insitux">
(var transpose2d @(... map vec))
 
(transpose2d [[1 1 1 1] [2 4 8 16] [3 9 27 81] [4 16 64 256] [5 25 125 625]])
</syntaxhighlight>
 
{{out}}
 
<pre>
[[1 2 3 4 5] [1 4 9 16 25] [1 8 27 64 125] [1 16 81 256 625]]
</pre>
 
=={{header|J}}==
Line 4,966 ⟶ 5,025:
{{libheader|Wren-matrix}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./matrix" for Matrix
import "./fmt" for Fmt
 
var m = Matrix.new([
9,476

edits