Scalaã«ã¯Streamã¨ããç¡éãªã¹ãããããã ãã©ãå¾®å¦ã«ä½¿ãã¥ãããã¨ãããåããã¥ãããHaskellã§ããcycleã¯ã©ãã ãã¨ãããå¿ããã®ã§ã¡ã¢ã 1def repeat[T](a:T) = Stream.const(a) 2def cycle[T](a:Iterable[T]) = Stream.const(a).flatMap(v=>v) 3def iterate[T](f:T => T, x:T):Stream[T] = Stream.cons(x, iterate(f, f(x))) 4def replicate[T](n:int, elem:T) = Stream.make(n, elem) ãããªæãããªãcycleã¯çµæ§ä½¿ããããStreamã«æ¨æºã§ãããããªæ°ããããã ãã©ããªããããªãã¨ããããã§ä¸ã®ãããªå®ç¾©ã¨ãªãã 1repeat(1) take 10
{{#tags}}- {{label}}
{{/tags}}