Computer Science, Programming, Python, Udacity Udacity – Intro to Computer Science – Python – Mean of Numbers April 6, 2015 Johnny 2 Comments Share this:EmailFacebookTumblrTwitterLinkedInMoreRedditPinterestPocketPrint
If I knew lambda back then I would definitely use lambda – so yes great nice short code thanks! (it was only a year later I posted this I learnt about the JavaScript map, filter, and reduce – and then functional programming.)
How about using lambda for this?
def list_mean(p): return (reduce(lambda x,y: x+y*1.0, p)/len(p))If I knew lambda back then I would definitely use lambda – so yes great nice short code thanks! (it was only a year later I posted this I learnt about the JavaScript map, filter, and reduce – and then functional programming.)