Programming Languages (CS302 2006S)
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[Instructions]
[Links]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[SamR]
[CSC302 1999S]
Back to Logic Programming (3). On to Haskell (2).
Held: Monday, April 24, 2006
Summary: Today we begin our exploration of Haskell, a typeful, lazy, pure functional programming language.
Related Pages:
Notes:
Overview:
http://haskell.org/
. The
Gentle Introduction to Haskell at
http://haskell.org/tutorial/index.html
is a good place to start learning the stuff that I don't teach you.
ghci
to run Haskell.
f a
represents
"apply f to a".
f a b
is
"apply f to a; apply the resulting function to b".
f (a b)
.
a + b
.
data
keyword, using
the form
data Typename = Definition
fact n = if (n == 0) then 1 else n * (fact (n - 1))
fact :: Int -> Int
[4, 2, 4, 1]
factorial :: Int -> Int factorial 0 = 1 factorial n = n * (fact (n-1))
if
(I'm writing it as iif so that
we don't collide with the built-in version.)
iif :: Bool -> a -> a -> a iif True x y = x iif False x y = y
Back to Logic Programming (3). On to Haskell (2).
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[Instructions]
[Links]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[SamR]
[CSC302 1999S]
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 Wed May 10 09:03:04 2006.
The source to the document was last modified on Thu Jan 12 09:00:38 2006.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS302/2006S/Outlines/outline.34.html
.
You may wish to
validate this document's HTML
;
;
Check with Bobby