Skip to content

Commit

Permalink
Merge pull request #67 from cite-architecture/dev
Browse files Browse the repository at this point in the history
Expanded documentation
  • Loading branch information
neelsmith authored Feb 10, 2022
2 parents 1b4d174 + 8c6d207 commit 4205355
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
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"
Expand Down
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ makedocs(
"Identifiers" => "urns.md",
"Citable objects" => "citable.md",
"Citable collections" => "collections.md",
"Julia collections" => "collections2.md",
"API documentation" => "apis.md"
]
)
Expand Down
78 changes: 78 additions & 0 deletions docs/src/collections2.md
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`
- ``


0 comments on commit 4205355

Please sign in to comment.