progs/pow.scala
changeset 676 41fee9bd4150
parent 669 e22b5faa7e66
child 765 b66602e0b42d
equal deleted inserted replaced
675:27119b4a8d0f 676:41fee9bd4150
     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 
     8 
     9 val A = Set("aa", "aaa")
     9 val A = Set("aa", "a")
    10 val B = Set("aaa", "aa")
    10 val B = Set("aaa", "aaaa")
    11 concat(A, B).size                     // -> 28 
    11 concat(A, B).size                     // -> 3 
    12 
    12 
    13 
    13 
    14 
    14 
    15 val A = Set("1", "2", "3", "")
    15 val A = Set("1", "2", "3", "")
    16 val B = Set("1", "2", "3", "4", "5", "6", "")
    16 val B = Set("1", "2", "3", "4", "5", "6", "")