Giter Site home page Giter Site logo

taktinc / uuid-divide Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ramirez7/uuid-divide

0.0 5.0 0.0 10 KB

Mutually-exclusive, collectively-exhaustive sets of UUID ranges

License: BSD 3-Clause "New" or "Revised" License

Haskell 95.11% Nix 4.89%

uuid-divide's Introduction

uuid-divide

Mutually-exclusive, collectively-exhaustive sets of UUID ranges.

Useful for evenly dividing operations over uniformly-distributed UUIDs.

Uses

Note that UUIDRange is inclusive on both ends.

Divide into 2^n equal ranges:

λ: uuidDivide 2
[ UUIDRange {uuidLower = 00000000-0000-0000-0000-000000000000, uuidUpper = 3fffffff-ffff-ffff-ffff-ffffffffffff}
, UUIDRange {uuidLower = 40000000-0000-0000-0000-000000000000, uuidUpper = 7fffffff-ffff-ffff-ffff-ffffffffffff}
, UUIDRange {uuidLower = 80000000-0000-0000-0000-000000000000, uuidUpper = bfffffff-ffff-ffff-ffff-ffffffffffff}
, UUIDRange {uuidLower = c0000000-0000-0000-0000-000000000000, uuidUpper = ffffffff-ffff-ffff-ffff-ffffffffffff} ]

Get the nth (starting at 0) range for a total division (must be a power of 2):

λ: nthRange 4 2
Right (UUIDRange {uuidLower = 80000000-0000-0000-0000-000000000000, uuidUpper = bfffffff-ffff-ffff-ffff-ffffffffffff})

Check for inclusion:

λ: :{
uuidRangeContains
  UUIDRange {
  uuidLower = fromJust $ fromText "80000000-0000-0000-0000-000000000000",
  uuidUpper = fromJust $ fromText "bfffffff-ffff-ffff-ffff-ffffffffffff" } $
  fromJust (fromText "a2cc10e1-57d6-4b6f-9899-38d972112d8c")
:}

True

uuid-divide's People

Contributors

ramirez7 avatar

Watchers

 avatar James Cloos avatar Greg Hale avatar Christian Selchau-Hansen avatar  avatar

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.