Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2XB3FinalProject
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Insights
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
Christopher Schankula
2XB3FinalProject
Commits
dde16d49
Commit
dde16d49
authored
7 years ago
by
Christopher Schankula
Browse files
Options
Downloads
Patches
Plain Diff
example of parameterized lambda functions
parent
9daad8b8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sandbox/GeneralCompare.java
+5
-0
5 additions, 0 deletions
src/sandbox/GeneralCompare.java
src/sandbox/TestLambdas.java
+11
-6
11 additions, 6 deletions
src/sandbox/TestLambdas.java
with
16 additions
and
6 deletions
src/sandbox/GeneralCompare.java
0 → 100644
+
5
−
0
View file @
dde16d49
package
sandbox
;
public
interface
GeneralCompare
<
T
>
{
public
int
eval
(
T
a1
,
T
a2
);
}
This diff is collapsed.
Click to expand it.
src/sandbox/TestLambdas.java
+
11
−
6
View file @
dde16d49
...
...
@@ -7,9 +7,9 @@ package sandbox;
public
class
TestLambdas
{
public
static
void
main
(
String
[]
args
)
{
//declare the instances of BinaryIntExpression
BinaryIntExpression
b0
;
BinaryIntExpression
b1
;
BinaryIntExpression
b2
;
GeneralCompare
<
Integer
>
b0
;
GeneralCompare
<
Integer
>
b1
;
GeneralCompare
<
Integer
>
b2
;
BinaryIntExpression
b3
;
BinaryIntExpression
b4
;
BinaryIntExpression
b5
;
...
...
@@ -34,13 +34,13 @@ public class TestLambdas {
};
//call the main function using the instances as a parameter.
result
=
binaryOperation
(
1
,
2
,
b0
);
result
=
binary
Integer
Operation
(
1
,
2
,
b0
);
System
.
out
.
println
(
result
);
result
=
binaryOperation
(
1
,
2
,
b1
);
result
=
binary
Integer
Operation
(
1
,
2
,
b1
);
System
.
out
.
println
(
result
);
result
=
binaryOperation
(
1
,
2
,
b2
);
result
=
binary
Integer
Operation
(
1
,
2
,
b2
);
System
.
out
.
println
(
result
);
result
=
binaryOperation
(
1
,
2
,
b3
);
...
...
@@ -61,4 +61,9 @@ public class TestLambdas {
return
exp
.
eval
(
a1
,
a2
);
}
public
static
int
binaryIntegerOperation
(
int
a1
,
int
a2
,
GeneralCompare
<
Integer
>
exp
)
{
//call the eval() function in the given BinaryIntExpression.
return
exp
.
eval
(
a1
,
a2
);
}
}
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