0% found this document useful (0 votes)
8 views

Activity1v2

Uploaded by

sharuanshu1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Activity1v2

Uploaded by

sharuanshu1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CS 381 – In-Class Activity 1

This is an ungraded activity. We will go over the solutions in class. Solutions will not be posted online.
Name your file Act1Functions.hs with the first line:

module Act1Functions where

You can test your functions using the act1Verifier.hs by running

ghc act1Verifier.hs
act1Verifier

1. Write a Haskell function called “range” that produces a consecutive list of numbers that starts with
the number n given as an argument and ends at 1 [n…1] . You can assume that n ≥ 0. For example:

2. Write a Haskell function called “copies” that produces a list of n copies of a list of integers. You can
assume that n ≥ 0. For examples:

3. Write a Haskell function called “greaterList” that produces a list of of elements from a list (second
argument) that are greater than the first argument n. For example:

Hint: Use (Ord a) => a → [a] → [a]


CS 381 – In-Class Activity 1

4. Write a Haskell function called “allSame” that returns True if the characters in a list (or String) are all
the same. If the characters differ or the list is empty the function evaluates to False.

5. Write a Haskell function called “minmax” that returns as a pair the minimum and maximum value
from a list of integers. Assume that the minimum and maximum of an empty list is (0,0). See the
examples below.

You might also like