Skip to content

Instantly share code, notes, and snippets.

@CyberShadow
Created June 23, 2015 23:46
Show Gist options
  • Save CyberShadow/5cc7e926f566d56a672f to your computer and use it in GitHub Desktop.
Save CyberShadow/5cc7e926f566d56a672f to your computer and use it in GitHub Desktop.
// Eager version
void main(string[] args)
{
import std.algorithm, std.file, std.path, std.range, std.uni;
args[1..$].each!(fn =>
fn
.readText()
.toLower
.copy(File(fn.setExtension(".lower"), "wb").lockingTextWriter)
);
}
// Range version - current names
void main(string[] args)
{
import std.algorithm, std.file, std.path, std.range, std.uni;
args[1..$].each!(fn =>
fn
.readText()
.toLowerCase()
.copy(File(fn.setExt(".lower"), "wb").lockingTextWriter)
);
}
// Range version - proposal 1
void main(string[] args)
{
import std.algorithm, std.file, std.path, std.range, std.uni;
args[1..$].each!(fn =>
fn
.readText()
.lowerCased()
.copy(File(fn.withExtension(".lower"), "wb").lockingTextWriter)
);
}
// Range version - proposal 2
void main(string[] args)
{
import std.algorithm, std.file, std.path, std.range, std.uni;
args[1..$].each!(fn =>
fn
.readText()
.toLowerLazy()
.copy(File(fn.setExtensionLazy(".lower"), "wb").lockingTextWriter)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment