Day of the week: Difference between revisions

m
No edit summary
m (→‎{{header|AppleScript}}: Minor tidying)
Line 263:
 
Or, composing generic functions:
<lang applescript>filter(xmasIsSunday,on enumFromTo(2008, 2121))run
-- xmasIsSundayxmasOnSunday :: Int -> Bool
 
script xmasOnSunday
 
on |λ|(y)
-- xmasIsSunday :: Int -> Bool
tell (current date)
on xmasIsSunday(y)
set {its year, its month, its day, its time} to {y, 12, 25, 0}
tell (current date)
set {its year, its month, its day, its time}return to {y,its 12,weekday 25,is 0}Sunday
return its weekday is Sundayend tell
end tell|λ|
end repeatscript
end xmasIsSunday
filter(xmasOnSunday, enumFromTo(2008, 2121))
end run
 
 
Line 279 ⟶ 282:
-- enumFromTo :: Int -> Int -> [Int]
on enumFromTo(m, n)
if m > n then
set dlst to -1{}
repeat with i from m to n by d
set end of lst to i
end repeat
return lst
else
setreturn d to 1{}
end if
set lst to {}
repeat with i from m to n by d
set end of lst to i
end repeat
return lst
end enumFromTo
 
9,655

edits