Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
JavaToScala
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
jorge.josegonc
JavaToScala
Commits
f2bca8eb
Commit
f2bca8eb
authored
4 years ago
by
geoffrey.menetrey
Browse files
Options
Downloads
Patches
Plain Diff
some more comments
parent
8a83461f
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
src/main/scala/example/Vector.scala
+9
-0
9 additions, 0 deletions
src/main/scala/example/Vector.scala
with
9 additions
and
0 deletions
src/main/scala/example/Vector.scala
+
9
−
0
View file @
f2bca8eb
...
@@ -3,10 +3,19 @@ import scala.math.sqrt
...
@@ -3,10 +3,19 @@ import scala.math.sqrt
case
class
Vector
(
var
list
:
List
[
Double
])
{
case
class
Vector
(
var
list
:
List
[
Double
])
{
// return the number of elements in the vector
val
size
=
()
=>
this
.
list
.
size
val
size
=
()
=>
this
.
list
.
size
// return the element at index i
val
get
=
(
i
:
Int
)
=>
this
.
list
(
i
)
val
get
=
(
i
:
Int
)
=>
this
.
list
(
i
)
// verify if two vectors are equals
val
equals
=
(
v
:
Vector
)
=>
this
.
list
==
v
.
list
val
equals
=
(
v
:
Vector
)
=>
this
.
list
==
v
.
list
// update an element with a value at index i
val
update
=
(
i
:
Int
,
value
:
Double
)
=>
this
.
list
=
this
.
list
.
updated
(
i
,
value
)
val
update
=
(
i
:
Int
,
value
:
Double
)
=>
this
.
list
=
this
.
list
.
updated
(
i
,
value
)
// verify if two vectors have the same size
val
sameSize
=
(
v
:
Vector
)
=>
this
.
size
()
==
v
.
size
()
val
sameSize
=
(
v
:
Vector
)
=>
this
.
size
()
==
v
.
size
()
// Add Terminal recursive
// Add Terminal recursive
...
...
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