abrudz / aplcart

A novel approach to finding your way in APL
https://aplcart.info/
Other
133 stars 18 forks source link

Synonyms for converting text matrix to nested vector of character vectors #82

Closed rikedyp closed 3 years ago

rikedyp commented 3 years ago

Recently did a few searches

First I'll paste all the searches, followed by the actual expression I wanted. At the end is the session log

      ]aplcart matrix to character vector
      ]aplcart matrix to vector no spaces
      ]aplcart matrix to vector spaces
      ]aplcart mat to vector spaces
      ]aplcart mat vector spaces
      ]aplcart remove trailing spaces

{(+/∨\' '≠⌽⍵)↑¨↓⍵}Dm

      ]aplcart matrix to character vector
X,Y,Z:any M,N:num I,J:int A,B:Bool C,D:char f,g,h:fn ax:axis s:scal v:vec m:mat                                    
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
r←(⎕CSV⍠2)data                      Convert CSV data to APL inverted table (character data as vectors of vectors)  
r←data {header}(⎕CSV⍠2)format_spec  Convert CSV data from APL inverted table (character data as vectors of vectors)
⊂[1]Ym                              Convert table to inverted table (character data as vectors of vectors)         
(⍉↑)Yv                              Convert inverted table to table (character data as vectors of vectors)         
{⎕D[1+⍉10⊥⍣¯1⊢⍵]}Jv                 Zero-padded character matrix from vector of integers                           
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Showing 5 of 5 matches                                                                                             
      ]aplcart matrix to vector no spaces
X,Y,Z:any M,N:num I,J:int A,B:Bool C,D:char f,g,h:fn ax:axis s:scal v:vec m:mat
───────────────────────────────────────────────────────────────────────────────
───────────────────────────────────────────────────────────────────────────────
Showing 0 of 0 matches                                                         
      ]aplcart matrix to vector spaces
X,Y,Z:any M,N:num I,J:int A,B:Bool C,D:char f,g,h:fn ax:axis s:scal v:vec m:mat                                
───────────────────────────────────────────────────────────────────────────────────────────────────────────────
1∘(⌷{(⎕NS⍬)(⊣⊣⍎)⍕⍺'←⍵'}⍤1↓)Ym  Convert table (matrix with names in header row) into vector of record namespaces
{⍵(⊢⍪∘.⍎)(⊃⍵).⎕NL¯2}Yv         Convert vector of record namespaces into table (matrix with names in header row)
───────────────────────────────────────────────────────────────────────────────────────────────────────────────
Showing 2 of 2 matches                                                                                         
      ]aplcart mat to vector spaces
X,Y,Z:any M,N:num I,J:int A,B:Bool C,D:char f,g,h:fn ax:axis s:scal v:vec m:mat                                
───────────────────────────────────────────────────────────────────────────────────────────────────────────────
1∘(⌷{(⎕NS⍬)(⊣⊣⍎)⍕⍺'←⍵'}⍤1↓)Ym  Convert table (matrix with names in header row) into vector of record namespaces
{⍵(⊢⍪∘.⍎)(⊃⍵).⎕NL¯2}Yv         Convert vector of record namespaces into table (matrix with names in header row)
───────────────────────────────────────────────────────────────────────────────────────────────────────────────
Showing 2 of 2 matches                                                                                         
      ]aplcart mat vector spaces
X,Y,Z:any M,N:num I,J:int A,B:Bool C,D:char f,g,h:fn ax:axis s:scal v:vec m:mat                                
───────────────────────────────────────────────────────────────────────────────────────────────────────────────
1∘(⌷{(⎕NS⍬)(⊣⊣⍎)⍕⍺'←⍵'}⍤1↓)Ym  Convert table (matrix with names in header row) into vector of record namespaces
{⍵(⊢⍪∘.⍎)(⊃⍵).⎕NL¯2}Yv         Convert vector of record namespaces into table (matrix with names in header row)
───────────────────────────────────────────────────────────────────────────────────────────────────────────────
Showing 2 of 2 matches                                                                                         
      ]aplcart remove trailing spaces
X,Y,Z:any M,N:num I,J:int A,B:Bool C,D:char f,g,h:fn ax:axis s:scal v:vec m:mat                                                                
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
{⍵↓⍨-⊥⍨' '=⍵}Dv                      Remove trailing blanks                                                                                    
Xs(1↓,⊢⍤/⍨1(⊢∨⌽)0,≠)Yv               Remove leading, multiple and trailing Xs's                                                                
' '∘(1↓,⊢⍤/⍨1(⊢∨⌽)0,≠)Dv             Remove leading, trailing and duplicate blanks                                                             
(⍉∘↑{(+/∨\' '≠⌽⍵)↑¨↓⍵}¨@(2=≢∘⍴¨))Yv  Convert inverted table to table (character data as matrices; remove trailing spaces)                      
cvec←dfns.vtrim cvec                 Remove trailing blanks                                                                                    
rslt←{blank} dfns.deb argt           Drop Ending Blanks                                                                                        
rslt←{blank} dfns.dtb argt           Drop Trailing Blanks                                                                                      
{⍵/⍨2∨/0,⍨' '≠⍵}Dv                   Remove multiple and trailing blanks                                                                       
{(+/∨\' '≠⌽⍵)↑¨↓⍵}Dm                 Fast: A nested vector comprising simple character vectors constructed from the rows of Dm (which must be  
                                     of depth 1) with trailing blank spaces removed                                                            
{⍵/⍨(∨\∧∘⌽∨\∘⌽)' '≠⍵}Dv              Remove leading and trailing blanks                                                                        
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Showing 10 of 10 matches