0% found this document useful (0 votes)
10 views2 pages

OOP and Functional Programming Homework 3

Uploaded by

ksshubhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

OOP and Functional Programming Homework 3

Uploaded by

ksshubhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Homework 3 Functional programming

Unit 12 OOP and functional programming

Homework 3 Functional programming

1. (a) What is a programming paradigm? [1]

(b) Name four programming paradigms and for each one, give an example of a
programming language which supports it. [8]
(i)

(ii)

(iii)

(iv)

2. (a) Use functional programming notation to define a function named trebleMinusFive,


defined below.
f(x) = 3x – 5 [2]

(b) Write a function definition for a second function named doubleIt which
returns the value of g(x) = 2x. [2]

(c) Combine the two functions in (a) and (b) to write a function h(x) which returns
the value of
h(x) = g(f(x))
Name the function trebleThenDouble.
What will be returned when this function is applied to the parameter 4? [2]

1
Homework 3 Functional programming
Unit 12 OOP and functional programming

3. In a functional programming language, variables are immutable.


Explain, with an example, what this means and compare the way variables can be used in
the functional and procedural paradigms. [3]

4. Functional programming is stateless and has no side effects.


Explain the meaning of these two terms. [3]

5. (a) List two properties of a first-class object. [2]

(b) Give two examples of first class objects. [2]

[Total 25 Marks]

You might also like