sample_test1 - 7 Define a function that collects the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Test Exam -- Midterm 1: 1) What is the value of (implies (not (and t t)) (and nil t))? 2) Formalize the statement âx or y is 5 when both a and b are t. 3) Define the function that zips two lists together Example: (zzip '(a b c) '(1 2 3)) ==> ((a 1) (b 2) (c 3)) 4) Write a function called del-nats that deletes all the natural numbers from a list. Example: (del-nats '(1 -1 a 2 b 5 )) ==> (-1 a b) 5) Write a function called collect-nats collects all the naturals in a list. (collect-nats '(1 -1 a 2 b 5 )) ==> (1 2 5) 6) Is there any x for which a) (collect-nats x) = x b) (collect-nats x) = (first x) c) (collect-nats x) = (rest x)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 7) Define a function that collects the elements that occur more than once: (collect-dups '(a b c a b a d e f)) ==> (a b) 8) Define a function that finds the position (0 based) in a list that a certain element appears for the first time. Example: (find-pos 'B '(A A B C D B)) ==> 2 If the element is found, find-pos returns a number less than the length of the list. But if the element is not found, it returns the length. Example:(find-pos 'X '(A A B C D B)) ==> 6 9) Formalize this: "For every object e, e exists in concatenation of x and y, when e exist in x or y."...
View Full Document

This note was uploaded on 11/30/2010 for the course CS 313K taught by Professor Boyer during the Spring '08 term at University of Texas.

Ask a homework question - tutors are online