Declarative Programming
Declarative Programming
This lab explores the use of the very safe functional language Haskell.
● Edit program1.hs as shown. Replace 1000 with the last four digits of your CMS ID.
S4: Lists
● Understand the following code. It may help to test out some of these examples:
● Write one line of Haskell to do each of the following:
a. Create a list myCMSID consisting of the digits in your CMS ID. There should be at
least eight digits in this list. Reverse this list.
b. Create a list myNewCMSID by prepending this list with the four digits that make
up the year in which you were born.
c. Create a variable maxDigit and assign it the maximum digit in the list
myNewCMSID.
d. Create a variable is8 that checks if the digit 8 occurs in myNewCMSID.
Take SCREENSHOT 3 showing your code and the value of all four of these variables.
● Write one line of Haskell to do the following:
e. auto generate and filter a list of numbers between 2000 and 5000 that are
divisible by 9 and 13.
Take SCREENSHOT 4 showing your code and the output.
● Write two lines of Haskell to create the multiplication table shown below:
You may use the following for reference “Chapters - Learn You a Haskell for Great Good!”
SUBMISSION: Instructions
● Convert the following into one PDF file and upload on the LMS submission link by the
due date:
○ Screenshot 1 to 6.
○ Answers to Q1