Thread overview | |||||
---|---|---|---|---|---|
|
July 01, 2011 Re: Generic invert function? | ||||
---|---|---|---|---|
| ||||
On 2011-06-30 18:27, Andrej Mitrovic wrote:
> So I thought this would be in Phobos, basically I want to reverse the "polarity" of a value in a range.
>
> What I mean is if I have a possible range of 0 .. 127, then the values of the left would equal the inverted values on the right:
>
> 0 -> 127
> 10 -> 117
> 20 -> 107
> 50 -> 77
> 77 -> 50
>
> and so on.. Quite easy to do, is it common enough to be in Phobos though?
std.range.retro?
- Jonathan M Davis
|
July 01, 2011 Re: Generic invert function? | ||||
---|---|---|---|---|
| ||||
Stupid brain, LOL. auto arr = array(retro(iota(0, 127))); Problem solved. |
July 01, 2011 Re: Generic invert function? | ||||
---|---|---|---|---|
| ||||
Woops, bug, right side not inclusive. Fixed: auto arr = array(retro(iota(0, 128))); |
Copyright © 1999-2021 by the D Language Foundation