2

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?

Adám
  • 6,573
  • 20
  • 37
Siddharth Bhat
  • 823
  • 5
  • 15

2 Answers2

2

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)

RikedyP
  • 632
  • 4
  • 8
2

In addition to Richard Park's excellent answer, it should be noted that Dyalog is working on multi-line arrays on two fronts:

Designing a new multi-line array notation

  • The newest edition was presented in 2018

  • ⎕SE.Link.Serialise can create multi-line notation from most any array

  • ⎕SE.Link.Deserialise will return the array specified by its argument notation array

Multi-line session input

  • Version 18.0 (due summer 2020) includes experimental multi-line session support. It has to be enabled with a configuration parameter.

  • It will detect unfinished dfns (e.g. MyFn←{ and 4{) and control structures (e.g. :If myVar>5 and :Class MyCl) but not array notation.

  • 18.0 will also contain a tool, ⎕SE.Link.Array which allows wrapping multi-line array notation in a dfn:

{
 [1 2 3
  4 5 6]
}⎕SE.Link.Array⍬
Adám
  • 6,573
  • 20
  • 37