elixir-range-extras alternatives and similar packages
Based on the "Text and Numbers" category.
Alternatively, view elixir-range-extras alternatives based on common mentions on social networks and blogs.
-
Ex_Money
Money arithmetic, conversion, serialisation with Ecto and exchange rate service integration. -
number
Number is a pretentiously-named Elixir library which provides functions to convert numbers into a variety of different formats. -
ua_inspector
User agent parser library like piwik/device-detector. -
secure_random
Convenience library for random base64 strings modeled after my love for Ruby's SecureRandom. -
chinese_translation
Translate between traditional chinese and simplified chinese based on wikipedia data, and translate chinese words/characters to pinyin (or slug with or without tone). -
veritaserum
Sentiment analysis based on afinn-165, emojis and some enhancements. -
haikunator
Generate Heroku-like memorable random names to use in your apps or anywhere else. -
Ex_Cldr_Numbers
CLDR-based Number and Currency Localization and Formatting -
inet_cidr
Classless Inter-Domain Routing (CIDR) for Elixir that is compatible with :inet and supports both IPv4 and IPv6. -
unit_fun
Attempt to add units to numbers in elixir to give some added type saftey when dealing with numeric quantities. -
custom_base
Allow you to make custom base conversion in Elixir. -
Ex_Cldr_Units
SI Unit formatting, localisation, arithmetic and conversion based on the CLDR data -
bencode
A Bencode encoder and decoder for Elixir. The decoder will return the checksum value of the info dictionary, if an info dictionary was found in the input.
Scout APM: A developer's best friend. Try free for 14-days
Do you think we are missing an alternative of elixir-range-extras or a related project?
README
RangeExtras
Elixir range utilities: constant-time random sampling and set operations.
Installation
First, please make sure that you’re running Erlang/OTP 18.0 or newer.
Add range_extras
to your list of dependencies in mix.exs
:
def deps do
[{:range_extras, "~> 0.1.0"}]
end
Run mix deps.get
.
Read the latest documentation at https://hexdocs.pm/range_extras/.
Set operations
union/2
difference/2
intersection/2
These functions take two ranges and return a list of zero to two ranges:
iex> RangeExtras.union(1..4, 3..5)
[1..5]
iex> RangeExtras.difference(8..1, 4..4)
[8..5, 3..1]
iex> RangeExtras.intersection(8..1, -4..0)
[]
They’re implemented as simple cond
clauses that match on the start and end
values of the ranges, so they run in constant time.
Ranges are always inclusive.
The direction of the resulting ranges is the same as the direction of the first given range:
iex> RangeExtras.union(1..4, 3..5)
[1..5]
iex> RangeExtras.union(4..1, 3..5)
[5..1]
Random sampling
random/1
Works in the same way as Enum.random/1
, but runs in constant time as well
since it only uses the start and end values of the range.
The implementation uses Erlang’s :rand
module. You don’t need to seed the
generator like you have to currently do with Enum.random/1
that uses
:random
instead.
(The development version of Elixir now uses :rand
.)
Licence
ISC License (ISC)
Copyright © 2015 Leo Nikkilä
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*Note that all licence references and agreements mentioned in the elixir-range-extras README section above
are relevant to that project's source code only.