use map-reduce instead of unclip reduce, "Why do we need this?" --> we don't
parent
dd43df655f
commit
77f99eb70c
|
@ -21,12 +21,12 @@ CONSTANT: epsilon T{ tagged-epsilon { tag t } }
|
|||
TUPLE: concatenation first second ;
|
||||
|
||||
: <concatenation> ( seq -- concatenation )
|
||||
[ epsilon ] [ unclip [ concatenation boa ] reduce ] if-empty ;
|
||||
[ epsilon ] [ [ ] [ concatenation boa ] map-reduce ] if-empty ;
|
||||
|
||||
TUPLE: alternation first second ;
|
||||
|
||||
: <alternation> ( seq -- alternation )
|
||||
unclip [ alternation boa ] reduce ;
|
||||
[ ] [ alternation boa ] map-reduce ;
|
||||
|
||||
TUPLE: star term ;
|
||||
C: <star> star
|
||||
|
|
|
@ -11,12 +11,7 @@ TUPLE: transition-table transitions start-state final-states ;
|
|||
H{ } clone >>transitions
|
||||
H{ } clone >>final-states ;
|
||||
|
||||
: maybe-initialize-key ( key hashtable -- )
|
||||
! Why do we have to do this?
|
||||
2dup key? [ 2drop ] [ [ H{ } clone ] 2dip set-at ] if ;
|
||||
|
||||
:: (set-transition) ( from to obj hash -- )
|
||||
to condition? [ to hash maybe-initialize-key ] unless
|
||||
from hash at
|
||||
[ [ to obj ] dip set-at ]
|
||||
[ to obj associate from hash set-at ] if* ;
|
||||
|
@ -25,7 +20,6 @@ TUPLE: transition-table transitions start-state final-states ;
|
|||
transitions>> (set-transition) ;
|
||||
|
||||
:: (add-transition) ( from to obj hash -- )
|
||||
to hash maybe-initialize-key
|
||||
from hash at
|
||||
[ [ to obj ] dip push-at ]
|
||||
[ to 1vector obj associate from hash set-at ] if* ;
|
||||
|
|
Loading…
Reference in New Issue