Day of the week: Difference between revisions

m
m (→‎{{header|QL SuperBASIC}}: minor corrections)
m (→‎{{header|AppleScript}}: (light refactor))
Line 334:
 
Or, composing generic functions:
<lang applescript>on run
-- xmasOnSundayxmasIsSunday :: Int -> Bool
on xmasIsSunday(y)
script xmasOnSunday
tell (current on |λ|(ydate)
set {its year, its month, its day, its time} to {y, 12, 25, 0}
tell (current date)
return its weekday is Sunday
set {its year, its month, its day, its time} to {y, 12, 25, 0}
end tell
return its weekday is Sunday
end xmasIsSunday
end tell
 
end |λ|
 
end script
-------------------------- TEST ---------------------------
on run
filter(xmasOnSundayxmasIsSunday, enumFromTo(2008, 2121))
filter(xmasOnSunday, enumFromTo(2008, 2121))
end run
 
 
-- GENERIC FUNCTIONS -------------------------------------- GENERIC FUNCTIONS --------------------
 
-- enumFromTo :: Int -> Int -> [Int]
Line 358 ⟶ 361:
set end of lst to i
end repeat
return lst
else
return {}
end if
end enumFromTo
 
 
-- filter :: (a -> Bool) -> [a] -> [a]
Line 376 ⟶ 380:
end tell
end filter
 
 
-- Lift 2nd class handler function into 1st class script wrapper
9,655

edits