[Question]
  [
Lists can contain lists and we have nested lists. But we don't like nested lists and want to flatten them. By flattening I mean create a list which does not contain any list, but elements of lists it contained before. I'll explain it more.
## Input
An arbitrary size list which has the below properties:
* it can contain integers
* it can be empty
* it can contain lists which have the same properties
These are some examples of valid lists:
```
[]
[1, 2, 46]
[[], []]
[[[14], [[5]]], 4, [2]]
```
## Output
The output must be a list, which is empty or only contains numbers. It must not contain lists. The output must be the flattened version of the input.
* all elements (beside empty lists) must be in the flattened version
* the order matters
# Test cases:
```
[[3],[3, [[6]]]] ->  [3, 3, 6]
[] -> []
[[], []] -> []
[[1, 4, 6], [1, [2, 67, [5, 7]]]] -> [1, 4, 6, 1, 2, 67, 5, 7]
```
  
[Answer]
# Languages with built-ins
[HBL](https://github.com/dloscutoff/hbl), 0.5: `-` - [Try it online!](https://dloscutoff.github.io/hbl/?f=0&p=LS4_&a=KCgpICgxIDQgNikgKDEgKDIgNjcgKDUgNykpKSk_)
[Fig](https://github.com/Seggan/Fig), ~0.823: `f` - [Try it online!](https://fig.fly.dev/#WyJmIiwiW1sxLDQsNl0sWzEsWzIsNjcsWzUsN11dXV0iXQ==)
[flax](https://github.com/PyGamer0/flax), 1: `F` - [Try it online!](https://staging.ato.pxeger.com/run?1=m70kLSexYsGCpaUlaboWC92WFCclF0N5N9WjlaKjow11FEx0FMxidRRAzGgjINscSJvqKJjHgoBSLFQ9AA)
[Japt](https://github.com/ETHproductions/japt), 1: `c` - [Try it online!](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=Yw&input=W1sxLCA0LCA2XSwgWzEsIFsyLCA2NywgWzUsIDddXV1d)
[Jelly](https://github.com/DennisMitchell/jelly), 1: `F` - [Try it online!](https://tio.run/##y0rNyan8/9/t////0dGGOgomOgpmsToKIGa0EZBtDqRNdRTMY4EAAA)
[Vyxal](https://github.com/Vyxal/Vyxal), 1: `f` - [Try it online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCJmIiwiIiwiW1sxLCA0LCA2XSwgWzEsIFsyLCA2NywgWzUsIDddXV1dIl0=)
[05AB1E](https://github.com/Adriandmen/05AB1E), 1: `˜` - [Try it online!](https://tio.run/##yy9OTMpM/f//9Jz//6OjDXUUTHQUzGJ1FEDMaCMg2xxIm@oomMcCAQA)
[Pyt](https://github.com/mudkip201/pyt), 1: `Ƒ` - [Try it online!](https://tio.run/##K6gs@f//2MT//6OjjXSMY3WijYxiYwE)
[J](https://www.jsoftware.com/#/), 1: `,` - [Try it online!](https://ato.pxeger.com/run?1=m70wa8GCpaUlaboW21KTM_IVNKx1NBWMwVBFIVPPyBwiCVUDUwsA)
[Pip](https://github.com/dloscutoff/pip), 2: `FA` - [Try it online!](https://dso.surge.sh/#@WyJwaXAiLG51bGwsIkZBIiwiWzI7WzM7WzRdXTs1XSIsIjIgMyIsIi1wIl0=)
[Pyth](https://github.com/isaacg1/pyth), 2: `.n` - [Try it online!](https://tio.run/##K6gsyfj/Xy/v///o6GhDk1gdheho09hYIG0CZBrFxgIA)
[Haskell](https://www.haskell.org/) + [hgl](https://gitlab.com/WheatWizard/haskell-golfing-library), 3: `rtc`
[Attache](https://github.com/ConorOBrien-Foxx/Attache), 4: `Flat` - [Try it online!](https://tio.run/##SywpSUzOSP2fpmBl@98tJ7Hkv19qakpxtEpBQXJ6LFdAUWZeSUhqcYlzYnFqcXSajkI0l4JCdLRxrE60MZATbRYLBDogMQgJpIBMKNtQR8FER8EMJARkRhsB2eZA2lRHwRykjSs29j8A)
[rSNBATWPL](https://github.com/Radvylf/rSNBATWPL), 5: `crush` - [Try it online!](https://dso.surge.sh/#@WyJyYWlzaW4tYmF0d2FmZmxlIixudWxsLCJjcnVzaCIsIiQgKCgoMSwyKSwzLCg0LDUpKSw1LCgyLDMpKSIsIiIsIiJd)
[R](https://www.r-project.org/) (almost), 6: `unlist` -
[Try it online!](https://tio.run/##K/qfZvu/NC8ns7jkf5oGiNLQ1FRW0LVTiI7lggqACUMdBRMdBTNNHQUYF0wbAcXMoWxTHQVzTRCA6Ifq0FEAMqDKQCpi/wMA "R – Try It Online")
[Clojure](https://clojure.org/), 7: `flatten` - [Try it online!](https://tio.run/##S87JzyotSv2vUVCUmVeSk6eg8T8tJ7GkJDXvv7qGhqGCiYKZpgKQ1jBSMDNX0DBVMNcEg/8A)
[jq](https://stedolan.github.io/jq/), 7: `flatten` - [Try it online!](https://tio.run/##yyr8/z8tJ7GkJDXv///oaONYnWhjHYXoaLNYIOCKBqLoWCAfxI421FEw0VEwA/GBzGgjINscSJvqKJiDVAMA "jq – Try It Online")
[Factor](https://factorcode.org), 7: `flatten` - [Try it online!](https://tio.run/##S0tMLskv@h8a7OnnbqVQnFpYmpqXnFqsl5KaWqBQUJRaUlJZUJSZV6JgzcVVrVCtYKxQCyZBbDMgGwz/p@UklpSk5v3XA6qpVYDyFPTAOmrBGF3UUMEErB/EqlYwUjAzB1KmCuYwIxHK/wMA "Factor – Try It Online")
[Haskell](https://www.haskell.org/) + [free](https://hackage.haskell.org/package/free-5.1.7/docs/Control-Monad-Free.html), 7: `retract` - [Try it online!](https://tio.run/##ZZHBatwwEIbvfoqB5GBDbGdbSulS@9ImEEiXUnIrIQy2ZIu1JCPJdEPaZ9@OLK26S0/W/P/MfDPjEe2eTdPxrbyCR1TDggODH6j2u6fXmVm4Kv9kZQlfGRdKOKGVhU7PgvXAjZbgRgZWL6ZjoPkaccMYSN0vE721AcesE2rwTUbnZrut6xG7PWGqMbArbYZ6Dlrty8sP1ab6WPe6s7U1Xf1FK2f0VH3TCvvqnjKq0ckp69Eh@BA4YAbQwPfFsPX5O@g5h/yUUBRZJpR1qGjY@0V1jqbj0LQpiKkF/BqZYdSFS5x9Cgw6aeCDPICKxMw9ILmhD9lNHIPEz9etlyjHn/ph9/iwuwsAf@LMMGewc7DdwrpmnCzODmW77njKSvyG@pG4GHXurmVog40W2raBaNINHDMec3GCPEKoZXmJxVDwcsY8afMoIkt6dQ2T4feVdHKup37NSZvJANQGpwkOUBHp4EkSDv/RJbFSh5eLu6e1k8/PN/cdwub//CNv4hmOEoWipF7ThWYjlIPrVP9zpWxuwq99F7/vb@DMPamf4ndz@/xcHP8C "Haskell – Try It Online")
[Kotlin](https://kotlinlang.org), 7: `flatten` - [Try it online!](https://tio.run/##XY5NCsIwEIX3OcUsGwgZ/F0ILjyBZ4ht0kYnP6RjQcSz1ypV0NkM7zHve3NJTD6Oo7tGCMbHSsJdDIagsTYfSjE32IN57aOrBEzzEQupfvRSwerPWivYKNhKIYXIxUemWH252pFhtlOjBESoU2PBlRSgY879DvHyfo1MbHUqLZrscUrYnvE8BOy5IX@aj3SdiGzNPsUeZ67uOJB4jOMT)
[Mathematica](https://www.wolfram.com/wolframscript/), 7: `Flatten` - [Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b73y0nsaQkNe9/QFFmXomCg0IaEFdXG@oomOgomNXqKICY1UZAtjmQNtVRMK8Fgv8A "Wolfram Language (Mathematica) – Try It Online")
[Prolog (SWI)](http://www.swi-prolog.org/), 7: `flatten` - [Try it online!](https://tio.run/##HY3BCoMwEER/ZfGU4KZQbRU8BOJXCEsOOdQiRBM00Ft@Pd04h5k3MDDxDD581fXbSjHtPKnVu5Q@hzA4y0eZ1O6i364kyFithWkXXMO5uySaHEFpyDEfDZLBxUqJRNRbpB6BaLAsBu50ZzV6IrwQhsqM1DGPnG@Ese4tn/4B "Prolog (SWI) – Try It Online")
[Racket](https://racket-lang.org/), 7: `flatten` - [Try it online!](https://tio.run/##K0pMzk4t@a@ck5iXrlAE5nBp/E/LSSwpSc37r66hYahgomCmqQCkNYwUzMwVNEwVzDVB4D8A)
[Ruby](https://www.ruby-lang.org/en/), 7: `flatten` - [Try it online!](https://tio.run/##ZY/LDoIwFET3/YpJ2GhyQ0V8kmBi/Iymi8ojGsWSUhd8fZWGAOJs58zcueZ9bZ0LcNF5gdLoKsHN2rpJOFf1PdfZI8x0xc0X42djVMvLp7K2eLEGKQQiwpoQQ2JUkJ4gekMy67kNYUvYEcSecJCe99zMkEx5viFYwpEQrYZuzw/F9J/tA5LVUGG/E3NN19G4q2sY8mrym4j7S93on@pFtHTuAw)
[Arturo](https://arturo-lang.io), 7: `flatten` - [Try it](http://arturo-lang.io/playground?I2Glkq)
---
Feel free to add to this community wiki. The below is a template to copy the code and links into to add to the above list.
```
[<language>](<language URL>), <byte-count>: `<code>` - [Try it online!](<interpreter url>)
```
[Answer]
# [Python 2](https://docs.python.org/2/), 39 bytes
```
f=lambda s:[s]*(s<f)or sum(map(f,s),[])
```
[Attempt This Online!](https://ato.pxeger.com/run?1=TZBRasMwDIbffQrhl9lDGSzd0hGaXETxQ9bN1OA4oXYKO8te8jJ2mV6gt5lcEpgQ6Jf0YUv6_p2-0mkM5bL8zMkWb7cH2_h-eP_oIdYUzaOKB6vHM8R5UEM_KYtRIxm94td0bKSUgmhnkHYIRJVhg6IFyDl7ZYSge4WyIsOU-Zc_I7xkisssqWS95_iKsN-e2hgEFitw74v8ueX5PLgA6fgUJ--Skl3ogtS1AIcjNJAn_7z0Hv0GFK3UWsB0diEpq5zGcd1pO8Uf)
Found independently but very similar to @xnor's [answer](https://codegolf.stackexchange.com/a/80123/101374) to the linked question.
[Answer]
# sh + coreutils, 8 bytes
`tr -d []`
[Answer]
# [R](https://www.r-project.org), 22 bytes
```
\(x)as.list(unlist(x))
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72waMGiNNulpSVpuhbbYjQqNBOL9XIyi0s0SvPAVIWmJkTy5t40DbAImDDW1IHQOgoIQTNNEFBW0LVTUIgGygCRWSwXVBtUIhouABGF6tfELm2oo2ACNASmyhBKGwHFzKFsUx0Fc4S90VAdOgpABlQZSEUsxBMLFkBoAA)
`unlist` is an almost-built-in ([see the CW answer](https://codegolf.stackexchange.com/a/248253/55372)) in R, as it doesn't correctly handle the empty lists - it returns `NULL`. Also, it returns a vector of values not a list, so we convert the result to list with `as.list`. Fortunately, `as.list(NULL)` results in an empty list as desired.
---
### [R](https://www.r-project.org), ~~40~~ 38 bytes
*Edit: -2 bytes thanks to [@Dominic van Essen](https://codegolf.stackexchange.com/users/95126/dominic-van-essen).*
```
\(x)`if`(is.null(r<-unlist(x)),1[0],r)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72waMGiNNulpSVpuhY31WI0KjQTMtMSNDKL9fJKc3I0imx0S_NyMotLgBKaOobRBrE6RZpQ1XvTNMAyYMJYUwdC6yggBM00QUBZQddOQSEaKANEZrFcUG1QiWi4AEQUql8Tu7ShjoIJ0BCYKkMobQQUM4eyTXUUzBH2RkN16CgAGVBlIBWxEE8sWAChAQ)
Outputs a vector (empty for input without any elements).
[Answer]
# [Whython](https://github.com/pxeger/whython), 31 bytes
```
f=lambda l:sum(map(f,l),[])?[l]
```
### Explanation
```
f=                               # f is
  lambda                         # a function
         l:                      # that takes a single argument l:
               map(f,l)          # First, apply f to every element of l
           sum(        ,[])      # Then concatenate all the resulting lists together
                           ?     # If l is an integer, the map errors, so instead
                            [l]  # just wrap l in a singleton list and return that
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m728PKOyJCM_b8GCpaUlaboW-9NscxJzk1ISFXKsiktzNXITCzTSdHI0daJjNe2jc2Ihqm6WJicWpxYr2CpEcylEx-oACSAJZEGYxiC2MRBHm8XGQsUMdRRMdBTMQDJAZrQRkG0OpE11FMxBarhiudLyixRAxipk5oHpYisuhYKizLwSjTQNEF9TE2I5zKkA)
[Answer]
# [R](https://www.r-project.org), 58 bytes
```
f=\(x,z=0[0]){for(i in x)z=c(z,`if`(is.list(i),f(i),i));z}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72waMGiNNulpSVpuhY3rdJsYzQqdKpsDaINYjWr0_KLNDIVMvMUKjSrbJM1qnQSMtMSNDKL9XIyi0s0MjV10kBEpqamdVUt1IS9aRpgSTBhrKkDoXUUEIJmmiCgrKBrp6AQDZQBIrNYLqg2qEQ0XAAiCtWviV3aUEfBBGgITJUhlDYCiplD2aY6CuYIe6OhOnQUgAyoMpCKWIgnFiyA0AA)
'Roll your own' `unlist`-like function in R. Returns a vector containing all the elements of the input (nested-)list, or an empty numeric vector if the input doesn't contain any elements.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 169 166 bytes
```
#include<ctype.h>
#define D isdigit(*c))
#define P putchar(
#define R while(*c&&!D c++;
main(char*c,int**v){c=v[1];P 91);R do{while(D P*c++);R P*c?44:93);}while(*c);}
```
[Try it online!](https://tio.run/##PYzNCoMwEITvPkWKICbagq0Xm/5cfADxKjnImuqCTaWNliJ99nSltAuzDB8zA@sWwDkfDfRjow9gX4PedCfPb/QFjWY5w0eDLdpQAOd/XLBhtNDV9/CPSvbssNeUC4JVziCKpHet0YRLTECMxgox8RmOU5UoWbAs4bJkzW3@9nJWCCotjMw5TffZjsv3b5Ssc1QkxVW1VYr@olTRfQA "C (gcc) – Try It Online")
[Answer]
# [brainfuck](https://github.com/TryItOnline/brainfuck), 350 bytes
```
-[<+>---]<++++++.[-]<,[>+<[>>+>+<<<-]>>>[<<<+>>>-]--[<->++++++]<-[>+>+<<<<[>>>>>+>+<<<<<<-]>>>>>>[<<<<<<+>>>>>>-]-[<->---]<------[<->[-]]<+<<<<[>>>>>+>+<<<<<<-]>>>>>>[<<<<<<+>>>>>>-]-[<->---]<--------[<->[-]]<[[-]<->]<[<<<.[>>>>+>+<<<<<-]>>>>>[<<<<<+>>>>>-]----[<-------->+]<[<<<<<[-]+>>>>>[-]]<[-]]<[-]<->]<[<<[>.>>][-]>>[-]]<,]>>-[<+>---]<++++++++.
```
[Try it online!](https://tio.run/##pZBNCkIxDISv0n2bB4o/mzIXGbJQQRDBheD566Ttg4dbA03SNt@k6fV9ebzun9uzNWPNMDOvudtCpYXIlUBWqNUcAJVkRXMTYhjVXo2zKuqxIis1wckOPOje0LrFVj3V/w@RjQxjAIMSAQu3clONG60Yp8PTkAeol5iPkqE63apMLIAzFPtVUfL7lfrM1shdSYeSTl4SY9HD65B7nZ4VjyWdXfYF "brainfuck – Try It Online")
Works by ignoring brackets inside the outermost list. It makes sure not to print a comma after another comma.
Can probably be improved.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 53 bytes
```
⊞υθＦυＦιＦ⁼κ⁺⟦⟧κ⊞υκＦ⮌υ«≔⟦⟧ηＷι⊞η⊟ιＦ⮌η¿⁼κ⁺⟦⟧κＦκ⊞ιλ⊞ικ»⭆¹θ
```
[Try it online!](https://tio.run/##dY@9DsIgFIXn9inuCAkOGrVDJwdHk0ZH0oE0tJCS/lHqYHx2vJDWxEGWcy6c8wGVElPVC@N94awijsFI87TuJyCOQlS96nV0wljSMiiMs4SXDFpKKWzFdive5SInKxFA4ZUmF2t108W8wkjyVNrIiI1Nhbx@wDGc/fQV9nX9/@IYbleMZmBoDtJY@d0IL3qnxaS7mTxmlOYmBrIPf6S595xz9EcGZyQGyw/oM9QTg6wMy@8W8wE "Charcoal – Try It Online") Link is to verbose version of code. Uses the same flattening code as I used in my answer to [Inverted ragged list](https://codegolf.stackexchange.com/q/242174/) but I'll explain it in slightly more detail here.
```
⊞υθＦυＦιＦ⁼κ⁺⟦⟧κ⊞υκ
```
Push the input list and all of its sublists to the predefined empty list.
```
Ｆ⮌υ«
```
Loop over all of the sublists in reverse order i.e. deepest first.
```
≔⟦⟧ηＷι⊞η⊟ι
```
Remove the elements of the sublist and push them to a temporary list.
```
Ｆ⮌η¿⁼κ⁺⟦⟧κＦκ⊞ιλ⊞ικ
```
Loop over the elements of the temporary list in the order they were in the original sublist. For those elements that are sublists push their elements (which by now are just integers) to the sublist otherwise just push the integer element to the sublist.
```
»⭆¹θ
```
Pretty-print the final list so that you can see that it has been flattened.
[Answer]
# [Python](https://www.python.org), ~~58~~ 55 bytes
```
lambda l:[*map(int,re.findall('\d+',str(l)))]
import re
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vweI025ilpSVpuhY3zXMSc5NSEhVyrKK1chMLNDLzSnSKUvXSMvNSEnNyNNRjUrTVdYpLijRyNDU1Y7kycwvyi0oUilKh2jMLioA6NNI0oqONY3WijXUUoqPNYoFAU5OLCy6HyouOBapCUxFtqKNgoqNgBpICMqONgGxzIG2qo2AOMQ5i4YIFEBoA)
Thought it was a bit cheeky using regex to flatten the list
-3 bytes thanks to @Dingus
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 13 bytes
```
#~Level~{-1}&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b7X7nOJ7UsNaeuWtewVu1/QFFmXkm0sq5dmoNyrFpdcHJiXl01V3WtDle1oY6RjokZiAXkVteCGdWGJkB2tWktkGuiU20EETUGihkDhc1qa8ECqHoMgSqBxgDpaiMdM3OdalMdc5BCrtr/AA "Wolfram Language (Mathematica) – Try It Online")
Not the built-in. Returns all atomic expressions, in order.
---
### [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 11 bytes
```
##&@@#0/@#&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b7X1lZzcFB2UDfQVntf0BRZl5JtLKuXZqDcqxaXXByYl5dNVd1rQ5XtaGOkY6JGYgF5FbXghnVhiZAdrVpLZBrolNtBBE1BooZA4XNamvBAqh6DIEqgcYA6WojHTNznWpTHXOQQq7a/wA "Wolfram Language (Mathematica) – Try It Online")
Returns a `Sequence` instead of a `List`.
### [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 6 bytes
```
#<>""&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b7X9nGTklJ7X9AUWZeSbSyrl2ag3KsWl1wcmJeXTVXda0OV7WhjpGOiRmIBeRW14IZ1YYmQHa1aS2Qa6JTbQQRNQaKGQOFzWprwQKoegyBKoHGAOlqIx0zc51qUx1zkEKu2v8A "Wolfram Language (Mathematica) – Try It Online")
Returns a `StringJoin` instead of a `List`, and an empty string when there are no elements (as `StringJoin[]` evaluates to `""`).
[Answer]
# Scala, 75 bytes
```
def f(l:List[_]):List[_]=l.flatMap{case n:Int=>List(n)case p:List[_]=>f(p)}
```
My first Scala answer! With a lot of help from @user.  
[Try it online!](https://scastie.scala-lang.org/m3aMNAlYS5CfEL77Gt12sQ)
[Answer]
# [Javascript (node)](https://nodejs.org/en/), ~~70~~ ~~49~~ 47 Bytes
* -21 Bytes thanks to [Matthew Jensen](https://codegolf.stackexchange.com/users/87728/matthew-jensen)!
* -2 Bytes thanks to [Dom Hastings](https://codegolf.stackexchange.com/users/9365/dom-hastings)!
```
f=(a,c=[])=>a.map(a=>a.map?f(a,c):c.push(a))&&c
```
[Try it online!](https://tio.run/##dY3dCsIwDEbvfYpejRZih043EKoPEnoR6uYPcy1Wff2aSgVRDIF85BySMz0ouusp3OaT3/cpDUYSOINWmS3pCwVJJeyGTNTG6XCPR0lKVZVLzk/Rj70e/UEOErGxgA0IxNZyKSXqWuQFd2tnX/ab/wC0fML@xwsQq3yQLY645NzxXIPoPt4WCwSHoryM9AQ)
[Answer]
# BQN, 8 bytes
```
∾⍟(¯1+≡)
```
[Try it here!](https://mlochbaum.github.io/BQN/try.html#code=RiDihpAg4oi+4o2fKMKvMSviiaEpCgoo4oCiU2hvdyBG4oiY4oCiSnMpwqgg4p+oCiJbWzNdLFszLCBbWzZdXV1dIgoiW10iCiJbW10sIFtdXSIKIltbMSwgNCwgNl0sIFsxLCBbMiwgNjcsIFs1LCA3XV1dXSIK4p+pCgpA)
Thanks to @Razetime for 6 bytes saved!
## Explanation
* `...⍟(¯1+≡)` repeat (depth - 1) times...
* `∾` join (same effect as flattening 1 level)
[Answer]
# [Javascript](https://nodejs.org/en/), ~~96~~ 83 bytes
```
f=a=>JSON.stringify(a).replace(/[\[\],]/g,' ').split(/\s/).filter(e=>e).map(e=>e-0)
```
[Try it online!](https://tio.run/##dY3BCsIwDIbvPkVva6G26nQ7bQ/gQQ8esx7K7EalrmUdgk8/szFBFEMgH/k/kpt@6Fj3Ngzrzl/NODaFLsrj5XwSceht19rmSTUTvQlO14ZKqKBSXMmWJyRhIgZnByqrKJlorBtMT01RGibuOsy03rCx9l30zgjnW9pQgFRxSDkByBQWY0RKMi2wM7X6st/5TwAKT6j/8ZaT/XQQLUTYIec4D5zkH28XixOERZmN8QU)
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), 45 bytes
```
[A|L]+B:-A+X,L+Y,append(X,Y,B).
[]+[].
A+[A].
```
[Try it online!](https://tio.run/##HYvNCoMwEITvPkXwlJBNoLVV8CDEsw@gLHsQ@oOgJqjQS/HV003nMPMNzITNz/5t9s8UI7pvR7qtjdM9dHqAMYTn@pA9DNAqmyFpJJs5jY5srM0yhnnaD8m1aWQ6vfy2jIfMzyBMI85wrjmgg56UAkQsCLAAgVgSi4E7/jMZXkDcQJSJGfHKXHHeQVRpT8rGHw "Prolog (SWI) – Try It Online")
Uses pattern matching to decompose and recursively call the function on the head and tail of the list.
### Explanation
```
[A|L]+B:-                         # Match on list input with at least one input
         A+X,                     # Recursively call on the head of the list
             L+Y,                 # And on the tail
                 append(X,Y,B).   # And combine the results together
[]+[].  # If the element is just an empty list, return the same
A+[A].  # If it just a single element, return a singleton list
```
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), ~~62~~ 38 bytes
*Thanks [@Steffan](https://codegolf.stackexchange.com/users/92689/steffan) for a staggering -24 bytes!!!*
```
L+X:-maplist(+,L,M),append(M,X);X=[L].
```
[Try it online!](https://tio.run/##RYrLCoMwFER/JbhKyCi0tgqWCu7jPnDJQugDQc1Fhe7y62nsprOYOQOHVz/5d759xhiNtk0@DzyN2y41DHqFgfm5PGQPq272TsYV8e9Q59pWdtri5dd52GUWWOStCByWDNTBOqVARKUDlRBElUtJkD799ig6QVwgqoMT0jlxnfYKUR@@U0X8Ag "Prolog (SWI) – Try It Online")
There's probably a builtin out there which flattens lists, but here's a non-builtin way of doing it.
[Answer]
# [PARI/GP](https://pari.math.u-bordeaux.fr), 34 bytes
```
f(a)=if(#a&&a!=b=concat(a),f(b),a)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m728ILEoMz69YMGCpaUlaboWN5XSNBI1bTPTNJQT1dQSFW2TbJPz85ITS4CiOmkaSZo6iZpQlamJBQU5lRqJCrp2CgVFmXlAJQpKII6SAsgMTR2F6Oho41idaGMQyywWCIAMEAYTYF60oY6CiY6CGYgNZEYbAdnmQNpUR8EcpCEWahnMeQA)
[Answer]
# [C (clang)](http://clang.llvm.org/), ~~114~~ ~~99~~ 89 bytes
* -15 bytes with help from @ceilingcat
```
main(c,v)char**v;{for(;v;c=!printf(v?c?"[%s":",%s":"[]"+!c,v))v=strtok(c?v[1]:0,",[ ]");}
```
[Try it online!](https://tio.run/##HctBCoMwEADAr9SFQqIp2Ksh5CFLDmHBKtWkJGEv4ttX7GVuQy/aYvqI7HFNigxrWmLpe7bHnIuybMl1v7KmNiv25AGfFSYwfzHA0N1Hs6uttPxV5BnfYRoNGHwE0PYUEQwX "C (clang) – Try It Online")
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 30 bytes
```
a=>eval(`[${a}]`).filter(x=>1)
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@z/R1i61LDFHIyFapTqxNjZBUy8tM6cktUijwtbOUPN/cn5ecX5Oql5OfrpGmkZ0tHGsTrSxjkJ0tFksEGhqKujrK4AEgMgslgtNNUweQyI6FmhELG5pQx0FE5CBQFVAZrQRkG0OpE11FMyRrIWq0lEAMqBKwCr@AwA "JavaScript (Node.js) – Try It Online")
# [JavaScript (Node.js)](https://nodejs.org), 39 bytes
```
a=>((a+'').match(/\d+/g)||[]).map(eval)
```
[Try it online!](https://tio.run/##dY3NCsIwEITvPsXeuqGxQavtqb7ImkNIf1RiU2zpqe8eN1JBFJeFHWY@Zm9mNqN9XIdp2/u6CW0VTHVCNGmSiOxuJntBda5T1YllIR2tAZvZOBGs70fvmsz5DlskyrWkXAJRoXmEAKUgGryF3nzR7/wnIM0V@n@8k3CIhUyxpD3rku9RQvnxdqUksFiRFxGe "JavaScript (Node.js) – Try It Online")
Assume no negative input
[Answer]
# [APL(Dyalog Unicode)](https://dyalog.com), 1 bytes [SBCS](https://github.com/abrudz/SBCS)
```
∊
```
[Try it on APLgolf!](https://razetime.github.io/APLgolf/?h=AwA&c=e9TRBQA&f=S3vUNzWrOD9PQT06OtrQJFZHITraNDYWSJsAmUaxseoA&i=AwA&r=tryapl&l=apl-dyalog&m=train&n=f)
[Answer]
# Javascript 46 bytes
```
f=a=>(a+'').split(',').filter(x=>x).map(s=>+s)
```
[Try it online!](https://tio.run/##dY3BCsIwDIbvPkVvbVnt0Ol26l4k9FBmK5W6jrXI3r5mMkEUQyAf@T@Sm3mYNMx@yvsxXmwpThnVM1NRymWags@MCkTnQ7YzW1S/cHk3E0uqrxIvQxxTDFaGeGWOATRaQCMIQKuxOCd1TdYFdqt3X/Y7/wlA4wn9Pz4IcloPooUIR@QO51mQ7uPtZgmCsCkvozwB "JavaScript (Node.js) – Try It Online")
Uses the trick that stringification of arrays unnests all arrays. After that empty elements need to be removed and the result mapped to integers.
]