Sunday, May 10, 2009

Hello Ruby

def reverse(value)
if value.length > 1 then
value[value.length-1] + reverse(value[0,value.length-1])
else
value[0]
end
end
The string formatting functions of Ruby caught my interest, but I haven't checked if any equivalents exist in Python.
irb> "#{reverse 'Hello, World!'}"
=> "!dlroW ,olleH"

No comments: