Skip to content

Commit 5930a8d

Browse files
committed
add sig/fibonacci.rbs
1 parent 3f8d102 commit 5930a8d

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Steepfile

+2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ target :lib do
88
check "lib/compsci/byte_pack.rb"
99
check "lib/compsci/collatz.rb"
1010
check "lib/compsci/elo.rb"
11+
check "lib/compsci/fibonacci.rb"
1112

1213
# library "pathname" # Standard libraries
1314
# library "strong_json" # Gems
1415

1516
library "zlib"
17+
# library "matrix"
1618

1719
# configure_code_diagnostics(D::Ruby.strict)
1820
end

lib/compsci/fibonacci.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def self.dynamic(n)
2727

2828
# https://ianthehenry.com/posts/fibonacci/
2929
def self.matrix(n)
30-
(Matrix[[1, 1], [1, 0]] ** n.pred)[0, 0]
30+
(Matrix[[1, 1], [1, 0]] ** n.pred)[0, 0] # steep:ignore
3131
end
3232
end
3333
end

sig/fibonacci.rbs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module CompSci
2+
module Fibonacci
3+
def self.classic: (Integer n) -> Integer
4+
def self.cache_recursive: (Integer n, ?Hash[Integer, Integer] cache) ->
5+
Integer
6+
def self.cache_iterative: (Integer n) -> Integer
7+
def self.dynamic: (Integer n) -> Integer
8+
def self.matrix: (Integer n) -> Integer
9+
end
10+
end

0 commit comments

Comments
 (0)