The Identity Function

In mathematics, an identity function is a function that returns the arguments that are passed to it unchanged.  While the concept of an identity function is quite often useful in formulating proofs, it is not something that I ever expected to use in a programming environment.   Here's the identity function written in PowerShell:


function identity{

    return $args

}

The surprising thing about this function is that it's actually pretty useful. PowerShell's array literal syntax is considerably more involved than it's argument syntax. Using this function lets us do this:

identity arg1 arg2 arg3

instead of this:

@('arg1','arg2','arg3')