Compose 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
iex\> sum\_plus\_one = compose\_list([&(&1 + 1), &Enum.sum/1]) ...\> sum\_plus\_one.([1, 2, 3]) 7
Pointfree 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 😄
🚚 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
⚡️ Also modernized the deps, updated the docs, and altered the layout of the doctests for readability.
🚀 🎉 🎉 🎉 Happy New Year and a happy first
Quarkrelease! 🎉 🎉 🎉
Quark 1.0.0has 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.
Yes, now you too can define all of your algorithms in incomprehensible strings of
k! Get your
s k (k k)on! But seriously, a lot of this stuff is pretty useful. We've provided friendlier names at the top-level
Quarkmodule, so that you can write
const, rather than having remember what
wcombinators 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 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.
Really here for
succon integers, by why stop there? This works with any ordered collection.
currycreates a 0-arity function that curries an existing function.
uncurryapplies arguments to curried functions, or if passed a function creates a function on pairs.
Why define the function before currying it?
defcurrypreturn fully-curried 0-arity functions.
🍱 👑 We think that this is really the crowning jewel of
defpartialpcreate 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.
We hope that you enjoy
Quark! Please let us know if you have new feature requests.