Module: Fr::TZipper
- Defined in:
- lib/fr/tzipper.rb,
lib/fr/tzipper/node.rb,
lib/fr/tzipper/path.rb,
lib/fr/tzipper/root_cursor.rb,
lib/fr/tzipper/edited_cursor.rb,
lib/fr/tzipper/abstract_cursor.rb,
lib/fr/tzipper/dangling_cursor.rb,
lib/fr/tzipper/memoized_cursor.rb
Defined Under Namespace
Classes: AbstractCursor, AbstractPath, DanglingCursor, EditedCursor, Hole, MemoizedCursor, Node, RootCursor
Constant Summary collapse
- Root =
Class.new(AbstractPath) do # @return self def parent self end # (see AbstractPath#left) def left [] end # (see AbstractPath#right) def right [] end # (see AbstractPath#last?) # @return true def last? true end # (see AbstractPath#first?) # @return true def first? true end # (see AbstractPath#depth) def depth 0 end def position nil end # @return [String] def inspect "root" end end.new
Class Method Summary collapse
-
.build(node) ⇒ AbstractCursor
Constructors a zipper for traversing the given tree or subtree.
Class Method Details
.build(node) ⇒ AbstractCursor
Constructors a zipper for traversing the given tree or subtree. The ‘node` value can be any structure where
node#children
an array of child nodes
node#leaf?
true if the node is not allowed have children
node#copy(children: [...])
creates a new node with the given children
node#cons(xs)
returns a new list [node, *xs]
33 34 35 |
# File 'lib/fr/tzipper.rb', line 33 def build(node) Fr::TZipper::RootCursor.new(node) end |