changed docs to use lambdas in examples to show shorter code

switched to lambda to show more concise code in documentation.