Make directory path: Difference between revisions

Content added Content deleted
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 160: Line 160:
return 0;
return 0;
}</lang>
}</lang>

=={{header|C sharp|C#}}==
<lang csharp>System.IO.Directory.CreateDirectory(path)</lang>


=={{header|C++|CPP}}==
=={{header|C++|CPP}}==
Line 189: Line 192:
}
}
}
}
</lang>

=={{header|C sharp|C#}}==
<lang csharp>System.IO.Directory.CreateDirectory(path)</lang>

=={{header|Common Lisp}}==
<lang lisp>
(ensure-directories-exist "your/path/name")
</lang>
</lang>


Line 205: Line 200:
true
true
(.mkdirs dir))))</lang>
(.mkdirs dir))))</lang>

=={{header|Common Lisp}}==
<lang lisp>
(ensure-directories-exist "your/path/name")
</lang>


=={{header|D}}==
=={{header|D}}==
Line 458: Line 458:


make_path('path/to/dir')</lang>
make_path('path/to/dir')</lang>

=={{header|Perl 6}}==
{{Works with|rakudo|2016.06}}

There is a built-in function for this:

<lang perl6>mkdir 'path/to/dir'</lang>

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

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


=={{header|Phix}}==
=={{header|Phix}}==
Line 612: Line 599:


</pre>
</pre>

=={{header|Raku}}==
(formerly Perl 6)
{{Works with|rakudo|2016.06}}

There is a built-in function for this:

<lang perl6>mkdir 'path/to/dir'</lang>

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

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


=={{header|REXX}}==
=={{header|REXX}}==