Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CS-210 Functional Programming 2019
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taha Zakariya
CS-210 Functional Programming 2019
Commits
e7c8dc94
Commit
e7c8dc94
authored
5 years ago
by
Julien Richard-Foy
Browse files
Options
Downloads
Patches
Plain Diff
Fixes to progfun1-week4
parent
f75eaf04
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
slides/sources/progfun1-4-3.md
+4
-4
4 additions, 4 deletions
slides/sources/progfun1-4-3.md
slides/sources/progfun1-4-4.md
+2
-2
2 additions, 2 deletions
slides/sources/progfun1-4-4.md
slides/sources/progfun1-4-5.md
+5
-5
5 additions, 5 deletions
slides/sources/progfun1-4-5.md
with
11 additions
and
11 deletions
slides/sources/progfun1-4-3.md
+
4
−
4
View file @
e7c8dc94
...
...
@@ -60,10 +60,10 @@ For instance, the `Student` type expands to something like:
}
~~~
Relationship With Case Classes(2)
================================
Comparison With Object Oriented Decomposition
================================
=============
Case classes
and algebraic data types are
very similar
.
OO decomposition
and algebraic data types are
two ways of defining types and operations
.
When should you use one or the other?
...
...
@@ -72,7 +72,7 @@ Use an algebraic data type to model
-
a type with a fixed number of alternatives, where
-
all alternatives are pure data types that do not contain methods.
Use a hierarchy with
classes or case
classes, if
Use a hierarchy with classes, if
-
The set of alternatives is open, i.e. new alternatives can be added after the fact, or
-
Alternatives are complex, consisting of methods as well as parameters.
...
...
This diff is collapsed.
Click to expand it.
slides/sources/progfun1-4-4.md
+
2
−
2
View file @
e7c8dc94
...
...
@@ -79,7 +79,7 @@ Like classes, functions can have type parameters.
For instance, here is a function that creates a list consisting of a single element.
def singleton[T](elem: T) =
Cons
[T](elem,
Nil
[T]())
def singleton[T](elem: T) =
Node
[T](elem,
Empty
[T]())
We can then write:
...
...
@@ -139,4 +139,4 @@ Elements are numbered from 0.
If index is outside the range from
`0`
up the the length of the list minus one, a
`IndexOutOfBoundsException`
should be thrown.
\q
uiz
\ No newline at end of file
\q
uiz
This diff is collapsed.
Click to expand it.
slides/sources/progfun1-4-5.md
+
5
−
5
View file @
e7c8dc94
...
...
@@ -120,10 +120,10 @@ To see why, consider the Java code below.
\b
egin{lstlisting}
NonEmpty[] a = new NonEmpty[]{
new NonEmpty(1, new Empty(), new Empty())}
IntSet[] b = a
b[0] = new Empty()
NonEmpty s = a[0]
new NonEmpty(1, new Empty(), new Empty())}
;
IntSet[] b = a
;
b[0] = new Empty()
;
NonEmpty s = a[0]
;
\e
nd{lstlisting}
It looks like we assigned in the last line an
`Empty`
set to a
...
...
@@ -172,4 +172,4 @@ When you try out this example, what do you observe?
\\
\v
erb
` O `
& A program that compiles and runs without exception
\e
nd{tabular}
->
\q
uiz
\ No newline at end of file
\q
uiz
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment