Created
August 16, 2012 20:25
-
-
Save perlmonger42/3373357 to your computer and use it in GitHub Desktop.
reverse_string(STRING): return a reversed copy of the input string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Normally, you'd just say | |
# reverse STRING | |
# since Perl provides a builtin for this functionality, but that would be | |
# cheating based on the rules of the assignment. | |
# my $desrever = reverse_string(STRING); | |
# | |
# Return a reversed copy of the input string. | |
sub reverse_string { | |
return join '', reverse split //, $_[0]; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment