ListToCsv.Option (list_to_csv v1.1.1) View Source
ListToCsv.Option
contains types and utilities for option.
Link to this section Summary
Functions
Split list
3 part with respect orders
Returns list
duplicated n
times. And replace first :N
with current 1 base index.
Returns true
if keys
starts with the given prefix
list; otherwise returns
false
.
Link to this section Types
Specs
t() :: [ headers: [ListToCsv.Header.t()] | nil, keys: [ListToCsv.Key.many()], length: [{ListToCsv.Key.many(), integer()}] | nil ]
Link to this section Functions
Specs
Split list
3 part with respect orders
- 1st not matched with
fun
- 2nd matched with
fun
- 3rd not matched with
fun
Examples
iex> chunks([1, 2, 3, 3, 2, 1, 3, 2], &(&1 == 3))
{[1, 2], [3, 3], [2, 1, 3, 2]}
iex> chunks([3, 2, 3, 2, 1, 3, 2], &(&1 == 3))
{[], [3], [2, 3, 2, 1, 3, 2]}
iex> chunks([1, 2, 4, 5, 2], &(&1 == 3))
{[1, 2, 4, 5, 2], [], []}
Specs
do_expand({ListToCsv.Key.many(), integer()}, [ {ListToCsv.Header.t(), ListToCsv.Key.many()} | ListToCsv.Key.many() ]) :: [{ListToCsv.Header.t(), ListToCsv.Key.many()} | ListToCsv.Key.many()]
Specs
duplicate( [{ListToCsv.Header.t(), ListToCsv.Key.many()} | ListToCsv.Key.many()], integer() ) :: [{ListToCsv.Header.t(), ListToCsv.Key.many()} | ListToCsv.Key.many()]
Returns list
duplicated n
times. And replace first :N
with current 1 base index.
Examples
iex> duplicate([[:name, :N]], 2)
[[:name, 1], [:name, 2]]
iex> duplicate([{"name#", [:name, :N]}], 2)
[{"name1", [:name, 1]}, {"name2", [:name, 2]}]
iex> duplicate([[:name, :N, :item, :N]], 2)
[[:name, 1, :item, :N], [:name, 2, :item, :N]]
iex> duplicate([{"name#.item#", [:name, :N, :item, :N]}], 2)
[{"name1.item#", [:name, 1, :item, :N]}, {"name2.item#", [:name, 2, :item, :N]}]
Specs
expand(t()) :: [ {ListToCsv.Header.t(), ListToCsv.Key.many()} | ListToCsv.Key.many() ]
Specs
starts_with?( {ListToCsv.Header.t(), ListToCsv.Key.many()} | ListToCsv.Key.many(), [ListToCsv.Key.t()] ) :: boolean()
Returns true
if keys
starts with the given prefix
list; otherwise returns
false
.
Note that :N
can match with integer
.
Examples
iex> starts_with?(:name, [:item, :N])
false
iex> starts_with?({"name", :name}, [:item, :N])
false
iex> starts_with?([:item, :N, :name], [:item, :N])
true
iex> starts_with?({"item#.name", [:item, :N, :name]}, [:item, :N])
true
iex> starts_with?([:name], [:item, :N])
false
iex> starts_with?({"name", [:name]}, [:item, :N])
false
iex> starts_with?([:item, 1, :name, :N, :first], [:item, :N, :name, :N])
true
iex> starts_with?({"item1.name#.first", [:item, 1, :name, :N, :first]}, [:item, :N, :name, :N])
true
iex> starts_with?([:packages, :N, :name], [:item, :N])
false
iex> starts_with?({"package#.name", [:packages, :N, :name]}, [:item, :N])
false