Re:C++11 and Boost - Succinct like Python
by BoppreH on Wednesday October 31, 2012 @01:01PM
(#4723851)
Or you could use the "reversed" built-in function:
It also has the plus of creating a generator, saving memory from a new array allocation.
[ Parent
| on HN ]
Re:C++11 and Boost - Succinct like Python
by wting on Wednesday October 31, 2012 @01:18PM
(#4723962)
`reversed(s)` returns an iterator. The much slower equivalent of `s[::-1]` is `''.join(reversed(s))`.
It's odd how Python has list.reverse() but not str.reverse(). Probably a conscious design decision sometime ago.