3

How can i reverse a string in Common Lisp?

I want to transform "Hello World" into "dlroW olleH". In Python it is done using extended slice: "Hello World"[::-1].

Community
  • 1
  • 1
Mirzhan Irkegulov
  • 17,660
  • 12
  • 105
  • 166

1 Answers1

7

reverse can take any sequence, including strings, so you only have to write:

> (reverse "Hello World")
"dlroW olleH"
Frédéric Hamidi
  • 258,201
  • 41
  • 486
  • 479