Created
June 16, 2015 13:58
-
-
Save shigemk2/e829dec20b054435bbd4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [0m[[0minfo[0m] [0mLoading project definition from /home/shigemk2/projects/github.com/fpinscala/fpinscala/project[0m | |
| [0m[[0minfo[0m] [0mSet current project to fpinscala (in build file:/home/shigemk2/projects/github.com/fpinscala/fpinscala/)[0m | |
| > console | |
| [0m[[0minfo[0m] [0mUpdating {file:/home/shigemk2/projects/github.com/fpinscala/fpinscala/}fpinscala...[0m | |
| [0m[[0minfo[0m] [0mResolving org.scala-lang#scala-library;2.11.5 ...[0m | |
| M[2K[0m[[0minfo[0m] [0mResolving org.scala-lang#scala-compiler;2.11.5 ...[0m | |
| M[2K[0m[[0minfo[0m] [0mResolving org.scala-lang#scala-reflect;2.11.5 ...[0m | |
| M[2K[0m[[0minfo[0m] [0mResolving org.scala-lang.modules#scala-xml_2.11;1.0.3 ...[0m | |
| M[2K[0m[[0minfo[0m] [0mResolving org.scala-lang.modules#scala-parser-combinators_2.11;1.0.3 ...[0m | |
| M[2K[0m[[0minfo[0m] [0mResolving jline#jline;2.12 ...[0m | |
| [0m[[0minfo[0m] [0mDone updating.[0m | |
| [0m[[0minfo[0m] [0mStarting scala interpreter...[0m | |
| [0m[[0minfo[0m] [0m[0m | |
| Welcome to Scala version 2.11.5 (OpenJDK 64-Bit Server VM, Java 1.7.0_79). | |
| Type in expressions to have them evaluated. | |
| Type :help for more information. | |
| scala> def maybeTwice2(b: Boolean, i: => Int) = { | |
| | lazy val j = i | |
| | if(b) j+j else 0 | |
| | } | |
| maybeTwice2: (b: Boolean, i: => Int)Int | |
| scala> my[9G[Kaybe[12G[K[11G[K[10G[K[9G[K[8G[KmaybeTwice2()[20Gt)[21Gr)[22Gu)[23Ge)[24G )[25G{)[26G})[27G[26G)[K[26G[25G)[K[25G[24G)[K[24G,)[25G )[26G{)[27G})[28G[27Gf})[28Ga})[29Gl})[30Gs})[31Ge})[32G,})[33G })[34G[33G})[K[33G[32G})[K[32G[31G})[K[31G[30G})[K[30G[29G})[K[29G[28G})[K[28G[27G})[K[27G[26G})[K[26G{})[27Gp})[28Gr})[29Gi})[30Gn})[31Gt})[32G(})[33G)})[34G[33G')})[34GH)})[35Gi)})[36G[35G)})[K[35G[34G)})[K[34G[33G)})[K[33G")})[34GH)})[35Gi)})[36G")})[37G,)})[38G )})[39G[38G)})[K[38G[37G)})[K[37G[38G;})[39G })[40G4})[41G2})[42G[41G})[K[41G[40G})[K[40G1})[41G+})[42G2})[43G4})[44G[43G})[K[43G[42G})[K[42G4})[43G2})[44G[8G[46G | |
| Hires0: Int = 86 | |
| scala> maybeTwice2(true, {print("Hi"); 1+42})[45G[44G[43G[42G[41G[40G[39G[38G[37G[36G[35G[34G[33G[32G[31G[30G[29G[28G[27G[28G[29G[30G[31G[32Gl("Hi"); 1+42})[33Gn("Hi"); 1+42})[34G[48G | |
| Hi | |
| res1: Int = 86 | |
| scala> maybeTwice2(true, {println("Hi"); 1+42})[47G[46G[45G[44G[43G[42G[41G[40G[39G[38G[37G[36G[35G[34G[33G[32G[31G[30G[29G[28G[27G[26G[25G[24G[23G[22G[21G[20G[19G[18G[17G[16G[15G[14G[13G[12G[11G[10G[9G[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[20G[21G[22G[23G[24G[23G, {println("Hi"); 1+42})[K[23G[22G, {println("Hi"); 1+42})[K[22G[21G, {println("Hi"); 1+42})[K[21G[20G, {println("Hi"); 1+42})[K[20Gf, {println("Hi"); 1+42})[21Ga, {println("Hi"); 1+42})[22Gl, {println("Hi"); 1+42})[23Gs, {println("Hi"); 1+42})[24Ge, {println("Hi"); 1+42})[25G[49G | |
| res2: Int = 0 | |
| scala> | |
| [0m[[32msuccess[0m] [0mTotal time: 410 s, completed 2015/06/16 19:48:32[0m | |
| > console[3G[K[1G[K (reverse-i-search)`': [1G[K (reverse-i-search)`a': answers/console[24G[39G[1G[K (reverse-i-search)`an': answers/console[25G[40G[1G[K (reverse-i-search)`ans': answers/console[26G[41G[1G[K (reverse-i-search)`answ': answers/console[27G[42G[1G[K (reverse-i-search)`answe': answers/console[28G[43G[1G[K (reverse-i-search)`answer': answers/console[29G[44G[1G[K > answers/console[3G[18G | |
| [0m[[0minfo[0m] [0mStarting scala interpreter...[0m | |
| [0m[[0minfo[0m] [0m[0m | |
| Welcome to Scala version 2.11.5 (OpenJDK 64-Bit Server VM, Java 1.7.0_79). | |
| Type in expressions to have them evaluated. | |
| Type :help for more information. | |
| scala> [1G[K (reverse-i-search)`': [1G[K (reverse-i-search)`i': maybeTwice2(false, {println("Hi"); 1+42})[31G[65G[1G[K (reverse-i-search)`im': import fpinscala.gettingstarted._[25G[58G[1G[K (reverse-i-search)`imp': import fpinscala.gettingstarted._[26G[59G[1G[K (reverse-i-search)`impo': import fpinscala.gettingstarted._[27G[60G[1G[K (reverse-i-search)`impor': import fpinscala.gettingstarted._[28G[61G[1G[K (reverse-i-search)`import': import fpinscala.gettingstarted._[29G[62G[1G[K scala> import fpinscala.gettingstarted._[8G[41G[40G[39G[38G[37G[36G[35G[34G[33G[32G[31G[30G[29G[28G[27G[26G[25G[24G[23G[22G[21G[20G[19G[18G[17G[16G[15G[16G[17G[18G[19G[20G[21G[22G[23G[24G[25G[26G[27G[28G[29G[30G[31G[32G[33G[34G[35G[36G[37G[38G[39G[38G[37G[36G[35G[34G[33G[32G[31G[30G[29G[28G[27G[26G[25G[Klaz[27G[K[26G[K[25G[Klaziness._ | |
| import fpinscala.laziness._ | |
| scala> val a = Stream()[23G1)[24G,)[25G2)[26G,)[27G[8G[28G[27G[26G)[K[26G[27G[8G[27G | |
| a: fpinscala.laziness.Stream[Int] = Cons(<function0>,<function0>) | |
| scala> a.he[11G[K[10G[KheadOption | |
| def headOption: Option[A] | |
| scala> a.headOption | |
| res0: Option[Int] = Some(1) | |
| scala> a.p[10G[Kap[11G[K[10G[Kappend | |
| def append[B >: A](s: => fpinscala.laziness.Stream[B]): Stream[B] | |
| scala> a.append[15G[K[14G[K[13G[K[12G[K[11G[K[10G[K[9G[K. | |
| append flatMap map takeViaUnfold toListRecursive | |
| asInstanceOf foldRight mapViaUnfold takeWhile toString | |
| drop forAll scanRight takeWhileViaUnfold zip | |
| exists hasSubsequence startsWith takeWhile_1 zipAll | |
| filter headOption tails toList zipWith | |
| find isInstanceOf take toListFast zipWithAll | |
| scala> a.[9G[K[8G[Kval x = Cons(() => expensive(x), tl) | |
| <console>:10: error: not found: value expensive | |
| val x = Cons(() => expensive(x), tl) | |
| ^ | |
| <console>:10: error: not found: value tl | |
| val x = Cons(() => expensive(x), tl) | |
| ^ | |
| scala> val h1 = x.headOption | |
| <console>:10: error: not found: value x | |
| val h1 = x.headOption | |
| ^ | |
| scala> val h2 = x.headOption | |
| <console>:10: error: not found: value x | |
| val h2 = x.headOption | |
| ^ | |
| scala> val h2 = x.headOption[13G[K1 = x.headOption[12G[Kx = Cons(() => expensive(x), tl)[8G[Ka.headOption[8G[Kval x = Cons(() => expensive(x), tl)[12G[Kh1 = x.headOption[12G[Kx = Cons(() => expensive(x), tl)[8G[KStream()[15G1)[16G,)[17G2)[18G,)[19G3)[20G,)[21G3)[22G[21G)[K[21G4)[22G,)[23G5)[24G,)[25G6)[26G,)[27G7)[28G,)[29G7)[30G[29G)[K[29G8)[30G,)[31G9)[32G[8GvStream(1,2,3,4,5,6,7,8,9)[9GaStream(1,2,3,4,5,6,7,8,9)[10GlStream(1,2,3,4,5,6,7,8,9)[11G Stream(1,2,3,4,5,6,7,8,9)[12GaStream(1,2,3,4,5,6,7,8,9)[13G Stream(1,2,3,4,5,6,7,8,9)[14G=Stream(1,2,3,4,5,6,7,8,9)[15G Stream(1,2,3,4,5,6,7,8,9)[16G[8G[41G | |
| a: fpinscala.laziness.Stream[Int] = Cons(<function0>,<function0>) | |
| scala> val a = Stream(1,2,3,4,5,6,7,8,9)[40G[39G[38G[37G[36G[35G[34G[33G[32G[31G[30G[29G[28G[27G[26G[25G[24G[23G[22G[21G(1,2,3,4,5,6,7,8,9)[K[21G[20G(1,2,3,4,5,6,7,8,9)[K[20G[19G(1,2,3,4,5,6,7,8,9)[K[19G[18G(1,2,3,4,5,6,7,8,9)[K[18G[17G(1,2,3,4,5,6,7,8,9)[K[17G[16G(1,2,3,4,5,6,7,8,9)[K[16GL(1,2,3,4,5,6,7,8,9)[17Gi(1,2,3,4,5,6,7,8,9)[18Gs(1,2,3,4,5,6,7,8,9)[19Gt(1,2,3,4,5,6,7,8,9)[20G[19G[18G[17G[16G[17G[18G[19G[20G[21G[22G[23G,3,4,5,6,7,8,9)[K[23G3,4,5,6,7,8,9)[K[23G,4,5,6,7,8,9)[K[23G4,5,6,7,8,9)[K[23G,5,6,7,8,9)[K[23G5,6,7,8,9)[K[23G,6,7,8,9)[K[23G6,7,8,9)[K[23G,7,8,9)[K[23G7,8,9)[K[23G,8,9)[K[23G8,9)[K[23G,9)[K[23G9)[K[23G[22G9)[K[22G 9)[23Gt9)[24Go9)[25G 9)[26G[25G[24G[23G[22G[21G[20G[19G[18G[17G[16G[17G[18G[19G[20G[19G(1 to 9)[K[19G[18G(1 to 9)[K[18G[17G(1 to 9)[K[17G[16G(1 to 9)[K[16GS(1 to 9)[17Ge(1 to 9)[18Gq(1 to 9)[19G[27G[26G[25G)[K[25G1)[26G0)[27G0)[28G[29G | |
| a: Seq[scala.collection.immutable.Range.Inclusive] = List(Range(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100)) | |
| scala> val a = Seq(1 to 100)[28G[27G)[K[27G0)[28G0)[29G0)[30G[29G)[K[29G[30G | |
| a: Seq[scala.collection.immutable.Range.Inclusive] = List(Range(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 1... | |
| scala> val a = Seq(1 to 1000)[28G[K)[17G[Ktream(1,2,3,4,5,6,7,8,9) | |
| a: fpinscala.laziness.Stream[Int] = Cons(<function0>,<function0>) | |
| scala> a.toList | |
| res1: List[Int] = List(1, 2, 3, 4, 5, 6, 7, 8, 9) | |
| scala> a.drop()[15G2)[16G[17G | |
| res2: fpinscala.laziness.Stream[Int] = Cons(<function0>,<function0>) | |
| scala> a.drop(2).toList | |
| res3: List[Int] = List(3, 4, 5, 6, 7, 8, 9) | |
| scala> a.drop(2).toList[8G[9G[10G[11G[12G[13G[14G[13G(2).toList[K[13G[12G(2).toList[K[12G[11G(2).toList[K[11G[10G(2).toList[K[10Gt(2).toList[11Ga(2).toList[12Gk(2).toList[13Ge(2).toList[14G[8G[24G | |
| res4: List[Int] = List(1, 2) | |
| scala> a.takel[14G[KWhi[16G[K[15G[K[14G[K[13G[K[12G[K[11G[K[10G[KtakeWhile | |
| takeWhile takeWhileViaUnfold takeWhile_1 | |
| scala> a.takeWhile()[20Gx)[21G )[22G=)[23G>)[24G )[25Gx)[26G )[27G>)[28G )[29G0)[30G[8G[31G.toList[8G[38G | |
| res5: List[Int] = List(1, 2, 3, 4, 5, 6, 7, 8, 9) | |
| scala> a.takeWhile(x => x > 0).toList[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[20G[21G[22G[23G[24G[25G[26G[27G[28G[29G[30G[29G).toList[K[29G1).toList[30G[8G[38G | |
| res6: List[Int] = List() | |
| scala> a.takeWhile(x => x > 1).toList[37G[36G[35G[34G[33G[32G[31G[30G[29G[28G[27G[26G[25G[26G[27G[28G[27G 1).toList[K[27G< 1).toList[28G[29G[30G[29G).toList[K[29G5).toList[30G[38G | |
| res7: List[Int] = List(1, 2, 3, 4) | |
| scala> Stream(1,2,3).take(2).toList | |
| res8: List[Int] = List(1, 2) | |
| scala> Stream(1,2,3).take(2).toList[35G[34G[33G[32G[31G[30G[29G[28G[27G[26G[25G[24G[23G[22G[23G[24G[25G[26G[25G(2).toList[K[25G[24G(2).toList[K[24G[23G(2).toList[K[23G[22G(2).toList[K[22Gd(2).toList[23Gr(2).toList[24Go(2).toList[25Gp(2).toList[26G[8G[36G | |
| res9: List[Int] = List(3) | |
| scala> Stream()[15G1)[16G,)[17G2)[18G,)[19G3)[20G[21G.ex<console>:1: error: ';' expected but ')' found. | |
| 3) | |
| ^ | |
| [23G[K[2J[1;1H | |
| scala> Stream(1,2,3).exists()[29G2)[30G[31G | |
| <console>:11: error: type mismatch; | |
| found : Int(2) | |
| required: Int => Boolean | |
| Stream(1,2,3).exists(2) | |
| ^ | |
| scala> Stream(1,2,3).exists(2)[30G[29G)[K[29Gx)[30G )[31G=)[32G )[33G[32G)[K[32G>)[33G )[34Gx)[35G )[36G>)[37G )[38G2)[39G[8G[40G | |
| res11: Boolean = true | |
| scala> Stream(1,2,3).exists(x => x > 2)[39G[38G[39G[38G[37G[36G 2)[K[36G= 2)[37G= 2)[38G[41G | |
| res12: Boolean = true | |
| scala> Stream(1,2,3).exists(x => x == 2)[40G[39G[38G[37G[36G[35G[34G[33G[32G[31G[30G[29G[30G[31G[32G[33G[34G[35G[36G[37G[38G[37G 2)[K[37G[36G 2)[K[36G> 2)[37G[40G | |
| res13: Boolean = true | |
| scala> Stream(1,2,3).exists(x => x > 2)[39G[38G[39G[38G)[K[38G3)[39G[40G | |
| res14: Boolean = false | |
| scala> Stream()[15G1)[16G,)[17G2)[18G,)[19G3)[20G[21GforA[24G[K[23G[K[22G[K[21G[K.forA<console>:1: error: ';' expected but ')' found. | |
| 3) | |
| ^ | |
| [8G[K[2J[1;1H | |
| scala> Stream(1,2,3).exists(x => x > 3)[39G[K[38G[K[37G[K[36G[K[35G[K[34G[Kx > 3[38G[K2)[39G[38G[37G[36G[35G[34G[33G[32G[31G[30G[29G[28G[27G[26G[25G[24G[23G[22G[23G[24G[25G[26G[27G[28G[27G(x => x > 2)[K[27G[26G(x => x > 2)[K[26G[25G(x => x > 2)[K[25G[24G(x => x > 2)[K[24G[23G(x => x > 2)[K[23G[22G(x => x > 2)[K[22Gf(x => x > 2)[23Go(x => x > 2)[24Gr(x => x > 2)[25GA(x => x > 2)[26Gl(x => x > 2)[27Gl(x => x > 2)[28G[8G[40G | |
| res15: Boolean = false | |
| scala> Stream(1,2,3).forAll(x => x > 2)[39G[38G[37G[36G[35G[34G[33G[32G[31G[30G[29G[28G[27G[26G[25G[24G[23G[22G[21G[20G[19G[20G[21G[22G[23G[24G[25G[26G[27G[28G[29G[30G[31G[32G[33G[34G[35G[36G[37G[38G[39G[38G[37G[36G[35G[36G[37G[38G[39G[38G[37G[36G[37G[36G 2)[K[36G< 2)[37G[40G | |
| res16: Boolean = false | |
| scala> Stream(1,2,3).forAll(x => x < 2)[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[20G,).forAll(x => x < 2)[21G4).forAll(x => x < 2)[22G,).forAll(x => x < 2)[23G4).forAll(x => x < 2)[24G,).forAll(x => x < 2)[25G4).forAll(x => x < 2)[26G[25G).forAll(x => x < 2)[K[25G[24G).forAll(x => x < 2)[K[24G[23G).forAll(x => x < 2)[K[23G5).forAll(x => x < 2)[24G,).forAll(x => x < 2)[25G6).forAll(x => x < 2)[26G[46G | |
| res17: Boolean = false | |
| scala> Stream(1,2,3,4,5,6).forAll(x => x < 2)[45G[44G)[K[44G7)[45G[46G | |
| res18: Boolean = true | |
| scala> Stream()[15G1)[16G,)[17G2)[18G,)[19G3)[20G,)[21G4)[22G,)[23G5)[24G[25G.takeWhi<console>:1: error: ';' expected but ')' found. | |
| 5) | |
| ^ | |
| [32G[K[31G[K[30G[K[29G[K[28G[K[27G[K[26G[K[25G[K[24G[K[23G[K[22G[K[21G[K[20G[K[19G[K[18G[K[17G[K[16G[K[15G[K[14G[K[13G[K[12G[K[11G[K[10G[K[9G[K[8G[K[2J[1;1H | |
| scala> Stream.()[16G[K[15G[K[14G[K()[15G1)[16G,)[17G2)[18G,)[19G3)[20G,)[21G4)[22G5)[23G,)[24G[23G)[K[23G[22G)[K[22G,)[23G5)[24G[25G.[8G[Kval a = Stream()[23G1)[24G,)[25G2)[26G,)[27G3)[28G,)[29G4)[30G,)[31G5)[32G[33G | |
| a: fpinscala.laziness.Stream[Int] = Cons(<function0>,<function0>) | |
| scala> a. | |
| append flatMap map takeViaUnfold toListRecursive | |
| asInstanceOf foldRight mapViaUnfold takeWhile toString | |
| drop forAll scanRight takeWhileViaUnfold zip | |
| exists hasSubsequence startsWith takeWhile_1 zipAll | |
| filter headOption tails toList zipWith | |
| find isInstanceOf take toListFast zipWithAll | |
| scala> a.fol[12G[K[11G[K[10G[Ktake[13G[K[12G[K[11G[K[10G[Ktake | |
| take takeViaUnfold takeWhile takeWhileViaUnfold takeWhile_1 | |
| scala> a.takeWhi[16G[K[15G[K[14G[K[13G[K[12G[K[11G[K[10G[KtakeWhile | |
| takeWhile takeWhileViaUnfold takeWhile_1 | |
| scala> a.takeWhile_1()[22Gx)[23G )[24G=)[25G>)[26G )[27G )[28G[27G)[K[27Gx)[28G )[29G>)[30G )[31G2)[32G[8G[33G | |
| res19: fpinscala.laziness.Stream[Int] = Empty | |
| scala> a.takeWhile_1(x => x > 2).toList | |
| res20: List[Int] = List() | |
| scala> a.takeWhile_1(x => x > 2).toList[39G[38G[37G[36G[35G[34G[33G[32G[31G[32G[31G).toList[K[31G0).toList[32G[40G | |
| res21: List[Int] = List(1, 2, 3, 4, 5) | |
| scala> a.head[13G[K[12G[K[11G[K[10G[KheadOption | |
| res22: Option[Int] = Some(1) | |
| scala> Stream().oea[19G[K[18G[K[17G[KheadOption | |
| res23: Option[Nothing] = None | |
| scala> List()[13G1)[14G,)[15G2)[16G,)[17G3)[18G[19G.head[23G[K[22G[K[21G[K[20G[Kforl[23G[K[22G[KldRi<console>:1: error: ';' expected but ')' found. | |
| 3) | |
| ^ | |
| [2J[1;1H | |
| scala> List(1,2,3).foldRi()[27G[K[26G[Kght()[30GN)[31GO)[32Gn)[33Ge)[34G[35G[34G[33G[32G[31G[35G[34G[33G[32G[31Gne)[K[31Gone)[32G[35G()[36Gh)[37Ge)[38G[37G)[K[37G[36G)[K[36Gh)[37Ge)[38Ga)[39Gd)[40G:)[41G:)[42G[41G)[K[41G[40G)[K[40G )[41G:)[42G:)[43G )[44G[8G[Ka.map()[14G[K[13G[K[12G[K[11G[K[10G[K[9G[K.toList | |
| res24: List[Int] = List(1, 2, 3, 4, 5) | |
| scala> a.map()[14Gx)[15G )[16G=)[17G>)[18G )[19Gx)[20G )[21G+)[22G )[23G1)[24G[8G[25G.toList | |
| res25: List[Int] = List(2, 3, 4, 5, 6) | |
| scala> a.map(x => x + 1).toList[8G[9G[10G[11G[12G[13G[12G[11G[10G[Kfilter()[17Gx)[18G )[19G=)[20G>)[21G )[22G[23G[22Gx)[23G )[24G+)[25G )[26G1)[27G[26G)[K[26G[25G)[K[25G[24G)[K[24G>)[25G )[26G2)[27G[28G.toList[8G[35G | |
| res26: List[Int] = List(3, 4, 5) | |
| scala> a.filter(x => x > 2).toList[8G[9G[10G[11G[12G[13G[14G[15G[16G[15G[14G[13G[12G[11G[10G[Kapp[12G[K[11G[K[10G[Kappend | |
| def append[B >: A](s: => fpinscala.laziness.Stream[B]): Stream[B] | |
| scala> a.append()[17GS)[18Gt)[19Gr)[20Ge)[21Ga)[22Gm)[23G()[24G))[25G[24G1))[25G[8G[27G | |
| res27: fpinscala.laziness.Stream[Int] = Cons(<function0>,<function0>) | |
| scala> a.append(Stream(1)).toLIst | |
| <console>:12: error: value toLIst is not a member of fpinscala.laziness.Stream[Int] | |
| a.append(Stream(1)).toLIst | |
| ^ | |
| scala> a.append(Stream(1)).toLIst[33G[32G[31Gst[K[31Gist[32G[34G | |
| res29: List[Int] = List(1, 2, 3, 4, 5, 1) | |
| scala> a | |
| res30: fpinscala.laziness.Stream[Int] = Cons(<function0>,<function0>) | |
| scala> a.toLIst | |
| <console>:12: error: value toLIst is not a member of fpinscala.laziness.Stream[Int] | |
| a.toLIst | |
| ^ | |
| scala> a.toLIst[15G[K[14G[K[13G[Ki[13G[K[12G[K[11G[K[10G[KtoList | |
| toList toListFast toListRecursive | |
| scala> a.toList | |
| res32: List[Int] = List(1, 2, 3, 4, 5) | |
| scala> a.toList[13G[KIst[9G[K.append(Stream(1)).toList | |
| res33: List[Int] = List(1, 2, 3, 4, 5, 1) | |
| scala> a.flatMap()[18Gx)[19G )[20G=)[21G>)[22G[21G)[K[21G[20G)[K[20G[19G)[K[19G[18G)[K[18G[17G)[K[17G[K[16G[K[15G[K[14G[K[13G[K[12G[K[11G[K[10G[KflatMap | |
| def flatMap[B](f: A => fpinscala.laziness.Stream[B]): Stream[B] | |
| scala> a.flatMap()[18Gx)[19G )[20G=)[21G>)[22G )[23GS)[24Gt)[25Gr)[26Ge)[27Ga)[28Gm)[29G()[30G))[31G[30Gx))[31G ))[32G+))[33G ))[34G1))[35G[8G[37G | |
| res34: fpinscala.laziness.Stream[Int] = Cons(<function0>,<function0>) | |
| scala> a.flatMap(x => Stream(x + 1)).toList[8G[44G | |
| res35: List[Int] = List(2, 3, 4, 5, 6) | |
| scala> Stream(1,2,3,4).map(_ + 10).filter(_ % 2 == 0).toList | |
| res36: List[Int] = List(12, 14) | |
| scala> a | |
| res37: fpinscala.laziness.Stream[Int] = Cons(<function0>,<function0>) | |
| scala> a.find()[15G5)[16G[17G | |
| <console>:12: error: type mismatch; | |
| found : Int(5) | |
| required: Int => Boolean | |
| a.find(5) | |
| ^ | |
| scala> a.find(5)[16G[K[15G[Kx => x == 5) | |
| res39: Option[Int] = Some(5) | |
| scala> a.find(x => x == 5)[26G[25G)[K[25G6)[26G[27G | |
| res40: Option[Int] = None | |
| scala> Stream(1,2,3,4).map(_ + 10).filter (_ % 2 == 0) | |
| res41: fpinscala.laziness.Stream[Int] = Cons(<function0>,<function0>) | |
| scala> Stream(1,2,3,4).map(_ + 10).filter (_ % 2 == 0).toList | |
| res42: List[Int] = List(12, 14) | |
| scala> Stream.ones[8GvStream.ones[9GaStream.ones[10GlStream.ones[11G Stream.ones[12GaStream.ones[13G-Stream.ones[14G Stream.ones[15G[14GStream.ones[K[14G[13GStream.ones[K[13G Stream.ones[14G=Stream.ones[15G Stream.ones[16G[27G | |
| a: fpinscala.laziness.Stream[Int] = Cons(<function0>,<function0>) | |
| scala> val a = Stream.ones[8G[Ka.to[11G[K[10G[K[9G[K[8G[Ka.toList.take()[22G3)[23G[8G[24G |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [0m[[0minfo[0m] [0mLoading project definition from /home/shigemk2/projects/github.com/fpinscala/fpinscala/project[0m | |
| [0m[[0minfo[0m] [0mSet current project to fpinscala (in build file:/home/shigemk2/projects/github.com/fpinscala/fpinscala/)[0m | |
| > [1G[K (reverse-i-search)`': [1G[K (reverse-i-search)`c': answers/console[32G[39G[1G[K > answers/console[11G[3G[18G | |
| [0m[[0minfo[0m] [0mStarting scala interpreter...[0m | |
| [0m[[0minfo[0m] [0m[0m | |
| Welcome to Scala version 2.11.5 (OpenJDK 64-Bit Server VM, Java 1.7.0_79). | |
| Type in expressions to have them evaluated. | |
| Type :help for more information. | |
| scala> [1G[K (reverse-i-search)`': [1G[K (reverse-i-search)`i': a.toList.take(3)[29G[40G[1G[K (reverse-i-search)`im': import fpinscala.laziness._[25G[52G[1G[K (reverse-i-search)`imp': import fpinscala.laziness._[26G[53G[1G[K (reverse-i-search)`impo': import fpinscala.laziness._[27G[54G[1G[K (reverse-i-search)`impor': import fpinscala.laziness._[28G[55G[1G[K (reverse-i-search)`import': import fpinscala.laziness._[29G[56G[1G[K scala> import fpinscala.laziness._[8G[35G | |
| import fpinscala.laziness._ | |
| scala> val a = Stream.ones | |
| a: fpinscala.laziness.Stream[Int] = Cons(<function0>,<function0>) | |
| scala> a.take()[15G3)[16G[8G[17G.toList[8G[24G | |
| res0: List[Int] = List(1, 1, 1) | |
| scala> a.take(3).toList[8G[9G[10G[11G[12G[13G[14G[15G[16G[15G).toList[K[15G1).toList[16G0).toList[17G0).toList[18G0).toList[19G0).toList[20G[8G[28G | |
| res1: List[Int] = List(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ... | |
| scala> one[10G[K[9G[K[8G[Ka.exiss[14G[Kts()[17G_)[18G )[19G%)[20G )[21G2)[22G )[23G!)[24G=)[25G )[26G0)[27G[8G[28G | |
| res2: Boolean = true | |
| scala> a.undl[13G[K[12G[Kfl[13G[Kold[8G.unfold[K[8GS.unfold[9Gt.unfold[10Gr.unfold[11Ge.unfold[12Ga.unfold[13Gm.unfold[14G[21G[20G[K[19G[K[18G[Kold()[22GS)[23Gt)[24Gr)[25Ge)[26Ga)[27Gm)[28G()[29G))[30G[29G1))[30G[32G()[33Gx)[34G )[35G=)[36G>)[37G )[38GO)[39Gp)[40Gt)[41Gi)[42Go)[43Gn)[44G()[45G))[46G[45Gx))[46G ))[47G+))[48G ))[49G1))[50G[8G[52G | |
| <console>:11: error: type mismatch; | |
| found : Int(1) | |
| required: String | |
| Stream.unfold(Stream(1))(x => Option(x + 1)) | |
| ^ | |
| scala> Stream.unfold(Stream(1))(x => Option(x + 1))[51G[50G[49G[48G[47G[46G[45G[44G[43G[42G[41G[40G[39G[38G[37G[36G[35G[34G[33G[34G[35G[36G[37G[38G[39G[40G[41G[42G[43G[44G[45G[46G+ 1))[K[46G 1))[K[46G1))[K[46G))[K[46G[48G | |
| <console>:11: error: type mismatch; | |
| found : Option[fpinscala.laziness.Stream[Int]] | |
| required: Option[(?, fpinscala.laziness.Stream[Int])] | |
| Stream.unfold(Stream(1))(x => Option(x)) | |
| ^ | |
| scala> Stream.unfold(Stream(1))(x => Option(x))[47G[46G[45G[44G[43G[42G[41G[40G[39G[38G[39G[40G[41G[42G[43G[44G[43G(x))[K[43G[42G(x))[K[42G[41G(x))[K[41G[40G(x))[K[40G[39G(x))[K[39G[38G(x))[K[38G[39G[40G,))[41G ))[42G1))[43G[45G | |
| <console>:11: error: type mismatch; | |
| found : (fpinscala.laziness.Stream[Int], Int) | |
| required: Option[(?, fpinscala.laziness.Stream[Int])] | |
| Stream.unfold(Stream(1))(x => (x, 1)) | |
| ^ | |
| scala> Stream.unfold(Stream(1))(x => (x, 1))[44G[43G[42G[41G[40G[39G[40G[39G[38GO(x, 1))[39Gp(x, 1))[40Gt(x, 1))[41Gi(x, 1))[42Go(x, 1))[43Gn(x, 1))[44G[51G[50G[49G[48G[47G[46G[45G[44G[43G[42G[41G[40G[39G[38G[39G[40G[41G[42G[43G[44G[43G(x, 1))[K[43G[42G(x, 1))[K[42G[41G(x, 1))[K[41G[40G(x, 1))[K[40G[39G(x, 1))[K[39G[38G(x, 1))[K[38GS(x, 1))[39Go(x, 1))[40Gm(x, 1))[41Ge(x, 1))[42G[8G[49G | |
| <console>:11: error: type mismatch; | |
| found : Some[(fpinscala.laziness.Stream[Int], Int)] | |
| required: Option[(?, fpinscala.laziness.Stream[Int])] | |
| Stream.unfold(Stream(1))(x => Some(x, 1)) | |
| ^ | |
| scala> Stream.unfold(Stream(1))(x => Some(x, 1))[48G[47G[46G[45G[44G[43G[42G[41G[40G[39G[38G[37G[36G[35G[34G[33G[32G[31G[30G[29G[28G[27G[26G[25G[24G[23G[22G[23G[24G[25G[26G[27G[28G[29G[30G[31G[32G[33G[34G[35G[36G[37G[38G[39G[40G[41G[42G((x, 1))[43G[44G[45G[46G[47G[48G[49G[48G[47G[46G[45G[44G[45G[46G[47G[48G)))[49G[51G | |
| <console>:11: error: type mismatch; | |
| found : Some[(fpinscala.laziness.Stream[Int], Int)] | |
| required: Option[(?, fpinscala.laziness.Stream[Int])] | |
| Stream.unfold(Stream(1))(x => Some((x, 1))) | |
| ^ | |
| scala> Stream.unfold(Stream(1))(x => Some((x, 1)))[50G[49G[48G[47G[51G[50G[K[49G[K[48G[47G[46G[45G[44G[43G[42G(x, 1)[K[42G[48G) | |
| <console>:11: error: type mismatch; | |
| found : Some[(fpinscala.laziness.Stream[Int], Int)] | |
| required: Option[(?, fpinscala.laziness.Stream[Int])] | |
| Stream.unfold(Stream(1))(x => Some(x, 1)) | |
| ^ | |
| scala> Stream.unfold(Stream(1))(x => Some(x, 1))[48G[47G[46G[45G[44G 1))[K[44G[43G 1))[K[43G1))[K[43G[44G,))[45G ))[46Gx))[47G[46G[45G[44G[43G[42G[41G[40G[39G[38G[37G[36G[35G[34G[33G[32G[31G[30G[29G[30G[31G[32G[33G[34G: => Some(1, x))[35G => Some(1, x))[36GI => Some(1, x))[37Gn => Some(1, x))[38Gt => Some(1, x))[39G[8G[54G | |
| <console>:1: error: ')' expected but '(' found. | |
| Stream.unfold(Stream(1))(x: Int => Some(1, x)) | |
| ^ | |
| <console>:1: error: ';' expected but ')' found. | |
| Stream.unfold(Stream(1))(x: Int => Some(1, x)) | |
| ^ | |
| scala> Stream.unfold(Stream(1))(x: Int => Some(1, x))[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[20G[21G[22G[23G[24G[25G[26G[27G[28G[29G[30G[31G[32G[33G(x: Int => Some(1, x))[34G[35G[36G[37G[38G[39G[40G) => Some(1, x))[41G[8G[56G | |
| <console>:11: error: type mismatch; | |
| found : Some[(Int, Int)] | |
| required: Option[(?, fpinscala.laziness.Stream[Int])] | |
| Stream.unfold(Stream(1))((x: Int) => Some(1, x)) | |
| ^ | |
| scala> Stream.unfold(Stream(1))((x: Int) => Some(1, x))[55G[54G[53G[52G[51G[50G, x))[K[50Gx, x))[51G[52G[53G[54G[53G))[K[53GS))[54Gt))[55Gr))[56Ge))[57Ga))[58Gm))[59G())[60G)))[61G[60Gx)))[61G[8G[64G | |
| <console>:11: error: type mismatch; | |
| found : Int => Some[(Int, fpinscala.laziness.Stream[Int])] | |
| required: fpinscala.laziness.Stream[Int] => Option[(?, fpinscala.laziness.Stream[Int])] | |
| Stream.unfold(Stream(1))((x: Int) => Some(x, Stream(x))) | |
| ^ | |
| scala> Stream.unfold(Stream(1))((x: Int) => Some(x, Stream(x)))[63G[62G[61G[60G[59G[58G[57G[56G[55G[54G[53G[52G[51G[50G[51G[52G[53G[54G[55G[56G[57G[58G[59G[58G[57G[56G[55G[54G[53G[52G[51G[50G[51G[52G[53G[54G[55G[56G[57G[58G[59G[60G[59Gx)))[K[59G[58Gx)))[K[58G[57Gx)))[K[57G[56Gx)))[K[56G[55Gx)))[K[55G[54Gx)))[K[54G[53Gx)))[K[53GSx)))[54Gtx)))[55Grx)))[56Gex)))[57Gax)))[58Gmx)))[59G(x)))[60G[61G[60G)))[K[60G1)))[61G[64G | |
| <console>:11: error: type mismatch; | |
| found : Int => Some[(Int, fpinscala.laziness.Stream[Int])] | |
| required: fpinscala.laziness.Stream[Int] => Option[(?, fpinscala.laziness.Stream[Int])] | |
| Stream.unfold(Stream(1))((x: Int) => Some(x, Stream(1))) | |
| ^ | |
| scala> Stream.unfold(Stream(1))((x: Int) => Some(x, Stream(1)))[63G[62G[61G[60G[59G[58G[57G[56G[55G[54G[53G[52G[51G[50G[49G[48G[47G[46G[45G[44G[43G[42G[41G[40G[39G[38G[37G[36G[35G[34G[35G[36G[37G[38G[39G[40G[41G[42G[43G[44G[45G[46G[47G[48G[49G[50G[51G[52G[51G Stream(1)))[K[51G[50G Stream(1)))[K[50GS Stream(1)))[51Gt Stream(1)))[52Gr Stream(1)))[53Ge Stream(1)))[54Ga Stream(1)))[55Gm Stream(1)))[56G( Stream(1)))[57Gx Stream(1)))[58G) Stream(1)))[59G[58G[57G[56G[55G[54G[53G[52G[51G[50G[51G[52G[53G[54G[55G[56G[57G[58G[59G, Stream(1)))[60G[59G[58G[57G[56G[55G[54G[53G[52G[51G[50G[49G[48G[47G[46G[45G[44G[43G[42G[41G[40G[39G[38G[37G[38G[39G[40G[41G[40G => Some(Stream(x), Stream(1)))[K[40G[39G => Some(Stream(x), Stream(1)))[K[39G[38G => Some(Stream(x), Stream(1)))[K[38G[37G => Some(Stream(x), Stream(1)))[K[37G[36G => Some(Stream(x), Stream(1)))[K[36G[35G[34G[35G[36G[35G => Some(Stream(x), Stream(1)))[K[35G[34G[33G[34G[33Gx => Some(Stream(x), Stream(1)))[K[33G[65G | |
| res12: fpinscala.laziness.Stream[fpinscala.laziness.Stream[fpinscala.laziness.Stream[Int]]] = Cons(<function0>,<function0>) | |
| scala> Stream.unfold(Stream(1))(x => Some(Stream(x), Stream(1))).toList[8G[72G |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [0m[[0minfo[0m] [0mLoading project definition from /home/shigemk2/projects/github.com/fpinscala/fpinscala/project[0m | |
| [0m[[0minfo[0m] [0mSet current project to fpinscala (in build file:/home/shigemk2/projects/github.com/fpinscala/fpinscala/)[0m | |
| > answers/console | |
| [0m[[0minfo[0m] [0mStarting scala interpreter...[0m | |
| [0m[[0minfo[0m] [0m[0m | |
| Welcome to Scala version 2.11.5 (OpenJDK 64-Bit Server VM, Java 1.7.0_79). | |
| Type in expressions to have them evaluated. | |
| Type :help for more information. | |
| scala> Stream.unfold(Stream(1))(x => Some(Stream(x), Stream(1))).toList[65G[K[33G[K(x: Int) => Some(x, Stream(1)))[60G[Kx)))[8G[K[1G[K (reverse-i-search)`': [1G[K (reverse-i-search)`i': Stream.unfold(Stream(1))(x => Option(x))[57G[64G[1G[K (reverse-i-search)`im': import fpinscala.laziness._[25G[52G[1G[K (reverse-i-search)`imp': import fpinscala.laziness._[26G[53G[1G[K (reverse-i-search)`impo': import fpinscala.laziness._[27G[54G[1G[K (reverse-i-search)`impor': import fpinscala.laziness._[28G[55G[1G[K (reverse-i-search)`import': import fpinscala.laziness._[29G[56G[1G[K scala> import fpinscala.laziness._[8G[35G | |
| import fpinscala.laziness._ | |
| scala> import fpinscala.laziness._[8G[KStream.unfold(Stream(1))(x => Some(Stream(x), Stream(1))).toList[71G[70G[69G[68G[67G[66GttoList[67GatoList[68GktoList[69GetoList[70G(toList[71G)toList[72G[71G3)toList[72G[73G.toList[74G[8G[80G | |
| res0: List[fpinscala.laziness.Stream[fpinscala.laziness.Stream[Int]]] = List(Cons(<function0>,<function0>), Cons(<function0>,<function0>), Cons(<function0>,<function0>)) | |
| scala> Stream.unfold(Stream(1))(x => Some(Stream(x), Stream(1))).take(3).toList[79G[K[78G[K[77G[K[76G[K[75G[K[74G[K[73G[K | |
| res1: fpinscala.laziness.Stream[fpinscala.laziness.Stream[fpinscala.laziness.Stream[Int]]] = Cons(<function0>,<function0>) | |
| scala> Stream.unfold(Stream(1))(x => Some(Stream(x), Stream(1))).take(3)[72G[71G[70G[69G[68G[67G[66G[65G[64G[63G[62G[61G[60G[59G[58G[57G[56G[55G[54G[53G[52G[51G[50G[49G[48G[47G[46G[45G[44G[43G[42G[41G[40G[39G[38Gome(Stream(x), Stream(1))).take(3)[K[38Gme(Stream(x), Stream(1))).take(3)[K[38Ge(Stream(x), Stream(1))).take(3)[K[38G(Stream(x), Stream(1))).take(3)[K[38GStream(x), Stream(1))).take(3)[K[38Gtream(x), Stream(1))).take(3)[K[38Gream(x), Stream(1))).take(3)[K[38Geam(x), Stream(1))).take(3)[K[38Gam(x), Stream(1))).take(3)[K[38Gm(x), Stream(1))).take(3)[K[38G(x), Stream(1))).take(3)[K[38Gx), Stream(1))).take(3)[K[38G), Stream(1))).take(3)[K[38G, Stream(1))).take(3)[K[38G Stream(1))).take(3)[K[38GStream(1))).take(3)[K[38Gtream(1))).take(3)[K[38G[8G[KStream.unfold(Stream(1))(x => Some(Stream(x), Stream(1))).take(3).toList[79G[78G[77G[76G[75G[74G[73G[72G[71G[70G[69G[68G[67G[66G[65G[64G[63G[62G[61G[60G[59G[58G[57G[56G[55G[54G[53G[52G[51G[50G[49G[48G[47G[46G[45G[44G[43G[42G[41G[40G[39G[38G[37G[36G[35G[34G[33G[34G[35G[36G[37G[38G[39G[40G[41G[42G[43G[44G[45G[46G[47G[48G[49G[50G[49Gx), Stream(1))).take(3).toList[K[49G[48Gx), Stream(1))).take(3).toList[K[48G[47Gx), Stream(1))).take(3).toList[K[47G[46Gx), Stream(1))).take(3).toList[K[46G[45Gx), Stream(1))).take(3).toList[K[45G[44Gx), Stream(1))).take(3).toList[K[44G[43Gx), Stream(1))).take(3).toList[K[43G[44G[45G[44G, Stream(1))).take(3).toList[K[44G[8G[72G | |
| res2: List[fpinscala.laziness.Stream[Int]] = List(Cons(<function0>,<function0>), Cons(<function0>,<function0>), Cons(<function0>,<function0>)) | |
| scala> Stream.unfold(Stream(1))(x => Some(x, Stream(1))).take(3).toList[71G[K[70G[K[69G[K[68G[K[67G[K[66G[K[65G[K | |
| res3: fpinscala.laziness.Stream[fpinscala.laziness.Stream[Int]] = Cons(<function0>,<function0>) | |
| scala> Stream.unfold(Stream(1))(x => Some(x, Stream(1))).take(3).[65G[64G[63G[62G[61G[60G[59G[58G[57G[56G[55G[54G[53G[52G[51G[50G[49G[48G[47G[46G[47G[48G[49G[50G[51G[52G[53G[52G[51G[50G[49G[48G[47G[46G[45G[44G[43G[42G[41G[40G[39G[38G[37G[36G[35G[34G[33G[32G[31G[30G[29G[30G[31G[30G)(x => Some(x, Stream(1))).take(3).[K[30G[29G)(x => Some(x, Stream(1))).take(3).[K[29G[28G)(x => Some(x, Stream(1))).take(3).[K[28G[27G)(x => Some(x, Stream(1))).take(3).[K[27G[26G)(x => Some(x, Stream(1))).take(3).[K[26G[25G)(x => Some(x, Stream(1))).take(3).[K[25G[24G)(x => Some(x, Stream(1))).take(3).[K[24G[23G)(x => Some(x, Stream(1))).take(3).[K[23G[22G)(x => Some(x, Stream(1))).take(3).[K[22G1)(x => Some(x, Stream(1))).take(3).[23G[8G[58G | |
| | toList | |
| <console>:11: error: type mismatch; | |
| found : Some[(Int, fpinscala.laziness.Stream[Int])] | |
| required: Option[(?, Int)] | |
| Stream.unfold(1)(x => Some(x, Stream(1))).take(3). | |
| ^ | |
| scala> toList[8G[KStream.unfold(1)(x => Some(x, Stream(1))).take(3).toList[8G[64G[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[20G[21G[22G[23G[22G)(x => Some(x, Stream(1))).take(3).toList[K[22G0)(x => Some(x, Stream(1))).take(3).toList[23G[24G[25G[26G[27G[28G[29G[30G[31G[32G[33G[34G[35G[36G., Stream(1))).take(3).toList[37Gt, Stream(1))).take(3).toList[38Go, Stream(1))).take(3).toList[39GS, Stream(1))).take(3).toList[40Gt, Stream(1))).take(3).toList[41Gr, Stream(1))).take(3).toList[42Gi, Stream(1))).take(3).toList[43Gn, Stream(1))).take(3).toList[44Gg, Stream(1))).take(3).toList[45G[46G[47Gtream(1))).take(3).toList[K[47Gream(1))).take(3).toList[K[47Geam(1))).take(3).toList[K[47Gam(1))).take(3).toList[K[47Gm(1))).take(3).toList[K[47G(1))).take(3).toList[K[47G1))).take(3).toList[K[47G))).take(3).toList[K[47G)).take(3).toList[K[47Gx)).take(3).toList[48G+)).take(3).toList[49G1)).take(3).toList[50G[67G[8G[67G | |
| res5: List[String] = List(0, 1, 2) | |
| scala> Stream.unfold(0)(x => Some(x.toString, x+1)).take(3).toList[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[20G[21G[22G[23G[24G[25G[26G[27G[28G[29G[30G[31G[32G[33G[34G[35G[36G[37G[38G[39G[40G[41G[42G[43G[44G[45G[44G, x+1)).take(3).toList[K[44G[43G, x+1)).take(3).toList[K[43G[42G, x+1)).take(3).toList[K[42G[41G, x+1)).take(3).toList[K[41G[40G, x+1)).take(3).toList[K[40G[39G, x+1)).take(3).toList[K[39GI, x+1)).take(3).toList[40Gn, x+1)).take(3).toList[41Gt, x+1)).take(3).toList[42G[8G[64G | |
| res6: List[Int] = List(0, 1, 2) | |
| scala> Stream.unfold(0)(x => Some(x.toInt, x+1)).take(3).toList[63G[K[62G[K[61G[K[60G[K[59G[K[58G[K[57G[K[8G[57G | |
| res7: fpinscala.laziness.Stream[Int] = Cons(<function0>,<function0>) | |
| scala> Stream.unfold(0)(x => Some(x.toInt, x+1)).take(3)[56G[55G[54G[53G[52G[51G[50G[49G[48G[47G[46Gb1)).take(3)[47G[46G1)).take(3)[K[46G[45G[44G[43G[42G[41G[40G[39G[38G[37G[38G[39G[40G[41G[42G[41G, x+1)).take(3)[K[41G[40G, x+1)).take(3)[K[40G[39G, x+1)).take(3)[K[39G[38G, x+1)).take(3)[K[38G[37G, x+1)).take(3)[K[37G[36G, x+1)).take(3)[K[36G[8G[51G.toList[8G[58G | |
| res8: List[Int] = List(0, 1, 2) | |
| scala> Stream.unfold(0)(x => Some(x, x+1)).take(3).toList[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[20G[21G[22G[23G[24G[25G[26G[27G[28G[29G[30G[31G[32G[33G[34G[33G[32G[31G[30G[29G[28G[27G[26G[25G[26G: => Some(x, x+1)).take(3).toList[27G[26G => Some(x, x+1)).take(3).toList[K[26G: => Some(x, x+1)).take(3).toList[27G => Some(x, x+1)).take(3).toList[28G[27G => Some(x, x+1)).take(3).toList[K[27G[26G => Some(x, x+1)).take(3).toList[K[26G[25G[24G[23G[22G[23G[24G[25G[26G[27G[26G[25G[24G[23G[22G)(x => Some(x, x+1)).take(3).toList[K[22G")(x => Some(x, x+1)).take(3).toList[23Ga)(x => Some(x, x+1)).take(3).toList[24G")(x => Some(x, x+1)).take(3).toList[25G[8G[60G | |
| res9: List[String] = List(a, a1, a11) | |
| scala> val a = Stream()[23G1)[24G,)[25G2)[26G,)[27G2)[28G,)[29G[28G)[K[28G[27G)[K[27G3)[28G,)[29G4)[30G,)[31G5)[32G[8G[33G | |
| a: fpinscala.laziness.Stream[Int] = Cons(<function0>,<function0>) | |
| scala> a.has[12G[K[11G[K[10G[KhasSubsequence()[25GS)[26Gt)[27Gr)[28Ge)[29Ga)[30Gm)[31G()[32G4)[33G))[34G[8G[35G | |
| res10: Boolean = true | |
| scala> a.hasSubsequence(Stream(4))[34G[33G[32G))[K[32G6))[33G[8G[35G | |
| res11: Boolean = false | |
| scala> a.hasSubsequence(Stream(6))[34G[33G[32G[31G6))[K[31G[30G6))[K[30G[29G6))[K[29G[28G6))[K[28G[27G6))[K[27G[26G6))[K[26G[25G6))[K[25G[28G[27G[26G)[K[26G[8G[27G | |
| <console>:12: error: type mismatch; | |
| found : Int(6) | |
| required: fpinscala.laziness.Stream[?] | |
| a.hasSubsequence(6) | |
| ^ | |
| scala> a.hasSubsequence(6)[26G[25G)[K[25GS)[26Gt)[27Gr)[28Ge)[29Ga)[30Gm)[31G()[32G))[33G[32G2))[33G,))[34G3))[35G,))[36G4))[37G[8G[39G | |
| res13: Boolean = true | |
| scala> a.hasSubsequence(Stream(2,3,4))[38G[37G[36G))[K[36G5))[37G[39G | |
| res14: Boolean = false | |
| scala> a.St[11G[K[10G[Kstar[13G[K[12G[K[11G[K[10G[KstartsWith()[21G3)[22G[23G | |
| <console>:12: error: type mismatch; | |
| found : Int(3) | |
| required: fpinscala.laziness.Stream[?] | |
| a.startsWith(3) | |
| ^ | |
| scala> a.startsWith(3)[22G[21G)[K[21GS)[22Gt)[23Gr)[24Ge)[25Ga)[26Gm)[27G()[28G))[29G[28G3))[29G[8G[31G | |
| res16: Boolean = false | |
| scala> a.startsWith(Stream(3))[30G[29G[28G13))[29G,3))[30G23))[31G,3))[32G33))[33G[8G[36G[35G[34G[33G))[K[33G[8G[35G | |
| res17: Boolean = true | |
| scala> a.startsWith(Stream(1,2,3))[8G[9G[10G[8G[Ka.[9G[K[8G[KStream.ones.toList[25G[24G[23G[22G[21G[20G[Ktake()[25G3)[26G[27G.toList[8G[34G | |
| res18: List[Int] = List(1, 1, 1) | |
| scala> Stream.ones.take(3).toList[33G[32G[31G[30G[29G[28G[27G[26G[25G[26G[25G).toList[K[25G4).toList[26G[25G).toList[K[25G5).toList[26G[25G).toList[K[25G1).toList[26G0).toList[27G[35G | |
| res19: List[Int] = List(1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | |
| scala> Stream.ones.take(10).toList[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[18G.take(10).toList[K[18G[17G.take(10).toList[K[17G[16G.take(10).toList[K[16G[15G.take(10).toList[K[15G .take(10).toList[16G[15Gc .take(10).toList[16Go .take(10).toList[17Gn .take(10).toList[18Gs .take(10).toList[19G[18G .take(10).toList[K[18G[17G .take(10).toList[K[17G[16G .take(10).toList[K[16G[15G .take(10).toList[K[15GconsWrapper .take(10).toList[26G[25G .take(10).toList[K[25G[24G .take(10).toList[K[24G[23G .take(10).toList[K[23G[22G .take(10).toList[K[22G[21G .take(10).toList[K[21G[20G .take(10).toList[K[20G[19G .take(10).toList[K[19Gt .take(10).toList[20Ga .take(10).toList[21Gn .take(10).toList[22Gt .take(10).toList[23G.take(10).toList[K[23G[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[20G[21G[22G[23G(.take(10).toList[24G).take(10).toList[25G[24G1).take(10).toList[25G[8G[42G | |
| res20: List[Int] = List(1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | |
| scala> Stream.constant(1).take(10).toList[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[20G[21G[22G[23G[24G[25G[24G).take(10).toList[K[24G1).take(10).toList[25G0).take(10).toList[26G[43G | |
| res21: List[Int] = List(10, 10, 10, 10, 10, 10, 10, 10, 10, 10) | |
| scala> Stream.constant(10).take(10).toList[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[20G[21G[22G[23G[24G[25G[26G[25G).take(10).toList[K[25G[24G).take(10).toList[K[24G9).take(10).toList[25G9).take(10).toList[26G[43G | |
| res22: List[Int] = List(99, 99, 99, 99, 99, 99, 99, 99, 99, 99) | |
| scala> Stream.constant(99).take(10).toList[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[20G[21G[22G[23G[24G[25G[26G[25G).take(10).toList[K[25G[24G).take(10).toList[K[24G").take(10).toList[25Gh).take(10).toList[26Go).take(10).toList[27Gg).take(10).toList[28Ge).take(10).toList[29Gh).take(10).toList[30Go).take(10).toList[31Gg).take(10).toList[32Ge).take(10).toList[33Gf).take(10).toList[34Gu).take(10).toList[35Gg).take(10).toList[36Ga).take(10).toList[37G[36G).take(10).toList[K[36G[35G).take(10).toList[K[35G[34G).take(10).toList[K[34G[33G).take(10).toList[K[33G").take(10).toList[34G[8G[51G | |
| res23: List[String] = List(hogehoge, hogehoge, hogehoge, hogehoge, hogehoge, hogehoge, hogehoge, hogehoge, hogehoge, hogehoge) | |
| scala> Stream.constant("hogehoge").take(10).toList[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[20G[21G[22G[23G[24G[25G[26G[27G[28G[29G[30G[31G[32G[33G[34G[35G[36G[37G[38G[39G[40G[39G[38G[37G[36G[35G[34G[33G[32G[31G[30G[29G[28G[27G[26G[25G[26G[27G[28G[29G[30G[31G[32G[33G[34G[33G).take(10).toList[K[33G[32G).take(10).toList[K[32G[31G).take(10).toList[K[31G[30G).take(10).toList[K[30G[29G).take(10).toList[K[29G[28G).take(10).toList[K[28G[27G).take(10).toList[K[27G[26G).take(10).toList[K[26G[25G).take(10).toList[K[25G[24G).take(10).toList[K[24GL).take(10).toList[25Gi).take(10).toList[26Gs).take(10).toList[27Gt).take(10).toList[28G().take(10).toList[29G)).take(10).toList[30G[29G1)).take(10).toList[30G,)).take(10).toList[31G2)).take(10).toList[32G,)).take(10).toList[33G3)).take(10).toList[34G[8G[52G | |
| res24: List[List[Int]] = List(List(1, 2, 3), List(1, 2, 3), List(1, 2, 3), List(1, 2, 3), List(1, 2, 3), List(1, 2, 3), List(1, 2, 3), List(1, 2, 3), List(1, 2, 3), List(1, 2, 3)) | |
| scala> Stream.constant(List(1,2,3)).take(10).toList[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[20G[21G[22G[23G[22G(List(1,2,3)).take(10).toList[K[22G[21G(List(1,2,3)).take(10).toList[K[21G[20G(List(1,2,3)).take(10).toList[K[20G[19G(List(1,2,3)).take(10).toList[K[19G[18G(List(1,2,3)).take(10).toList[K[18G[17G(List(1,2,3)).take(10).toList[K[17G[16G(List(1,2,3)).take(10).toList[K[16G[15G(List(1,2,3)).take(10).toList[K[15Gf(List(1,2,3)).take(10).toList[16Go(List(1,2,3)).take(10).toList[17Gr(List(1,2,3)).take(10).toList[18G[17G(List(1,2,3)).take(10).toList[K[17G[16G(List(1,2,3)).take(10).toList[K[16Gr(List(1,2,3)).take(10).toList[17Go(List(1,2,3)).take(10).toList[18Gm(List(1,2,3)).take(10).toList[19G[20G[K1).to[24G[K[23G[Kto[24G[K[23G[Ktake()[28G1)[29G0)[30G[31G.toList[8G[38G | |
| res25: List[Int] = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) | |
| scala> Stream.from(1).take(10).toList[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[20G[21G[20G).take(10).toList[K[20G2).take(10).toList[21G[38G | |
| res26: List[Int] = List(2, 3, 4, 5, 6, 7, 8, 9, 10, 11) | |
| scala> Stream.from(2).take(10).toList[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[20G[21G[20G).take(10).toList[K[20G3).take(10).toList[21G0).take(10).toList[22G[8G[39G | |
| res27: List[Int] = List(30, 31, 32, 33, 34, 35, 36, 37, 38, 39) | |
| scala> Stream.from(30).take(10).toList[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[20G[21G[22G[21G).take(10).toList[K[21G[20G).take(10).toList[K[20G").take(10).toList[21Gs).take(10).toList[22Gt).take(10).toList[23G[22G).take(10).toList[K[22G[21G).take(10).toList[K[21Gh).take(10).toList[22Go).take(10).toList[23Gg).take(10).toList[24Ge).take(10).toList[25G").take(10).toList[26G[8G[43G | |
| <console>:11: error: type mismatch; | |
| found : String("hoge") | |
| required: Int | |
| Stream.from("hoge").take(10).toList | |
| ^ | |
| scala> Stream.from("hoge").take(10).toList[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[8G[KStream.from(30).take(10).toList[20G[K2).take(10).toList[20G[K30).take(10).toList[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[18G(30).take(10).toList[K[18G[17G(30).take(10).toList[K[17G[16G(30).take(10).toList[K[16G[15G(30).take(10).toList[K[15Gf(30).take(10).toList[16Gi(30).take(10).toList[17Gb(30).take(10).toList[18G[8G[38G[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[20G[21G[22G[21G[22G[21G.take(10).toList[K[21G[20G.take(10).toList[K[20G[19G.take(10).toList[K[19G[18G.take(10).toList[K[18G[17G.take(10).toList[K[17G[8G[33G[8G[9G[10G[11G[12G[13G[14G[15G[16G[17Gb.take(10).toList[18G[8G[34G | |
| <console>:11: error: value fib is not a member of object fpinscala.laziness.Stream | |
| Stream.fib.take(10).toList | |
| ^ | |
| scala> Stream.fib.take(10).toList[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18Gs.take(10).toList[19G[35G | |
| res30: List[Int] = List(0, 1, 1, 2, 3, 5, 8, 13, 21, 34) | |
| scala> Stream.unfoldViaMap[8G[27G[8G[K[1G[K (reverse-i-search)`': [1G[K (reverse-i-search)`u': a.hasSubsequence(Stream(2,3,5))[30G[55G[1G[K (reverse-i-search)`un': Stream.unfold("a")(x => Some(x, x+1)).take(3).toList[32G[77G[1G[K (reverse-i-search)`unf': Stream.unfold("a")(x => Some(x, x+1)).take(3).toList[33G[78G[1G[K (reverse-i-search)`unfo': Stream.unfold("a")(x => Some(x, x+1)).take(3).toList[34G[79G[1G[K (reverse-i-search)`unfol': Stream.unfold("a")(x => Some(x, x+1)).take(3).toList[35G[80G[1G[K (reverse-i-search)`unfold': Stream.unfold("a")(x => Some(x, x+1)).take(3).toList[36G[81G[1G[K scala> Stream.unfold("a")(x => Some(x, x+1)).take(3).toList[15G[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[20G[21G[22G[23G[24G[25G[24G)(x => Some(x, x+1)).take(3).toList[K[24G[23G)(x => Some(x, x+1)).take(3).toList[K[23G[22G)(x => Some(x, x+1)).take(3).toList[K[22G0)(x => Some(x, x+1)).take(3).toList[23G[22G[21GV(0)(x => Some(x, x+1)).take(3).toList[22Gi(0)(x => Some(x, x+1)).take(3).toList[23Ga(0)(x => Some(x, x+1)).take(3).toList[24GM(0)(x => Some(x, x+1)).take(3).toList[25Ga(0)(x => Some(x, x+1)).take(3).toList[26Gp(0)(x => Some(x, x+1)).take(3).toList[27G[28G[29G[64G | |
| res31: List[Int] = List(0, 1, 2) | |
| scala> Stream.unfoldViaMap(0)(x => Some(x, x+1)).take(3).toList[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[20G[21G[22G[23G[24G[25G[26G[27G[28G[29G[28G[27G[26G[25G[24G[23G[22G[21G[20G[19G[18G[17G[16G[15G[16G[17G[18G[19G[20G[21G[22G[23G[24G[25G[26G[27G[26G(0)(x => Some(x, x+1)).take(3).toList[K[26G[25G(0)(x => Some(x, x+1)).take(3).toList[K[25G[24G(0)(x => Some(x, x+1)).take(3).toList[K[24GF(0)(x => Some(x, x+1)).take(3).toList[25Go(0)(x => Some(x, x+1)).take(3).toList[26Gl(0)(x => Some(x, x+1)).take(3).toList[27Gd(0)(x => Some(x, x+1)).take(3).toList[28G[8G[65G | |
| res32: List[Int] = List(0, 1, 2) | |
| scala> Stream.fibsViaUnfold()[29G0)[30G[31G[30G[29G)[K[29G1)[30G0)[31G[8G[32G.to[34G[K[33G[Ktake()[38G3)[39G[8G[40G.toList[8G[47G | |
| <console>:11: error: fpinscala.laziness.Stream[Int] does not take parameters | |
| Stream.fibsViaUnfold(10).take(3).toList | |
| ^ | |
| scala> Stream.fibsViaUnfold(10).take(3).toList[8G[9G[10G[11G[12G[13G[14G[15G[16G[17G[18G[19G[20G[21G[22G[23G[24G[25G[26G[27G[28G[29G[30G[31G[30G).take(3).toList[K[30G[29G).take(3).toList[K[29G[28G).take(3).toList[K[28G.take(3).toList[K[28G[8G[43G | |
| res34: List[Int] = List(0, 1, 1) | |
| scala> Stream.fibsViaUnfold.take(3).toList[42G[41G[40G[39G[38G[37G[36G[35G[34G[35G[34G).toList[K[34G1).toList[35G0).toList[36G[44G | |
| res35: List[Int] = List(0, 1, 1, 2, 3, 5, 8, 13, 21, 34) | |
| scala> Stream.fibsViaUnfold.take(10).toList[8G[KStream(1,2,3,4,5).zipWith(Stream(1,2,3,4))((x,y) => x + y).toList | |
| res36: List[Int] = List(2, 4, 6, 8) | |
| scala> Stream(1,2,3,4,5).zipWith(Stream(1,2,3,4))((x,y) => x + y).toList[72G[71G[70G[69G[68G[67G[66G[65G[64G[63G[62G y).toList[K[62G* y).toList[63G[8G[73G | |
| res37: List[Int] = List(1, 4, 9, 16) | |
| scala> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment