RosettaCodeData/Task/Rot-13/Elena/rot-13.elena

32 lines
663 B
Text
Raw Permalink Normal View History

2019-09-12 10:33:56 -07:00
import system'routines;
import extensions;
import extensions'text;
2018-06-22 20:57:24 +00:00
singleton rotConvertor
{
char convert(char ch)
2019-09-12 10:33:56 -07:00
{
if (($97 <= ch && ch <= $109) || ($65 <= ch && ch <= $77))
{
^ (ch.toInt() + 13).toChar()
};
if (($110 <= ch && ch <= $122) || ($78 <= ch && ch <= $90))
{
^ (ch.toInt() - 13).toChar()
};
2018-06-22 20:57:24 +00:00
^ ch
2019-09-12 10:33:56 -07:00
}
2018-06-22 20:57:24 +00:00
2019-09-12 10:33:56 -07:00
string convert(string s)
= s.selectBy:(ch => rotConvertor.convert(ch)).summarize(new StringWriter());
2018-06-22 20:57:24 +00:00
}
2019-09-12 10:33:56 -07:00
public program()
{
if (program_arguments.Length > 1)
{
console.printLine(rotConvertor.convert(program_arguments[1]))
}
}