Naming Conventions

Scalar

Vector

Matrix

Any
rank

Non-
scalar

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
vector

ES

EV

EM

EA

EN

enclosed
Text vector

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 scalarvector

B3, I4 &c. to specify higher ranks.

Open full technical reference

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
5

Note 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
 ⎕IO←0      ⍝ You may change this; however, zero IS the default in the Phrasebook
  ⎕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' 
⍝ ---- Start Test cases (do not delete this!)
 0 ≡ Weekday 1996 1 1
 4 ≡ Weekday 1999 1 1
 5 ≡ Weekday 2000 1 1
 2 ≡ Weekday 2003 1 1
 1 ≡ Weekday 2008 1 1
(365⍴5 6 0 1 2 3 4)≡Weekday¨↓2011,⊃⊃,/(,¨1+⍳12),¨¨1+¨⍳¨31 28 31 30 31 30 31 31 30 31 30 31

For details see the PhraseBook/TestCasesGuidelines.

Test my code, both Examples and Test Cases.

See also: ...

Mentor: KaiJaeger

Tags:


CategoryPhrasesAll CategoryPhraseDates

PhraseBook/Weekday (last edited 2011-12-26 10:33:27 by KaiJaeger)