Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
7
Task/Forward-difference/Ruby/forward-difference-1.rb
Normal file
7
Task/Forward-difference/Ruby/forward-difference-1.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
def dif(s)
|
||||
s.each_cons(2).collect { |x, y| y - x }
|
||||
end
|
||||
|
||||
def difn(s, n)
|
||||
n.times.inject(s) { |s, | dif(s) }
|
||||
end
|
||||
2
Task/Forward-difference/Ruby/forward-difference-2.rb
Normal file
2
Task/Forward-difference/Ruby/forward-difference-2.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
p dif([1, 23, 45, 678]) # => [22, 22, 633]
|
||||
p difn([1, 23, 45, 678], 2) # => [0, 611]
|
||||
Loading…
Add table
Add a link
Reference in a new issue