Compare length of two strings: Difference between revisions
Content added Content deleted
mNo edit summary |
(PascalABC.NET) |
||
Line 2,144: | Line 2,144: | ||
6 Pascal |
6 Pascal |
||
6 Foobar</pre> |
6 Foobar</pre> |
||
=={{header|PascalABC.NET}}== |
|||
<syntaxhighlight lang="pascal"> |
|||
begin |
|||
var (s1,s2) := ('Bye','Hello'); |
|||
if s1.Length > s2.Length then |
|||
Swap(s1,s2); |
|||
Println(s1,s1.Length); |
|||
Println(s2,s2.Length); |
|||
Println; |
|||
var strArr := |'wolf','cat','crocodile','tiger'|; |
|||
strArr.OrderByDescending(s -> s.Length).PrintLines(s -> $'{s,9} - {s.Length}'); |
|||
end. |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
Bye 3 |
|||
Hello 5 |
|||
crocodile - 9 |
|||
tiger - 5 |
|||
wolf - 4 |
|||
cat - 3 |
|||
</pre> |
|||
=={{header|Perl}}== |
=={{header|Perl}}== |