ArrayMac > Function display > TEST_rm_20170201_heapsort

     ∇ r←TEST_rm_20170201_heapsort;ckFnExists;unless;aOk;aEq;on;chkFeature;ckObExists;chkFeatureLine;tfuuN;tfuu;fThis;hFoo1;fHeapBuild;hFoo2;fHeapSort
[1]   ⍝∇ 20170201/20190207 ra⌈ --()-- test "rm_20170201_heapsort" 2015.0825                                                                           
[2]    test_start                                                                                                                                     
[3]    r←0                                                                                                                                            
[4]    unless←{(~⍵)/⍺}                                                                                                                                
[5]    aOk←#.Assert                                                                                                                                   
[6]    aEq←#.AssertEq                                                                                                                                 
[7]    on←{⍺ ⍵}                                                                                                                                       
[8]   ⍝⍝--------                                                                                                                                      
[9]    ckObExists←{(⍵ omrepl'missing "⍵"')AssertEq ⍺ on ⍬⍴⎕NC ⍵}                                                                                      
[10]   ckFnExists←3∘ckObExists                                                                                                                        
[11]   chkFeature←{⍺←0 ⋄ ('Requirement:',⍵)aEq 1 ⍺}                                                                                                   
[12]   chkFeatureLine←{⍺←0 ⋄ ⍺ chkFeature'⍝⍝--'{(¯1+(⍬⍴⍴⍺)+⍬⍴where ⍺⍷⍵)↓⍵}(1 atpars 2⌷[1]qSI'')FNline ⍵}                                              
[13]   ⍝⍝--                                                                                                                                           
[14]   tfuuN←'rm_20170201_heapsort'                                                                                                                   
[15]   :If 0                                                                                                                                          
[16]       :If ~ckFnExists{⍵}tfuuN                                                                                                                    
[17]           ⎕←APLPmtMFS tfuuN                                                                                                                      
[18]           ⎕←0 APLPmt ThisFN''                                                                                                                    
[19]           →XIT                                                                                                                                   
[20]       :EndIf                                                                                                                                     
[21]       tfuu←⍎tfuuN                                                                                                                                
[22]   :EndIf                                                                                                                                         
[23]   fThis←{({⍵,'.'if×⍬⍴⍴⍵}2↓⍕⎕THIS),⍵}                                                                                                             
[24]   ⍝⍝--                                                                                                                                           
[25]   :If 0                                                                                                                                          
[26]                                                                                                                                                  
[27]       hFoo1←{2⊃heapifyIter redu⍣≡⍺ ⍵}                                                                                                            
[28]       hFoo2←{shX list←⍵ ⋄ (shX-1)(2⊃1 heapifyIter(shX-1)on 1 shX(⌽amend)list)}                                                                   
[29]       fHeapBuild←{hFoo1 redu(⍳⌊(≢⍵)÷2),⊂(≢on⊢)⍵}                                                                                                 
[30]       fHeapSort←hFoo2{⍺⍺{i←1⊃⍵ ⋄ 2⊃(⍺⍺⍣i)⍵}fHeapBuild ⍵}                                                                                         
[31]                                                                                                                                                  
[32]   ⍝   →fail unless aEq(⍳9)on{hfoo2{i←1⊃⍵ ⋄ 2⊃(⍺⍺⍣i)⍵}fHeapBuild ⍵}9?9                                                                            
[33]       →fail unless aEq(⍳9)on fHeapSort 9?9                                                                                                       
[34]                                                                                                                                                  
[35]                                                                                                                                                  
[36]                                                                                                                                                  
[37]   :EndIf                                                                                                                                         
[38]   ⍝⍝--                                                                                                                                           
[39]   :If ~(dtIsBefore 6 FNymiudts fThis ThisFN'')chkFeature tfuuN omrepl'implement "⍵"'                                                             
[40]       ⎕←APLPmtMFS fThis'TEST_',tfuuN                                                                                                             
[41]       →XIT                                                                                                                                       
[42]   :EndIf                                                                                                                                         
[43]   r←1                                                                                                                                            
[44]   →XIT                                                                                                                                           
[45]  fail2:                                                                                                                                          
[46]   ⎕←APLPmtMFS tfuuN                                                                                                                              
[47]   ⎕←0 APLPmt ThisFN''                                                                                                                            
[48]   →XIT                                                                                                                                           
[49]  fail:                                                                                                                                           
[50]   ⎕←APLPmtMFS fThis ThisFN''                                                                                                                     
[51]  XIT: ⍝⍝-------                                                                                                                                  
[52]   test_complete                                                                                                                                  
     ∇                                                                                                                                                

Page served at: Wed, 08 Apr 2020 06:58:36 AST.