apldyalog

Dyalog APL: How to filter an array like filter() but more weakness


How to change the solution from the answer to the question Dyalog APL: How to filter an array like filter() To:

  1. it performed an incomplete match search
  2. ignoring the case

Original solution:

   tmpSymbolsT←(data←⎕JSON(HttpCommand.Get'api.binance.com/api/v3/exchangeInfo').Data).symbols
      tmpSymbols←{(⍵.status∊⊂'TRADING')⌿⍵}tmpSymbolsT
      tmpSymbols[1]
   #.[JSON object].[JSON object]

It's required to filter by: "adin", "trade", "ADIn", "ADING" instead of 'TRADING'


Solution

  • You can use ⎕S (search operator) to access PCRE and search for regular expressions. I think the following would do what you want - assuming index origin 1:

    tmpSymbols←tmpSymbolsT[1+'trade|adin|ading' ⎕S 2⍠'IC'1⊢tmpSymbolsT.status]
    

    The use of variant ('IC'1) to ignore case. More about Search and Replace at https://help.dyalog.com/latest/Content/Language/System%20Functions/r.htm.