Git Product home page Git Product logo

elm-natural's People

Contributors

dwayne avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

elm-natural's Issues

Add `toBase` and `fromBase` functions

The library currently has a few functions for converting to strings in different bases. It would be nice to have a more general function for converting to a List Int in an arbitrary base (up to 2^26).

My specific use case is converting a Natural to Bytes (in a compact way) and back again, so:

  • It'd be nice if 2^n bases could be optimised using bit shifts instead of divisions.
  • I only need one specific base (256), but it'd be nice to have a general function to do it for all bases.
  • Specific functions for working directly with Bytes would be nice, but probably not worth the extra dependency.

Proposed functions

{-| Create the natural number that represents the given list of base-`b` digits.
-}
fromBase : Int -> List Int -> Natural
fromBase b digits =
    Debug.todo ""


{-| Convert the given natural number to a list of digits in base-`b`.
-}
toBase : Int -> Natural -> List Int
toBase b n =
    Debug.todo ""

These could perhaps be named toBaseBDigits and fromBaseBDigits for better consistency with the string functions.

JSON interop?

Hi, I'm dealing with big integers and your package seems to fit well with some of my needs for handling unbounded integers with exact computations, instead of approximate for anything > 2^53.

Another common use-case I have is dealing with big integers in JSON files I may receive or send. JSON has no issue with big integers (contrary to JS) so it's common in tools I interact with to have integers > 2^53 in JSON, that are encoded as integers, and not as strings. I was wondering if you encountered similar use cases, and your general thoughts about JSON interop for elm-natural.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.