Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,31 @@
import strutils
const progUpper = staticRead("calendar_upper.txt")
proc transformed(s: string): string {.compileTime.} =
## Return a transformed version (which can compile) of a program in uppercase.
let upper = s.toLower() # Convert all to lowercase.
var inString = false # Text in string should be in uppercase…
var inBraces = false # … except if this is in an expression to interpolate.
for ch in upper:
case ch
of '"':
inString = not inString
of '{':
if inString: inBraces = true
of '}':
if inString: inBraces = false
of 'a'..'z':
if inString and not inBraces:
result.add(ch.toUpperAscii()) # Restore content of strings to uppercase.
continue
else:
discard
result.add(ch)
const prog = progUpper.transformed()
static: writeFile("calendar_transformed.nim", prog)
include "calendar_transformed.nim"

View file

@ -0,0 +1,38 @@
IMPORT TIMES
IMPORT STRFORMAT
PROC PRINTCALENDAR(YEAR, NCOLS: INT) =
VAR ROWS = 12 DIV NCOLS
VAR DATE = INITDATETIME(1, MJAN, YEAR, 0, 0, 0, UTC())
IF ROWS MOD NCOLS != 0:
INC ROWS
VAR OFFS = GETDAYOFWEEK(DATE.MONTHDAY, DATE.MONTH, DATE.YEAR).INT
VAR MONS: ARRAY[12, ARRAY[8, STRING]]
FOR M IN 0..11:
MONS[M][0] = &"{$DATE.MONTH:^21}"
MONS[M][1] = " SU MO TU WE TH FR SA"
VAR DIM = GETDAYSINMONTH(DATE.MONTH, DATE.YEAR)
FOR D IN 1..42:
VAR DAY = D > OFFS AND D <= OFFS + DIM
VAR STR = IF DAY: &" {D-OFFS:2}" ELSE: " "
MONS[M][2 + (D - 1) DIV 7] &= STR
OFFS = (OFFS + DIM) MOD 7
DATE = DATE + MONTHS(1)
VAR SNOOPYSTRING, YEARSTRING: STRING
FORMATVALUE(SNOOPYSTRING, "[SNOOPY PICTURE]", "^" & $(NCOLS * 24 + 4))
FORMATVALUE(YEARSTRING, $YEAR, "^" & $(NCOLS * 24 + 4))
ECHO SNOOPYSTRING, "\N" , YEARSTRING, "\N"
FOR R IN 0..<ROWS:
VAR S: ARRAY[8, STRING]
FOR C IN 0..<NCOLS:
IF R * NCOLS + C > 11:
BREAK
FOR I, LINE IN MONS[R * NCOLS + C]:
S[I] &= &" {LINE}"
FOR LINE IN S:
IF LINE == "":
BREAK
ECHO LINE
ECHO ""
PRINTCALENDAR(1969, 5)