Computer Science Fundamentals (CS153 2004S)
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[Instructions]
[Links]
[Search]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[Experiments in Java]
[Java API]
[Scheme Reference]
[Scheme Report]
[CS153 2003S]
[CS151 2003F]
[CS152 2000F]
[SamR]
Assigned: Thursday, 29 January 2004
Due: 10:00 a.m., Wednesday, 4 February 2004
No extensions!
Summary: In this assignment, you will develop a procedure that computes the type of a Scheme value.
Purposes: To give experience writing procedures that use conditionals and recursion. To help you think further about Scheme's type system.
Collaboration: Although you may discuss this assignment with your colleagues, and even get help debugging, each student should write his or her own program. If you receive help from anyone, you should clearly document that help.
Helpful References:
Turning it in: Email me your answers.
You have learned a number of types in Scheme already, including lists, procedures, Boolean values, symbolic values, and a host of numeric types. Many Scheme programmers, but particularly beginning Scheme programmers, benefit from learning the type of a value.
Write and test a Scheme procedure, type, that returns the a symbol
that represents the narrowest possible interpretation of the type of its
argument. If the argument is a list, you should determine
if all the component values are the same basic type. If so,
return the symbol list-of-type. If not, return
heterogeneous-list. Classify exact non-integer real and
rational numbers as rational. Classify inexact non-integer real and
rational numbers as real.
For example,
> (type 3) integer > (type 3.0) real > (type 3.5) real > (type 7/2) rational > (type (list 1 2 3)) list-of-integer > (type 'one) symbol > (type (list 'one)) list-of-symbol > (type (list 1 'one)) heterogeneous-list > (type "hello") string > (type 'type) symbol > (type type) procedure
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[Instructions]
[Links]
[Search]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[Experiments in Java]
[Java API]
[Scheme Reference]
[Scheme Report]
[CS153 2003S]
[CS151 2003F]
[CS152 2000F]
[SamR]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Fri May 7 09:44:06 2004.
The source to the document was last modified on Wed Jan 28 20:45:48 2004.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS153/2004S/Homework/hw.02.html.
You may wish to
validate this document's HTML
;
;
Check with Bobby