|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
592 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|---|
| 4 |
|
|---|
| 5 | function zip(...arrs) {
|
|---|
| 6 | let rowCount = 0;
|
|---|
| 7 | for (let i = 0; i < arrs.length; i++) {
|
|---|
| 8 | if (arrs[i].length > rowCount) {
|
|---|
| 9 | rowCount = arrs[i].length;
|
|---|
| 10 | }
|
|---|
| 11 | }
|
|---|
| 12 | const columnCount = arrs.length;
|
|---|
| 13 | const result = Array(rowCount);
|
|---|
| 14 | for (let i = 0; i < rowCount; ++i) {
|
|---|
| 15 | const row = Array(columnCount);
|
|---|
| 16 | for (let j = 0; j < columnCount; ++j) {
|
|---|
| 17 | row[j] = arrs[j][i];
|
|---|
| 18 | }
|
|---|
| 19 | result[i] = row;
|
|---|
| 20 | }
|
|---|
| 21 | return result;
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | exports.zip = zip;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.