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
f75eaf04
Commit
f75eaf04
authored
5 years ago
by
Nicolas Alexander Stucki
Browse files
Options
Downloads
Patches
Plain Diff
Use traits
parent
e429b9a2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
recitation-sessions/recitation-session-3.md
+2
-2
2 additions, 2 deletions
recitation-sessions/recitation-session-3.md
with
2 additions
and
2 deletions
recitation-sessions/recitation-session-3.md
+
2
−
2
View file @
f75eaf04
...
...
@@ -16,7 +16,7 @@ Note that the above defines a total order.
Here is the structure we will be using for implementing these trees:
```
scala
abstract
class
Tree
[
T
]
{
...
}
trait
Tree
[
T
]
{
...
}
case
class
EmptyTree
[
T
](
leq
:
(
T
,
T
)
=>
Boolean
)
extends
Tree
[
T
]
{
...
}
case
class
Node
[
T
](
left
:
Tree
[
T
],
elem
:
T
,
right
:
Tree
[
T
],
leq
:
(
T
,
T
)
=>
Boolean
)
extends
Tree
[
T
]
{
...
}
...
...
@@ -39,7 +39,7 @@ Given only `leq` for comparison, how can you test for equality? How about strict
Define the size method on
`Tree[T]`
, which returns its size, i.e. the number of Nodes in the tree.
```
scala
abstract
class
Tree
[
T
]
{
trait
Tree
[
T
]
{
def
size
:
Int
...
}
...
...
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