-
Notifications
You must be signed in to change notification settings - Fork 270
Update official docs #491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update official docs #491
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ higher order function from ``functools``. Currying provides syntactic sugar. | |
| .. code:: | ||
|
|
||
| >>> double = partial(mul, 2) # Partial evaluation | ||
| >>> doubled = double(2) # Currying | ||
| >>> doubled = double(5) # Currying | ||
|
Comment on lines
10
to
+11
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel the choice of passing in |
||
|
|
||
| This syntactic sugar is valuable when developers chain several higher order | ||
| functions together. | ||
|
|
@@ -54,7 +54,7 @@ In general | |
| >>> def g(z): | ||
| ... return f(a, b, z) | ||
|
|
||
| >>> # partially evaluate f with known values a and b | ||
| >>> # alternatively we could use `partial` | ||
| >>> g = partial(f, a, b) | ||
|
|
||
| Curry | ||
|
|
@@ -74,7 +74,7 @@ compute a result. | |
|
|
||
| >>> double = mul(2) # mul didn't receive enough arguments to evaluate | ||
| ... # so it holds onto the 2 and waits, returning a | ||
| ... # partially evaluated function, double | ||
| ... # partially evaluated function `double` | ||
|
|
||
| >>> double(5) | ||
| 10 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,7 +38,7 @@ These functions correspond to the SQL commands ``SELECT`` and ``WHERE``. | |
| ... map(get([1, 2])), | ||
| ... list) | ||
|
|
||
| Note: this uses the `curried`_ versions of ``map`` and ``filter``. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| Note: this uses the `curried`` versions of ``map`` and ``filter``. | ||
|
|
||
| Of course, these operations are also well supported with standard | ||
| list/generator comprehension syntax. This syntax is more often used and | ||
|
|
@@ -89,7 +89,7 @@ groups. | |
| 'M': [(2, 'Bob', 200, 'M'), (3, 'Charlie', 150, 'M'), (4, 'Dennis', 50, 'M')]} | ||
|
|
||
| >>> valmap(compose(sum, pluck(2)), | ||
| ... _) | ||
| ... _) # The underscore captures results from the previous prompt | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might not be obvious to everyone. |
||
| {'F': 400, 'M': 400} | ||
|
|
||
|
|
||
|
|
@@ -116,8 +116,8 @@ understand this section you should first be familiar with the builtin function | |
|
|
||
| The ``reduceby`` operation takes a key function, like ``get(3)`` or ``lambda x: | ||
| x[3]``, and a binary operator like ``add`` or ``lesser = lambda acc, x: acc if | ||
| acc < x else x``. It successively applies the key function to each item in | ||
| succession, accumulating running totals for each key by combining each new | ||
| acc < x else x``. It applies the key function to each item in succession, | ||
| accumulating running totals for each key by combining each new | ||
| value with the previous using the binary operator. It can't accept full | ||
| reduction operations like ``sum`` or ``min`` as these require access to the | ||
| entire group at once. Here is a simple example: | ||
|
|
@@ -180,8 +180,9 @@ common first column, id. | |
| .. code:: | ||
|
|
||
| SELECT accounts.name, addresses.address | ||
| FROM accounts, addresses | ||
| WHERE accounts.id = addresses.id; | ||
| FROM accounts | ||
| JOIN addresses | ||
| ON accounts.id = addresses.id; | ||
|
|
||
|
|
||
| .. code:: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ Tips and Tricks | |
| =============== | ||
|
|
||
| Toolz functions can be combined to make functions that, while common, aren't | ||
| a part of toolz's standard library. This section presents | ||
| a part of toolz's standard offerings. This section presents | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To avoid confusion with the python standard library. |
||
| a few of these recipes. | ||
|
|
||
|
|
||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel the presence of
coinsis somewhat antithetical to the principal of function purity as described in the docs.