bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] Novice question regarding APL


From: Juergen Sauermann
Subject: Re: [Bug-apl] Novice question regarding APL
Date: Wed, 19 Feb 2014 11:44:45 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130330 Thunderbird/17.0.5

Hi Thomas,

you can use ⎕INP like this:

TEXT←⎕INP 'END-OF-TEXT' ⍝ the subsequent lines until 'END-OF-TEXT'
1 1 1 0 0 0
1 0 0 0 0 0
0 1 0 0 0 0
1 1 1 1 1 1
0 0 0 1 0 0
0 0 0 0 1 0
'END-OF-TEXT'

MATRIX←⊃⍎¨TEXT

/// Jürgen


On 02/19/2014 07:28 AM, address@hidden wrote:
Hi Jürgen,

I  can now solve my first problems from the Project Euler with GNU APL.
I am very happy with that.

But I couldn't figure out how I can directly embed a matrix in a script file
(other than reshapping a huge single-line vector).

For instance, here is my solution in J programming language for problem n° 191 
(Project Euler) :

     matrix =: (". ;. _2) 0 : 0
       1 1 1 0 0 0
       1 0 0 0 0 0
       0 1 0 0 0 0
       1 1 1 1 1 1
       0 0 0 1 0 0
       0 0 0 0 1 0
     )
echo +/ (matrix&(+/ .*)) ^: 29 ] 1 1 0 1 0 0

Is there a way of including such a multiline matrix in a GNU APL script file?

Thank you very much,

best regards,





reply via email to

[Prev in Thread] Current Thread [Next in Thread]