Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HASKELL you are going to write a pure functional program using the Haskell language. Define a function named primes with the following signature: primes ::

HASKELL
you are going to write a pure functional program using the Haskell language.

Define a function named “primes” with the following signature:
primes :: Integer -> Integer -> [Integer]
That is, primes is a function that takes two Integers as parameters and returns a list of Integers. For any
positive value a and b, primes a b should return a list of all prime numbers1 that are between a and b
(inclusive). You can assume the parameters are always positive. But you cannot assume that a ≤ b (that is,
they may be out of order). For example:
primes 5 10 → [5, 7]
primes 10 20 → [11, 13, 17, 19]
primes 5 41 → [5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41]
primes 20 22 → []
primes 30 20 → [23, 29]

You are not allowed to use any import statement in your code.

You can only define one single function on the top level. If you define other functions and/or symbols on the
top level, 20% of your raw score will be deducted.




Step by Step Solution

3.54 Rating (151 Votes )

There are 3 Steps involved in it

Step: 1

Functional Haskell program step by step explanation primes Integer Integer Integer This line defines the primes function that takes two integers as in... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building Java Programs A Back To Basics Approach

Authors: Stuart Reges, Marty Stepp

5th Edition

013547194X, 978-0135471944

More Books

Students also viewed these Programming questions