User Tools

Site Tools


hourlist

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
hourlist [2009/08/04 00:24] 64.122.198.69hourlist [2009/08/04 22:50] 64.122.198.69
Line 1: Line 1:
-Don Park 3:15pm feeling tricky by listing all hours in a day with this ruby: +3-Aug-2009  
 + 
 +Don Park 2:45pm feeling tricky by listing all hours in a day with this ruby: 
 <code ruby> <code ruby>
 irb(main):001:0> ["am","pm"].map{|m| (["12"]+1.upto(11).to_a).map{|h| "#{h} #{m}"}}.flatten irb(main):001:0> ["am","pm"].map{|m| (["12"]+1.upto(11).to_a).map{|h| "#{h} #{m}"}}.flatten
Line 20: Line 22:
 @MarkusQ 4:22pm: @donpdonp If you'd like to feel even trickier:  @MarkusQ 4:22pm: @donpdonp If you'd like to feel even trickier: 
 <code ruby> <code ruby>
-(0..23).map { |h| "#{((h-1) % 12)+1} #{%w{A P}[h/12]}M" }  +irb(main):001:0> (0..23).map { |h| "#{((h-1) % 12)+1} #{%w{A P}[h/12]}M" }  
 => ["12 AM", "1 AM", "2 AM", "3 AM", "4 AM", "5 AM", "6 AM", "7 AM", "8 AM", "9 AM", "10 AM", "11 AM", "12 PM", "1 PM", "2 PM", "3 PM", "4 PM", "5 PM", "6 PM", "7 PM", "8 PM", "9 PM", "10 PM", "11 PM"] => ["12 AM", "1 AM", "2 AM", "3 AM", "4 AM", "5 AM", "6 AM", "7 AM", "8 AM", "9 AM", "10 AM", "11 AM", "12 PM", "1 PM", "2 PM", "3 PM", "4 PM", "5 PM", "6 PM", "7 PM", "8 PM", "9 PM", "10 PM", "11 PM"]
 </code> </code>
  
-@skaldef 4:26pm: @selenamarie @donpdonp @robotadam Haskell: +@kscaldef 4:26pm: @selenamarie @donpdonp @robotadam Haskell: 
 <code haskell> <code haskell>
 Prelude> [ show h ++ " " ++ m | m<- ["am", "pm"], h <- [12] ++ [1..11]] Prelude> [ show h ++ " " ++ m | m<- ["am", "pm"], h <- [12] ++ [1..11]]
hourlist.txt · Last modified: 2024/01/31 04:08 by 127.0.0.1