Skip to main content
added 403 characters in body
Source Link
marinus
  • 31.2k
  • 7
  • 71
  • 112

APL (22)

{⍵+.×⍨2 2⍴3 5 1}⍣⎕⍨2↑1

Explanation:

  • {...}⍣⎕⍨2↑1: read a number, and run the following function that many times, using [1,0] as the initial input.
    • 2 2⍴3 5 1: the matrix [[3,5],[1,3]]
    • ⍵+.×⍨: multiply the first number in ⍵ by 3, the second by 5, and sum them, this is the new first number; then multiply the first number in ⍵ by 1, the second by 3, and sum those, that is the new second number.

APL (22)

{⍵+.×⍨2 2⍴3 5 1}⍣⎕⍨2↑1

APL (22)

{⍵+.×⍨2 2⍴3 5 1}⍣⎕⍨2↑1

Explanation:

  • {...}⍣⎕⍨2↑1: read a number, and run the following function that many times, using [1,0] as the initial input.
    • 2 2⍴3 5 1: the matrix [[3,5],[1,3]]
    • ⍵+.×⍨: multiply the first number in ⍵ by 3, the second by 5, and sum them, this is the new first number; then multiply the first number in ⍵ by 1, the second by 3, and sum those, that is the new second number.
Source Link
marinus
  • 31.2k
  • 7
  • 71
  • 112

APL (22)

{⍵+.×⍨2 2⍴3 5 1}⍣⎕⍨2↑1