First order array difference in Ruby -


What is the hottest, most popular way to do this?

  should produce [1, 3, 10, 5] .diff  

  [2, 7 , -5]  

That is, an array of first order difference I have come up with a solution that I will add below, but it requires 1.9 and it's not all clever. And what is possible?

Yet another way ... looks so far at least :)

< Pre> module enfamous def deff self [1 ..- 1]. Zip (self) .map {| X | X [0] -X [1]} End End

Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -