CS代考 HOSP404 – cscodehelp代写

HOSP404

Student ID Number:
COMP712 MID-TERM TEST S2 2021 Student ID Number:

MID-TERM ASSESSMENT – ONLINE

Semester 2 2021
COURSE NAME: Programming Languages
COURSE CODE: COMP712
TIME ALLOWED: 2hrs including upload/download time
TOTAL MARKS: 75

ASSESSMENT Instructions
PLEASE REad the BELOW CAREFULLY BEFORE YOU BEGIN
1. Please email me ) or phone me (021-774510) immediately if you have any queries and/or problems regarding the test.
2. This is an individual assessment – there must be no discussion or collaboration with anyone else. No component of this assessment may be shared with any person, in any manner other than your course coordinator or DCT Exam office.
3. This is an open book exam which means you are allowed to consult your lecture notes and other course material but not the internet.
4. Open the header of the document and insert your ID number
5. The assessment must be completed in one sitting. Ensure frequent saving and do not leave the assessment before clicking Save and Submit.

SUMMARY:
Number of Questions
Marks
Suggested time (Minutes)

Q1
10

Q2
10

Q3
10

Q4
10

Q5
10

Q6
10

Q7
15

Total
75
120

ACADEMIC INTEGRITY GUIDELINES
AUT takes Academic Integrity very seriously and you are reminded that the following actions may be deemed to constitute a breach of the General Academic Regulations Part 7: Academic Discipline, Section 2 Dishonesty During Assessment or Course of Study

· 2.1.1 copies from, or inappropriately communicates with another person
· 2.1.3 plagiarises the work of another person without indicating that the work
is not the student’s own – using the full work or partial work of another person without giving due credit to the original creator of that work
· 2.1.4 collaborates with others in the preparation of material, except where this has been approved as an assessment requirement.
· 2.1.5 resubmits previously submitted work without prior approval of the assessment board
· 2.1.6 using any other unfair means.

Additional Information

· Your assessment responses must be your own work. You may be required to orally defend your responses to assessment questions.

THERE ARE SEVEN QUESTIONS ON LISP. PLEASE ANSWER ALL QUESTIONS AND WRITE YOUR ANSWERS ON THIS FILE.

1. Write a LISP function, duplicate-second (D-S), which given a list will return the same list with its second element duplicated. Some examples are given below:

· (D-S ‘(a b c d e))
(a b b c de)

· (D-S ‘(a))
(a)

· (D-S ‘())
()
[10 marks]

2. Write a LISP function, remove-even-length-list (R-eLL), which given a list of lists will return a list of lists that are even in length. Some examples are given below:

· (R-eLL ‘((8 3) (a b x) (6 1 2 3) (7)))
((8 3) (6 1 2 3))

· (R-eLL ‘((8 3) (6 1 2 3) () (7 3 1)))
((8 3) (6 1 2 3) ())
[10 marks]

3. Write a LISP function, first-and-last (FnL), which given a list will return the first and last element in it. For examples:

· (FnL ‘(a b c d))
(a d)

· (FnL ‘(a))
(a a)
[10 marks]

4. Write a LISP function, sum-first-three (SF3), which given a list of numbers will return the sum of the first three numbers in it. For examples:

· (SF3 ‘(1 2 3 4 5))
6

· (SF3 ‘(1))
1

· (SF3 ‘())
0
[10 marks]

5. Assume there is a built-in LISP function, magic, which when applied to a number returns randomly the name of an animal. Write a function, apply-magic, which given any number of numbers will return a list of animals obtained using the function, magic. Some examples are given below

· (apply-magic 1 2 3 5 7)
(cat dog cow sheep kangaroo)

· (apply-magic 3 4 5)
(snake dragon monkey)
[10 marks]

6. Write a function, remove-num (Rem-num), which given a list, will remove all the numbers in it.

· (rem-num ‘(d c 3 5 s))
(d c s)

· (rem-num ‘( 1 a 2 c (3 4 t d 5)))
(a c (t d))
[10 marks]

7. Write a function, Powerball, that generates seven numbers for you. The first 6 numbers (also known as lotto) are generated as a unique number in the range 1-40 and the 7th number is generated from 1-10. You may use the function, random, that will give you a random number as shown below:

· (random 40) ;returns a number 0 – 40
39

However, beware that the function, random, returns 0 – 40 and hence you have to remove zero if generated. Furthermore, you don’t want to include a number that has already been generated.

· (powerball)
(3 7 20 40 32 11 8) ; 8 is the powerball

[15 marks]

Page 1 of 2
Page 2 of 2

Leave a Reply

Your email address will not be published. Required fields are marked *