Académique Documents
Professionnel Documents
Culture Documents
Instructions
1. Naming conventions are to be followed with extreme precision. A script
will automatically evaluate your programs. And any deviation from the
prescribed folder names, file names or function names results in that
folder/file/program/function being discarded/unrecognized. This will only
reward you with 0 marks (for that particular question).
2. Hope you have all created a bitbucket account as per the invitation sent
to you guys (again). You will notice a shared repo already under your
username. This is where this lab assignment has to be finally uploaded.
3. Firstly create your own local repo titled lab-2. All your programs shall
be written within this repo.
4. Name each of your programs as per the question number. If the question
number is 1, then the program name should be 1.rkt.
5. Push the local lab-2 repository to the shared bitbucket repository.
6. Lab questions should be completed by the end of the lab session.
7. A set of practice questions have also been attached apart from the questions that are to be attempted in the lab. These may be attempted upon
completion and submission of those questions assigned for the lab time.
Lab Questions
Write the following functions in separate .rkt files as per the question numbers
indicated.
Q.N.
Function
name
Input
a,b,c
(3
natural
numbers)
swap
fibonacci
n (a natural
number)
Purpose/Description
Swap the numbers a,b,c
amongst themselves
ab
bc
ca
Note: Try not to use any extra variables
expSeries
the
ex =
i!
numTri
n (a natural
number)
sumDigit
n (a natural
number)
dec2BOH
n (a decimal
number)
> (fibonacci 7)
0
1
1
2
3
5
8
> (numTri 5)
1
23
456
7 8 9 10
11 12 13 14 15
1.5+1.5 (1.5
marks each
for
each
loop)
2+1 (Isolate
P
digits=2,
digits=1)
exponential
n
X
xi
i=0
These questions may be attempted once the first 5 have been submitted. Write
the following functions in separate .rkt files as per the question numbers indicated.
Marks
> (swap 5 10 7)
Before swap: a=5 b=10
2
c=7
After swap: a=7 b=5
c=10
Evaluates
function
3
Sample Implementation +
Output
2+2+2 (2 for
each conversion)
20
Q.N.
Function
name
Input
Purpose/Description
pascalTri
n (a natural
number)
palindrome
n (a natural
number)
tribonacci
n (a natural
number)
10a
bin2Dec
n (a binary
number)
10b
oct2Hex
n (an octal
number)
11a
lcm
11b
hcf
Sample Implementation +
Output
> (pascalTri 4)
1
121
12321
1234321
> (palindrome 1234)
#f
> (palindrome 25352)
#t
> (tribonacci 7)
0
1
1
2
4
7
13
> (bin2Dec 111)
7
> (oct2Hex #o34)
1C
> (oct2Hex 34)
1C
> (lcm 12 15)
60
> (hcf 12 20)
4