Contents
Naming Conventions |
|||||
|
Scalar |
Vector |
Matrix |
Any |
Non- |
Boolean |
BS |
BV |
BM |
BA |
BN |
Integer |
IS |
IV |
IM |
IA |
IN |
Float |
FS |
FV |
FM |
FA |
FN |
Numeric |
NS |
NV |
NM |
NA |
NN |
Character |
CS |
CV |
CM |
CA |
CN |
Enclosed |
ES |
EV |
EM |
EA |
EN |
enclosed |
TS |
TV |
TM |
TA |
TN |
Simple |
SS |
SV |
SM |
SA |
SN |
Any |
AS |
AV |
AM |
AA |
AN |
phrase e.g.: .X...Y. ⍝ X←BS; Y←IV |
|||||
combinations: use ISV for Integer scalar∨vector |
|||||
B3, I4 &c. to specify higher ranks. |
|||||
Weekday
This phrase determines the week day of a date given as a three-item vector Y M D.
Week days start with 0 for Monday and therefore end with 6 for Sunday.
7|+/D((M-~⎕IO)⊃¯1 2 1 4 ¯1 2 4 0 3 5 1 3),⌊5 1.25×4 100⊤Y-3>M
Examples
⎕FX ⍕3 1⍴'r←Weekday IV;Y;D;M' '(Y M D)←IV' 'r←7|+/D((M-~⎕IO)⊃¯1 2 1 4 ¯1 2 4 0 3 5 1 3),⌊5 1.25×4 100⊤Y-3>M'
Weekday 1996 1 1
0
Weekday 2000 1 1
5
Weekday 2011 1 1
5Note that the algorithm does not care about the validity of the date given. For example, 2011 2 29 is an invalid date:
Weekday 2011 2 29
1
Weekday 2011 3 1
1
Compatibility
Checked with: APLX, Dyalog, NARS2000
Test Cases
Show test cases
Test my code, both Examples and Test Cases.
See also: ...
Mentor: KaiJaeger
Tags:
APL Wiki