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 begin our exploration of the Haskell programming language.
Prerequisites: Tate, Sections 8.1 and 8.2.
Contents:
a. Create a directory for the lab.
b. Open a browser window on Tate's examples, in case you want to try any of them.
Explore each of Tate's Fibonacci examples and verify that they work the way you expect.
This exercise is taken from Tate.
Write a function that computes the reverse of a list.
a. Write mytake n lst, which extracts the first n
elements of a list.
b. Write mydrop n lst, which drops the first n
elements of a list.
c. Write mynth n lst, which computes the nth element of a list.
At some point, you may have noted that it's a bit strange that
fib is defined as a function, given that we normally
talk about the Fibonacci sequence. Write a recursive
definition of the sequence.
In Lazy Scheme, we might write this as
(define fib (cons 1 (cons 1 (map + fib (cdr fb)))))
You may find the following definition helpful.
module Main where map2 f [] [] = [] map2 f (x:xs) (y:ys) = (f x y):(map2 f xs ys)
This exercise is taken from Tate.
Write allEven in as many ways as you can.
This exercise is taken from Tate.
Write a list comprehension to build a childhood multiplication table. The table would be a list of three-tuples where the first two are integers from 1-12 and the third is the product of the first two.
This exercise is taken from Tate.
Write a function that builds two-tuples with all possible
combinations of two of the colors black, white, blue, yellow,
and red. Note that you should only include one of
(black, blue) and (blue, black).
If you find yourself with extra time, begin reading the next section of Tate.
Monday, 14 March 2011 [Samuel A. Rebelsky]
http://www.cs.grinnell.edu/~rebelsky/Courses/CSC302/2011S/Labs/haskell-1.html.
[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:44 2011.
The source to the document was last modified on Mon Mar 14 09:45:49 2011.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CSC302/2011S/Labs/haskell-1.html.
A PDF version of this document may be found at
http://www.cs.grinnell.edu/~rebelsky/Courses/CSC302/2011S/Labs/haskell-1.pdf
You may wish to
validate this document's HTML
;
;