Skip to content

Implement average() for more numeric types #36

@knothed

Description

@knothed

Currently, func average() -> Double is defined as an extension on Collection where Element == Double. What about CGFloats?

I suggest to add a protocol Field (based on algebraic fields) providing addition, multiplication and division with Self elements, and also a zero and one element. This would allow both average() and sum() to be implemented more generically. Double, Float and CGFloat could conform to this protocol (with nearly no additional implementation effort).

The integer case would have to be treated specially though.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions