Proposal for a generic showIntAtBase

Vikas Menon menonvikas at gmail.com
Mon Apr 6 21:43:19 UTC 2015


The idea is the same function can deal with Chars, "digits" or any other
types (UTF16 for instance). This would subsume the current implementation
of decomposeVarPositional and deal with many more.


On Mon, Apr 6, 2015 at 3:04 PM, Henning Thielemann <
lemming at henning-thielemann.de> wrote:

>
> On Mon, 6 Apr 2015, Jon Purdy wrote:
>
>  Could you offer a specific use case? When I need to convert a number
>> to its representation in some base, it’s because I’m displaying or
>> serialising it. A base is a notation (or a variant of a notation) and
>> it seems sensible to represent such notations with characters.
>>
>
> E.g. you can use it to pack a tuple of small integers space efficiently
> into a larger integer type. E.g. you can pack 3 integers from the range
> 0..4 into 7 bits using a base-5 representation, but you would need 9 bits
> if you reserve three bits for every small integer.
>
> Using the positional representation you can also convert between tupled
> and linear indexes of an array with equal extents in all dimensions (i.e. a
> hypercube).
>
> Both examples also work with mixed-base representations.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20150406/876a3f39/attachment.html>


More information about the Libraries mailing list