Skip to content

Commit

Permalink
Better docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Qqwy committed Sep 4, 2021
1 parent 489dc7d commit 18af856
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ By using `Collectable`:

#### Some common array operations:

Indexing is constant-time,
the full Access calls are supported,
and variants of many common functions known from `Enum`, but that keep the result an array, are available.

```elixir
iex> words = Arrays.new(["the", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"])
#Arrays.Implementations.MapArray<["the", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"]>
Expand Down
5 changes: 4 additions & 1 deletion lib/arrays.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ contents = quote do
#### Some common array operations:
Indexing is constant-time,
the full Access calls are supported,
and variants of many common functions known from `Enum`, but that keep the result an array, are available.
iex> words = Arrays.new(["the", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"])
##{@current_default_array}<["the", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"]>
iex> Arrays.size(words) # Runs in constant-time
Expand All @@ -37,7 +41,6 @@ contents = quote do
"fox"
iex> words = put_in(words[2], "purple") # All of `Access` is supported
##{@current_default_array}<["the", "quick", "purple", "fox", "jumps", "over", "the", "lazy", "dog"]>
iex> # Common operations are available without having to turn the array back into a list (as `Enum` functions would do):
iex> Arrays.map(words, &String.upcase/1) # Map a function, keep result an array
##{@current_default_array}<["THE", "QUICK", "PURPLE", "FOX", "JUMPS", "OVER", "THE", "LAZY", "DOG"]>
iex> lengths = Arrays.map(words, &String.length/1)
Expand Down

0 comments on commit 18af856

Please sign in to comment.