Snippets tagged generic functions

  • Pex4fun - Merging strings

    A random pex4fun puzzle to write a snippet to merge two strings.

    2 people like this

    Posted: 8 years ago by Joel Huang

  • Exponentiation by squaring

    Function, what calculates x^n by non-recursive basic exponentiation squaring algorithm. This method uses the bits of the exponent to determine computing powers. Generic parameter x suitable for any type what supports multiplication. I do not suppose existence of inverse operator like "/", thus parameter n must be a positive integer only. It is not difficult to define an extended variant for a type what supports division.

    3 people like this

    Posted: 10 months ago by Pavel Tatarintsev