CSC 388 - Programming Languages Assignment 3 Fall 2020 Assignment 3 must be submitted to Canvas. The code must be in the R5RS dialect of Scheme. See “Racket Installation Directions” on Canvas for more...

Assignment instructions are attached. Lot's of instructions but an overall easy assignment.


CSC 388 - Programming Languages Assignment 3 Fall 2020 Assignment 3 must be submitted to Canvas. The code must be in the R5RS dialect of Scheme. See “Racket Installation Directions” on Canvas for more details. You will also be required to write an analysis of your solution. You can find more information under the Submission section in this document. Goal The purpose of this assignment is to give you exposure to a new language, new paradigm, and new way of thinking about problems. The syntax is simple enough that the focus should be on the problem. The syntax is simpler than most imperative languages with the few rules it does have. Problem Write a function closest in Scheme that takes a list of at least size 1 of positive integers, duplicates are possible, and a target value that is either 0 or a positive integer, return the closest positive value or, 0 if target is 0, without going over the target after placing either a plus or minus symbol in front of every value. If no such value can be made, then return -1. There may be more than 1 combination which results in the closest value or the value itself. The function should just return a single value. Suppose the list is (1 2 3) then the possible permutations of placing a plus or minus are +1+2+3 = 6 +1+2-3 = 0 +1-2+3 = 2 +1-2-3 = -4 -1+2+3 = 4 -1+2-3 = -2 -1-2+3 = 0 -1-2-3 = -6 It is up to you to choose the auxiliary parameters that closest takes. (Auxiliary parameters are parameters used to help find the solution. The list parameter is mandatory and thus not an auxiliary parameter.) All auxiliary parameters must be numeric (not lists) and should have initial values set to zero. For example, if L is ‘(1 2 3) and you decide to use two additional auxiliary parameters, closest should be called as follows: (closest ‘(1 2 3) 0 0) If there are three auxiliary parameters, then it must be called: (closest ‘(1 2 3) 0 0 0) Examples Example 1: ‘(1 2 3 4) with target 0. Returns 0. There are a few combinations. One of those combinations is +1-2-3+4 = 0. It should not matter the order of the values. For instance, ‘(3, 1, 4, 2) with target 0 should still return 0. A possible combination is +3-1-4+2 = 0. Example 2: ‘(3 4) with target 2 should return 1. The only combination is -3 + 4 = 1. Example 3: ‘(7 1 5 9 3) with target 13 should return 13. The only combination is +7-1+9-5+3 = 13. Example 4: ‘(6 10 4 14 20 17 7 3 3 1) with target 0 should return -1. There are no combinations which are positive and do not go over 0. Example 5: ‘(20 14 15 20 13) with target 5 should return 2. The only combination is -20+14+15-20+13 = 2. Example 6: ‘(413 337 228 402 476 480 497) with target 36 should return -1. There are no combinations which are positive and do not go over 36. Code The whole solution must be packed into one recursive function called closest which must look as follows (define closest (lambda () (cond …your code… ))) In other words, you must choose your auxiliary parameters and define ONE COND statement. Criteria You must follow the given criteria. Not doing so will result in heavy point reduction. First, you must only define the one function. No additional functions may be defined. Second, you are restricted to the following constructs · null? · car · cdr · else · + · - · > · >= · < ·=""><= · closest · if · user defined names (for the names of your parameters) · integer literals · parentheses you cannot use a construct not listed above. in other words, you cannot call any other function except for closest and what is listed above. submission for this assignment, you must submit 2 items. 1. your r5rs scheme solution as a .rkt file. you can do this in dr. racket with file → “save definitions as”. call it closest.rkt. 2. a 1 - 2 page document with a description of your algorithm and its complexity. the document should be either an ascii text file, ms word file, or a pdf. answer this question as well. pack all your files in a zip file. use the following naming convention. if your name is john smith, then your file name must be jsmith.zip. zipped files which are not properly named or packed correctly will receive 0 points. plagiarism plagiarism is defined as copying or receiving materials from a source or sources and submitting this material as one's own without acknowledging the debts to the source (quotations, paraphrases, basic ideas), or otherwise representing the work of another as one's own, is not allowed. collaboration or group work, usually evidenced by unjustifiable similarity, is not permitted. the homework will be subject to screening by software programs designed to detect evidence of plagiarism or collaboration. keep in mind that posting a message (including anonymous messages) about the homework on the internet (blog, software development forums, etc.) is plagiarism. i will be monitoring the web for the next couple of weeks and taking actions if such a message is posted. any student (or a group of students) accused of a violation of academic integrity will receive an f for the course. you have been warned. additionally, you can find the academic honesty policy for the department with this link: https://csc.uis.edu/honesty as well as the university policy here: https://www.uis.edu/academicintegrity/policy/ ·="" closest="" ·="" if="" ·="" user="" defined="" names="" (for="" the="" names="" of="" your="" parameters)="" ·="" integer="" literals="" ·="" parentheses="" you="" cannot="" use="" a="" construct="" not="" listed="" above.="" in="" other="" words,="" you="" cannot="" call="" any="" other="" function="" except="" for="" closest="" and="" what="" is="" listed="" above.="" submission="" for="" this="" assignment,="" you="" must="" submit="" 2="" items.="" 1.="" your="" r5rs="" scheme="" solution="" as="" a="" .rkt="" file.="" you="" can="" do="" this="" in="" dr.="" racket="" with="" file="" →="" “save="" definitions="" as”.="" call="" it="" closest.rkt.="" 2.="" a="" 1="" -="" 2="" page="" document="" with="" a="" description="" of="" your="" algorithm="" and="" its="" complexity.="" the="" document="" should="" be="" either="" an="" ascii="" text="" file,="" ms="" word="" file,="" or="" a="" pdf.="" answer="" this="" question="" as="" well.="" pack="" all="" your="" files="" in="" a="" zip="" file.="" use="" the="" following="" naming="" convention.="" if="" your="" name="" is="" john="" smith,="" then="" your="" file="" name="" must="" be="" jsmith.zip.="" zipped="" files="" which="" are="" not="" properly="" named="" or="" packed="" correctly="" will="" receive="" 0="" points.="" plagiarism="" plagiarism="" is="" defined="" as="" copying="" or="" receiving="" materials="" from="" a="" source="" or="" sources="" and="" submitting="" this="" material="" as="" one's="" own="" without="" acknowledging="" the="" debts="" to="" the="" source="" (quotations,="" paraphrases,="" basic="" ideas),="" or="" otherwise="" representing="" the="" work="" of="" another="" as="" one's="" own,="" is="" not="" allowed.="" collaboration="" or="" group="" work,="" usually="" evidenced="" by="" unjustifiable="" similarity,="" is="" not="" permitted.="" the="" homework="" will="" be="" subject="" to="" screening="" by="" software="" programs="" designed="" to="" detect="" evidence="" of="" plagiarism="" or="" collaboration.="" keep="" in="" mind="" that="" posting="" a="" message="" (including="" anonymous="" messages)="" about="" the="" homework="" on="" the="" internet="" (blog,="" software="" development="" forums,="" etc.)="" is="" plagiarism.="" i="" will="" be="" monitoring="" the="" web="" for="" the="" next="" couple="" of="" weeks="" and="" taking="" actions="" if="" such="" a="" message="" is="" posted.="" any="" student="" (or="" a="" group="" of="" students)="" accused="" of="" a="" violation="" of="" academic="" integrity="" will="" receive="" an="" f="" for="" the="" course.="" you="" have="" been="" warned.="" additionally,="" you="" can="" find="" the="" academic="" honesty="" policy="" for="" the="" department="" with="" this="" link:="" https://csc.uis.edu/honesty="" as="" well="" as="" the="" university="" policy="" here:="">
Nov 10, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here