【问题标题】:Outputing the result of a function from another function in Scala从Scala中的另一个函数输出函数的结果
【发布时间】:2013-12-16 14:43:46
【问题描述】:

我有一个函数应该返回 List[(Int, Int, Set[Int])] 作为输出,我编写了一个返回 (Int,Int) 部分的函数“a”和另一个返回的函数“b” Set[Int] 部分。如何在“a”中调用函数“b”来连接两个结果以返回最终的 List[(Int, Int, Set[Int])] 结果?谢谢

def a(): List[(Int, Int, Set[Int])] = 
{ 
   lis.zipWithIndex flatMap 
   {
     row=> row._1.zipWithIndex.withFilter(_._1 == 1) map 
    {
      col => (row._2, col._2) 
    } 
  } 
}

【问题讨论】:

    标签: list scala set


    【解决方案1】:

    你还没有告诉我们b 的参数应该是什么,所以我再次猜测它们应该是什么:

    def a(): List[(Int, Int, Set[Int])] = 
    { 
       lis.zipWithIndex flatMap 
       {
         row=> row._1.zipWithIndex.withFilter(_._1 == 1) map 
        {
          col => (row._2, col._2, b(row._2, col._2)) 
        } 
      } 
    }
    

    【讨论】:

      猜你喜欢
      • 2011-10-17
      • 1970-01-01
      • 2022-01-26
      • 1970-01-01
      • 2022-07-25
      • 1970-01-01
      • 2022-01-04
      • 2020-10-20
      • 1970-01-01
      相关资源
      最近更新 更多