User Tools

Site Tools


hourlist

**This is an old revision of the document!**

Don Park 3:15pm feeling tricky by listing all hours in a day with this ruby:

["am","pm"].map{|m| (["12"]+1.upto(11).to_a).map{|h| "#{h} #{m}"}}.flatten

RobotAdam 2:53pm @donpdonp That's fun. A Python variation:

itertools.chain(*(("%d %s" % (h, t) for h in [12] + range(1, 12)) for t in ('am', 'pm')))  

@selenamarie 3:10pm @donpdonp @robotadam hmmm…

for my $meridiem (qw/am pm/) { print map { $_ . $meridiem . ' '} (12,1..11); }

@MarkusQ 4:22pm: @donpdonp If you'd like to feel even trickier:

(0..23).map { |h| "#{((h-1) % 12)+1} #{%w{A P}[h/12]}M" }  
hourlist.1249345085.txt.gz · Last modified: 2024/01/31 04:08 (external edit)