Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

50%
+0 −0
Challenges Shape of an array

JavaScript (Node.js), 39 bytes Returns dimensions from innermost to outermost f=a=>a?.pop?f(a[0]).concat(a.length):[] JavaScript (Node.js), 41 bytes Returns dimensions from outermost to ...

posted 4y ago by Moshi‭  ·  edited 4y ago by Moshi‭

Answer
#2: Post edited by user avatar Moshi‭ · 2020-11-22T21:41:28Z (almost 4 years ago)
  • # [JavaScript (Node.js)](https://nodejs.org), 49 bytes
  • Returns dimensions from innermost to outermost
  • ```javascript
  • f=a=>Array.isArray(a)?f(a[0]).concat(a.length):[]
  • ```
  • [Try it online!](https://tio.run/##dctBCsIwEIXhvSeZQAwBi4JSxXMMsxhiUishkSQUevrY6k7S1YP/47144mzS@C77EB@2Vtdzf72nxLMa83eBxc0BoyahTAyGC7DyNgzlKc5IdWk5eqt8HMABkhCX3V/TrYjUrnIDOtktpuWhzbjqkTYQT@uXflw/ "JavaScript (Node.js) – Try It Online")
  • -----
  • # [JavaScript (Node.js)](https://nodejs.org), 51 bytes
  • Returns dimensions from outermost to innermost
  • ```
  • f=a=>Array.isArray(a)?[a.length].concat(f(a[0])):[]
  • ```
  • [Try it online!](https://tio.run/##dctBCsMgEIXhfU@iYEVIaKElLTnHMIvBmDRFtKgEcnpr2l0wqwffz3vTQlGH@ZPOzg8m57Gj7tGHQKuc428Z8SeQtMZN6YVSe6cpsZERKOT8BpgLRW@NtH4qDkXvp52pGgLWVRyEVrSlKdHUM2z1ggcRrtsX/zl/AQ "JavaScript (Node.js) – Try It Online")
  • # [JavaScript (Node.js)](https://nodejs.org), 39 bytes
  • Returns dimensions from innermost to outermost
  • ```javascript
  • f=a=>a?.pop?f(a[0]).concat(a.length):[]
  • ```
  • -----
  • # [JavaScript (Node.js)](https://nodejs.org), 41 bytes
  • Returns dimensions from outermost to innermost
  • ```
  • f=a=>a?.pop?[a.length].concat(f(a[0])):[]
  • ```
#1: Initial revision by user avatar Moshi‭ · 2020-11-22T21:30:19Z (almost 4 years ago)
# [JavaScript (Node.js)](https://nodejs.org), 49 bytes

Returns dimensions from innermost to outermost

```javascript
f=a=>Array.isArray(a)?f(a[0]).concat(a.length):[]
```

[Try it online!](https://tio.run/##dctBCsIwEIXhvSeZQAwBi4JSxXMMsxhiUishkSQUevrY6k7S1YP/47144mzS@C77EB@2Vtdzf72nxLMa83eBxc0BoyahTAyGC7DyNgzlKc5IdWk5eqt8HMABkhCX3V/TrYjUrnIDOtktpuWhzbjqkTYQT@uXflw/ "JavaScript (Node.js) – Try It Online")

-----

# [JavaScript (Node.js)](https://nodejs.org), 51 bytes

Returns dimensions from outermost to innermost

```
f=a=>Array.isArray(a)?[a.length].concat(f(a[0])):[]
```

[Try it online!](https://tio.run/##dctBCsMgEIXhfU@iYEVIaKElLTnHMIvBmDRFtKgEcnpr2l0wqwffz3vTQlGH@ZPOzg8m57Gj7tGHQKuc428Z8SeQtMZN6YVSe6cpsZERKOT8BpgLRW@NtH4qDkXvp52pGgLWVRyEVrSlKdHUM2z1ggcRrtsX/zl/AQ "JavaScript (Node.js) – Try It Online")