CSC302 2011S Programming Languages
[Skip to Body]
Admin:
[Front Door]
[Schedule]
[Handouts]
[Honesty]
[Piazzza]
Current:
[Current Outline]
[Current EBoard]
[Current Assignment]
[Current Lab]
[Current Reading]
Groupings:
[Assignments]
[EBoards]
[Examples]
[Exams]
[Handouts]
[Labs]
[Outlines]
[Readings]
[Reference]
Languages:
[Clojure]
[Erlang]
[Haskell]
[Io]
[Prolog (GNU)]
[Ruby]
[Scala]
Misc:
[SamR]
[CSC302 2007S]
[7L7W]
Summary: We continue our exploration of the Io programming language.
Prerequisites: The first Io lab. Section 3.3 of Tate.
Contents:
a. Create a directory for the lab.
b. Verify that Io is installed on the workstation you're using. If not, you can ssh to church, where it's installed.
Io is a bit less friendly than Ruby in its provision of methods. For example, if I wanted to find what slots are available for an integer, I might write
Io> 0 slotNames ==> list()
As this suggests, the results are not necessarily as helpful as
possible. Add a method, slots, that gives more useful
results.
Override the + operator so that it does subtraction
rather than addition.
The average message averages a list of numbers. But
what if we have a heterogeneous list? Write a method, aveNums,
that averages all numbers in a list. (You may want to explore the list
methods to figure out how to extract parts of a list.)
This problem is based upon a problem from Tate.
Write a program that averages all the numbers in a two dimensional heterogeneous array.
This problem is based upon a problem from Tate.
a. Add three operators, a, b, and c,
with places 0, 1, and 2. E.g.,
Io> OperatorTable addOperator("a", 0)
b. Define them as follows.
Io> Number a := method(x, self * 2 + x) Io> Number b := method(x, self + x * 2) Io> Number c := method(x, self - x)
c. Predict the values of the following:
1 a 1
1 b 1
1 c 1
1 c 1 b 1 a 1
d. Check your answer experimentlaly.
e. Change the level of a to 2.
f. Predict the value of the following:
1 c 1 b 1 a 1
g. Check your answer experimentally.
Right now, Io's division operation returns Inf when the
divisor is 0. Rewrite it to return 0 if the divisor is 0.
This problem is taken from Tate. I will admit that I am not quite sure how to solve it.
[Skip to Body]
Admin:
[Front Door]
[Schedule]
[Handouts]
[Honesty]
[Piazzza]
Current:
[Current Outline]
[Current EBoard]
[Current Assignment]
[Current Lab]
[Current Reading]
Groupings:
[Assignments]
[EBoards]
[Examples]
[Exams]
[Handouts]
[Labs]
[Outlines]
[Readings]
[Reference]
Languages:
[Clojure]
[Erlang]
[Haskell]
[Io]
[Prolog (GNU)]
[Ruby]
[Scala]
Misc:
[SamR]
[CSC302 2007S]
[7L7W]
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 Mon Apr 25 08:06:48 2011.
The source to the document was last modified on Fri Feb 4 08:47:05 2011.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CSC302/2011S/Labs/io-2.html.
A PDF version of this document may be found at
http://www.cs.grinnell.edu/~rebelsky/Courses/CSC302/2011S/Labs/io-2.pdf
You may wish to
validate this document's HTML
;
;