The "calendar" verb from J's "stdlib" has an optional left argument that
allows you to specify the starting day of the week:
calendar=: 3 : 0
0 calendar y
:
a=. ((j<100)*(-100&|){.6!:0'')+j=. {.y
b=. (a-x)+-/<.4 100 400%~<:a
r=. 28+3,(~:/0=4 100 400|a),10$5$3 2
r=. (-7|b+0,+/\}:r)|."0 1 r(]&:>:*"1>/)i.42
m=. (<:}.y),i.12*1=#y
h=. 'JanFebMarAprMayJunJulAugSepOctNovDec'
h=. ((x*3)|.' Su Mo Tu We Th Fr Sa'),:"1~_3(_12&{.)\h
<"2 m{h,"2[12 6 21 ($,) r{' ',3":1+i.31 1
)
E.g.
calendar 2017 9
+---------------------+
| Sep |
| 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|
| |
+---------------------+
1 calendar 2017 9
+---------------------+
| Sep |
| Mo Tu We Th Fr Sa Su|
| 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 |
| |
+---------------------+
On Fri, Sep 29, 2017 at 11:28 PM, Jimmy Gauvin <[email protected]>
wrote:
> Is a two-step process too ugly?
>
> a
> =:6 7$ 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 1011
>
> 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0 0 0 0 0
> (a='_')}' ',:~a=: ":(a=0)}_,:~a
> 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
>
>
> On Thu, Sep 28, 2017 at 6:12 AM, Rudolf Sykora <[email protected]>
> wrote:
>
> > On 28 September 2017 at 01:09, Devon McCormick <[email protected]>
> wrote:
> > > Assuming a is a numeric matrix:
> > >
> > > a=. ":a
> > > (a='0')}a,:' '
> > > 1
> > > 2 3 4 5 6 7 8
> > > 9 1 11 12 13 14 15
> > > 16 17 18 19 2 21 22
> > > 23 24 25 26 27 28 29
> > > 3 31
> > >
> > >
> >
> > see the missing zero in 10, 20, 30; isolated zeros
> > were to be removed...
> >
> > Thanks anyway!
> > Ruda
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
Devon McCormick, CFA
Quantitative Consultant
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm