apldyalog

What are the APL2 equivalents for QUAD VI, QUAD FI, and QUAD VFI?


I've been looking at APL code samples, and some of them use QUAD FI, QUAD VI and QUAD VFI. The first two are described in my textbooks (APL an interactive approach). When I try these in APL2, I get a VALUE ERROR.

Is there a equivalent in APL2?


Solution

  • While I think QUAD FI and QUAD VI are part of MicroAPL's APLX, APL2 (according to the available IBM APL2 manual) appears having no direct support for them.

    If you just need to find an implementation that can run your code samples, APLX as a discontinued APL2 compatible product can be download for free at http://www.dyalog.com/aplx.htm

    In plain APL2 you could simulate the behavior by split the input string at space, write your own checker for validness (to avoid arbitrary code been executed), and use (Execute) to get the value.

    A not so correct implementation of QUAD VI can be:

    ∇r←valide str
     ⍝ This doesn't test if ¯ sign occurs in the middle
     r←∧/str∊'¯0123456789.'
    ∇
    ∇r←VI str
    r←valide¨(' '≠str)⊂str
    ∇
        VI '100.32 $4 2,,3 0 12.2 ¯3 +2 -2'
    1 0 0 1 1 1 0 0
    

    With the QUAD VI in hand we can make QUAD FI by

    ∇r←FI str;mesh
    ⍝ again this is very crude on edge cases
    r←mesh\⍎¨(mesh←VI str)/(' '≠str)⊂str
    ∇
    

    (Note the above example won't work in Dyalog APL)

    Since the question has a dyalog tag, Dyalog APL has the QUAD VFI system function, which is simply a composition of the other two. So (⊃⊢⌿)∘⎕VFI is apparently equal to ⎕FI and (⊃⊣⌿)∘⎕VFI is equivalent to ⎕VI.