require 'strings'     NB. not needed for J801 (but harmless)
fix12=: rplc&('12am';'12midnight';'12pm';'12noon')L:0

Thanks,

-- 
Raul


On Thu, Apr 3, 2014 at 1:47 AM, Dan Abell <[email protected]> wrote:

> a pet peeve of mine ...
> the 'm' in am and pm stands for meridiem, from the Latin "mid-day",
> so
>   12am, 12 ante-meridiem, is either nonsensical
>   or refers to the preceding midnight
> similarly
>   12pm, 12 post-meridiem, is either nonsensical
>   or refers to the following midnight
> by using 12noon and 12midnight (or abbreviations thereof),
> one avoids the ambiguity
>
> unfortunately, as I'm still learning J, I have little clue
> how to modify any of the suggested solutions
>
> -Dan
>
> On 2 Apr 2014, at 18:07, Roger Hui wrote:
>
> >   (;:'am pm') ,~&.>/ ":&.>>:i.12
> > ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬────┬────┬────┐
> > │1am│2am│3am│4am│5am│6am│7am│8am│9am│10am│11am│12am│
> > ├───┼───┼───┼───┼───┼───┼───┼───┼───┼────┼────┼────┤
> > │1pm│2pm│3pm│4pm│5pm│6pm│7pm│8pm│9pm│10pm│11pm│12pm│
> > └───┴───┴───┴───┴───┴───┴───┴───┴───┴────┴────┴────┘
> >
> >
> >
> >
> >
> > On Wed, Apr 2, 2014 at 4:40 PM, Linda Alvord <[email protected]
> >wrote:
> >
> >> Now we can both wait for a virtuoso. Here's my first try which can
> >> probably
> >> be simplified a lot.
> >>
> >>
> >>     <"1 (":,.(>:i.12),>:i.12),.(12 2$'am'),12 2$'pm'
> >>
> >>
> -----T----T----T----T----T----T----T----T----T----T----T----T----T----T----T
> >> ----T----T----T----T----T----T----T----T----┐
> >> │ 1am│ 2am│ 3am│ 4am│ 5am│ 6am│ 7am│ 8am│ 9am│10am│11am│12am│ 1pm│ 2pm│
> >> 3pm│
> >> 4pm│ 5pm│ 6pm│ 7pm│ 8pm│ 9pm│10pm│11pm│12pm│
> >>
> >>
> L----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
> >> ----+----+----+----+----+----+----+----+-----
> >>
> >> Now we can both wait for a virtuoso.
> >>
> >> Linda
> >>
> >> -----Original Message-----
> >> From: [email protected]
> >> [mailto:[email protected]] On Behalf Of glts
> >> Sent: Wednesday, April 02, 2014 8:12 AM
> >> To: [email protected]
> >> Subject: Re: [Jprogramming] Pretty print hours of the 12-hour clock
> >>
> >> On Wed, Apr 2, 2014 at 12:59 PM, chris burke <[email protected]>
> wrote:
> >>> The argument i.24 to fmthours may be unnecessary.
> >>>
> >>>
> >>> In any case, you can generate all hours as:
> >>>
> >>>
> >>> allhours=: , (;:'am pm') (,~":) each/ _1|.1+i.12
> >>>
> >>>
> >>> Then fmthours is:
> >>>
> >>>
> >>> fmthours=: {&allhours
> >>>
> >>>
> >>> For example;
> >>>
> >>>
> >>>   fmthours 4
> >>>
> >>> +---+
> >>>
> >>> |4am|
> >>>
> >>> +---+
> >>>
> >>>   fmthours i.24
> >>>
> >>> +----+---+---+---+...
> >>>
> >>> |12am|1am|2am|3am|...
> >>>
> >>> +----+---+---+---+...
> >>
> >> Very nice and very instructive. It hadn't occurred to me to use 'each'
> >> on an unboxed argument, this will be useful in the future.
> >>
> >> And I had used this thing to obtain the hours:
> >>
> >>   hours=: 12&(|`[@.(0=|))"0
> >>   hours i.24
> >> 12 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11
> >>
> >> Incrementing and shifting is simpler and more elegant. Thanks!
> >>
> >>
> >> --
> >> David
> >> ----------------------------------------------------------------------
> >> For information about J forums see http://www.jsoftware.com/forums.htm
> >> ----------------------------------------------------------------------
> >> For information about J forums see http://www.jsoftware.com/forums.htm
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
>
> --
> Dan T. Abell :: dabell at txcorp dot com :: 303.444.2452
> Tech-X Corp., 5621 Arapahoe Ave, Ste A, Boulder CO 80303
> http://www.txcorp.com :: 303.748.6894/c  303.448.7756/fx
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to