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
a6459cb7
Commit
a6459cb7
authored
7 years ago
by
Christopher Schankula
Browse files
Options
Downloads
Patches
Plain Diff
a few more examples
parent
5049201a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sandbox/TestLambdas.java
+14
-2
14 additions, 2 deletions
src/sandbox/TestLambdas.java
with
14 additions
and
2 deletions
src/sandbox/TestLambdas.java
+
14
−
2
View file @
a6459cb7
...
...
@@ -12,6 +12,8 @@ public class TestLambdas {
BinaryIntExpression
b2
;
BinaryIntExpression
b3
;
BinaryIntExpression
b4
;
BinaryIntExpression
b5
;
BinaryIntExpression
b6
;
int
result
;
//specify the instances of the functions (these implicitly become the "eval()" function)
...
...
@@ -20,10 +22,14 @@ public class TestLambdas {
b1
=
(
a1
,
a2
)
->
a1
-
a2
;
b2
=
(
a1
,
a2
)
->
a1
*
a2
;
b3
=
(
a1
,
a2
)
->
a1
/
a2
;
b4
=
(
a1
,
a2
)
->
12
*
2
+
46
;
//multi-line examples
b4
=
(
a1
,
a2
)
->
{
b5
=
(
a1
,
a2
)
->
{
return
a1
+
a2
;
};
b6
=
(
a1
,
a2
)
->
{
int
n
=
a1
*
a2
;
n
=
n
*
a1
+
a2
;
n
=
n
*
a1
+
2
*
a2
;
return
n
;
};
...
...
@@ -42,6 +48,12 @@ public class TestLambdas {
result
=
binaryOperation
(
1
,
2
,
b4
);
System
.
out
.
println
(
result
);
result
=
binaryOperation
(
1
,
2
,
b5
);
System
.
out
.
println
(
result
);
result
=
binaryOperation
(
1
,
2
,
b6
);
System
.
out
.
println
(
result
);
}
public
static
int
binaryOperation
(
int
a1
,
int
a2
,
BinaryIntExpression
exp
)
{
...
...
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