scheme programming language

for given data scheme programming language recursion should be used

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Aim
The aims of this project are as follows:
To get you to think recursively.
To expose you to Scheme programming.
Requirements
Implement all the functions documented in the file prj2-sol.scm.
Your solutions is not allowed to use any of Scheme’s imperative features; i.e., you
may not use any Scheme built-in with a name ending with the ! character.
Provided Files
You should use the provided prj2-sol directory as a starting point for your project
directory.
It contains the following files: prj2-sol.scm
A skeleton file which contains skeleton functions for all the required functions.
The file is executable so that it can be executed directly via the command line as a
racket script.
It also contains unit tests for each of the functions you are required to implement.
README
A README file which must be submitted along with your project. It contains an initial
header which you must complete (replace the dummy entries with your name, knumber and email address at which you would like to receive project-related email).
After the header you may include any content which you would like read during the
grading of your project.
Hints
The provided files contain hints for each individual question. This section provides
general hints.
The unit tests provided for each function have been commented out. Uncomment
them after making your first attempt at the function. You may encounter the limits on
the number of ‘a’ and ‘d’ characters in the c[ad]+r functions. In that case, simply break
up your desired function into multiple functions.
The prj2-sol.scm file inside :
#!/usr/bin/env racket
;comment out following line to run in repl
#lang racket
(require rackunit)
;to trace function fn, add (trace fn) after fn’s definition
(require racket/trace)
;;; Some of the exercises below refer to employees.;;; An employee is
represented by a 4-tuple (name age department salary)
;;test data for employees
(define EMPLOYEES
‘((tom 33 cs 85000.00)
(joan 23 ece 110000.00)
(bill 29 cs 69500.00)
(john 28 me 58200.00)
(sue 19 cs 22000.00)
))
;; #1: 15-points;;return list of employees having department
dept;;must be implemented recursively;; Hint: use equal? to check for
department equality
(define (dept-employees dept employees)
‘TODO)
;; (check-equal? (dept-employees ‘ece EMPLOYEES) ‘((joan 23 ece
110000.00)));; (check-equal? (dept-employees ‘cs EMPLOYEES);;
‘((tom 33 cs 85000.00);;
(bill 29 cs 69500.00);;
;; #2: 5-points;;return list of names of employees belonging to
department dept;;must be implemented recursively;;Hint: almost the
same as the previous exercise
(define (dept-employees-names dept employees)
‘TODO)
;; (check-equal? (dept-employees-names ‘ece EMPLOYEES) ‘(joan));;
(check-equal? (dept-employees-names ‘cs EMPLOYEES) ‘(tom bill sue));;
(check-equal? (dept-employees-names ‘ce EMPLOYEES) ‘())
;; #3: 15-points;;Given list indexes containing 0-based indexes and a
list possibly;;containing lists nested to an abitrary depth, return
the element;;in list indexed successively by indexes. Return ‘nil if
there is;;no such element.;;Hint: use list-ref
(define (list-access indexes list)
‘TODO)
;; (check-equal? (list-access ‘(1) ‘(a b c)) ‘b);; (check-equal?
(list-access ‘(2) ‘(a b (c))) ‘(c));; (check-equal? (list-access ‘(2
0) ‘(a b (c))) ‘c);; (check-equal? (list-access ‘(3) ‘(a b (c)))
‘nil);; (check-equal? (list-access ‘(2 1) ‘(a b (c))) ‘nil);; (checkequal? (list-access ‘() ‘((1 2 3) (4 (5 6 (8)))) );;
‘((1 2 3)
(4 (5 6 (8)))));; (check-equal? (list-access ‘(1) ‘((1 2 3) (4 (5 6
(8)))) );;
‘(4 (5 6 (8))));; (check-equal? (list-access
‘( 1 1 2) ‘((1 2 3) (4 (5 6 (8)))) );;
‘(8));; (checkequal? (list-access ‘( 1 1 2 0) ‘((1 2 3) (4 (5 6 (8)))) );;
‘8);; (check-equal? (list-access ‘(0 1) ‘((1))) ‘nil)
(sue 19
;; #4: 15-points;;return sum of salaries for all employees;;must be
tail-recursive;;Hint: use a nested auxiliary function with an
accumulating parameter
(define (employees-salary-sum employees)
‘TODO)
;; (check-equal? (employees-salary-sum EMPLOYEES) 344700.00);;
(check-equal? (employees-salary-sum ‘()) 0)
;; #5: 15-points;;return list of pairs giving name and salary of
employees belonging to;;department dept;;cannot use recursion;;Hint:
use filter and map
(define (dept-employees-names-salaries dept employees)
‘TODO)
;; (check-equal? (dept-employees-names-salaries ‘ece EMPLOYEES)
‘((joan 110000.00)));; (check-equal? (dept-employees-names-salaries
‘cs EMPLOYEES);;
‘((tom 85000.00);;
(bill
69500.00);;
(sue 22000.00);;
));; (checkequal? (dept-employees ‘ce EMPLOYEES) ‘())
;; #6: 15-points;;return average salary of all employees; 0 if
employees empty;;cannot use recursion;;Hint: use foldl
(define (employees-average-salary employees)
‘TODO)
;; (check-equal? (employees-average-salary EMPLOYEES) (/ 344700.00
5));; (check-equal? (employees-average-salary ‘()) 0)
;; #7: 20-points;; given an integer or list of nested lists
containing integers,;; return a string containing its JSON
representation without any;; whitespace;; Hints: use (number->string
n) to convert integer n to a string.;;
use (string-append str1
str2 …) to append str1 str2 …;;
use (string-join str-list
sep) to join strings in str-list using sep;; also see toJson()
methods in java-no-deps Parser.java in prj1-sol
(define (int-list-json int-list)
‘TODO)
;; (check-equal? (int-list-json ‘(1 2 3)) “[1,2,3]”);; (checkequal? (int-list-json ‘(1 (2 (4 5) 6))) “[1,[2,[4,5],6]]”);; (checkequal? (int-list-json ‘()) “[]”);; (check-equal? (int-list-json 42)
“42”)

Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER