Igniter.Code.List (igniter v0.1.0)
Utilities for working with lists.
Summary
Functions
Appends quoted
to the list unless it is alread present, determined by equality_pred
.
Appends quoted
to the list
Finds the index of the first list item that satisfies pred
Returns true if the zipper
is at a list literal
Moves to the list item matching the given predicate
Prepends quoted
to the list unless it is alread present, determined by equality_pred
.
Prepends quoted
to the list
Removes the item at the given index, returning :error
if nothing is at that index
Types
equality_pred()
@type equality_pred() :: (Sourceror.Zipper.t(), Macro.t() -> boolean())
Functions
append_new_to_list(zipper, quoted, equality_pred \\ &Common.nodes_equal?/2)
@spec append_new_to_list(Sourceror.Zipper.t(), quoted :: Macro.t(), equality_pred()) :: {:ok, Sourceror.Zipper.t()} | :error
Appends quoted
to the list unless it is alread present, determined by equality_pred
.
append_to_list(zipper, quoted)
@spec append_to_list(Sourceror.Zipper.t(), quoted :: Macro.t()) :: {:ok, Sourceror.Zipper.t()} | :error
@spec append_to_list(Sourceror.Zipper.t(), quoted :: Macro.t()) :: {:ok, Sourceror.Zipper.t()} | :error
Appends quoted
to the list
find_list_item_index(zipper, pred)
@spec find_list_item_index(Sourceror.Zipper.t(), (Macro.t() -> boolean())) :: integer() | nil
Finds the index of the first list item that satisfies pred
list?(zipper)
@spec list?(Sourceror.Zipper.t()) :: boolean()
Returns true if the zipper
is at a list literal
move_to_list_item(zipper, pred)
@spec move_to_list_item(Sourceror.Zipper.t(), (Macro.t() -> boolean())) :: {:ok, Sourceror.Zipper.t()} | :error
Moves to the list item matching the given predicate
prepend_new_to_list(zipper, quoted, equality_pred \\ &Common.nodes_equal?/2)
@spec prepend_new_to_list(Sourceror.Zipper.t(), quoted :: Macro.t(), equality_pred()) :: {:ok, Sourceror.Zipper.t()} | :error
Prepends quoted
to the list unless it is alread present, determined by equality_pred
.
prepend_to_list(zipper, quoted)
@spec prepend_to_list(Sourceror.Zipper.t(), quoted :: Macro.t()) :: {:ok, Sourceror.Zipper.t()} | :error
Prepends quoted
to the list
remove_index(zipper, index)
Removes the item at the given index, returning :error
if nothing is at that index