Find the last Sunday of each month: Difference between revisions
→{{Header|AppleScript}}: Simpler closures, updated primitives
(Added F# version) |
(→{{Header|AppleScript}}: Simpler closures, updated primitives) |
||
Line 98:
-- lastWeekDaysOfYear :: Int -> Int -> [Date]
on lastWeekDaysOfYear(intYear, iWeekday)
{intYear:intYear, iWeekday:iWeekday}), my lastDaysOfMonths(intYear))▼
end script▼
end lastWeekDaysOfYear
▲on lastWeekDay(iLastDay, iMonth)
▲ calendarDate(iYear, iMonth, iLastDay - ¬
▲ (((weekday of calendarDate(iYear, iMonth, iLastDay)) as integer) + ¬
▲ (7 - (iWeekday of my closure))) mod 7)
▲end lastWeekDay
Line 156 ⟶ 155:
-- transpose :: [[a]] -> [[a]]
on transpose(
script column
-- Just the index
on
script nthCell
on
end
end script
-- Column n consists of
-- cell n of each row
map(nthCell, rows)
end lambda
end script
-- A column from each item of the top row
map(column, item 1 of rows)
end transpose
Line 222 ⟶ 229:
end script
end mReturn
▲ script
▲ property lambda : f
▲ end script
-- cond :: Bool -> (a -> b) -> (a -> b) -> (a -> b)
Line 243 ⟶ 242:
on apply(f, a)
mReturn(f)'s lambda(a)
end apply</lang>
{{Out}}
|