小编aba*_*rek的帖子

在图表中查找已连接的组件

如果我有一个无向图(实现为顶点列表),我怎样才能找到它的连通组件?我怎样才能使用快速联合?

algorithm graph

41
推荐指数
1
解决办法
4万
查看次数

Scala Typeclasses

我正在尝试实现简单类型类模式.它假设与scalaz的类型类似.不幸的是我无法让它发挥作用.我有特质Str

trait Str[T] {
  def str(t: T): String
}

object Str {
  def apply[T](implicit instance: Str[T]) : Str[T] = instance
}
Run Code Online (Sandbox Code Playgroud)

在我和它的隐含实例中.

object Temp extends App {

  implicit val intStr = new Str[Int] {
    def str(i: Int) = i.toString
  }

  1.str //error: value str is not a member of Int

}
Run Code Online (Sandbox Code Playgroud)

我很感激任何见解.

functional-programming scala typeclass

3
推荐指数
1
解决办法
135
查看次数