Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
@200_success: A & S 26.2.17 explicitly says the valid inputs are non-negative. The code shouldn't be called with negative values, and in an environment where invalid calls are likely, maybe it should include a check. The error bound is listed as 7.5 * 10 ** -8. Is the accuracy specified somehow for math.erfc? I'm not suggesting either algorithm is better or worse, I'm just saying the tradeoffs should be understood in the context of the problem being solved.
Use caution before changing to a different algorithm to do the "same" calculation. Of the 8 or so different approximations in Abramowitz and Stegun (A & S) for the normal distribution function, somebody picked this particular approximation. There might have been a very good reason for the choice. Don't assume an off-the-shelf library function will give adequate accuracy for the problem at hand, unless you take the time to understand the ugly details of the calculation. People who rummage around in A & S tend not to be casual users; accuracy and error bounds may be very important.
I echo nhgrif's question... if the array elements are single characters, this implementation is really overkill. You should use an NSMutableString, or just a C string, in that case. You could improve the question by adding sample code that calls your permute method.
strtok_r also modifies the input string. I don't have a suggested one-size-fits-all replacement to suggest; it depends on the situation. In this case, I might start with sscanf to find one integer at a time from the string.
I would explore having your init function return an optional Fraction, with a nil value when the denominator is 0. Fraction(numerator:1, denominator:0) should NOT just silently return a Fraction object that is invalid and will cause trouble later. Swift's optionals seem tailor-made to handle this situation.