Question: WRITE A LISP PROGRAM THAT CHECKS IF THE VALUES ARE VALID IN A LIST AND CONVERT FROM ONE LIST TO ANOTHER. DO NOT USE LOOPS.
WRITE A LISP PROGRAM THAT CHECKS IF THE VALUES ARE VALID IN A LIST AND CONVERT FROM ONE LIST TO ANOTHER. DO NOT USE LOOPS. ONLY RECURSION ; data type descriptions: ; joblist: a list is a valid joblist iff it is a list of pairs in which: ; - each pair has the form (employee jobid) ; - the employee is a non-empty string ; - the jobid is a non-negative integer ; Note: an empty list is considered a valid joblist ; Example (("shaggy" 17) ("shaggy" 92) ("velma" 11) ("daphne" 103) ("fred" 77) ("velma" 3)) ; jobsummary: a list is a valid jobsummary iff it is a list of sublists in which: ; - each sublists begins with an employee (non-empty string) and is followed ; by one or more jobids (non-negative integer) ; Note: an empty list is considered a valid jobsummary ; Example (("shaggy" 17 92) ("velma" 11 3) ("daphne" 103) ("fred" 77))
(defun okjsum (jobsummary) "return t if jobsummary is a valid jobsummary, nil otherwise" nil) (defun okjlist (joblist) "return t if joblist is a valid joblist, nil otherwise" nil) (defun jlist2sum (joblist) "given a joblist, return an equivalent jobsummary (or 'Error if joblist is invalid)" nil) (defun jsum2list (jobsummary) "given a jobsummary, return an equivalent joblist (or 'Error if jobsummary is invalid)" nil)
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
