[swift-users] A protocol-oriented numerics library
Xiaodi Wu
xiaodi.wu at gmail.com
Fri Jun 9 20:18:04 CDT 2017
Hi all,
A few weeks ago, Joe Groff challenged users on Twitter to create a
Rational<T> type making use of the new integer protocols implemented for
Swift 4. As it happens, I'd already started a project to try out these new
number protocols. Now that I think the most embarrassing bugs have been
squashed in that project, I thought I'd share it here in case anyone else
might find it useful.
NumericAnnex <https://github.com/xwu/NumericAnnex> is meant to supplement
the standard library's numerics facilities in Swift 4. At the moment, it
provides:
* Extensions to BinaryInteger for GCD, LCM, and exponentiation
* Protocols Math (refines SignedNumeric), Real (refines Math and
FloatingPoint), and PRNG (refines Sequence and IteratorProtocol)
* Types Complex<T>, Rational<T>, and Random
Documentation is available at <https://xwu.github.io/NumericAnnex/>.
I'd love to hear feedback. I'll follow up shortly on Swift Evolution with
some thoughts on future improvements to integer protocols based on this
experience.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170609/c6787ea8/attachment.html>
More information about the swift-users
mailing list