@@ -42,7 +42,7 @@ def merge(left, right)
4242 end
4343
4444 def states
45- ( @table . keys + @table . values . map ( &:keys ) . flatten ) . uniq
45+ ( @table . keys + @table . values . flat_map ( &:keys ) ) . uniq
4646 end
4747
4848 # Returns a generalized transition graph with reduced states. The states
@@ -93,7 +93,7 @@ def generalized_table
9393 # Returns set of NFA states to which there is a transition on ast symbol
9494 # +a+ from some state +s+ in +t+.
9595 def following_states ( t , a )
96- Array ( t ) . map { |s | inverted [ s ] [ a ] } . flatten . uniq
96+ Array ( t ) . flat_map { |s | inverted [ s ] [ a ] } . uniq
9797 end
9898
9999 # Returns set of NFA states to which there is a transition on ast symbol
@@ -107,7 +107,7 @@ def move(t, a)
107107 end
108108
109109 def alphabet
110- inverted . values . map ( &:keys ) . flatten . compact . uniq . sort_by { |x | x . to_s }
110+ inverted . values . flat_map ( &:keys ) . compact . uniq . sort_by { |x | x . to_s }
111111 end
112112
113113 # Returns a set of NFA states reachable from some NFA state +s+ in set
@@ -131,9 +131,9 @@ def eclosure(t)
131131 end
132132
133133 def transitions
134- @table . map { |to , hash |
134+ @table . flat_map { |to , hash |
135135 hash . map { |from , sym | [ from , sym , to ] }
136- } . flatten ( 1 )
136+ }
137137 end
138138
139139 private
0 commit comments