progs/re4.scala
changeset 546 6589afc6789b
parent 477 b78664a24f5d
child 550 71fc4a7a7039
equal deleted inserted replaced
545:76a98ed71a2a 546:6589afc6789b
    50     case (r1s, r2s) => SEQ(r1s, r2s)
    50     case (r1s, r2s) => SEQ(r1s, r2s)
    51   }
    51   }
    52   case r => r
    52   case r => r
    53 }
    53 }
    54 
    54 
       
    55 //example
       
    56 val r = SEQ(SEQ(CHAR('x'), CHAR('y')), CHAR('z'))
       
    57 der('x', r)
       
    58 der('y', der('x', r))
       
    59 der('z', der('y', der('x', r)))
       
    60 simp(der('z', der('y', der('x', r))))
       
    61 
    55 // *new*
    62 // *new*
    56 // derivative w.r.t. a string (iterates der)
    63 // derivative w.r.t. a string (iterates der)
    57 def ders2(s: List[Char], r: Rexp) : Rexp = (s, r) match {
    64 def ders2(s: List[Char], r: Rexp) : Rexp = (s, r) match {
    58   case (Nil, r) => r
    65   case (Nil, r) => r
    59   case (s, ZERO) => ZERO
    66   case (s, ZERO) => ZERO