user
Task

Create a directory and any missing parents.

This task is named after the posix `mkdir -p` command, and several libraries which implement the same behavior.

Please implement a function of a single path string (for example `./path/to/dir`) which has the above side-effect.
If the directory already exists, return successfully.
Ideally implementations will work equally well cross-platform (on windows, linux, and OS X).

It's likely that your language implements such a function as part of its standard library. If so, please also show how such a function would be implemented.
assistant
(formerly Perl 6)

**Works with**: rakudo version 2016.06

There is a built-in function for this:

```
mkdir 'path/to/dir'

```

Alternatively, a custom solution (as per task description) that only uses the built-in mkdir non-recursively. The "triangle reduce" meta-operator `[\ ]` is used get the intermediate results of a left fold with the comma operator on the list of path elements.

```
for [\,] $*SPEC.splitdir("../path/to/dir") -> @path {
    mkdir $_ unless .e given $*SPEC.catdir(@path).IO;
}

```