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

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -