fork(8) download
  1. object Main extends App {
  2. def f(a:Seq[Int])=a.indices.flatMap(a.combinations).filter(_.sum==10)
  3. val array = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
  4. println(f(array))
  5. }
  6.  
  7.  
Success #stdin #stdout 0.2s 322432KB
stdin
Standard input is empty
stdout
Vector(List(10), List(1, 9), List(2, 8), List(3, 7), List(4, 6), List(1, 2, 7), List(1, 3, 6), List(1, 4, 5), List(2, 3, 5), List(1, 2, 3, 4))