September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
4
Task/Tree-traversal/APL/tree-traversal-1.apl
Normal file
4
Task/Tree-traversal/APL/tree-traversal-1.apl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
preorder ← {l r←⍺ ⍵⍵ ⍵ ⋄ (⊃r)∇⍨⍣(×≢r)⊢(⊃l)∇⍨⍣(×≢l)⊢⍺ ⍺⍺ ⍵}
|
||||
inorder ← {l r←⍺ ⍵⍵ ⍵ ⋄ (⊃r)∇⍨⍣(×≢r)⊢⍵ ⍺⍺⍨(⊃l)∇⍨⍣(×≢l)⊢⍺}
|
||||
postorder← {l r←⍺ ⍵⍵ ⍵ ⋄ ⍵ ⍺⍺⍨(⊃r)∇⍨⍣(×≢r)⊢(⊃l)∇⍨⍣(×≢l)⊢⍺}
|
||||
lvlorder ← {0=⍴⍵:⍺ ⋄ (⊃⍺⍺⍨/(⌽⍵),⊂⍺)∇⊃∘(,/)⍣2⊢⍺∘⍵⍵¨⍵}
|
||||
3
Task/Tree-traversal/APL/tree-traversal-2.apl
Normal file
3
Task/Tree-traversal/APL/tree-traversal-2.apl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
tree←1(2(4(7⍬⍬)⍬)(5⍬⍬))(3(6(8⍬⍬)(9⍬⍬))⍬)
|
||||
visit←{⍺,(×≢⍵)⍴⊃⍵}
|
||||
children←{⊂¨@(×∘≢¨)1↓⍵}
|
||||
Loading…
Add table
Add a link
Reference in a new issue