Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
7eb83223
Commit
7eb83223
authored
Jun 22, 2015
by
Chinmay Garde
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dry up multiplication and division of equation members
parent
5288d466
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
6 additions
and
27 deletions
+6
-27
constant_member.dart
packages/cassowary/lib/constant_member.dart
+0
-8
equation_member.dart
packages/cassowary/lib/equation_member.dart
+4
-0
expression.dart
packages/cassowary/lib/expression.dart
+2
-3
term.dart
packages/cassowary/lib/term.dart
+0
-8
variable.dart
packages/cassowary/lib/variable.dart
+0
-8
No files found.
packages/cassowary/lib/constant_member.dart
View file @
7eb83223
...
...
@@ -9,14 +9,6 @@ class ConstantMember extends EquationMember {
ConstantMember
(
this
.
value
);
Expression
asExpression
()
=>
new
Expression
([],
this
.
value
);
EquationMember
operator
*(
double
m
)
{
return
new
ConstantMember
(
this
.
value
*
m
);
}
EquationMember
operator
/(
double
m
)
{
return
new
ConstantMember
(
this
.
value
/
m
);
}
}
ConstantMember
CM
(
num
value
)
{
...
...
packages/cassowary/lib/equation_member.dart
View file @
7eb83223
...
...
@@ -16,4 +16,8 @@ abstract class EquationMember {
Expression
operator
+(
EquationMember
m
)
=>
asExpression
()
+
m
;
Expression
operator
-(
EquationMember
m
)
=>
asExpression
()
-
m
;
Expression
operator
*(
double
m
)
=>
asExpression
()
*
m
;
Expression
operator
/(
double
m
)
=>
asExpression
()
/
m
;
}
packages/cassowary/lib/expression.dart
View file @
7eb83223
...
...
@@ -105,13 +105,12 @@ class Expression extends EquationMember {
EquationMember
operator
*(
double
m
)
{
var
terms
=
this
.
terms
.
fold
(
new
List
<
Term
>(),
(
list
,
term
)
=>
list
..
add
(
new
Term
(
term
.
variable
,
term
.
coefficient
*
m
)));
return
new
Expression
(
terms
,
this
.
constant
);
return
new
Expression
(
terms
,
this
.
constant
*
m
);
}
// TODO(csg): Figure out how to dry this up.
EquationMember
operator
/(
double
m
)
{
var
terms
=
this
.
terms
.
fold
(
new
List
<
Term
>(),
(
list
,
term
)
=>
list
..
add
(
new
Term
(
term
.
variable
,
term
.
coefficient
/
m
)));
return
new
Expression
(
terms
,
this
.
constant
);
return
new
Expression
(
terms
,
this
.
constant
/
m
);
}
}
packages/cassowary/lib/term.dart
View file @
7eb83223
...
...
@@ -13,12 +13,4 @@ class Term extends EquationMember {
Expression
asExpression
()
=>
new
Expression
([
new
Term
(
this
.
variable
,
this
.
coefficient
)],
0.0
);
EquationMember
operator
*(
double
m
)
{
return
new
Term
(
this
.
variable
,
this
.
coefficient
*
m
);
}
EquationMember
operator
/(
double
m
)
{
return
new
Term
(
this
.
variable
,
this
.
coefficient
/
m
);
}
}
packages/cassowary/lib/variable.dart
View file @
7eb83223
...
...
@@ -9,12 +9,4 @@ class Variable extends EquationMember {
Variable
(
this
.
value
);
Expression
asExpression
()
=>
new
Expression
([
new
Term
(
this
,
1.0
)],
0.0
);
EquationMember
operator
*(
double
m
)
{
return
new
Term
(
this
,
m
);
}
EquationMember
operator
/(
double
m
)
{
return
new
Term
(
this
,
1.0
/
m
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment