This repository has been archived by the owner on Sep 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
first pass at adding docstrings #98
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
docs/build/ | ||
docs/site/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Documenter, Iterators | ||
|
||
makedocs( | ||
modules = [Iterators], | ||
format = :html, | ||
sitename = "Iterators", | ||
pages = Any[ | ||
"Introduction" => "index.md", | ||
"Function index" => "functionindex.md" | ||
]) | ||
|
||
deploydocs( | ||
repo = "github.com/JuliaCollections/Iterators.jl.git", | ||
target = "build", | ||
julia = "0.5", | ||
osname = "osx", | ||
deps = nothing, | ||
make = nothing | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Index | ||
|
||
```@index | ||
``` | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
```@meta | ||
DocTestSetup = quote | ||
using Iterators | ||
end | ||
``` | ||
|
||
# Iterators | ||
|
||
## Installation | ||
|
||
Install this package with `Pkg.add("Iterators")` | ||
|
||
# Usage | ||
|
||
## chain(xs...) | ||
|
||
Iterate through any number of iterators in sequence. | ||
|
||
```@docs | ||
chain | ||
``` | ||
|
||
## distinct(xs) | ||
|
||
Iterate through values skipping over those already encountered. | ||
|
||
```@docs | ||
distinct | ||
``` | ||
|
||
## groupby(f, xs) | ||
|
||
Group consecutive values that share the same result of applying `f`. | ||
|
||
```@docs | ||
groupby | ||
``` | ||
|
||
## imap(f, xs1, [xs2, ...]) | ||
|
||
Iterate over values of a function applied to successive values from one or more iterators. | ||
|
||
```@docs | ||
imap | ||
``` | ||
|
||
## iterate(f, x) | ||
|
||
Iterate over successive applications of `f`, as in `f(x), f(f(x)), f(f(f(x))), ...`. | ||
|
||
```@docs | ||
iterate | ||
``` | ||
|
||
## ncycle(xs, n) | ||
|
||
Cycles through an iterator `n` times. | ||
|
||
```@docs | ||
ncycle | ||
``` | ||
|
||
## nth(xs, n) | ||
|
||
Return the `n`th element of `xs`. | ||
|
||
```@docs | ||
nth | ||
``` | ||
|
||
## partition(xs, n, [step]) | ||
|
||
Group values into `n`-tuples. | ||
|
||
```@docs | ||
partition | ||
``` | ||
|
||
## peekiter(xs) | ||
|
||
Peek at the head element of an iterator without updating the state. | ||
|
||
```@docs | ||
peekiter | ||
``` | ||
|
||
## product(xs...) | ||
|
||
Iterate over all combinations in the Cartesian product of the inputs. | ||
|
||
```@docs | ||
product | ||
``` | ||
|
||
## repeatedly(f, [n]) | ||
|
||
Call a function `n` times, or infinitely if `n` is omitted. | ||
|
||
```@docs | ||
repeatedly | ||
``` | ||
|
||
## takenth(xs, n) | ||
|
||
Iterate through every n'th element of `xs` | ||
|
||
```@docs | ||
takenth | ||
``` | ||
|
||
## subsets(xs, [k]) | ||
|
||
Iterate over every subset of a collection `xs`, or iterate over every subset of size `k` from a collection `xs`. | ||
|
||
```@docs | ||
subsets | ||
``` | ||
|
||
## takestrict(xs, n) | ||
|
||
Equivalent to `take`, but will throw an exception if fewer than `n` items are encountered in `xs`. | ||
|
||
```@docs | ||
takestrict | ||
``` | ||
|
||
# The `@itr` macro for automatic inlining in `for` loops | ||
|
||
Using functional iterators is powerful and concise, but may incur in some overhead, and manually inlining the operations can typically improve performance in critical parts of the code. The `@itr` macro is provided to do that automatically in some cases. | ||
|
||
Its usage is trivial: for example, given this code: | ||
|
||
``` | ||
for (x,y) in zip(a,b) | ||
@show x,y | ||
end | ||
``` | ||
|
||
the automatically inlined version can be obtained by simply doing: | ||
|
||
``` | ||
@itr for (x,y) in zip(a,b) | ||
@show x,y | ||
end | ||
``` | ||
|
||
This typically results in faster code, but its applicability has limitations: | ||
|
||
* it only works with `for` loops; | ||
* if multiple nested iterators are used, only the outermost is affected by the transformation; | ||
* explicit expressions are required (i.e. when a `Tuple` is expected, an explicit tuple must be provided, a tuple variable won't be accepted); | ||
* splicing is not supported; | ||
* multidimensional loops (i.e. expressions such as `for x in a, y in b`) are not supported | ||
|
||
The `@itr` macro can be used with the following supported iterators: | ||
|
||
* zip | ||
* enumerate | ||
* take | ||
* takestrict | ||
* drop | ||
* chain | ||
|
||
```@docs | ||
@itr | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Did you mean for this to be empty?
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 think if it's empty it defaults to doing everything...
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.
Oh, okay. I'm not so good with Documenter, I just wanted to make sure. 🙂