Python oneliner to differentiate polynomial list

From wikiluntti
Revision as of 11:39, 5 August 2021 by Mol (talk | contribs) (Created page with "== Introduction == Oneliners are powerful and often beautiful solutions to programming challenges (see [https://www.ee.columbia.edu/~marios/matlab/Matlab%20array%20manipulati...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Introduction

Oneliners are powerful and often beautiful solutions to programming challenges (see Acklamization).

Theory

  1. D(poly) = 2*0 + 3*1 + 5*2 + 1*3
  2. Dpoly = [3, 10, 3]


<syntaxhighlight lang="Python"> poly = [2, 3, 5, 1] # Degrees starting from zero

print( [(i+1)*j for i,j in enumerate( poly[1:] )] ) <syntaxhighlight>