Devon's latest suggestion is very clean and
attractive. I'll not let that discourage me from
posting what I came up with in the meantime, but I
suspect I'd prefer Devon's in practice.

Oleg Kobchenko posted, in reply to Raul:

> Also, ISO is positional,
>
>   (11 12 14 15 17 18){'2001-01-02T03:04:05Z-05:00'
030405
>
>   ".(11 12,14 15,:17
18){'2001-01-02T03:04:05Z-05:00'
3 4 5
>

As an extension to the approach of relying on
positional constants, I concocted the following:

   ISOdateAsText =: '2007-08-09T10:11:12Z-13:00'
   HMStext ISOdateAsText
101112
   HMSnum ISOdateAsText
10 11 12
   
   NB. Positional constants include:
   ISOpYear; ISOpMonth; ISOpDay; ISOpHour; ISOpMinute;
ISOpSecond
+-------+---+---+-----+-----+-----+
|0 1 2 3|5 6|8 9|11 12|14 15|17 18|
+-------+---+---+-----+-----+-----+
   NB. One method of defining these values is:
   (": ,(6 4 $
'ISOp'),.'Year','Month','Day','Hour','Minute
',:'Second') =: (i.4);(10$0 1) <;.2 (15 $ 1 1
0)#5+i.15
   
   NB. Main definitions:

   HMStext =: (ISOpHour,ISOpMinute,:ISOpSecond)&(,
@:{)
   HMSnum  =:
(ISOpHour,ISOpMinute,:ISOpSecond)&(".@:{)
   
   NB. The components may be used in any order, of
course.
   MDYtext =: (ISOpMonth; ISOpDay; ISOpYear)&(,@:{)
   
I'm not thinking that my technique for setting the six
positional constants counts as good style.  It just
happened to fit my fancy this evening.


       
____________________________________________________________________________________
Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.com/
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to