progs/pow.scala
changeset 676 62d168bf7ac8
parent 669 2f5a4d76756d
child 765 b294cfbb5c01
equal deleted inserted replaced
675:d665e7dd66d7 676:62d168bf7ac8
     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", "")