Calendar - for "REAL" programmers: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
|||
Line 1,039: | Line 1,039: | ||
26 27 28 29 30 31 23 24 25 26 27 28 29 28 29 30 31 |
26 27 28 29 30 31 23 24 25 26 27 28 29 28 29 30 31 |
||
30 </pre> |
30 </pre> |
||
=={{header|GUISS}}== |
|||
In Graphical User Interface Support Script, we utilize applications that are already written. So for this task, we shall just display the calendar that sets the system clock. |
|||
<lang guiss>RIGHTCLICK:CLOCK,ADJUST DATE AND TIME,BUTTON:CANCEL</lang> |
|||
=={{header|Elena}}== |
=={{header|Elena}}== |
||
Line 1,733: | Line 1,727: | ||
30 |
30 |
||
</pre> |
</pre> |
||
=={{header|GUISS}}== |
|||
In Graphical User Interface Support Script, we utilize applications that are already written. So for this task, we shall just display the calendar that sets the system clock. |
|||
<lang guiss>RIGHTCLICK:CLOCK,ADJUST DATE AND TIME,BUTTON:CANCEL</lang> |
|||
=={{header|Icon}} and {{header|Unicon}}== |
=={{header|Icon}} and {{header|Unicon}}== |
||
Line 2,351: | Line 2,351: | ||
</pre> |
</pre> |
||
=={{header|M2000 Interpreter}}== |
=={{header|M2000 Interpreter}}== |
||
Console 132 characters by 43 lines. Six columns for months. |
Console 132 characters by 43 lines. Six columns for months. |
||
Line 2,548: | Line 2,549: | ||
`${E}${C}${H}${O} $PROGRAM | ${T}${R} A-Z ${A}-${Z} | ${P}${E}${R}${L}`;</lang> |
`${E}${C}${H}${O} $PROGRAM | ${T}${R} A-Z ${A}-${Z} | ${P}${E}${R}${L}`;</lang> |
||
Although, if we are abusing the backticks and other innocent programs, why not just: <lang Perl>$_=$ARGV[0]//1969;`\143\141\154 $_ >&2`</lang> |
Although, if we are abusing the backticks and other innocent programs, why not just: <lang Perl>$_=$ARGV[0]//1969;`\143\141\154 $_ >&2`</lang> |
||
=={{header|Perl 6}}== |
|||
Uppercase is no challenge, who needs letters at all? |
|||
[Requires the year to be supplied as a command-line argument, and Unixish <i>cal</i> command.] |
|||
<lang perl6>$_="\0".."~";< |
|||
115 97 121 32 34 91 73 78 83 69 82 84 32 83 78 79 79 80 89 32 72 69 82 69 93 34 |
|||
59 114 117 110 32 60 99 97 108 62 44 64 42 65 82 71 83 91 48 93 47 47 49 57 54 57 |
|||
>."$_[99]$_[104]$_[114]$_[115]"()."$_[69]$_[86]$_[65]$_[76]"()</lang> |
|||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
Line 2,623: | Line 2,616: | ||
REALPROGRAMMERSTHINKINUPPERCASEANDCHEATBYUSINGPRINT |
REALPROGRAMMERSTHINKINUPPERCASEANDCHEATBYUSINGPRINT |
||
; // MAGICAL SEMICOLON</lang> |
; // MAGICAL SEMICOLON</lang> |
||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |
||
The "CALENDAR.L" source file: |
The "CALENDAR.L" source file: |
||
Line 2,760: | Line 2,754: | ||
(CALENDAR 1969)) |
(CALENDAR 1969)) |
||
</lang> |
</lang> |
||
=={{header|Raku}}== |
|||
(formerly Perl 6) |
|||
Uppercase is no challenge, who needs letters at all? |
|||
[Requires the year to be supplied as a command-line argument, and Unixish <i>cal</i> command.] |
|||
<lang perl6>$_="\0".."~";< |
|||
115 97 121 32 34 91 73 78 83 69 82 84 32 83 78 79 79 80 89 32 72 69 82 69 93 34 |
|||
59 114 117 110 32 60 99 97 108 62 44 64 42 65 82 71 83 91 48 93 47 47 49 57 54 57 |
|||
>."$_[99]$_[104]$_[114]$_[115]"()."$_[69]$_[86]$_[65]$_[76]"()</lang> |
|||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
Line 4,160: | Line 4,163: | ||
</pre> |
</pre> |
||
=={{header|XLISP}}== |
|||
XLISP isn't case-sensitive, so in principle it would be possible just to reproduce the solution given in the "ordinary" Calendar task. But that program makes use of recursion, "fancy" data structures, long variable names, pretty-printy indentation, and a whole host of other features that I don't think REAL programmers like any better than they like lower case: so, instead, here is a version using only global variables and "<tt>DO</tt> loops like God meant them to be". |
|||
<lang lisp>(SETQ YR 1969) |
|||
(SETQ M #("JANUARY" "FEBRUARY" "MARCH" "APRIL" "MAY" "JUNE" "JULY" "AUGUST" "SEPTEMBER" "OCTOBER" "NOVEMBER" "DECEMBER")) |
|||
(SETQ ML #(31 28 31 30 31 30 31 31 30 31 30 31)) |
|||
(SETQ WD #("SU" "MO" "TU" "WE" "TH" "FR" "SA")) |
|||
(IF (AND (= (REM YR 4) 0) (OR (/= (REM YR 100) 0) (= (REM YR 400) 0))) (VECTOR-SET! ML 1 29)) |
|||
(SETQ D (REM (+ 1 (+ (* 5 (REM (- YR 1) 4)) (* 4 (REM (- YR 1) 100)) (* 6 (REM (- YR 1) 400)))) 7)) |
|||
(TERPRI) |
|||
(DO ((I 0 (+ I 1))) ((> I 60)) |
|||
(PRINC " ")) |
|||
(PRINC "SNOOPY CALENDAR ") |
|||
(PRINC YR) |
|||
(TERPRI) |
|||
(DO ((I 0 (+ I 1))) ((> I 11)) |
|||
(TERPRI) |
|||
(DO ((J 0 (+ J 1))) ((> J 65)) |
|||
(PRINC " ")) |
|||
(PRINC (VECTOR-REF M I)) |
|||
(TERPRI) |
|||
(PRINC " ") |
|||
(DO ((J 0 (+ J 1))) ((> J 6)) |
|||
(DO ((K 0 (+ K 1))) ((> K 14)) |
|||
(PRINC " ")) |
|||
(PRINC (VECTOR-REF WD J)) |
|||
(PRINC " ")) |
|||
(TERPRI) |
|||
(DO ((J 0 (+ J 1))) ((> J 6)) |
|||
(IF (< J D) (DO ((K 0 (+ K 1))) ((> K 18)) (PRINC " ")))) |
|||
(DO ((J 1 (+ J 1))) ((> J (VECTOR-REF ML I))) |
|||
(PRINC " ") |
|||
(IF (< J 10) (PRINC " ")) |
|||
(DO ((K 0 (+ K 1))) ((> K 14)) |
|||
(PRINC " ")) |
|||
(PRINC J) |
|||
(SETQ D (+ D 1)) |
|||
(IF (> D 6) (TERPRI)) |
|||
(IF (> D 6) (SETQ D 0))))</lang> |
|||
{{out}} |
|||
<pre> SNOOPY CALENDAR 1969 |
|||
JANUARY |
|||
SU MO TU WE TH FR SA |
|||
1 2 3 4 |
|||
5 6 7 8 9 10 11 |
|||
12 13 14 15 16 17 18 |
|||
19 20 21 22 23 24 25 |
|||
26 27 28 29 30 31 |
|||
FEBRUARY |
|||
SU MO TU WE TH FR SA |
|||
1 |
|||
2 3 4 5 6 7 8 |
|||
9 10 11 12 13 14 15 |
|||
16 17 18 19 20 21 22 |
|||
23 24 25 26 27 28 |
|||
MARCH |
|||
SU MO TU WE TH FR SA |
|||
1 |
|||
2 3 4 5 6 7 8 |
|||
9 10 11 12 13 14 15 |
|||
16 17 18 19 20 21 22 |
|||
23 24 25 26 27 28 29 |
|||
30 31 |
|||
APRIL |
|||
SU MO TU WE TH FR SA |
|||
1 2 3 4 5 |
|||
6 7 8 9 10 11 12 |
|||
13 14 15 16 17 18 19 |
|||
20 21 22 23 24 25 26 |
|||
27 28 29 30 |
|||
MAY |
|||
SU MO TU WE TH FR SA |
|||
1 2 3 |
|||
4 5 6 7 8 9 10 |
|||
11 12 13 14 15 16 17 |
|||
18 19 20 21 22 23 24 |
|||
25 26 27 28 29 30 31 |
|||
JUNE |
|||
SU MO TU WE TH FR SA |
|||
1 2 3 4 5 6 7 |
|||
8 9 10 11 12 13 14 |
|||
15 16 17 18 19 20 21 |
|||
22 23 24 25 26 27 28 |
|||
29 30 |
|||
JULY |
|||
SU MO TU WE TH FR SA |
|||
1 2 3 4 5 |
|||
6 7 8 9 10 11 12 |
|||
13 14 15 16 17 18 19 |
|||
20 21 22 23 24 25 26 |
|||
27 28 29 30 31 |
|||
AUGUST |
|||
SU MO TU WE TH FR SA |
|||
1 2 |
|||
3 4 5 6 7 8 9 |
|||
10 11 12 13 14 15 16 |
|||
17 18 19 20 21 22 23 |
|||
24 25 26 27 28 29 30 |
|||
31 |
|||
SEPTEMBER |
|||
SU MO TU WE TH FR SA |
|||
1 2 3 4 5 6 |
|||
7 8 9 10 11 12 13 |
|||
14 15 16 17 18 19 20 |
|||
21 22 23 24 25 26 27 |
|||
28 29 30 |
|||
OCTOBER |
|||
SU MO TU WE TH FR SA |
|||
1 2 3 4 |
|||
5 6 7 8 9 10 11 |
|||
12 13 14 15 16 17 18 |
|||
19 20 21 22 23 24 25 |
|||
26 27 28 29 30 31 |
|||
NOVEMBER |
|||
SU MO TU WE TH FR SA |
|||
1 |
|||
2 3 4 5 6 7 8 |
|||
9 10 11 12 13 14 15 |
|||
16 17 18 19 20 21 22 |
|||
23 24 25 26 27 28 29 |
|||
30 |
|||
DECEMBER |
|||
SU MO TU WE TH FR SA |
|||
1 2 3 4 5 6 |
|||
7 8 9 10 11 12 13 |
|||
14 15 16 17 18 19 20 |
|||
21 22 23 24 25 26 27 |
|||
28 29 30 31</pre> |
|||
=={{header|X86 Assembly}}== |
=={{header|X86 Assembly}}== |
||
Line 4,505: | Line 4,378: | ||
31 30 |
31 30 |
||
</pre> |
</pre> |
||
=={{header|XLISP}}== |
|||
XLISP isn't case-sensitive, so in principle it would be possible just to reproduce the solution given in the "ordinary" Calendar task. But that program makes use of recursion, "fancy" data structures, long variable names, pretty-printy indentation, and a whole host of other features that I don't think REAL programmers like any better than they like lower case: so, instead, here is a version using only global variables and "<tt>DO</tt> loops like God meant them to be". |
|||
<lang lisp>(SETQ YR 1969) |
|||
(SETQ M #("JANUARY" "FEBRUARY" "MARCH" "APRIL" "MAY" "JUNE" "JULY" "AUGUST" "SEPTEMBER" "OCTOBER" "NOVEMBER" "DECEMBER")) |
|||
(SETQ ML #(31 28 31 30 31 30 31 31 30 31 30 31)) |
|||
(SETQ WD #("SU" "MO" "TU" "WE" "TH" "FR" "SA")) |
|||
(IF (AND (= (REM YR 4) 0) (OR (/= (REM YR 100) 0) (= (REM YR 400) 0))) (VECTOR-SET! ML 1 29)) |
|||
(SETQ D (REM (+ 1 (+ (* 5 (REM (- YR 1) 4)) (* 4 (REM (- YR 1) 100)) (* 6 (REM (- YR 1) 400)))) 7)) |
|||
(TERPRI) |
|||
(DO ((I 0 (+ I 1))) ((> I 60)) |
|||
(PRINC " ")) |
|||
(PRINC "SNOOPY CALENDAR ") |
|||
(PRINC YR) |
|||
(TERPRI) |
|||
(DO ((I 0 (+ I 1))) ((> I 11)) |
|||
(TERPRI) |
|||
(DO ((J 0 (+ J 1))) ((> J 65)) |
|||
(PRINC " ")) |
|||
(PRINC (VECTOR-REF M I)) |
|||
(TERPRI) |
|||
(PRINC " ") |
|||
(DO ((J 0 (+ J 1))) ((> J 6)) |
|||
(DO ((K 0 (+ K 1))) ((> K 14)) |
|||
(PRINC " ")) |
|||
(PRINC (VECTOR-REF WD J)) |
|||
(PRINC " ")) |
|||
(TERPRI) |
|||
(DO ((J 0 (+ J 1))) ((> J 6)) |
|||
(IF (< J D) (DO ((K 0 (+ K 1))) ((> K 18)) (PRINC " ")))) |
|||
(DO ((J 1 (+ J 1))) ((> J (VECTOR-REF ML I))) |
|||
(PRINC " ") |
|||
(IF (< J 10) (PRINC " ")) |
|||
(DO ((K 0 (+ K 1))) ((> K 14)) |
|||
(PRINC " ")) |
|||
(PRINC J) |
|||
(SETQ D (+ D 1)) |
|||
(IF (> D 6) (TERPRI)) |
|||
(IF (> D 6) (SETQ D 0))))</lang> |
|||
{{out}} |
|||
<pre> SNOOPY CALENDAR 1969 |
|||
JANUARY |
|||
SU MO TU WE TH FR SA |
|||
1 2 3 4 |
|||
5 6 7 8 9 10 11 |
|||
12 13 14 15 16 17 18 |
|||
19 20 21 22 23 24 25 |
|||
26 27 28 29 30 31 |
|||
FEBRUARY |
|||
SU MO TU WE TH FR SA |
|||
1 |
|||
2 3 4 5 6 7 8 |
|||
9 10 11 12 13 14 15 |
|||
16 17 18 19 20 21 22 |
|||
23 24 25 26 27 28 |
|||
MARCH |
|||
SU MO TU WE TH FR SA |
|||
1 |
|||
2 3 4 5 6 7 8 |
|||
9 10 11 12 13 14 15 |
|||
16 17 18 19 20 21 22 |
|||
23 24 25 26 27 28 29 |
|||
30 31 |
|||
APRIL |
|||
SU MO TU WE TH FR SA |
|||
1 2 3 4 5 |
|||
6 7 8 9 10 11 12 |
|||
13 14 15 16 17 18 19 |
|||
20 21 22 23 24 25 26 |
|||
27 28 29 30 |
|||
MAY |
|||
SU MO TU WE TH FR SA |
|||
1 2 3 |
|||
4 5 6 7 8 9 10 |
|||
11 12 13 14 15 16 17 |
|||
18 19 20 21 22 23 24 |
|||
25 26 27 28 29 30 31 |
|||
JUNE |
|||
SU MO TU WE TH FR SA |
|||
1 2 3 4 5 6 7 |
|||
8 9 10 11 12 13 14 |
|||
15 16 17 18 19 20 21 |
|||
22 23 24 25 26 27 28 |
|||
29 30 |
|||
JULY |
|||
SU MO TU WE TH FR SA |
|||
1 2 3 4 5 |
|||
6 7 8 9 10 11 12 |
|||
13 14 15 16 17 18 19 |
|||
20 21 22 23 24 25 26 |
|||
27 28 29 30 31 |
|||
AUGUST |
|||
SU MO TU WE TH FR SA |
|||
1 2 |
|||
3 4 5 6 7 8 9 |
|||
10 11 12 13 14 15 16 |
|||
17 18 19 20 21 22 23 |
|||
24 25 26 27 28 29 30 |
|||
31 |
|||
SEPTEMBER |
|||
SU MO TU WE TH FR SA |
|||
1 2 3 4 5 6 |
|||
7 8 9 10 11 12 13 |
|||
14 15 16 17 18 19 20 |
|||
21 22 23 24 25 26 27 |
|||
28 29 30 |
|||
OCTOBER |
|||
SU MO TU WE TH FR SA |
|||
1 2 3 4 |
|||
5 6 7 8 9 10 11 |
|||
12 13 14 15 16 17 18 |
|||
19 20 21 22 23 24 25 |
|||
26 27 28 29 30 31 |
|||
NOVEMBER |
|||
SU MO TU WE TH FR SA |
|||
1 |
|||
2 3 4 5 6 7 8 |
|||
9 10 11 12 13 14 15 |
|||
16 17 18 19 20 21 22 |
|||
23 24 25 26 27 28 29 |
|||
30 |
|||
DECEMBER |
|||
SU MO TU WE TH FR SA |
|||
1 2 3 4 5 6 |
|||
7 8 9 10 11 12 13 |
|||
14 15 16 17 18 19 20 |
|||
21 22 23 24 25 26 27 |
|||
28 29 30 31</pre> |
|||
=={{header|zkl}}== |
=={{header|zkl}}== |