Search code examples
arraysmultilineread-eval-print-loopapldyalog

Multi-line inputs in RIDE (APL)?


I wish to type in a multi-line array as follows:

ast ← ('∘'
           ('a' ('p'))
           ('b' 
             ('q' ('v'))
             ('r'))
           ('c' 
             ('s' ('w' 'x'))
             ('t' ('y' 'z'))))

This is correctly paranthesized, but I am unable to copy-paste it into the Dyalog APL RIDE interface. I searched around, and found two answers both of which do not help me:

So, how does one type multiline data in APL?


Solution

  • The session doesn't currently support multi line arrays.

    For now, you still have to create multi dimensional arrays programmatically for the most part (although you can, for example, create an editable text matrix, fill it with "numbers" and then use ⍎¨)

    cmat←⍪''
    )ed cmat
    

    paste this

    0123
    2314
    1244
    

    then fix it (press Esc) and use

          ⍎¨cmat
    

    For me, I find Shift-Enter and Ctrl-Enter are my best friends most of the time

    It looks like you're trying to represent a tree as a nested array (look at dfns tview and tnest and other tree stuff for more on that). As such, it doesn't look like you really need multiline (all arrays in APL are hyperrectangular)?

    ast←('∘'('a' ('p'))('b'('q'('v'))('r'))('c'('s' ('w' 'x'))('t' ('y' 'z'))))
    

    Traditional functions (tradfns) can be copy and pasted readily, if they use the session input format:

         ∇ r ← larg Fun rarg
         r ← larg, rarg
         ∇
    

    Multi-line dfns can be pasted. First use the ]dinput user command.

          ]dinput
    

    then paste

          dfn ← {
       ⍺, ⍵
    }
    

    (btw, regarding from the previous comment, you can paste the multiline dfn and prepend with , but you have to put on the last line [n] and press enter for it to fix the function. The ]dinput user command is a bit simpler)