Rot-13: Difference between revisions

2,205 bytes added ,  1 month ago
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(8 intermediate revisions by 5 users not shown)
Line 1,711:
"Gur Dhvpx Oebja Sbk Whzcf Bire Gur Ynml Qbt!".rot13().writeln();
}</syntaxhighlight>
 
=={{header|Dart}}==
{{trans|Swift}}
<syntaxhighlight lang="Dart">
String rot13char(int charCode) {
if ((charCode >= 'A'.codeUnitAt(0) && charCode <= 'M'.codeUnitAt(0)) ||
(charCode >= 'a'.codeUnitAt(0) && charCode <= 'm'.codeUnitAt(0))) {
return String.fromCharCode(charCode + 13);
} else if ((charCode >= 'N'.codeUnitAt(0) && charCode <= 'Z'.codeUnitAt(0)) ||
(charCode >= 'n'.codeUnitAt(0) && charCode <= 'z'.codeUnitAt(0))) {
return String.fromCharCode(charCode - 13);
} else {
return String.fromCharCode(charCode);
}
}
 
String rot13(String str) {
return String.fromCharCodes(str.runes.map((rune) {
return rot13char(rune).codeUnitAt(0);
}));
}
 
void main() {
print(rot13("The quick brown fox jumps over the lazy dog"));
}
</syntaxhighlight>
{{out}}
<pre>
Gur dhvpx oebja sbk whzcf bire gur ynml qbt
 
</pre>
 
=={{header|Delphi}}==
{{libheader| System.SysUtils}}
Line 2,208 ⟶ 2,240:
 
PAUSE
</syntaxhighlight>
 
=={{header|Fennel}}==
{{trans|Lua}}
 
<syntaxhighlight lang="fennel">
(fn rot13 [s]
(let [a :ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
b :NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm]
(s:gsub :%a #(b:sub (a:find $)))))
</syntaxhighlight>
 
Line 2,628 ⟶ 2,670:
WRITE(ClipBoard, Name) txt, cod ! txt=abc? XYZ!; cod=nop? KLM!;
END</syntaxhighlight>
 
=={{header|Haxe}}==
<syntaxhighlight lang="haxe">
public static function rot13(input: String): String {
var buf = new StringBuf();
for (charInt in new haxe.iterators.StringIterator(input)) {
if (charInt >= 0x41 && charInt <= 0x4d || charInt >= 0x61 && charInt <= 0x6d)
charInt += 13;
else if (charInt >= 0x4e && charInt <= 0x5a || charInt >= 0x6e && charInt <= 0x7a)
charInt -= 13;
buf.addChar(charInt);
}
return buf.toString();
}
</syntaxhighlight>
 
=={{header|Hy}}==
Line 6,159 ⟶ 6,216:
rot13("Shall Not Perish")
Funyy Abg Crevfu</syntaxhighlight>
 
=={{header|Stringle}}==
<syntaxhighlight lang="stringle">a "The quick brown fox jumps over the lazy dog."
b "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz"
c b
#@c 78
#\c 52
#a
b %.a d " " b
b %.a #d .a
b %.a e c
b %.a #e #d
b %.a a .\e :a
f f .a
a :a
#a
$ f</syntaxhighlight>
{{out}}
Gur dhvpx oebja sbk whzcf bire gur ynml qbt.
 
=={{header|Swift}}==
Line 6,864 ⟶ 6,940:
</pre>
 
 
=={{header|YAMLScript}}==
<syntaxhighlight lang="yaml">
!yamlscript/v0
 
s =: set(nil).into('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
m =: drop(26 s).concat(take(26 s)).zipmap(s _)
 
defn main(s):
say: map(\(m %1 %1) s).apply(str _)
</syntaxhighlight>
 
=={{header|Zig}}==
62

edits