For this assignment you must write the following functions in Scheme:
1. Write a function called slope that takes two arguments, both pairs of numbers representing points,
and calculates the slope of the line between those two points.
2. Write a predicate called square? that takes one argument, a number, and returns #t if that number is
the square of two integers.3. Write a function called replace-first that takes two arguments, an item and a list, and returns a
version of the list with its first element replaced by the item. If the list is empty (you can use the null?
predicate to determine this) return the empty list.4. Write a function called replace-first! that takes the same arguments as replace-first but modifies
the list itself using set-car!.
5. Write a recursive predicate called all-odd? that takes a list as an argument and returns #t if every
number in a list is odd, and returns #f if any number in the list is even. If the list is empty, return #t.6. Write a recursive function called filter-odd that takes a list as an argument, and returns a list
containing only the odd numbers in the original list. If the list is empty, return the empty list.
7. Write a recursive function called product that takes a list of numbers as an argument and returns the
result of multiplying them all together. If the list is empty, return 1.8. Write a recursive function called smallest that takes a list of numbers as an argument and returns the
smallest number in the list. The function does not need to work on the empty list.
9. Write a recursive function called remove-first that takes a number and a list of numbers as arguments
and returns a list consisting of the items in the original list with the first occurence of the number
removed. If the list is empty, return the empty list.10. Write a recursive function called selection-sort that takes a list of numbers as an argument and uses
smallest and remove-first to perform a selection sort on the list. If the list is empty, return the
empty list.What to Hand In
Implement all of the functions described above in a source file called yourlastnameAssign3.scm with your
actual last name. Upload the source file to D2L to the dropbox called Assignment 3.
4230, Assignment, CSCI, solved
[SOLVED] Csci 4230 – assignment 3
$25
File Name: Csci_4230_____assignment_3.zip
File Size: 244.92 KB
Reviews
There are no reviews yet.