Skip to content

Instantly share code, notes, and snippets.

@rightfold
Created September 2, 2013 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rightfold/c49d404577d84d00a809 to your computer and use it in GitHub Desktop.
Save rightfold/c49d404577d84d00a809 to your computer and use it in GitHub Desktop.
func (multiplication *Multiplication) Flatten() []Numeric {
first := multiplication.first.Simplify()
second := multiplication.second.Simplify()
result := make([]Numeric)
if m, ok := first.(*Multiplication); ok {
result = append(result, m.Flatten())
} else {
result = append(result, first)
}
if m, ok := second.(*Multiplication); ok {
result = append(result, m.Flatten())
} else {
result = append(result, second)
}
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment