Add code + a few extra comments from the scalar UDF examples in the

docs. Didn't do extra testing, just reused the code straight from
the docs with 2-space indentation.

High probability that I'll get dinged for using BSD brace style and comment lines > 90 characters.