On 20/04/2014 02:33, Warren D Smith wrote:
Anyway, how about SWAP(a,b)? That is something that one does very often, but no(?) high level language provides it. That kind of thing is like a thorn in your side. It just annoys you a little each day.
Common Lisp: (rotatef a b) Python: a,b = b,a Ruby: a,b = b,a C++: std::swap(a,b)
And why do we get cyclic shifts of words, but not reversal, so we cannot get the dihedral group? Why? For what possible reason?
The vast majority of the world's software doesn't have any particular need to represent subsets of small dihedral groups with machine integers. There's only so much space in the instruction set encoding, and it's not clear that bit reversal would earn its place. (Perhaps it might, for FFT-related reasons. But if no major CPU architecture has ever had a bit-reversal operation -- is that true? -- then it seems pretty likely that at least once someone's given careful thought to whether it would be worth including and decided not.) -- g