[Question]
  [
Given a ragged list, we can define an element's depth as the number of arrays above it, or the amount that it is nested.
For example, with the list `[[1, 2], [3, [4, 5]]]` the depth of the `2` is 2, as it is nested within two lists: The base list, and the list `[1, 2]`. The depth of the `4` is 3 as it is nested within three lists.
Your challenge is to, given a ragged list of positive integers, multiply them by their depths.
For example, given the list `[[1, 2], [3, [4, 5]], 6]`:
* The depth of 1 is 2, so double it -> 2
* The depth of 2 is also 2, so double it -> 4
* The depth of 3 is 2, so double it -> 6
* The depth of 4 is 3, so triple it -> 12
* The depth of 5 is 3, so triple it -> 15
* The depth of 6 is 1, so leave it alone -> 6
So, the result is `[[2, 4], [6, [12, 15]], 6]`.
Another way of viewing it:
```
[[1, 2], [3, [4, 5 ]], 6]  - Original list
[[2, 2], [2, [3, 3 ]], 1]  - Depth map
[[2, 4], [6, [12,15]], 6]  - Vectorising product
```
You can assume the list won't contain empty lists.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), shortest wins!
## Testcases
```
[[1, 2], [3, [4, 5]], 6] => [[2, 4], [6, [12, 15]], 6]
[[3, [2, 4]]] => [[6, [6, 12]]]
[[9, [[39], [4, [59]]]], 20] => [[18, [[156], [16, [295]]]], 20]
[2, [29]] => [2, [58]]
[[[[[[[[9]]]]]]]] => [[[[[[[[72]]]]]]]]
```
  
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 4 bytes
```
‚ÅΩL‚Ç¨*
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyJBUCIsIiIsIuKBvUzigqwqIiwiIiwiW1sxLCAyXSwgWzMsIFs0LCA1XV0sIDZdXG5bWzMsIFsyLCA0XV1dXG5bWzksIFtbMzldLCBbNCwgWzU5XV1dXSwgMjBdXG5bMiwgWzI5XV1cbltbW1tbW1tbOV1dXV1dXV1dIl0=)
```
‚ÅΩL‚Ç¨*
‚ÅΩ ‚Ç¨  # At each value in the input, all the way down, run the following on the multi-dimensional index of the current value:
 L   # Length. This gets the current depth
   * # Vectorizically (is that a word?) multiply by the input
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 12 bytes
```
#0/@#-#&@-#&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b7X9lA30FZV1nNAYj/BxRl5pVEK@vapTkox6rVBScn5tVVc1VXG@oY1epUG@tUm@iY1tbqmNXqAAWBXCMdk9paMMdSByhgWQtSUW1qWQsSNTIAyRgBVVlC1EAAWBIEuGr/AwA "Wolfram Language (Mathematica) ‚Äì Try It Online")
```
         -# negate
#0/@#  &@   at each level:
     -#       subtract original value(s)
            (atoms: #0/@#-# = #-# = 0)
```
[Answer]
# [Python](https://www.python.org), ~~51~~ ~~49~~ ~~44~~ 43 bytes
```
f=lambda l,d=0:l*d*-1or[f(s,d-1)for s in l]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vwYKlpSVpuhY3tdNscxJzk1ISFXJ0UmwNrHK0UrR0DfOLotM0inVSdA010_KLFIoVMvMUcmKhWpQKijLzSjTSNKKjDXUUjGJ1FKKNgdhER8E0Fsgxi9XUhKiEWQIA)
This is a really fun abuse of the overloading of the `*` operator:
* If `l` is a positive integer, then `l*d*-1` equals `l*-d`, which is always truthy (because the integers are always positive, so non-zero), so it returns `l*-d`, where `d` is the negation of the depth.
* If `l` is an array, then `l*d` produces `d` copies of the list joined together, which is actually interpreted as 0 copies of the list joined together (because `d` is negative), i.e. `[]`. So `l*d*-1` equals equals `[]*-1` equals `[]`, which is falsy, so the second part of the conditional is run.
---
-1 bytes from @loopywalt by flipping the sign of `d`.
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 17 bytes
```
{$[x~*x;0;x+o'x]}
```
[Try it online!](https://ngn.codeberg.page/k#eJxLs6pWia6o06qwNrCu0M5Xr4it5eJKsdIwVDCyVtAwtlYwUTDVtFYw0+TSMFIwAQqZWSsYGikYQgTr0hRSQMp1oMCSSwPGNDcCywIASXYVFQ==)
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 5 bytes
```
≈íJ·∫à·πÅ√ó
```
[Try it online!](https://tio.run/##y0rNyan8///oJK@Huzoe7mw8PP3/4fajkx7unKEZ@f9/dLShjoJRrI5CtDEQm@gomMYCOWYgAbCIkY6CSWwsmGsJFrOMhaiLNrWMBUsYGcRC1EUbWUIUQgBYGgQA "Jelly ‚Äì Try It Online")
```
≈íJ       All multidimensional indices, in flat order.
  ·∫à      Get the length of each index (= depth of value at index).
   ·πÅ     Mold to the structure of the input,
    √ó    and multiply corresponding elements.
```
[Answer]
# BQN, 9 bytes
```
{+‚üúùïä‚çü=¬®ùï©}
```
[Try it here!](https://mlochbaum.github.io/BQN/try.html#code=RuKGkHsr4p+c8J2ViuKNnz3CqPCdlal9Cgoo4oCiU2hvdyBG4oiY4oCiSnMpwqjin6gKIltbMSwgMl0sIFszLCBbNCwgNV1dLCA2XSIKIltbMywgWzIsIDRdXV0iCiJbWzksIFtbMzldLCBbNCwgWzU5XV1dXSwgMjBdIgoiWzIsIFsyOV1dIgoiW1tbW1tbW1s5XV1dXV1dXV0iCuKfqQpA)
-5 bytes thanks to @att!
## Explanation
* `{...¬®ùï©}` for each element *n* over input...
	+ `...‚çü=` if rank of *n* > 0 (i.e. *n* is a list)...
		- `+‚üúùïä` *n* + F(*n*)
[Answer]
# JavaScript, 32 bytes
```
(g=k=>a=>a.map?.(g(-~k))??a*k)()
```
```
f =
(g=k=>a=>a.map?.(g(-~k))??a*k)()
testcases = `
[[1, 2], [3, [4, 5]], 6] => [[2, 4], [6, [12, 15]], 6]
[[3, [2, 4]]] => [[6, [6, 12]]]
[[9, [[39], [4, [59]]]], 20] => [[18, [[156], [16, [295]]]], 20]
[2, [29]] => [2, [58]]
[[[[[[[[9]]]]]]]] => [[[[[[[[72]]]]]]]]
`.trim().split('\n').map(l => l.split(' => ').map(t => JSON.parse(t)));
testcases.forEach(([i, e]) => {
  console.log(JSON.stringify(f(i)) === JSON.stringify(e), JSON.stringify(f(i)));
});
```
The submitted function is partial invoked currying function. Maybe the first time I try to use this pattern in a code-golf.
However, the `a.map?.(‚Ä¶)??‚Ä¶` pattern is quite common for [ragged-list](/questions/tagged/ragged-list "show questions tagged 'ragged-list'").
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 51 bytes
```
\d+
$*
1(?=((\[)|(?<-2>])|(])|[^][])+)
$#3$*
1+
$.&
```
[Try it online!](https://tio.run/##JYrNCsIwEITveYqARRKbit20QqA/DzIdQdCDFw/i0XePm3RhYL@Z7/P8vt73nLdHa5qT6d06O7fB/9w6dbJQHw1uBH3rTXOIxVL3fMwZ6IMVBouoGYIdqXClQS0k2IEslJQQE3cLY9JaQS46SjFT1farY7k/ "Retina 0.8.2 ‚Äì Try It Online") Link includes test cases. Explanation:
```
\d+
$*
```
Convert to unary.
```
1(?=((\[)|(?<-2>])|(])|[^][])+)
$#3$*
```
Replace each `1` with the number of unmatched `]`s in the input's suffix, which equals its depth, thereby multiplying each number by its depth.
```
1+
$.&
```
Convert to decimal.
Just creating the depth map can be readily achieved with the following code:
```
\d+(?=((\[)|(?<-2>])|(])|[^][])+)
$#3
```
Retina 1 can perform multiplication as part of a substitution, solving the original problem as follows:
```
\d+(?=((\[)|(?<-2>])|(])|[^][])+)
$.($#3**
```
[Try it online!](https://tio.run/##JYrBCsIwGIPve4qCO/zdqri/m1BQ9yBZBEEPXjzIjnv3@rcLBPIl@b3Xz/c55Ly8eplvIgv8JvP1qHdaMONB0Pe@aU/SHmLX5QwMwSmDQzSPwU00uLBBLTS4kSyUjBAT9xemZLWBnm3U8kz1tquORX8 "Retina ‚Äì Try It Online") Link includes test cases. Explanation: The `**` causes the capture result (the depth) to be implicitly multiplied by the matched integer, converted to unary, and the `$.(` then converts back to decimal.
[Answer]
# [PARI/GP](https://pari.math.u-bordeaux.fr), 25 bytes
```
f(a)=if(#a',a+apply(f,a))
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m728ILEoMz69YMGCpaUlaboWO9M0EjVtM9M0lBPVdRK1EwsKcio10nQSNTUh8jfbIUKJCrp2CgVFmXklQKYSiKOkANKqqaMQHR1tqKNgFAtkGQOxiY6CaSyQYwYSAIsY6SiYxMaCuZZgMctYiLpoU8tYsISRQSxEXbSRJUQhBIClwQDqHJizAQ)
[Answer]
# [Racket](https://racket-lang.org/), ~~88~~ 63 bytes
```
(define(m l[d 0])(if(list? l)(map(Œª(n)(m n(+ 1 d)))l)(* l d)))
```
[Try it online!](https://tio.run/##RYpBDoIwFET3nmISF/6vG6hg0pUHaf6C2GIaS2OA23kHr4QfGnVWM/Pe2N0eYV72qct3jGWQD33MgQYk51EJU@wpxWm@IjEN3ZPeL8rakOmEGp6ZFRyRtrooODhXwwjcGa5BK4KL8K4AvQwakd9hoaeV1XStVSAw1Zcate3fLdmkNbx8AA "Racket ‚Äì Try It Online")
-25 from removing whitespace, ty @emanresu A!
[Answer]
# [lin](https://github.com/molarmanful/lin), 26 bytes
```
"deps1> (.+ \@ ' + ) e&".'
```
[Try it here!](https://replit.com/@molarmanful/try-lin) Uses stack as nested list.
For testing purposes (use `-i` flag when running locally):
```
[[1 2] [3 [4 5]] 6] \; '
"deps1> (.+ \@ ' + ) e&".'
```
## Explanation
Prettified:
```
( deps 1> (.+ \@ ' + ) e& ).'
```
* `(...).'` map...
	+ `deps 1> (...) e&` if depth > 1 (i.e. is list)...
	+ `.+ \@ ' +` recurse and vector-add to current element
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 16 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
_"Ddi√´¬ÆŒ¥.V>"¬©.V*
```
[Try it online](https://tio.run/##yy9OTMpM/f8/XsklJfPw6kPrzm3RC7NTOrRSL0zr///oaEsdhehoY8tYIGUCxKaWsUCgo2BkEAsA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfaXL/3gll5TMw6sPrTu3RS/MTunQSr0wrf86/6Ojow11jGJ1oo11ok10TGNjdcxidRSiQVwjHZPYWDDHUgcoYBkLUhFtahkLEjUyAMkYAVVZQtRAAFgSDAA).
**Explanation:**
First step of [this 05AB1E answer of mine](https://codegolf.stackexchange.com/a/242190/52210).
```
_            # Transform each integer in the (implicit) input to 0
 "..."       # Push the recursive string explained below
      ¬©      # Store it in variable `¬Æ` (without popping)
       .V    # Evaluate and execute it as 05AB1E code
             # (we now have the depth of each item in the ragged input-list)
         *   # Multiply each by the value in the (implicit) input-list at the same
             # positions
             # (after which the result is output implicitly)
  D          # Duplicate the current list
   di√´       # If it's not an integer (so it's a list):
       Œ¥     #  Map over each item:
      ¬Æ .V   #   Do a recursive call
          >  #  Then increase each integer in this list by 1
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~23~~ ~~16~~ 15 bytes
```
.Œ≥d}D≈æuSŒ¥¬¢√ÜŒ∑O*J
```
[Try it online!](https://tio.run/##yy9OTMpM/f9f79zmlFqXo/tKg89tObTocNu57f5aXv//KykpaWhY6ihoaBhbagIpEyA2tdQEAh0FIwNNoDQA "05AB1E ‚Äì Try It Online")
-2 thanks to @Kevin Cruijssen
Takes the input list as a string, using `(` and `)`.
If `a` and `b` are valid list boundaries, then it's -1 for replacing `≈æu` with `A`. [Try it online!](https://tio.run/##yy9OTMpM/f9f79zmlFoXx@BzWw4tOtx2bru/ltf//4mJljoKiYnGlklAygSITS2TgEBHwcggCQA)
[Answer]
# [Perl 5](https://www.perl.org/) `-p`, 33 bytes
```
s/\d+/$&*($`=~y|[||-$`=~y|]||)/ge
```
[Try it online!](https://tio.run/##PY1NCsIwEIX3PUUWRbSmTZM2sUHqDTzBGHBhEUFssW6E4NGNkx87MDDvvS8v0/C8Szcz0lcFY3u8Tpcty1fFOj/3n7cFa8t4GWs37Do4B8ApEYYSaHBbSqRBoQzpDwRAUNL6TOFyFDylGQQ8xCaxKnJcoIO5RgmNNrEVpEYbhagTzjsPcKk8wf1joeXCZL4bnVTuhexCb5zQZpa/4@zE3/2O0@s2PmZXTq48yqrm9Q8 "Perl 5 ‚Äì Try It Online")
For each number, depth is determined by counting the number of `[` and subtracting the number of `]` that come before it in the string.
[Answer]
# [Ruby](https://www.ruby-lang.org/), 38 bytes
```
f=->a,d=0{a*0==0?a*d:a.map{f[_1,d+1]}}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGCpaUlaboWN9XSbHXtEnVSbA2qE7UMbG0N7BO1UqwS9XITC6rTouMNdVK0DWNrayGq9xYopEVHRxvqKBjF6ihEGwOxiY6CaSyQYxYbC1EDMxkA)
[Answer]
# [Ruby](https://www.ruby-lang.org/), 38 bytes
```
f=->a,i=1{a.map{f[_1,i+1]rescue _1*i}}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=PZBBCsJADEX3PUVAcKGjmNGpnUW9SAhSpcUuhFLtQkpP4qYLPZTH8AYmndpAFj95_w-T56tuTo--fzf3YpV85kW6OmSmTLHN1tesags6oimXyHV-Ozc5HHFRdt1IfykiQgOWDdBWemfAsYiYzQzSAxBZAzvdxtIoAse9GNUwrHmi40CilZkQXiRtPYdkcp6VBbuZDJgogi5WBtVuvZuoSPNlMj2g0iVDdqghUWvMC7W3_3HE6zw7X9oK9BA8fvx_rh8)
An alternative to [Razetime's answer](https://codegolf.stackexchange.com/a/250330/78274) for the same byte count.
[Answer]
# [Knight](https://github.com/knight-lang/knight-lang), ~~124~~ 118 bytes
```
;=p++=o""=i=d 0P;W<=i+1iLp;=n=cGp i 1I>c"9";=d-d-1*2<c"]"=o+o cI<"/"c;W&<=tGp+1i 1"["<"/"t;=i+1i=n+n t=o+o*d n=o+o cOo
```
[Try it online!](https://tio.run/##rVlRU9tIEn62f8WgFLYky0ESbNXGskyRLFDUEchCcnkwviBkGVQrSzpZhuUI@eu57p4ZaWSb3OVuqYplzXT3fP1NT3ePE/Zvw/D7qzgNk@U0Gi7KaZy9vhu11ZEkvmkMheVjHq0IFXF62xgq4zmXmUazOI1YkrAkS2/po12Nf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Cm6DKOT1@2RPEEWldXWjOaNlI0vs/JCYnc3EbP9QaXuz0j@IzYZD/I5BY67qpSdo56z7rO9ULJMsUO/AOes7cMYcVdj9SekhpNGGrO@jKK07kCO2pJyIdke24No1qK0xfeK/vXogaJJcgbsEJWIsRfAdrxZ3URF1FyzNoNeOkzJO2UPwCLyxaQaX1zK6jQrQybM0Sss4wNsGnOSMPUTsLriPQFAYQvGSzYN0CeHz@BpH0bsbZByoICYWy6TEXxdo8SrhSZG@KiOXXKFM1atEVsyjvZcl7ZeBVGLDhpRNF/kgwRr6CF6n0ySasusa9nVl5Qm/8QZOWaR2ZoTG@n35bpB4S4iaCvTnKg8OKVhXCiQmvUZe9JtZcZ@ph3@oHgNUHYgfADuMC@yzRkNJgxZTsiHasLmmLM0urwMou@VDtVG6pREcSgytbJoN2DyahzmGWcpG1/v/ryujv8CVkXRla4MvvvBFuLL/Mvt81Q2QcXqfNQTcSsKVBXRrE876pXJPZh7VQAWvU6c/9GVTbdhXNUUqqfS//jf6IgcpZip9rztQpRvt8KqsX2fd5vRPX3hkD1zfeFCu1bj1VKmQZNDixG9oK2kSNVCi16vUOOTP4B7/eUxtSBveMbV3EWonze4eRRX9fXewq9ByzK8WvtJh9dQCtH6XSsUFxarOwm6j8b3kRK8Y9VZLnrup5O0aVR/gVtp7NPgfGiIEhk/cirC6JFTtkNobueAhrtpzsEmiBoHHP5@kB0n0xEmA1afRLIAkCZ7JDjNOYTKe0o9NQVhCmepuh13sOXHEYC/cdtFYVQOhGxQ/OMyDOMVmlQXFbWiRUdOE7/cG/qxF91D8/yTdJjTN697z9/H4jcXG4903E3jswb9f3kzgz2KuPfk3 "C (gcc) ‚Äì Try It Online")
Nice, big ole fat Knight program. Parses it as a string lol
Ungolfed and commented:
```
; = p + + = o "" = i = d 0 PROMPT                # p = (o = "") + (i = d = 0) + input()
; W < = i + 1 i LENGTH p                         # while (i = i + 1) < len(p):
  ; = n = c GET p i 1                            #   n = c = p[i]
  : IF > c "9"                                   #   if c > "9":
    ; = d - d - 1 * 2 < c "]"                    #     d = d - (1 - 2 * (c < "["))
    : = o + o c                                  #     o = o + c
  # ELSE                                         #   else:
    : IF < "/" c                                 #     if "/" < c:
      ; WHILE & < = t GET p + 1 i 1 "[" < "/" t  #       while ((t = p[i + 1]) < "[") and ("/" < t):
        ; = i + 1 i                              #         i = i + 1
        : = n + n t                              #         n = n + t
      : = o + o * d n                            #       o = o + d * n
    # ELSE                                       #     else:
      : = o + o c                                #       o = o + c
: OUTPUT o                                       # print(o)
```
-6 bytes thanks to Adam.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 35 bytes
```
‚äûœÖ‚ü¶¬πŒ∏‚üßÔº¶œÖÔºµÔº≠‚äüŒπ‚éá‚Å∫‚ü¶‚üßŒ∫‚àß‚äûÔºØœÖ‚ü¶‚äïŒ£ŒπŒ∫‚üßŒ∫√óŒ£ŒπŒ∫‚≠Ü¬πŒ∏
```
[Try it online!](https://tio.run/##LY49C8IwEIZ3f0XGC0TwcyhO0slBDLRbyBDaaEubpF4TwV8fr@rBcfDwflzTGWyCGXOWae4gCaa2gj01P63uARkkzq5mKoNzxrcgwwQ9F6y26A2@QY5pBqUFGwieFwGF3CaLJgb8hl18g9ZZH20LVXLkJuWg@c9S987Of74QTrUSex@hinQeVA3LO8RzVkoVlKj2BRWqA@2x0DSC7TZa5/Vr/AA "Charcoal ‚Äì Try It Online") Link is to verbose version of code. Explanation:
```
‚äûœÖ‚ü¶¬πŒ∏‚üß
```
Start by considering the input list at depth `1`.
```
Ôº¶œÖ
```
Loop through the list and its sublists.
```
ÔºµÔº≠‚äüŒπ
```
Loop through the elements of the current list.
```
‚éá‚Å∫‚ü¶‚üßŒ∫
```
If this is a sublist, then...
```
‚àß‚äûÔºØœÖ‚ü¶‚äïŒ£ŒπŒ∫‚üßŒ∫
```
... push it with the incremented depth to the list of sublists, but don't actually change the list itself yet, otherwise...
```
√óŒ£ŒπŒ∫
```
... multiply the element by the current depth.
```
‚≠Ü¬πŒ∏
```
Pretty-print the result, since Charcoal's default formatting is not designed for ragged lists.
[Answer]
# [J](https://www.jsoftware.com), 12 bytes
Takes input as a boxed array.
```
*L:0#L:1@{::
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m70wa8FOJT31NAVbKwV1BR0FAwUrINbVU3AO8nFbWlqSpmuxRsvHykDZx8rQodrKCiJ085EmF1dqcka-QpqChoYNEBlq6mjYGGlqgigg1xhKm4BoU01NiISZpiaqLpgyIxBtAlaGpsISqgKk2BJuvAmUNrXUhAGQ9QYouo1ghltiGouJECZBAcSnCxZAaAA)
`{::` Map; replaces each leaf by its multidimensional index.  
`#L:1` At level 1 (for each index vector), take the length.  
`*L:0` multiply with input at level 0 (leafs).
[Answer]
# [jq](https://stedolan.github.io/jq/), 31 bytes
```
def f(n):map(f(n+1))?//.*n;f(0)
```
[Try it online!](https://tio.run/##JYrLDsIgEEX3fsUsQaEP2ppQF37IZBZNlUSTAkb6@@JAbzLJnHvP@5Pz4@nACS/nbYmCn0sv5b1tm7O/OdHJnBF7BYYU4MA3KpiI4UonrIVRMBIVskw4WDosnCzXDKbj0RTTVu1IHUt@IaZX8N@s9Rq2uKxJhz3FPf0B "jq ‚Äì Try It Online")
The key to the base case: If `map()` fails (since we try to map over a number instead of an array), `?` suppresses the error, `//` substitutes the alternate value of `.*n`
[Answer]
brev, 46 bytes
```
(c(fn(if(list? y)(map(c f(+ x 1))y)(* y x)))0)
```
Classic lispy depth first tree walking: map if not atom
]