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
495846e6
Commit
495846e6
authored
7 years ago
by
Christopher Schankula
Browse files
Options
Downloads
Patches
Plain Diff
example of using lambda functions with a class
parent
84f94a6a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+2
-1
2 additions, 1 deletion
.gitignore
src/sandbox/BinaryIntExpression.java
+5
-0
5 additions, 0 deletions
src/sandbox/BinaryIntExpression.java
src/sandbox/TestLambdas.java
+42
-0
42 additions, 0 deletions
src/sandbox/TestLambdas.java
with
49 additions
and
1 deletion
.gitignore
+
2
−
1
View file @
495846e6
...
...
@@ -5,4 +5,5 @@
*.aux
*.bbl
*.blg
*DS_STORE*
*DS_Store*
*.csv
This diff is collapsed.
Click to expand it.
src/sandbox/BinaryIntExpression.java
0 → 100644
+
5
−
0
View file @
495846e6
package
sandbox
;
public
interface
BinaryIntExpression
{
public
int
eval
(
int
a1
,
int
a2
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/sandbox/TestLambdas.java
0 → 100644
+
42
−
0
View file @
495846e6
package
sandbox
;
public
class
TestLambdas
{
public
static
void
main
(
String
[]
args
)
{
BinaryIntExpression
b0
;
BinaryIntExpression
b1
;
BinaryIntExpression
b2
;
BinaryIntExpression
b3
;
BinaryIntExpression
b4
;
int
result
;
b0
=
(
a1
,
a2
)
->
a1
+
a2
;
b1
=
(
a1
,
a2
)
->
a1
-
a2
;
b2
=
(
a1
,
a2
)
->
a1
*
a2
;
b3
=
(
a1
,
a2
)
->
a1
/
a2
;
b4
=
(
a1
,
a2
)
->
{
int
n
=
a1
*
a2
;
n
=
n
*
a1
+
a2
;
return
n
;
};
result
=
binaryOperation
(
1
,
2
,
b0
);
System
.
out
.
println
(
result
);
result
=
binaryOperation
(
1
,
2
,
b1
);
System
.
out
.
println
(
result
);
result
=
binaryOperation
(
1
,
2
,
b2
);
System
.
out
.
println
(
result
);
result
=
binaryOperation
(
1
,
2
,
b3
);
System
.
out
.
println
(
result
);
result
=
binaryOperation
(
1
,
2
,
b4
);
System
.
out
.
println
(
result
);
}
public
static
int
binaryOperation
(
int
a1
,
int
a2
,
BinaryIntExpression
exp
)
{
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