scene.org File Archive

File download

<root>­/­parties­/­2023­/­vccc23­/­christmas-diamonds/paul7_ibm5110_apl_vc3-2023.zip

File size:
9 079 bytes (8.87K)
File date:
2024-01-03 14:15:18
Download count:
all-time: 38

Preview

  • paul7_ibm5110_apl_vc3-2023/file_id.diz.txt 2.98K
  • paul7_ibm5110_apl_vc3-2023/result.png 9.05K
  • paul7_ibm5110_apl_vc3-2023/source.png 6.37K
  • paul7_ibm5110_apl_vc3-2023/source.utf8.txt 33B

file_id.diz

Vintage Computing Christmas Challenge 2022: APL

Author:   paul7
Category: Christmas Challenge
System:   IBM 5110
Language: APL
Len source code: 23 bytes
Len exe file:    n/a
Len code only:   n/a
Instructions:
   The online IBM 5110 emulator can be found here: https://norbertkehrer.github.io/ibm_5110/emu5110.html
   To boot the emulator into APL mode press APL switch, then Restart switch.
   When the emulator displays CLEAR WS, you can enter the code.
   The safest bet to do so is to use the screen keyboard. 
   Note: ⌽ is Cmd+M. ∨ is Shift+9, NOT Shift+0 as the screen keyboard indicates.
   The code also should work in any modern APL (e.g. Dyalog). Just copy&paste and press enter.
   The 5110's screen size is too small to display the full result, so it scrolls. 
   The correctness of the program can be verified in a modern APL interpreter or by replacing first 19 in the program with a smaller number of rows.
Description:
   APL expressions are evaluated right to left.
   ⍝ This is a comment
   ⍝ Build a list of integers from 1 to 6:
      ⍳6
1 2 3 4 5 6
   ⍝ Element-wise compare to 4
      4=⍳6
0 0 0 1 0 0
   ⍝ Reshape to a 19x19 matrix, reusing the previous cyclically
      19 19⍴4=⍳6
0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0
0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0
0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0
1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1
   ⍝ .... <snipped for brevity>
   ⍝ Assign to a variable T, then mirror the matrix
      ⌽T←19 19⍴4=⍳6
0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0
0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0
0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0
1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1
   ⍝ .... <snipped for brevity>
   ⍝ Now that we have both kinds of diagonals, compute logical or to combine them
      T∨⌽T←19 19⍴4=⍳6
0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0
0 0 1 0 1 0 0 0 1 0 1 0 0 0 1 0 1 0 0
0 1 0 0 0 1 0 1 0 0 0 1 0 1 0 0 0 1 0
1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1
   ⍝ .... <snipped for brevity>
   ⍝ Add 1 to matrix
      1+T∨⌽T←19 19⍴4=⍳6
1 1 1 2 1 1 1 1 1 2 1 1 1 1 1 2 1 1 1
1 1 2 1 2 1 1 1 2 1 2 1 1 1 2 1 2 1 1
1 2 1 1 1 2 1 2 1 1 1 2 1 2 1 1 1 2 1
2 1 1 1 1 1 2 1 1 1 1 1 2 1 1 1 1 1 2
   ⍝ .... <snipped for brevity>
   ⍝ Finally, use the matrix as indices into character array (1-based, hence adding 1 on the previous step)
     ' *'[1+T∨⌽T←19 19⍴4=⍳6]
   *     *     *   
  * *   * *   * *  
 *   * *   * *   * 
*     *     *     *
 *   * *   * *   * 
  * *   * *   * *  
   *     *     *   
  * *   * *   * *  
 *   * *   * *   * 
*     *     *     *
 *   * *   * *   * 
  * *   * *   * *  
   *     *     *   
  * *   * *   * *  
 *   * *   * *   * 
*     *     *     *
 *   * *   * *   * 
  * *   * *   * *  
   *     *     *   
Comments:
   File source.utf8.txt included in the submission is 33 bytes due to encoding APL glyphs in Unicode. However IBM 5110 utilizes one-byte encoding for them, which is why I list state the source size as 23 bytes.' *'[1+T∨⌽T←19 19⍴4=⍳6]