1. Homepage
  2. Programming
  3. [2022] 159.272 Programming Language Paradigms Assignment 1

[2022] 159.272 Programming Language Paradigms Assignment 1

Engage in a Conversation
159.272 Programming Language ParadigmsMasseyHaskellAssignment 1

159.272 Programming Language Paradigms Assignment 1 CourseNana.COM


CourseNana.COM


CourseNana.COM

Write a Haskell function that takes a date and an offset as parameters and returns the date that is a certain number of days before or after the input date. The number of days is given by the offset parameter. CourseNana.COM

Top-level function CourseNana.COM

The top-level function must have the following function declaration: CourseNana.COM

adjust_date :: (Int, Int, Int) -> Int -> (Int, Int, Int) CourseNana.COM

Thefirstparameterisatuplethatspecifiesaday,monthandyear,e.g.(24, 4, 1959). The date must be a valid date between (1, 1, 1600) and (31, 12, 3000). The second parameter specifies an offset between -25 and 25. If the offset is negative, then the resulting date is before the given date; if it is positive, the resulting date is after the given date. For example, if the date is (24, 4, 1959) and the offset is 9, then the resulting date is (3, 5, 1959). On the other hand, if the offset is -5, then the resulting dateis(19, 4, 1959). CourseNana.COM

The top-level function may call other Haskell functions to achieve the task. CourseNana.COM

Things to watch out for CourseNana.COM

The offset may shift the date into the next or the previous month. Obviously not every month has the same number of days, and February (the second month) has either 28 or 29 days, depending on whether the year is a leap year or not. CourseNana.COM

It may also be the case that the date is shifted into the next or the previous year. This also needs to be taken care of. However, due to the range of the offset being restricted, the shift will also be less than a month. CourseNana.COM

Tip: a leap year is a year that is an integer multiple of 4 (except for years evenly divisible by 100, but not by 400). CourseNana.COM

What we are looking for CourseNana.COM

  • A set of Haskell functions that do not depend on any modules to be imported.
  • Each function needs to have a comment explaining its purpose.
  • The top-level function must adhere to the function declaration shown above.
  • If an incorrect date or offset is given as parameter, i.e. a date or offset not within the permissible range, a sensible error message needs to be displayed.

  CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
159.272 Programming Language Paradigms代写,Massey代写,Haskell代写,Assignment 1代写,159.272 Programming Language Paradigms代编,Massey代编,Haskell代编,Assignment 1代编,159.272 Programming Language Paradigms代考,Massey代考,Haskell代考,Assignment 1代考,159.272 Programming Language Paradigmshelp,Masseyhelp,Haskellhelp,Assignment 1help,159.272 Programming Language Paradigms作业代写,Massey作业代写,Haskell作业代写,Assignment 1作业代写,159.272 Programming Language Paradigms编程代写,Massey编程代写,Haskell编程代写,Assignment 1编程代写,159.272 Programming Language Paradigmsprogramming help,Masseyprogramming help,Haskellprogramming help,Assignment 1programming help,159.272 Programming Language Paradigmsassignment help,Masseyassignment help,Haskellassignment help,Assignment 1assignment help,159.272 Programming Language Paradigmssolution,Masseysolution,Haskellsolution,Assignment 1solution,