Permalink
Browse files

Code style.

  • Loading branch information...
1 parent eaa84d4 commit 5f650f5264e11a6ff8f1f802678da2ffca7905e9 @blambeau committed Jul 17, 2012
Showing with 3 additions and 17 deletions.
  1. +1 −3 lib/stamina-core/stamina/automaton.rb
  2. +2 −14 lib/stamina-core/stamina/automaton/state.rb
View
4 lib/stamina-core/stamina/automaton.rb
@@ -763,9 +763,7 @@ def to_valid_edge_data(data)
# Returns true if the automaton is deterministic, false otherwise
def deterministic?
- if @deterministic.nil?
- @deterministic = @states.all?{|s| s.deterministic?}
- end
+ @deterministic = @states.all?{|s| s.deterministic?} if @deterministic.nil?
@deterministic
end
View
16 lib/stamina-core/stamina/automaton/state.rb
@@ -182,21 +182,9 @@ def delta(symbol)
target = dfa_delta(symbol)
target.nil? ? [] : [target]
else
- # 1) first compute epsilon closure of self
at_epsilon = epsilon_closure
-
- # 2) now, look where we can go from there
- at_espilon_then_symbol = at_epsilon.collect do |s|
- s.step(symbol)
- end.flatten.uniq
-
- # 3) look where we can go from there using epsilon
- result = at_espilon_then_symbol.collect do |s|
- s.epsilon_closure
- end.flatten.uniq
-
- # return result as an array
- result
+ at_espilon_then_symbol = at_epsilon.map{|s| s.step(symbol)}.flatten.uniq
+ at_espilon_then_symbol.map{|s| s.epsilon_closure}.flatten.uniq
end
end

0 comments on commit 5f650f5

Please sign in to comment.