What are Python's equivalent of the following (Javascript):
function wordParts (currentPart, lastPart) {
return currentPart+lastPart;
}
word = ['Che', 'mis', 'try'];
console.log(word.reduce(wordParts))
and this:
var places = [
{name: 'New York City', state: 'New York'},
{name: 'Oklahoma City', state: 'Oklahoma'},
{name: 'Albany', state: 'New York'},
{name: 'Long Island', state: 'New York'},
]
var newYork = places.filter(function(x) { return x.state === 'New York'})
console.log(newYork)
lastly, this:
function greeting(name) {
console.log('Hello ' + name + '. How are you today?');
}
names = ['Abby', 'Cabby', 'Babby', 'Mabby'];
var greet = names.map(greeting)
Thanks all!
reduce,map, andfilter:P unless you're in python3, in which case it'sfunctools.reduceSee here: docs.python.org/2/library/functions.htmlArray.prototype.map; you should instead useArray.prototype.forEachor;[].forEach.callmapandfilter, these days. So it looks like[mutate(x) for x in list if x > 10]