: find-transitions ( dfa-state nfa -- next-dfa-state )
transitions>>
'[ _ at keys [ condition-states ] map concat ] gather
- [ tagged-epsilon? not ] filter ;
+ [ tagged-epsilon? ] reject ;
: add-todo-state ( state visited-states new-states -- )
- 3dup drop key? [ 3drop ] [
- [ conjoin ] [ push ] bi-curry* bi
- ] if ;
+ 2over ?adjoin [ nip push ] [ 3drop ] if ;
: add-todo-states ( state/condition visited-states new-states -- )
[ condition-states ] 2dip
[ transitions>> keys ] bi*
[ intersects? ] with filter
fast-set
- ] keep (>>final-states) ;
+ ] keep final-states<< ;
: initialize-dfa ( nfa -- dfa )
<transition-table>
: construct-dfa ( nfa -- dfa )
dup initialize-dfa
dup start-state>> condition-states >vector
- H{ } clone
+ HS{ } clone
new-transitions
[ set-final-states ] keep ;