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
e788fe53
Commit
e788fe53
authored
Jun 22, 2015
by
Chinmay Garde
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor: Match style guide
parent
7eb83223
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
24 deletions
+24
-24
expression.dart
packages/cassowary/lib/expression.dart
+24
-24
No files found.
packages/cassowary/lib/expression.dart
View file @
e788fe53
...
...
@@ -17,27 +17,27 @@ class Expression extends EquationMember {
Constraint
_createConstraint
(
EquationMember
/* rhs */
value
,
Relation
relation
)
{
if
(
value
is
ConstantMember
)
{
return
new
Constraint
(
new
Expression
(
new
List
.
from
(
this
.
terms
),
this
.
constant
-
value
.
value
),
relation
);
return
new
Constraint
(
new
Expression
(
new
List
.
from
(
terms
),
constant
-
value
.
value
),
relation
);
}
if
(
value
is
Variable
)
{
var
newTerms
=
new
List
<
Term
>.
from
(
this
.
terms
)
..
add
(
new
Term
(
value
,
-
1.0
));
return
new
Constraint
(
new
Expression
(
newTerms
,
this
.
constant
),
relation
);
var
newTerms
=
new
List
<
Term
>.
from
(
terms
)..
add
(
new
Term
(
value
,
-
1.0
));
return
new
Constraint
(
new
Expression
(
newTerms
,
constant
),
relation
);
}
if
(
value
is
Term
)
{
var
newTerms
=
new
List
<
Term
>.
from
(
t
his
.
t
erms
)
var
newTerms
=
new
List
<
Term
>.
from
(
terms
)
..
add
(
new
Term
(
value
.
variable
,
-
value
.
coefficient
));
return
new
Constraint
(
new
Expression
(
newTerms
,
this
.
constant
),
relation
);
return
new
Constraint
(
new
Expression
(
newTerms
,
constant
),
relation
);
}
if
(
value
is
Expression
)
{
var
newTerms
=
value
.
terms
.
fold
(
new
List
<
Term
>.
from
(
t
his
.
t
erms
),
var
newTerms
=
value
.
terms
.
fold
(
new
List
<
Term
>.
from
(
terms
),
(
list
,
t
)
=>
list
..
add
(
new
Term
(
t
.
variable
,
-
t
.
coefficient
)));
return
new
Constraint
(
new
Expression
(
newTerms
,
this
.
constant
-
value
.
constant
),
relation
);
new
Expression
(
newTerms
,
constant
-
value
.
constant
),
relation
);
}
assert
(
false
);
...
...
@@ -55,21 +55,21 @@ class Expression extends EquationMember {
Expression
operator
+(
EquationMember
m
)
{
if
(
m
is
ConstantMember
)
{
return
new
Expression
(
new
List
.
from
(
t
his
.
terms
),
this
.
constant
+
m
.
value
);
return
new
Expression
(
new
List
.
from
(
t
erms
),
constant
+
m
.
value
);
}
if
(
m
is
Variable
)
{
return
new
Expression
(
new
List
.
from
(
t
his
.
terms
)..
add
(
new
Term
(
m
,
1.0
)),
this
.
constant
);
new
List
.
from
(
t
erms
)..
add
(
new
Term
(
m
,
1.0
)),
constant
);
}
if
(
m
is
Term
)
{
return
new
Expression
(
new
List
.
from
(
t
his
.
terms
)..
add
(
m
),
this
.
constant
);
return
new
Expression
(
new
List
.
from
(
t
erms
)..
add
(
m
),
constant
);
}
if
(
m
is
Expression
)
{
return
new
Expression
(
new
List
.
from
(
this
.
terms
)..
addAll
(
m
.
terms
),
this
.
constant
+
m
.
constant
);
return
new
Expression
(
new
List
.
from
(
terms
)..
addAll
(
m
.
terms
),
constant
+
m
.
constant
);
}
assert
(
false
);
...
...
@@ -78,24 +78,24 @@ class Expression extends EquationMember {
Expression
operator
-(
EquationMember
m
)
{
if
(
m
is
ConstantMember
)
{
return
new
Expression
(
new
List
.
from
(
t
his
.
terms
),
this
.
constant
-
m
.
value
);
return
new
Expression
(
new
List
.
from
(
t
erms
),
constant
-
m
.
value
);
}
if
(
m
is
Variable
)
{
return
new
Expression
(
new
List
.
from
(
t
his
.
terms
)..
add
(
new
Term
(
m
,
-
1.0
)),
this
.
constant
);
new
List
.
from
(
t
erms
)..
add
(
new
Term
(
m
,
-
1.0
)),
constant
);
}
if
(
m
is
Term
)
{
return
new
Expression
(
new
List
.
from
(
t
his
.
t
erms
)
..
add
(
new
Term
(
m
.
variable
,
-
m
.
coefficient
)),
this
.
constant
);
return
new
Expression
(
new
List
.
from
(
terms
)
..
add
(
new
Term
(
m
.
variable
,
-
m
.
coefficient
)),
constant
);
}
if
(
m
is
Expression
)
{
var
copiedTerms
=
new
List
<
Term
>.
from
(
t
his
.
t
erms
);
var
copiedTerms
=
new
List
<
Term
>.
from
(
terms
);
m
.
terms
.
forEach
(
(
t
)
=>
copiedTerms
.
add
(
new
Term
(
t
.
variable
,
-
t
.
coefficient
)));
return
new
Expression
(
copiedTerms
,
this
.
constant
-
m
.
constant
);
return
new
Expression
(
copiedTerms
,
constant
-
m
.
constant
);
}
assert
(
false
);
...
...
@@ -103,14 +103,14 @@ class Expression extends EquationMember {
}
EquationMember
operator
*(
double
m
)
{
var
terms
=
this
.
terms
.
fold
(
new
List
<
Term
>(),
(
list
,
term
)
=>
list
var
newTerms
=
terms
.
fold
(
new
List
<
Term
>(),
(
list
,
term
)
=>
list
..
add
(
new
Term
(
term
.
variable
,
term
.
coefficient
*
m
)));
return
new
Expression
(
terms
,
this
.
constant
*
m
);
return
new
Expression
(
newTerms
,
constant
*
m
);
}
EquationMember
operator
/(
double
m
)
{
var
terms
=
this
.
terms
.
fold
(
new
List
<
Term
>(),
(
list
,
term
)
=>
list
var
newTerms
=
terms
.
fold
(
new
List
<
Term
>(),
(
list
,
term
)
=>
list
..
add
(
new
Term
(
term
.
variable
,
term
.
coefficient
/
m
)));
return
new
Expression
(
terms
,
this
.
constant
/
m
);
return
new
Expression
(
newTerms
,
constant
/
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