Comparison of programming languages (string functions): Difference between revisions

Content deleted Content added
Loudogni (talk | contribs)
Loudogni (talk | contribs)
CharAt: Add Perl 5 snippet and showcase only the requested example for Perl 6
Line 175:
MyChar: Char;
begin
MyChar := MyStr[2]; // 'e'
</syntaxhighlight>
 
<pre>
# Example in ALGOL 68 #
"Hello, World"[2]; // 'e'
</pre>
 
<syntaxhighlight lang="csharp">
// Example in C# and Ya
"Hello, World"[2]; // 'l'
</syntaxhighlight>
 
<syntaxhighlight lang="perl">
# Example in Perl 5
substr("Hello, World".substr(*-, 1, *1); # 'de'
</syntaxhighlight>
 
<syntaxhighlight lang="perl6">
# ExamplesExample in Perl 6
"Hello, World".substr(01, 1); # 'He'
"Hello World".substr(*-1, *) # 'd'
</syntaxhighlight>
 
<syntaxhighlight lang="python">
# Examples in Python
"Hello, World"[2] # 'l'
"Hello, World"[-3] # 'r'
</syntaxhighlight>
 
Line 212 ⟶ 216:
<syntaxhighlight lang="smalltalk">
" Example in Smalltalk "
'Hello, World' at: 2. "$e"
</syntaxhighlight>
<!-- endsection -->