Changelog History
-
v2.3.0 Changes
June 27, 2017Compose functions, from the head of the list of functions. The is the reverse
order versus what one would normally expect (left-to-right rather than
right-to-left).Examples
iex\> sum\_plus\_one = compose\_list([&(&1 + 1), &Enum.sum/1]) ...\> sum\_plus\_one.([1, 2, 3]) 7
-
v2.2.0 Changes
September 12, 2016Pointfree unary functions!
๐ Allows defining functions as straight function composition (ie: no need to state the argument). Provides a clean, composable named functions. Also doubles as an aliasing device.
defmodule Foo douse Quark defx foo, do: Enum.sum |\> succ defx bar, do: ((&Enum.sum/1) \<~\> succ).()end[1,2,3] |\> Foo.foo#=\> 7[1,2,3] |\> Foo.bar#=\> 7
๐ฑ Pointfree n-ary functions (based on the first function in the body) is still coming ๐
-
v2.0.0 Changes
August 29, 2016๐ Nothing terribly major. The breaking change is that a number of top-level functions have moved into submodules, and there's now a handy top-level
use
macro.โก๏ธ Also modernized the deps, updated the docs, and altered the layout of the doctests for readability.
-
v1.0.0 Changes
January 02, 2016๐ ๐ ๐ ๐ Happy New Year and a happy first
Quark
release! ๐ ๐ ๐Quark 1.0.0
has arrived! Having recently undergone mitosis from Witchcraft, we've fleshed out quite a few functional programming basics that we felt would be useful in Elixir.Functional Overview
SKI combinators
Yes, now you too can define all of your algorithms in incomprehensible strings of
s
andk
! Get yours k (k k)
on! But seriously, a lot of this stuff is pretty useful. We've provided friendlier names at the top-levelQuark
module, so that you can writeconst
, rather than having remember whatk
does.BCKW combinators
The classic
b
,c
,k
, andw
combinators of lore. Pretty much the same idea as with SKI, but some different functionality. And as usual, we've aliased the names at the top-level.๐ Fixed Point
๐ Fixed point combinators, for helping with recursion. Several formulations are provided, but stick to
fix
(should be the most efficient at any given time, and thus somewhat more future-proof).Compose
Compose functions to do convenient partial applications. Versions for composing left-to-right and right-to-left are provided, but the operator
<|>
is done "the math way" (right-to-left). Versions on lists also available.Sequence
Really here for
pred
andsucc
on integers, by why stop there? This works with any ordered collection.Curry
Functions
curry
creates a 0-arity function that curries an existing function.uncurry
applies arguments to curried functions, or if passed a function creates a function on pairs.Macros
Why define the function before currying it?
defcurry
anddefcurryp
return fully-curried 0-arity functions.Partial
๐ฑ ๐ We think that this is really the crowning jewel of
Quark
.defpartial
anddefpartialp
create all arities possible for the defined function, bare, partially applied, and fully curried. This does use up all the full arity-space for that function name, however.Closing Remarks
We hope that you enjoy
Quark
! Please let us know if you have new feature requests.With humanity,