The challenge there (hand-coding Cintcode) is that there isn’t a separate assembler for it (yet?) The compiler keeps it internally but it can generate the cintcode for checking… This is the output:
Did someone say APL? I’m just a novice and this is very clunky. Anyone know how to print the rows while iterating over the SEQ array without needing an explicit loop?
I programmed this in TOPS-20 APLSF, then ported to Dyalog to display the APL characters.
∇XMASTR[⎕]∇
[0] XMASTR WIDTH;SEQ;I
[1] ⍝ XMASTR - VINTAGE COMPUTING CHRISTMAS CHALLENGE 2021
[2] ⍝ PRINT XMAS TREE CENTERED FOR SCREEN OF <WIDTH>
[3] ⍝ 2021 DAVID MEYER <PAPA AT SDF.ORG>
[4] ⍝ SEQ - NUMBER OF STARS FOR EACH ROW OF TREE
[5] ⍝ I - CURRENT ROW INDEX
[6] SEQ←(¯1+2×⍳4),(¯1+4×⍳4),(¯1+6×⍳4),3,3
[7] I←1
[8] LOOP:→(I>⍴SEQ)/END
[9] ⍝ (⌊(W-N)÷2) IS NUMBER OF PREFIX SPACE CHARS TO CENTER
[10] ⍝ STRING OF <N> CHARS ON LINE OF <W> CHARS
[11] ((⌊(WIDTH-SEQ[I])÷2)⍴' '),SEQ[I]⍴'*'
[12] I←I+1
[13] →LOOP
[14] END:
XMASTR 80
*
***
*****
*******
***
*******
***********
***************
*****
***********
*****************
***********************
***
***
If ⎕ appears to the left of the ← symbol, it causes the result so far to be displayed. This may not be the result of evaluating the complete line as ⎕ can occur anywhere on the line. The data is output together with a newline (carriage return) character
I learned a few more tricks. Here’s a more APL-ish solution without a loop, though it uses a lot more memory, and I haven’t been able to get it to run on TOPS-20. (This was coded in Dyalog on my PC.)
It considers the display as an array of characters, and creates a series of arrays to store the display row and column of each cell, as well as the number of stars and the first and last columns of printed stars on each cell’s row. Finally, a map for printing stars is generated by comparing each cell’s column with the first and last star columns for the cell’s row.
And just to get this completely out of my system (!!!) some years ago when I was into Pi stuff, I wrote a CESIL interpreter in my RTB Basic - which would normally be somewhat boring however I added a ‘tree’ command in to it with some “lights” that could be “lit up” via a CESIL program…
REAL PROGRAMS ARE PUNCHED ON CARDS
What version of FORTRAN are you using?
How does modern FORTRAN handle program
data that come on punched cards after the FORTAN
SOURCE deck?
Ben.
NOTICES FORTRAN-20 ON TOPS-20 AFTER POSTING.
One of my first experiences of programming was at a Summer camp during Junior High in the late 1970s with FORTRAN on punch cards.Video terminals were for wimpy BASIC programmers.
Turns out encoding for the spaces and calculating the number of asterisks makes for slightly shorter code than vice versa. I’m sure I could write something truly incomprehensible in PostScript or Perl, but I don’t want to unleash the Old High Ones again …
split //,"LKJIKIGEJGDAKK" returns a list of characters: “L”, “K”, “J”, …
map{ord()-64} transforms the list from characters to integers based on their ASCII code (ord()) less 64: 12, 11, 10, …
map{" "x$_."*"x(25-2*$_)."\n"} converts those numbers (via the $_ default variable) into a string of that number of spaces, plus that-number-massaged-a-bit number of asterisks, plus a newline.
If I were a good Perl programmer, I’d make the source look like something related to the output. I’m merely a mediocre one, though.
Sadly, my attempt to paste the program written using Perl’s Acme::Bleach was foiled by Markdown. Let’s just say it works just like Wile E. Coyote might expect it would …