[Jprogramming] Pretty print hours of the 12-hour clock
glts
676c7473 at gmail.com
Thu Apr 3 10:49:11 UTC 2014
On Wed, Apr 2, 2014 at 11:12 AM, glts <676c7473 at gmail.com> wrote:
> fmthours i.24
> ┌────┬───┬───┬───┬───┬───┬───┬───┬───┬───┬────┬────┬────┬───┬───┬───┬───┬───┬───┬───┬───┬───┬────┬────┐
> │12am│1am│2am│3am│4am│5am│6am│7am│8am│9am│10am│11am│12pm│1pm│2pm│3pm│4pm│5pm│6pm│7pm│8pm│9pm│10pm│11pm│
> └────┴───┴───┴───┴───┴───┴───┴───┴───┴───┴────┴────┴────┴───┴───┴───┴───┴───┴───┴───┴───┴───┴────┴────┘
>
> Newbie here. With some effort I managed to squeeze the verb 'fmthours'
> into a single line, but the result wasn't too pretty. The edge cases
> (12am/pm) caused me the most trouble. How would a virtuos@ do it?
Thank you all very much for your answers.
Only now do I realise that my original problem description was rather
vague. So, for the record, what 'fmthours' achieves is pretty printing
integers in the interval [0, 23] as hours of the 12-hour clock.
schedule=: fmthours 8 10 12 19 22 23 0
schedule
┌───┬────┬────┬───┬────┬────┬────┐
│8am│10am│12pm│7pm│10pm│11pm│12am│
└───┴────┴────┴───┴────┴────┴────┘
--
David
More information about the Programming
mailing list