On Wed, Apr 2, 2014 at 12:59 PM, chris burke <cbu...@jsoftware.com> 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