-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from cite-architecture/dev
Expanded documentation
- Loading branch information
Showing
3 changed files
with
80 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "CitableBase" | ||
uuid = "d6f014bd-995c-41bd-9893-703339864534" | ||
authors = ["Neel Smith <[email protected]>"] | ||
version = "10.1.0" | ||
version = "10.1.1" | ||
|
||
[deps] | ||
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" | ||
|
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
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,78 @@ | ||
## Julia collections | ||
|
||
By defining five functions on your citable collection, you can make them interoperate with dozens of generic Julia functions for working with collections of data. | ||
|
||
|
||
## What you need to define | ||
|
||
Thes are the five functions you want to define: | ||
|
||
```@example bigfive | ||
using Base.Iterators | ||
import Base: length | ||
import Base: eltype | ||
import Base: iterate | ||
import Base: filter | ||
import Base.Iterators: reverse | ||
``` | ||
|
||
In many cases, you can implement these functions with a single line of code. | ||
|
||
- `length`: return the number of items in your collection | ||
- `eltype`: return the type of object your collection contains | ||
- `iterate`: you need to implement two required methods, one for an initial state and taking a single parameter for the collection, a second with two parameters, giving the collection and some state information. If your collection is indexed (e.g., an Array type), your state information might simply be an index value. | ||
- `filter`: you can use `collect` to create an Array on your citable collection and filter the resulting Array. | ||
- `reverse`: similarly, just collect the values of your collection and pass that to `reverse` | ||
|
||
|
||
|
||
|
||
## What you get | ||
|
||
|
||
Some of the functions this gives you are: | ||
|
||
*functions returning iterators*: | ||
|
||
- `collect` | ||
- `drop` | ||
- `dropwhile` | ||
- `enumerate` | ||
- `flatten` | ||
- `partition` | ||
- `product` | ||
- `rest` | ||
- `take` | ||
- `takewhile` | ||
- `zip` | ||
|
||
*functions returning other kinds of value*: | ||
|
||
|
||
- `accumulate` | ||
- `all` | ||
- `allunique` | ||
- `any` | ||
- `argmax` | ||
- `argmin` | ||
- `collect` | ||
- `count` | ||
- `extrema` | ||
- `first` | ||
- `in` | ||
- `isempty` | ||
- `map` | ||
- `reduce` | ||
- `foldl` | ||
- `foldr` | ||
- `maximum` | ||
- `map` | ||
- `mapfoldl` | ||
- `mapfoldr` | ||
- `mapreduce` | ||
- `minimum` | ||
- `prod` | ||
- `unique` | ||
- `∌` | ||
|
||
|