Tags
agent ajax API automation backup books C cron currying databases dns emacs event handler exersize exim F# facebook find firefox functional programming Google hadoop hadoop-streaming http installation java javascript jython languages linux lwp makefile map MSSQL mysql Nagios NLP nrpe one-liner Open Library perl php Programming proxy python randomization recursion regex resources sorting ssh stanford parser testing thumbnails time & dates ubuntu vim Wordpress
Using reduce in Python.
Python has a built in operator called reduce. This is just another name for what a functional programmer would called a fold. They’re really useful, but you don’t know so until you actually need one. The easiest example to understand is listed below and is the same example provided on Python’s documentation.
Think of acc as the ‘accumulator’. This is the value that is threaded into each add operation, literally accumulating whatever your function is doing. They’re fun an make your code readable and concise.