Naming Conventions

Scalar

Vector

Matrix

Any
rank

Non-
scalar

Boolean

BS

BV

BM

BA

BN

Integer

IS

IV

IM

IA

IN

Float

FS

FV

FM

FA

FN

Numeric

NS

NV

NM

NA

NN

Character

CS

CV

CM

CA

CN

Enclosed
vector

ES

EV

EM

EA

EN

enclosed
Text vector

TS

TV

TM

TA

TN

Simple

SS

SV

SM

SA

SN

Any

AS

AV

AM

AA

AN

phrase e.g.: .X...Y. ⍝ X←BS; Y←IV

combinations: use ISV for Integer scalarvector

B3, I4 &c. to specify higher ranks.

Open full technical reference

PhraseBook/FindInMatrix

This phrase is searching a pattern in a matrix an return pairs of (row, column) in a vector for every hit.

      ⊂[⎕IO+1]⍉(⍴AM)⊤v/⍳⍴v←AV⍷,AM      

Examples

      ⎕FX ⍕2 1⍴'r←AM FindInMatrix AV;b' '  r←⊂[⎕IO+1]⍉(⍴AM)⊤v/⍳⍴v←AV⍷,AM'
      M←''
      M←M,⊂'January'  
      M←M,⊂'February' 
      M←M,⊂'March'    
      M←M,⊂'April'    
      M←M,⊂'May'      
      M←M,⊂'June'     
      M←M,⊂'July'     
      M←M,⊂'August'   
      M←M,⊂'September'
      M←M,⊂'October'  
      M←M,⊂'November' 
      M←M,⊂'December' 
      M←⊃M
      M FindInMatrix 'em'
 (8 4) (10 3) (11 3)
      M FindInMatrix'nuar'
 0 2 

Compatibility

Checked with: APLX, NARS2000

Test Cases

Show test cases

Test;M
 ⎕IO←0      ⍝ You may change this; however, zero IS the default in the Phrasebook
⍝⎕ML←3      ⍝ Enable this line in Dyalog APL if appropriate
  ⎕FX ⍕2 1⍴'r←AM FindInMatrix AV;b' 'r←↓⍉(⍴AM)⊤v/⍳⍴v←AV⍷,M'
  M←''
  M,←⊂'January'  
  M,←⊂'February' 
  M,←⊂'March'    
  M,←⊂'April'    
  M,←⊂'May'      
  M,←⊂'June'     
  M,←⊂'July'     
  M,←⊂'August'   
  M,←⊂'September'
  M,←⊂'October'  
  M,←⊂'November' 
  M,←⊂'December' 
  M←⊃M
⍝ ---- Start Test cases (do not delete this!)
 (,⊂0 2) ≡ M FindInMatrix'nuary'
 (,0) ≡ ⍴M FindInMatrix'nuaraAAA'

For details see the PhraseBook/TestCasesGuidelines.

Test my code, both Examples and Test Cases.

See also: ...

Mentor: KaiJaeger

Tags:


CategoryPhrasesAll

PhraseBook/FindInMatrix (last edited 2012-08-03 05:46:50 by KaiJaeger)