CS代考 HOSP404 – cscodehelp代写
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
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.
Number of Questions
Suggested time (Minutes)
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.
· 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))
· (D-S ‘())
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) ())
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))
· (FnL ‘(a))
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))
· (SF3 ‘(1))
· (SF3 ‘())
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)
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))
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
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.
(3 7 20 40 32 11 8) ; 8 is the powerball
Page 1 of 2
Page 2 of 2