Date: Fri, 06 Feb 2004 10:38:11 -0600 (CST) From: Mark Jacobson To: 810-151-04@uni.edu Subject: [810-151-04] Last Scheme Assignment, part a. Hello 151 students, Here is the next Scheme programming assignment for you to start working on. It will be due on Wednesday, the 2nd to last day of Scheme class. Implement the list-head procedure in Scheme. Note that list-tail is built into Scheme. The procedure list-head operates on a list by returning only the items from the head of theList, and removing the last n items of theList, when the arguments are theList and n. Welcome to DrScheme, version 205. Language: Textual (MzScheme, includes R5RS). > (define myList '(1 2 3 4 5 6 7 8 9 10 11 12)) > (list-tail myList 4) <----- list-tail is built into Scheme. (5 6 7 8 9 10 11 12) > (list-head myList 4) <----- your assignment is (list-head li n) (1 2 3 4 5 6 7 8) > (list-head myList 6) (1 2 3 4 5 6) > (list-head myList 1) (1 2 3 4 5 6 7 8 9 10 11) > (list-head myList 8) (1 2 3 4) > (list-head myList 9) (1 2 3) > (list-head myList 11) (1) > (list-head myList 12) () > (list-tail myList 9) (10 11 12) > myList (1 2 3 4 5 6 7 8 9 10 11 12) This is only a portion of your last Scheme assignment. There will be at least part b. and part c. coming later. Mark ---------------------------------------------------------------------------- part b. Write the sublist procedure. It can utilize your list-head and the Scheme list-tail procedures for implementation. ---------------------------------------------------------------------------- > (define myList '(1 2 3 4 5 6 7 8 9 10 11 12)) > (sublist myList 2 10) (2 3 4 5 6 7 8 9 10) > (sublist myList 5 (length myList)) (5 6 7 8 9 10 11 12) > (sublist myList 5 9) (5 6 7 8 9) > (sublist myList 1 4) (1 2 3 4)