progs/pow.scala
changeset 801 7aab258bf72a
parent 768 34f77b976b88
child 882 5fcad75ade92
equal deleted inserted replaced
800:9eea6a801e10 801:7aab258bf72a
     3 
     3 
     4 def pow(A: Set[String], n: Int) : Set[String] = n match {
     4 def pow(A: Set[String], n: Int) : Set[String] = n match {
     5   case 0 => Set("")
     5   case 0 => Set("")
     6   case n => concat(A, pow(A, n- 1))
     6   case n => concat(A, pow(A, n- 1))
     7 }
     7 }
       
     8 
       
     9 val A = Set("a", "b", "c", "d", "e")
       
    10 val B = Set("a", "b", "c", "d", "")
       
    11 pow(A, 4).size
       
    12 pow(B, 4).size
       
    13 
     8 
    14 
     9 val A = Set("aa", "a")
    15 val A = Set("aa", "a")
    10 val B = Set("aaa", "aaaa")
    16 val B = Set("aaa", "aaaa")
    11 concat(A, B).size                     // -> 3 
    17 concat(A, B).size                     // -> 3 
    12 
    18