Hoon101/201/week6/lib/dfs.hoon

25 lines
282 B
Plaintext

:: depth first library
::
|%
++ traverse
|= t=(tree @)
^- (list @)
?~ t
~
%+ weld
(traverse l.t)
%+ weld
(traverse r.t)
[n.t ~]
++ search
|= [t=(tree @) x=@]
^- ?
?~ t
%.n
?| (search l.t x)
(search r.t x)
=(n.t x)
==
--