diff options
author | Eduardo Julian | 2017-11-29 04:51:04 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-11-29 04:51:04 -0400 |
commit | 8c5cca122817bc63f4f84cc8351ced3cb67e5eea (patch) | |
tree | 8803dd3ed59ddcc6b964354fd312ab9e62e12cd8 /stdlib/source/lux/data/coll/tree/zipper.lux | |
parent | 1ef969c8ce0f1a83ffa8d26d779806190ac3eced (diff) |
- Changed the identifier separator, from the semi-colon (;) to the period/dot (.).
Diffstat (limited to 'stdlib/source/lux/data/coll/tree/zipper.lux')
-rw-r--r-- | stdlib/source/lux/data/coll/tree/zipper.lux | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/stdlib/source/lux/data/coll/tree/zipper.lux b/stdlib/source/lux/data/coll/tree/zipper.lux index e355f7238..421c10fe9 100644 --- a/stdlib/source/lux/data/coll/tree/zipper.lux +++ b/stdlib/source/lux/data/coll/tree/zipper.lux @@ -1,4 +1,4 @@ -(;module: +(.module: lux (lux (control functor comonad) @@ -14,7 +14,7 @@ ## [Types] (type: #export (Zipper a) - {#;doc "Tree zippers, for easy navigation and editing over trees."} + {#.doc "Tree zippers, for easy navigation and editing over trees."} {#parent (Maybe (Zipper a)) #lefts (Stack (Tree a)) #rights (Stack (Tree a)) @@ -23,9 +23,9 @@ ## [Values] (def: #export (zip tree) (All [a] (-> (Tree a) (Zipper a))) - {#parent #;None - #lefts stack;empty - #rights stack;empty + {#parent #.None + #lefts stack.empty + #rights stack.empty #node tree}) (def: #export (unzip zipper) @@ -34,15 +34,15 @@ (def: #export (value zipper) (All [a] (-> (Zipper a) a)) - (|> zipper (get@ [#node #rose;value]))) + (|> zipper (get@ [#node #rose.value]))) (def: #export (children zipper) (All [a] (-> (Zipper a) (List (Tree a)))) - (|> zipper (get@ [#node #rose;children]))) + (|> zipper (get@ [#node #rose.children]))) (def: #export (branch? zipper) (All [a] (-> (Zipper a) Bool)) - (|> zipper children list;empty? not)) + (|> zipper children list.empty? not)) (def: #export (leaf? zipper) (All [a] (-> (Zipper a) Bool)) @@ -50,13 +50,13 @@ (def: #export (end? zipper) (All [a] (-> (Zipper a) Bool)) - (and (list;empty? (get@ #rights zipper)) - (list;empty? (children zipper)))) + (and (list.empty? (get@ #rights zipper)) + (list.empty? (children zipper)))) (def: #export (root? zipper) (All [a] (-> (Zipper a) Bool)) (case (get@ #parent zipper) - #;None + #.None true _ @@ -65,27 +65,27 @@ (def: #export (down zipper) (All [a] (-> (Zipper a) (Zipper a))) (case (children zipper) - #;Nil + #.Nil zipper - (#;Cons chead ctail) - {#parent (#;Some zipper) - #lefts stack;empty + (#.Cons chead ctail) + {#parent (#.Some zipper) + #lefts stack.empty #rights ctail #node chead})) (def: #export (up zipper) (All [a] (-> (Zipper a) (Zipper a))) (case (get@ #parent zipper) - #;None + #.None zipper - (#;Some parent) + (#.Some parent) (|> parent (update@ #node (: (-> (Tree ($ +0)) (Tree ($ +0))) (function [node] - (set@ #rose;children (L/compose (list;reverse (get@ #lefts zipper)) - (#;Cons (get@ #node zipper) + (set@ #rose.children (L/compose (list.reverse (get@ #lefts zipper)) + (#.Cons (get@ #node zipper) (get@ #rights zipper))) node))))))) @@ -93,20 +93,20 @@ (All [a] (-> (Zipper a) (Zipper a))) (loop [zipper zipper] (case (get@ #parent zipper) - #;None zipper - (#;Some _) (recur (up zipper))))) + #.None zipper + (#.Some _) (recur (up zipper))))) (do-template [<one-name> <all-name> <side> <op-side>] [(def: #export (<one-name> zipper) (All [a] (-> (Zipper a) (Zipper a))) (case (get@ <side> zipper) - #;Nil + #.Nil zipper - (#;Cons next side') + (#.Cons next side') (|> zipper (update@ <op-side> (function [op-side] - (#;Cons (get@ #node zipper) op-side))) + (#.Cons (get@ #node zipper) op-side))) (set@ <side> side') (set@ #node next)))) @@ -122,7 +122,7 @@ [(def: #export (<name> zipper) (All [a] (-> (Zipper a) (Zipper a))) (case (get@ <h-side> zipper) - #;Nil + #.Nil (<v-op> zipper) _ @@ -134,44 +134,44 @@ (def: #export (set value zipper) (All [a] (-> a (Zipper a) (Zipper a))) - (set@ [#node #rose;value] value zipper)) + (set@ [#node #rose.value] value zipper)) (def: #export (update f zipper) (All [a] (-> (-> a a) (Zipper a) (Zipper a))) - (update@ [#node #rose;value] f zipper)) + (update@ [#node #rose.value] f zipper)) (def: #export (prepend-child value zipper) (All [a] (-> a (Zipper a) (Zipper a))) - (update@ [#node #rose;children] + (update@ [#node #rose.children] (function [children] (list& (: (Tree ($ +0)) - (rose;tree [value {}])) + (rose.tree [value {}])) children)) zipper)) (def: #export (append-child value zipper) (All [a] (-> a (Zipper a) (Zipper a))) - (update@ [#node #rose;children] + (update@ [#node #rose.children] (function [children] (L/compose children (list (: (Tree ($ +0)) - (rose;tree [value {}]))))) + (rose.tree [value {}]))))) zipper)) (def: #export (remove zipper) (All [a] (-> (Zipper a) (Maybe (Zipper a)))) (case (get@ #lefts zipper) - #;Nil + #.Nil (case (get@ #parent zipper) - #;None - #;None + #.None + #.None - (#;Some next) - (#;Some (|> next - (update@ [#node #rose;children] (|>> list;tail (maybe;default (list))))))) + (#.Some next) + (#.Some (|> next + (update@ [#node #rose.children] (|>> list.tail (maybe.default (list))))))) - (#;Cons next side) - (#;Some (|> zipper + (#.Cons next side) + (#.Some (|> zipper (set@ #lefts side) (set@ #node next))))) @@ -179,14 +179,14 @@ [(def: #export (<name> value zipper) (All [a] (-> a (Zipper a) (Maybe (Zipper a)))) (case (get@ #parent zipper) - #;None - #;None + #.None + #.None _ - (#;Some (|> zipper + (#.Some (|> zipper (update@ <side> (function [side] - (#;Cons (: (Tree ($ +0)) - (rose;tree [value {}])) + (#.Cons (: (Tree ($ +0)) + (rose.tree [value {}])) side)))))))] [insert-left #lefts] @@ -203,13 +203,13 @@ ## (struct: #export _ (CoMonad Zipper) ## (def: functor Functor<Zipper>) -## (def: unwrap (get@ [#node #rose;value])) +## (def: unwrap (get@ [#node #rose.value])) ## (def: (split wa) ## (let [tree-splitter (function tree-splitter [tree] -## {#rose;value (zip tree) -## #rose;children (L/map tree-splitter -## (get@ #rose;children tree))})] +## {#rose.value (zip tree) +## #rose.children (L/map tree-splitter +## (get@ #rose.children tree))})] ## {#parent (|> wa (get@ #parent) (M/map split)) ## #lefts (|> wa (get@ #lefts) (L/map tree-splitter)) ## #rights (|> wa (get@ #rights) (L/map tree-splitter)) |