Forward difference: Difference between revisions
Content added Content deleted
No edit summary |
(→{{header|Haskell}}: Added type signatures, main. Minor tidying) |
||
Line 1,222: | Line 1,222: | ||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
<lang haskell>forwardDifference |
<lang haskell>forwardDifference :: Num a => [a] -> [a] |
||
forwardDifference = tail >>= zipWith (-) |
|||
nthForwardDifference |
nthForwardDifference :: Num a => [a] -> Int -> [a] |
||
nthForwardDifference = (!!) . iterate forwardDifference |
|||
main :: IO () |
|||
⚫ | |||
main = |
|||
⚫ | |||
mapM_ print $ |
|||
[-43,11,-29,-7,10,23,-50,50,18], |
|||
⚫ | |||
[54,-40,22,17,13,-73,100,-32], |
|||
{{Out}} |
|||
⚫ | |||
⚫ | |||
⚫ | |||
[-43,11,-29,-7,10,23,-50,50,18] |
|||
[54,-40,22,17,13,-73,100,-32] |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
[-223,68,-83,341,-564] |
|||
⚫ | |||
[291,-151,424,-905] |
|||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|HicEst}}== |
=={{header|HicEst}}== |