YAPC::EU 2018 Glasgow Update!
This commit is contained in:
parent
22f33d4004
commit
4e2d22a71d
1170 changed files with 15042 additions and 3047 deletions
37
Task/Nautical-bell/Phix/nautical-bell.phix
Normal file
37
Task/Nautical-bell/Phix/nautical-bell.phix
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
constant watches = {"First","Middle","Morning","Forenoon","Afternoon","First dog","Last dog","First"},
|
||||
watch_ends = {"00:00", "04:00", "08:00", "12:00", "16:00", "18:00", "20:00", "23:59"},
|
||||
bells = {"One","Two","Three","Four","Five","Six","Seven","Eight"},
|
||||
ding = "ding!"
|
||||
|
||||
procedure nb(integer h,m)
|
||||
integer bell = mod(floor((h*60+m)/30),8)
|
||||
if bell==0 then bell = 8 end if
|
||||
string hm = sprintf("%02d:%02d",{h,m})
|
||||
integer watch=1
|
||||
while hm>watch_ends[watch] do watch += 1 end while
|
||||
string plural = iff(bell==1?" ":"s")
|
||||
string dings = ding
|
||||
for i=2 to bell do dings &= iff(mod(i,2)?" ":"")&ding end for
|
||||
printf(1,"%s %9s watch %5s bell%s %s\n",
|
||||
{hm,watches[watch],bells[bell],plural,dings})
|
||||
end procedure
|
||||
|
||||
procedure simulate1day()
|
||||
for h=0 to 23 do
|
||||
for m=0 to 30 by 30 do
|
||||
nb(h,m)
|
||||
end for
|
||||
end for
|
||||
nb(0,0) -- (again)
|
||||
end procedure
|
||||
|
||||
simulate1day()
|
||||
|
||||
while 1 do
|
||||
sequence d = date(DT_GMT)
|
||||
integer m = d[DT_SECOND] + mod(d[DT_MINUTE],30)*60
|
||||
if m=0 then
|
||||
nb(d[DT_HOUR],d[DT_MINUTE])
|
||||
end if
|
||||
sleep(30*60-m)
|
||||
end while
|
||||
Loading…
Add table
Add a link
Reference in a new issue