Scheme code needed


​1.)​The source code must be in R5RS. Any other scheme or lisp dialect will be an automatic 0.

​2.)​1 - 2 page description of your algorithm and its complexity as an ACII text document, MS Word document, or a PDF file. Since the program you must write is short, the description of the algorithm and complexity analysis carry significant weight on your grade.

Pack all your files in a zip file. Use the following naming conventions. If your name is John Smith, then your file name must be jsmith.zip. Zip files which are not properly named or packed will receive 0 points.

Write a function has-subtarget? that takes a list of three or more positive integers, duplicates are possible and 0 is not included, and returns true (#t) if there are two non-empty sublists whose sums are both equal to a value in the list that is not part of either sublist. False (#f), if no two such sublists exist. The values of the sublist do not need to be contiguous in the original list.

Not all values need to be used. In other words, values can belong to either sublist or neither sublist. They cannot, however, belong to both sublists at the same time.

The list passed to has-target-num? is flat, i.e., it does not itself contain sublists. It is up to you to choose the auxiliary parameters that has-target-num? takes. Auxiliary parameters are parameters used to help find the solution and are scalar. In other words, they hold single values not a collection of values. The list parameter is mandatory is not an auxiliary parameter. All auxiliary parameters must be numeric and must be initialized to zero when the function is called.

There may be more than two values that have two sublists or more than two sublists that equal some value. In both cases a single true (#t) should be returned.

Example Calls:

If the list is ‘(1 2 3) and you decide to use two additional auxiliary parameters, has-subtarget? should be called as follows.

(has-subtarget? ‘(1 2 3) 0 0)

If three auxiliary parameters are used then the call should be:

(has-subtarget? ‘(1 2 3) 0 0 0)

Test Calls:

‘ (2 1 3 9 4 8) returns true because {2 4 3} and {1 8} both sum to 9.

‘(1 1 2 2) returns true because {1 1} and {2} both sum to 2, however…

‘(1 1 2) returns false because there are no two sublists have sums that are a target in the list.

‘(5 6 7) returns false because no two sublists have sums that are a target in the list.

'(17 35 1 26 24 12 25 40 33 31) returns false.

‘(6 21 84 66 100 53 73 38 29 81 66 69 54 8 94) returns true.

The Code

The whole code solution must be packed into one recursive function, has-subtarget?, which must look as follows

(define has-subtarget? (lambda (<list L followed by your auxiliary ​​​​​​​​​parameters of your choice>)




In other words, your function must take as its first argument a list followed by as many auxiliary parameters of your choice that will be initialized to 0 when called. You may only have a single cond statement in your entire function.

Inside cond you can only use the following scheme constructs:

- null?

- car

- cdr

- else

- +

- =

- >

- if

- and

- or

- has-subtarget?

- user defined names (for the names of your parameters)

- integer literals

- parentheses

You may not use a construct if it is not listed. The use of user-defined functions, except for has-subtarget?, is not allowed. You cannot define or call any other function except for what is listed above. This means you must write only a single function.

If your program uses a construct not on the list, then it is not a solution to this homework. Points will be drastically removed for any construct used not in the list above.

If you have a question about a construct you want to use you may ask. This will not guarantee you will be allowed to use it.

NOTE: Make sure before you submit to remove any debug code. If you leave any code that writes to stdout or have extra lists outside the main list, it will be counted against your score.

Beceriler: Yazılım Mimarisi

Daha fazlasını gör: scheme language, small occupational pension scheme, scheme in hindi, dc scheme investment, scheme programming tutorial, scheme lisp, core financial transactions, pension benefit statement regulations, email setup without verification code needed, image processing matlab project code needed, source code needed, code needed, javascript code quiz score, learning source code music score, html code needed fade fade images, code needed form, php code live score updates, source code needed online casino, write html code count score game, java code cricket score

İşveren Hakkında:
( 381 değerlendirme ) Mutrah, Oman

Proje NO: #18126746