HtDP Problem Set | Section 15 |
The following set of problems deal with taxonomic classification. Organisms are classified according to a heirarchy of types such as kingdom, phylum, and so on. These types have associated names, for example the kingdom "Plantae" representing plants. Humans are categorized in the kingdom "Animalia" and have the genus "Homo" and the species "Sapien". Use a biology textbook or other reference to create some example classifications.
A T-node (taxonomic node) is one of Level or empty A Level is a structure (make-level Type Symbol List-of-T-node) (define-struct level (type name children)) A Type is one of 'kingdom 'phylum 'class 'order 'family 'genus 'species A List-of-T-node is one of empty (cons T-node List-of-T-node)Develop the function child-names. The function consumes the name of a Level and a T-node and returns a list of names of the Level's immediate children.
Develop the function is-classified?. The function consumes a Type, a string representing the name of the Type, and a T-node and determines whether or not the name occurs with that Type in the tree.
Develop the function get-type. The function consumes a string representing the name of a Type and a T-node and returns the first Type associated with that name or false if no Types are associated with it.
Develop the function get-all-of-type. The function consumes a Type and a T-node and returns a list of names associated with that Type in the tree.
Develop the function get-species-under-type. The function consumes a Type, a string representing the Type's associated name, and a T-node then returns all species' names classified under that name. Hint: use the function from the previous problem to help you.
Jamie Raymond | Matthias Felleisen |
01 december 2003 |