Home > Archive > APL > June 2004 > Re: Does anyone have a APL calendar function that would be useful for a blogger?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: Does anyone have a APL calendar function that would be useful for a blogger?
|
|
|
| Thanks Brian. I don't know J but I'm impressed by its similar
conciseness with APL. The output is what I want and conversion of the
text to HTML with corresponding links for a blogger should be trivia.
It would be interesting to see how many lines of APL code it would
take to handle the same task. It's no doubt in my mind that I can now
avoid the PHP, javascript script languages most website host provide
their users.
It's now easier than ever to convert between APL dialects. Too bad
there's no easy way to pop your J code into a APL workspace that does
the same thing.
Still, with that said -- I'm not one to look a gift horse in the
mouth.
Thanks,
Harry
[color=darkred]
> Here's a calendar function that is distributed with J. No HTML, just
> plain text.
>
> NB. ========================================
=================
> NB.*calendar v calendar for year [months]
> NB. returns calendar for year, as a 12 element list
> NB.
> NB. argument is one or more numbers: year, months
> NB. If no months are given, it defaults to all months.
> NB.
> NB. example:
> NB. calendar 1998 5 6
> NB. +---------------------+---------------------+
> NB. | May | Jun |
> NB. | Su Mo Tu We Th Fr Sa| Su Mo Tu We Th Fr Sa|
> NB. | 1 2| 1 2 3 4 5 6|
> NB. | 3 4 5 6 7 8 9| 7 8 9 10 11 12 13|
> NB. | 10 11 12 13 14 15 16| 14 15 16 17 18 19 20|
> NB. | 17 18 19 20 21 22 23| 21 22 23 24 25 26 27|
> NB. | 24 25 26 27 28 29 30| 28 29 30 |
> NB. | 31 | |
> NB. +---------------------+---------------------+
>
> calendar=: 3 : 0
> y=. ((j<100)*(-100&|){.6!:0'')+j=. {.y.
> b=. y+-/<.4 100 400%~<:y
> r=. 28+3,(~:/0=4 100 400|y),10$5$3 2
> r=. ,(-7|b+0,+/\}:r)|."0 1 r(]&:>:*"1>/)i.42
> m=. m,(0=#m=. <:}.y.)#i.12
> h=. 'JanFebMarAprMayJunJulAugSepOctNovDec'
> h=. ' Su Mo Tu We Th Fr Sa',:"1~_3(_12&{.)\h
> <"2 m{h,"2[12 6 21$,>(<'') ((r=0)#i.#r)} <"1 [ 3":,.r
> )
>
>
> Harry wrote:
| |
|
| Are there any APL'ers who know J that would convert the few lines of
code below into APL. I ask because I don't have a way translate it?
Regards,
Harry
[color=darkred]
| |
|
| This problem has been solved.
Regards,
Harry
[color=darkred]
> Are there any APL'ers who know J that would convert the few lines of
> code below into APL. I ask because I don't have a way translate it?
>
> Regards,
> Harry
>
|
|
|
|
|