s/sfc/gsc/g
'
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
-module(sfc_ntree).
|
||||
|
||||
-export([
|
||||
nstem/2, meta/1, kids/1,
|
||||
flatten_tree/1, flatten_forest/1
|
||||
]).
|
||||
|
||||
|
||||
-include("$sfc_include/sfc.hrl").
|
||||
|
||||
|
||||
%%=====================================================
|
||||
%% API: functions
|
||||
%%=====================================================
|
||||
|
||||
-spec nstem(Root, Forest) -> Tree when
|
||||
Root :: S,
|
||||
Forest :: nforest(S, L),
|
||||
Tree :: ntree(S, L),
|
||||
S :: any(),
|
||||
L :: any().
|
||||
|
||||
nstem(Root, List) ->
|
||||
{ns, Root, List}.
|
||||
|
||||
|
||||
meta(#ns{meta = M}) -> M.
|
||||
kids(#ns{kids = K}) -> K.
|
||||
|
||||
|
||||
|
||||
-spec flatten_tree(Tree) -> Leafs when
|
||||
Tree :: ntree(_, L),
|
||||
Leafs :: [L],
|
||||
L :: any().
|
||||
|
||||
flatten_tree(T) ->
|
||||
lists:flatten(ft(T)).
|
||||
|
||||
|
||||
|
||||
-spec flatten_forest(Forest) -> Leafs when
|
||||
Forest :: nforest(_, L),
|
||||
Leafs :: [L],
|
||||
L :: any().
|
||||
|
||||
flatten_forest(F) ->
|
||||
lists:flatten(ff(F)).
|
||||
|
||||
|
||||
ft(#ns{kids = F}) -> ff(F);
|
||||
ft(Leaf) -> [Leaf].
|
||||
|
||||
ff(F) ->
|
||||
[ft(T) || T <- F].
|
||||
Reference in New Issue
Block a user