P07 - Flatten a nested array structure.

Author: Eric Hodges

Specification

P07 (**) Flatten a nested array structure.
    Transform an array, possibly holding arrays as elements into a `flat'
    list by replacing each array with its elements (recursively).

Example

> splat([1,[2,[3,4],5]]).perl.say;
(1, 2, 3, 4, 5)

Source code: P07-eric256.pl

use v6;

sub splat (@t) {
    return (gather @t.deepmap(*.take)).list;
}

splat(['a', ['b',['c','d'], 'e']]).perl.say;