Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created July 14, 2015 14:59
Show Gist options
  • Save shigemk2/011e531f312324c39a90 to your computer and use it in GitHub Desktop.
Save shigemk2/011e531f312324c39a90 to your computer and use it in GitHub Desktop.
[info] Loading project definition from /home/shigemk2/projects/github.com/fpinscala/fpinscala/project
[info] Set current project to fpinscala (in build file:/home/shigemk2/projects/github.com/fpinscala/fpinscala/)
>  (reverse-i-search)`':  (reverse-i-search)`a': answers/console (reverse-i-search)`an': answers/console (reverse-i-search)`anw':  >
> answers/console
[info] Starting scala interpreter...
[info] 
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>  (reverse-i-search)`':  (reverse-i-search)`i': println(a(List(1))) (reverse-i-search)`im': import fpinscala.parallelism._ (reverse-i-search)`imp': import fpinscala.parallelism._ (reverse-i-search)`impo': import fpinscala.parallelism._ (reverse-i-search)`impor': import fpinscala.parallelism._ scala> import fpinscala.parallelism._._._._._._._._._._._._state_.._
import fpinscala.state._
scala> import fpinscala.state._Add(N(1),Add(x(1,3),x(3,2),x(2,2),x(6,1),x(1,2),x(3,1),x(2,1),N(6)))} Var("x", a, n)def x(a: Int, n: Int): Var = {)Add(N(1),Add(x(1,3),x(3,2),x(2,2),x(6,1),x(1,2),x(3,1),x(2,1),N(6)))println(a(List(1)))} case List(xs) => Add(N(xs))) => N(1)xs) => Add(N(xs))}println(a(List(1)))Add(N(1)),Add(x(1,3),x(3,2),x(2,2),x(6,1),x(1,2),x(3,1),x(2,1),N(6)))def x(a: Int, n: Int): Var = { Var("x", a, n)}Add(N(1),Add(x(1,3),x(3,2),x(2,2),x(6,1),x(1,2),x(3,1),x(2,1),N(6)))import fpinscala.state._import fpinscala.state._Add(N(1),Add(x(1,3),x(3,2),x(2,2),x(6,1),x(1,2),x(3,1),x(2,1),N(6)))} Var("x", a, n)def x(a: Int, n: Int): Var = {)Add(N(1),Add(x(1,3),x(3,2),x(2,2),x(6,1),x(1,2),x(3,1),x(2,1),N(6)))println(a(List(1)))} case List(xs) => Add(N(xs))) => N(1)def a(xs: List[Int]): Expr = xs match {case class Mul(n: Expr*) extends ExprAdd(n: Expr*) extends ExprVar(x: String, a: Int, n: Int) extends ExprN(n: Int) extends Exprsealed trait Expr X.y("a" +: Seq("b", "c"):_*)X.y(Seq("a", "b", "c")):_*)"a", "b", "c")object X { def y(s: String*) = println(s(0)) }for (x <- List(1,2,3,4,5,6,7,8,9); y <- List(1,2,3,4,5,6,7,8,9); z = x * y; if z == 24) yield(x,y) to 9); y <- List(1 to 9); z = x * y; if z == 24) yield(x+y),2,3,4,5,6,7,8,9); y <- List(1,2,3,4,5,6,7,8,9); z = x * y; if z == 24) yield(x+y)1 to 9; y <- 1 to 9; z = x * y; if z == 24) yield(x+y),y)z)+ y) yield(z)List(1 to 9); y <- List(1 to 9); z = x + y) yield(z)) yield(x,y)println(x + y)) xx(x + y)yield (x + y); ) yield (x + y){x <- List(1 to 9); y <- List(1 to 9); if x > 3} yield (x + y)(x <- List(1 to 9); y <- List(1 to 9); if x > 3) yield (x + y) if x > 3) yield (x + y){x + y}(x + y)x + y) yield x + yif (x * y) == 24) yield x + yx * y == 24) yield x + y{x <- List(1 to 9) y <- List(1 to 9) if x * y == 24} yield x + y(x <- List(1 to 9) y <- List(1 to 9) if x * y == 24) yield x + y) yield x if x == 3) println(x) xxyield x, y <- List(1 to 9) if x * y == 24) yield x + yList(1 to 9)Seq(1 to 9)List(List(1,2,3),List(4,5,6)).flatMap(x => List(x,x+1))1 + x))x + 1))0,1,2).flatMap(n => List(n,'A'+n))List(1,2,3),List(4,5,6)).flatMap(x => x + "1")(0) + "1")1).toInt + 1)tn + 1)(x: Int) => x + 1)x: Int => x + 1) => x + 1)List(x) => x + 1)x => List(x + "A"))'A'))1))x + 1)) + 1)List(x + 1))'A'))"A"))List(x) => x + 1)x => x + 1): Int => x + 1)(x: Int) => x + 1)x => x.toItn + 1)nt + 1)(0) + 1)"1")1).toInt + 1)tn + 1)(x: Int) => x + 1)x: Int => x + 1) => x + 1)List(x) => x + 1)x => List(x + "A"))'A'))1))x + 1)) + 1)List(x + 1))'A'))"A")) (reverse-i-search)`':  (reverse-i-search)`v': val a = List(1,2,3) (reverse-i-search)`va': val a = List(1,2,3) (reverse-i-search)`val': val a = List(1,2,3) (reverse-i-search)`val ': val a = List(1,2,3) scala> val a = List(1,2,3) (reverse-i-search)`':  (reverse-i-search)`R': val rng = RNG.Simple(42) (reverse-i-search)`RN': val rng = RNG.Simple(42) (reverse-i-search)`RNG': val rng = RNG.Simple(42) scala> val rng = RNG.Simple(42)
rng: fpinscala.state.RNG.Simple = Simple(42)
scala> rng.
asInstanceOf copy nextInt productElement productPrefix toString
canEqual isInstanceOf productArity productIterator seed
scala> rng.
asInstanceOf copy nextInt productElement productPrefix toString
canEqual isInstanceOf productArity productIterator seed
scala> rng. (reverse-i-search)`':  (reverse-i-search)`R': val rng = RNG.Simple(42) (reverse-i-search)`RN': val rng = RNG.Simple(42) (reverse-i-search)`RNG': val rng = RNG.Simple(42) (reverse-i-search)`RNG': val rng = RNG.Simple(42) (reverse-i-search)`RNG': val rand = RNG scala> val rand = RNG
rand: fpinscala.state.RNG.type = fpinscala.state.RNG$@7dca2b98
scala> rand.mmap
map map2
scala> rand.map
def map[A, B](s: RNG => (A, fpinscala.state.RNG))(f: A => B): RNG => (B, fpinscala.state.RNG)
scala> rand.map2() (reverse-i-search)`':  (reverse-i-search)`r': val rand = RNG (reverse-i-search)`rn': val rng = RNG.Simple(42) (reverse-i-search)`rng': val rng = RNG.Simple(42) (reverse-i-search)`rng1':  (reverse-i-search)`rng1':  scala> val rand = RNGng = RNG.Simple(42)1 = RNG.Simple(42)
rng1: fpinscala.state.RNG.Simple = Simple(42)
scala> val rng1 = RNG.Simple(42)0) = RNG.Simple(420)2 = RNG.Simple(420)
rng2: fpinscala.state.RNG.Simple = Simple(420)
scala> rand.map2())map2
def map2[A, B, C](ra: RNG => (A, fpinscala.state.RNG), rb: RNG => (B, fpinscala.state.RNG))(f: (A, B) => C): RNG => (C, fpinscala.state.RNG)
scala> rand.map2()r)n)g)1),) )r)n)g)2)
scala> rand.map2(rng1, rng2)).()_),)_)
<console>:14: error: missing parameter type for expanded function ((x$1, x$2) => rand.map2(rng1, rng2)(x$1, x$2))
rand.map2(rng1, rng2)(_,_)
^
<console>:14: error: missing parameter type for expanded function ((x$1: <error>, x$2) => rand.map2(rng1, rng2)(x$1, x$2))
rand.map2(rng1, rng2)(_,_)
^
<console>:14: error: type mismatch;
found : fpinscala.state.RNG.Simple
required: rand.Rand[?]
(which expands to) fpinscala.state.RNG => (?, fpinscala.state.RNG)
rand.map2(rng1, rng2)(_,_)
^
<console>:14: error: type mismatch;
found : fpinscala.state.RNG.Simple
required: rand.Rand[?]
(which expands to) fpinscala.state.RNG => (?, fpinscala.state.RNG)
rand.map2(rng1, rng2)(_,_)
^
scala> rand.map2(rng1, rng2)(_,_), rng2)(_,_), rng2)(_,_), rng2)(_,_), rng2)(_,_)r, rng2)(_,_)a, rng2)(_,_)n, rng2)(_,_)d, rng2)(_,_))(_,_))(_,_))(_,_))(_,_)r)(_,_)a)(_,_)n)(_,_)d)(_,_)
<console>:12: error: missing parameter type for expanded function ((x$1, x$2) => rand.map2(rand, rand)(x$1, x$2))
rand.map2(rand, rand)(_,_)
^
<console>:12: error: missing parameter type for expanded function ((x$1: <error>, x$2) => rand.map2(rand, rand)(x$1, x$2))
rand.map2(rand, rand)(_,_)
^
<console>:12: error: type mismatch;
found : fpinscala.state.RNG.type
required: rand.Rand[?]
(which expands to) fpinscala.state.RNG => (?, fpinscala.state.RNG)
rand.map2(rand, rand)(_,_)
^
<console>:12: error: type mismatch;
found : fpinscala.state.RNG.type
required: rand.Rand[?]
(which expands to) fpinscala.state.RNG => (?, fpinscala.state.RNG)
rand.map2(rand, rand)(_,_)
^
scala> rand.map2
def map2[A, B, C](ra: RNG => (A, fpinscala.state.RNG), rb: RNG => (B, fpinscala.state.RNG))(f: (A, B) => C): RNG => (C, fpinscala.state.RNG)
scala> rand.map2
def map2[A, B, C](ra: RNG => (A, fpinscala.state.RNG), rb: RNG => (B, fpinscala.state.RNG))(f: (A, B) => C): RNG => (C, fpinscala.state.RNG)
scala> rand.map2rand
res2: fpinscala.state.RNG.type = fpinscala.state.RNG$@7dca2b98
scala> randrand.map2(rand, rand)(_,_)ng1, rng2)(_,_)()_),)\))_)
<console>:14: error: missing parameter type for expanded function ((x$1, x$2) => rand.map2(rng1, rng2)(x$1, x$2))
rand.map2(rng1, rng2)(_,_)
^
<console>:14: error: missing parameter type for expanded function ((x$1: <error>, x$2) => rand.map2(rng1, rng2)(x$1, x$2))
rand.map2(rng1, rng2)(_,_)
^
<console>:14: error: type mismatch;
found : fpinscala.state.RNG.Simple
required: rand.Rand[?]
(which expands to) fpinscala.state.RNG => (?, fpinscala.state.RNG)
rand.map2(rng1, rng2)(_,_)
^
<console>:14: error: type mismatch;
found : fpinscala.state.RNG.Simple
required: rand.Rand[?]
(which expands to) fpinscala.state.RNG => (?, fpinscala.state.RNG)
rand.map2(rng1, rng2)(_,_)
^
scala>  (reverse-i-search)`':  (reverse-i-search)`d': rand.map2(rng1, rng2)(_,_) (reverse-i-search)`do': rand.double(rng) (reverse-i-search)`dou': rand.double(rng) (reverse-i-search)`doub': rand.double(rng) (reverse-i-search)`doubl': rand.double(rng) (reverse-i-search)`double': rand.double(rng) scala> rand.double(rng)
res4: (Double, fpinscala.state.RNG) = (0.007524831686168909,Simple(1059025964525))
scala> rand.double(rng) (reverse-i-search)`':  (reverse-i-search)`i': val rng2 = RNG.Simple(420) (reverse-i-search)`in': import fpinscala.state._ (reverse-i-search)`int': println(a(List(1))) (reverse-i-search)`intD': a.intDouble(rng) (reverse-i-search)`intDo': a.intDouble(rng) scala> a.intDouble(rng)
<console>:12: error: not found: value a
a.intDouble(rng)
^
scala> a.intDouble(rng).intDouble(rng)r.intDouble(rng)a.intDouble(rng)n.intDouble(rng)d.intDouble(rng)
res6: ((Int, Double), fpinscala.state.RNG) = ((16159453,0.5967354848980904),Simple(197491923327988))
scala> rand.intDouble(rng)randrand
randDoubleInt randIntDouble
scala> rand.randrand
randDoubleInt randIntDouble
scala> rand.randDoublrandDoubleInt
res7: rand.Rand[(Double, Int)] = <function1>
scala> rand.randDoubleIntrandIntDouble
res8: rand.Rand[(Int, Double)] = <function1>
scala> rand.randIntDouble()2).)0),) )1)))))))1),) )2).)0)
<console>:12: error: too many arguments for method apply: (v1: fpinscala.state.RNG)((Int, Double), fpinscala.state.RNG) in trait Function1
rand.randIntDouble(1, 2.0)
^
scala> rand.randIntDouble(1, 2.0)1, 2.0)
res10: rand.Rand[(Int, Double)] = <function1>
scala> rand.randIntDoublevrand.randIntDoublearand.randIntDoublelrand.randIntDouble rand.randIntDoublearand.randIntDouble rand.randIntDouble=rand.randIntDouble rand.randIntDouble
a: rand.Rand[(Int, Double)] = <function1>
scala> val a = rand.randIntDoublea.
andThen apply asInstanceOf compose isInstanceOf toString
scala> a.
andThen apply asInstanceOf compose isInstanceOf toString
scala> a.()2).)).)0))))1),) )2).)0)
<console>:13: error: too many arguments for method apply: (v1: fpinscala.state.RNG)((Int, Double), fpinscala.state.RNG) in trait Function1
a(1, 2.0)
^
scala> a(1, 2.0)a(1, 2.0)p(1, 2.0)p(1, 2.0)(1, 2.0)(1, 2.0)(1, 2.0).(1, 2.0)a(1, 2.0)p(1, 2.0)p(1, 2.0)l(1, 2.0)y(1, 2.0)
<console>:13: error: too many arguments for method apply: (v1: fpinscala.state.RNG)((Int, Double), fpinscala.state.RNG) in trait Function1
a.apply(1, 2.0)
^
scala> a.apply(1, 2.0)apply(1, 2.0)pply(1, 2.0)ply(1, 2.0)ly(1, 2.0)y(1, 2.0)(1, 2.0)1, 2.0)a(1, 2.0)val a = rand.randIntDoublerand.randIntDouble(1, 2.0)DoubleInt
res13: rand.Rand[(Double, Int)] = <function1>
scala> rand.randDoubleInt (reverse-i-search)`':  (reverse-i-search)`i': rand.intDouble(rng) (reverse-i-search)`in': rand.intDouble(rng) (reverse-i-search)`ind': a.find(x => x == 6) (reverse-i-search)`indD':  (reverse-i-search)`ind': a.find(x => x == 6) (reverse-i-search)`in': rand.intDouble(rng) (reverse-i-search)`int': rand.intDouble(rng) (reverse-i-search)`intD': rand.intDouble(rng) (reverse-i-search)`intDo': rand.intDouble(rng) (reverse-i-search)`intDou': rand.intDouble(rng) (reverse-i-search)`intDoub': rand.intDouble(rng) (reverse-i-search)`intDoubl': rand.intDouble(rng) (reverse-i-search)`intDouble': rand.intDouble(rng) scala> rand.intDouble(rng)
res14: ((Int, Double), fpinscala.state.RNG) = ((16159453,0.5967354848980904),Simple(197491923327988))
scala> rand.intDouble(rng)randDoubleInta.apply(1, 2.0)rand.randDoubleInt)()r)n)g)
res15: ((Double, Int), fpinscala.state.RNG) = ((0.007524831686168909,-1281479697),Simple(197491923327988))
scala> rand.randDoubleInt(rng)IntDouble()r)n)g)
res16: ((Int, Double), fpinscala.state.RNG) = ((16159453,0.5967354848980904),Simple(197491923327988))
scala> rand.randIntDouble(rng)DoubleInt(rng)intDouble(rng)randDoubleIntintDouble(rng)randDoubleInt(rng)IntDouble(rng)rand.randIntDouble(rng)DoubleInt(rng)intDouble(rng)randDoubleInta.apply(1, 2.0)(1, 2.0)val a = rand.randIntDoublerand.randIntDouble(1, 2.0)DoubleIntintDouble(rng)a.intDouble(rng)rand.double(rng)map2(rng1, rng2)(_,_).map2(rand, rand)(_,_)ng1, rng2)(_,_)val rng2 = RNG.Simple(420)1 = RNG.Simple(42)and = RNGng = RNG.Simple(42)import fpinscala.state._Add(N(1),Add(x(1,3),x(3,2),x(2,2),x(6,1),x(1,2),x(3,1),x(2,1),N(6)))} Var("x", a, n)def x(a: Int, n: Int): Var = {)Add(N(1),Add(x(1,3),x(3,2),x(2,2),x(6,1),x(1,2),x(3,1),x(2,1),N(6)))println(a(List(1)))}println(a(List(1)))Add(N(1)),Add(x(1,3),x(3,2),x(2,2),x(6,1),x(1,2),x(3,1),x(2,1),N(6)))def x(a: Int, n: Int): Var = { Var("x", a, n)}Add(N(1),Add(x(1,3),x(3,2),x(2,2),x(6,1),x(1,2),x(3,1),x(2,1),N(6)))import fpinscala.state._val rng = RNG.Simple(42)and = RNGng1 = RNG.Simple(42)2 = RNG.Simple(420)rand.map2(rng1, rng2)(_,_)and, rand)(_,_).map2(rng1, rng2)(_,_)double(rng)a.intDouble(rng)rand.intDouble(rng)randDoubleIntIntDouble(1, 2.0)val a = rand.randIntDoublea(1, 2.0).apply(1, 2.0)(1, 2.0)val a = rand.randIntDoublerand.randIntDouble(1, 2.0)DoubleIntintDouble(rng)a.intDouble(rng)rand.double(rng)map2(rng1, rng2)(_,_).map2(rand, rand)(_,_)ng1, rng2)(_,_)val rng2 = RNG.Simple(420)1 = RNG.Simple(42)and = RNGng = RNG.Simple(42)import fpinscala.state._Add(N(1),Add(x(1,3),x(3,2),x(2,2),x(6,1),x(1,2),x(3,1),x(2,1),N(6)))} Var("x", a, n)def x(a: Int, n: Int): Var = {)Add(N(1),Add(x(1,3),x(3,2),x(2,2),x(6,1),x(1,2),x(3,1),x(2,1),N(6)))println(a(List(1)))} case List(xs) => Add(N(xs))) => N(1)def a(xs: List[Int]): Expr = xs match {case class Mul(n: Expr*) extends ExprAdd(n: Expr*) extends ExprVar(x: String, a: Int, n: Int) extends ExprN(n: Int) extends Exprsealed trait Expr X.y("a" +: Seq("b", "c"):_*)X.y(Seq("a", "b", "c")):_*)"a", "b", "c")object X { def y(s: String*) = println(s(0)) }for (x <- List(1,2,3,4,5,6,7,8,9); y <- List(1,2,3,4,5,6,7,8,9); z = x * y; if z == 24) yield(x,y) to 9); y <- List(1 to 9); z = x * y; if z == 24) yield(x+y),2,3,4,5,6,7,8,9); y <- List(1,2,3,4,5,6,7,8,9); z = x * y; if z == 24) yield(x+y)1 to 9; y <- 1 to 9; z = x * y; if z == 24) yield(x+y),y)z)+ y) yield(z)List(1 to 9); y <- List(1 to 9); z = x + y) yield(z)) yield(x,y)println(x + y)) xx(x + y)yield (x + y); ) yield (x + y){x <- List(1 to 9); y <- List(1 to 9); if x > 3} yield (x + y)(x <- List(1 to 9); y <- List(1 to 9); if x > 3) yield (x + y) if x > 3) yield (x + y){x + y}(x + y)x + y) yield x + yif (x * y) == 24) yield x + yx * y == 24) yield x + y{x <- List(1 to 9) y <- List(1 to 9) if x * y == 24} yield x + y(x <- List(1 to 9) y <- List(1 to 9) if x * y == 24) yield x + y) yield x if x == 3) println(x) xxyield x, y <- List(1 to 9) if x * y == 24) yield x + yList(1 to 9)Seq(1 to 9)List(List(1,2,3),List(4,5,6)).flatMap(x => List(x,x+1))1 + x))x + 1))0,1,2).flatMap(n => List(n,'A'+n))List(1,2,3),List(4,5,6)).flatMap(x => x + "1")(0) + "1")1).toInt + 1)tn + 1)(x: Int) => x + 1)List(List(1,2,3),List(4,5,6)).flatMap(x: Int => x + 1) (reverse-i-search)`':  (reverse-i-search)`i': List(List(1,2,3),List(4,5,6)).flatMap(x => x + 1) (reverse-i-search)`in': object X { def y(s: String*) = println(s) } (reverse-i-search)`int': object X { def y(s: String*) = println(s) } scala> object X { def y(s: String*) = println(s) }
scala>  (reverse-i-search)`':  (reverse-i-search)`i': rand.intDouble(rng) (reverse-i-search)`in': rand.intDouble(rng) (reverse-i-search)`int': rand.intDouble(rng) scala> rand.intDouble(rng)
res17: ((Int, Double), fpinscala.state.RNG) = ((16159453,0.5967354848980904),Simple(197491923327988))
scala> rand.nonnonNegative
nonNegativeEven nonNegativeInt nonNegativeLessThan
scala> rand.nonNegativeLnonNegativeLessThan
def nonNegativeLessThan(n: Int): RNG => (Int, fpinscala.state.RNG)
scala> rand.nonNegativeLessThan()2)
res18: rand.Rand[Int] = <function1>
scala> rand.nonNegativeLessThan(2)()r)n)g)
res19: (Int, fpinscala.state.RNG) = (1,Simple(1059025964525))
scala> rand.nonNegativeLessThan(2)(rng)
res20: (Int, fpinscala.state.RNG) = (1,Simple(1059025964525))
scala> rand.nonNegativeLessThan(2)(rng))(rng)3)(rng)
res21: (Int, fpinscala.state.RNG) = (1,Simple(1059025964525))
scala> rand.nonNegativeLessThan(3)(rng)
res22: (Int, fpinscala.state.RNG) = (1,Simple(1059025964525))
scala> rand.nonNegativeLessThan(3)(rng) (reverse-i-search)`':  (reverse-i-search)`s': rand.nonNegativeLessThan(2)(rng) (reverse-i-search)`si': version (reverse-i-search)`sim': // This definition and `formatAbs` are very similar.. (reverse-i-search)`simp': like this from simpler components, without giving up the efficiency
[info] Loading project definition from /home/shigemk2/projects/github.com/fpinscala/fpinscala/project
[info] Set current project to fpinscala (in build file:/home/shigemk2/projects/github.com/fpinscala/fpinscala/)
> answers/console
[info] Starting scala interpreter...
[info] 
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> rand.nonNegativeLessThan(3)(rng) (reverse-i-search)`':  (reverse-i-search)`r': rand.nonNegativeLessThan(2)(rng) (reverse-i-search)`rn': rand.nonNegativeLessThan(2)(rng) (reverse-i-search)`rng': rand.nonNegativeLessThan(2)(rng) (reverse-i-search)`rng': rand.intDouble(rng) (reverse-i-search)`rng': rand.randIntDouble(rng) (reverse-i-search)`rng': rand.randDoubleInt(rng) (reverse-i-search)`rng ': val rng = RNG.Simple(42) scala> val rng = RNG.Simple(42)
<console>:7: error: not found: value RNG
val rng = RNG.Simple(42)
^
scala>  (reverse-i-search)`':  (reverse-i-search)`i': val rng = RNG.Simple(42) (reverse-i-search)`im': val rng = RNG.Simple(42) (reverse-i-search)`imp': val rng = RNG.Simple(42) (reverse-i-search)`impo': import fpinscala.state._ (reverse-i-search)`impor': import fpinscala.state._ scala> import fpinscala.state._
import fpinscala.state._
scala> import fpinscala.state._val rng = RNG.Simple(42)
rng: fpinscala.state.RNG.Simple = Simple(42)
scala> val rng = RNG.Simple(42)import fpinscala.state._val rng = RNG.Simple(42)rand.nonNegativeLessThan(3)(rng))))R)N)G).)S)i)m)p)l)e)()))4))4))
<console>:11: error: not found: value rand
rand.nonNegativeLessThan(3)(RNG.Simple(44))
^
scala> rand.nonNegativeLessThan(3)(RNG.Simple(44)) (reverse-i-search)`':  (reverse-i-search)`v': val rng = RNG.Simple(42) (reverse-i-search)`va': val rng = RNG.Simple(42) (reverse-i-search)`val': val rng = RNG.Simple(42) (reverse-i-search)`val ': val rng = RNG.Simple(42) (reverse-i-search)`val r': val rng = RNG.Simple(42) (reverse-i-search)`val ra': val rand = RNG (reverse-i-search)`val ran': val rand = RNG (reverse-i-search)`val rand': val rand = RNG scala> val rand = RNG
rand: fpinscala.state.RNG.type = fpinscala.state.RNG$@71f24c5e
scala> val rand = RNGrand.nonNegativeLessThan(3)(RNG.Simple(44))
res1: (Int, fpinscala.state.RNG) = (2,Simple(1109455772359))
scala> rand.nonNegativeLessThan(3)(RNG.Simple(44)))(RNG.Simple(44))4)(RNG.Simple(44))4)(RNG.Simple(44))
res2: (Int, fpinscala.state.RNG) = (39,Simple(1109455772359))
scala> rand.nonNegativeLessThan(44)(RNG.Simple(44))
res3: (Int, fpinscala.state.RNG) = (39,Simple(1109455772359))
scala> rand.nonNegativeLessThan(44)(RNG.Simple(44))
res4: (Int, fpinscala.state.RNG) = (39,Simple(1109455772359))
scala> rand.nonNegativeLessThan(44)(RNG.Simple(44))
res5: (Int, fpinscala.state.RNG) = (39,Simple(1109455772359))
scala> rand.nonNegativeLessThan(44)(RNG.Simple(44))
res6: (Int, fpinscala.state.RNG) = (39,Simple(1109455772359))
scala> rand.nonNegativeLessThan(44)(RNG.Simple(44))))))4))3))
res7: (Int, fpinscala.state.RNG) = (26,Simple(1084240868442))
scala> rand.nonNegativeLessThan(44)(RNG.Simple(43))
res8: (Int, fpinscala.state.RNG) = (26,Simple(1084240868442))
scala> val rng = new scala.util.Random
rng: scala.util.Random = scala.util.Random@72c5e634
scala> rng.nextDouble
res9: Double = 0.9763503745002748
scala> rng.nextDoubleInt
res10: Int = -1849569144
scala> rng.nextInt
res11: Int = 553186662
scala> rng.nextInt
res12: Int = -744285841
scala> rng.nextInt
res13: Int = 1873741984
scala> rng.nextInt
res14: Int = -1094483583
scala> rng.nextInt (reverse-i-search)`':  (reverse-i-search)`r': rng.nextDouble (reverse-i-search)`rn': rng.nextDouble (reverse-i-search)`rng': rng.nextDouble (reverse-i-search)`rng': val rng = new scala.util.Random (reverse-i-search)`rng': val rng = RNG.Simple(42) (reverse-i-search)`rng': val rng = RNG.Simple(42) (reverse-i-search)`rng': rand.nonNegativeLessThan(3)(rng) scala> rand.nonNegativeLessThan(3)(rng)ne
Rand boolean int map2 sequence
_double both intDouble nonNegativeEven toString
_ints double ints nonNegativeInt unit
_map double3 ints2 nonNegativeLessThan
_map2 doubleInt isInstanceOf randDoubleInt
asInstanceOf flatMap map randIntDouble
scala> rand.intint
int intDouble ints ints2
scala> rand.int
val int: RNG => (Int, fpinscala.state.RNG)
scala> rand.int()3),) )R))R)N)G).)S)i)m)p)l)e)()))4))2))
<console>:12: error: too many arguments for method apply: (v1: fpinscala.state.RNG)(Int, fpinscala.state.RNG) in trait Function1
rand.int(3, RNG.Simple(42))
^
scala> rand.int(3, RNG.Simple(42)) RNG.Simple(42))) RNG.Simple(42))RNG.Simple(42))(RNG.Simple(42))
<console>:12: error: type mismatch;
found : Int(3)
required: fpinscala.state.RNG
rand.int(3)(RNG.Simple(42))
^
scala> rand.int(3)(RNG.Simple(42))RNG.Simple(42))RNG.Simple(42))RNG.Simple(42))RNG.Simple(42))(RNG.Simple(42))
res17: (Int, fpinscala.state.RNG) = (16159453,Simple(1059025964525))
scala> rand.int(RNG.Simple(42))
res18: (Int, fpinscala.state.RNG) = (16159453,Simple(1059025964525))
scala> rand.int(RNG.Simple(42))
res19: (Int, fpinscala.state.RNG) = (16159453,Simple(1059025964525))
scala> rand.int(RNG.Simple(42))
res20: (Int, fpinscala.state.RNG) = (16159453,Simple(1059025964525))
scala> rand.int(RNG.Simple(42))
res21: (Int, fpinscala.state.RNG) = (16159453,Simple(1059025964525))
scala> rand.int(RNG.Simple(42))mapmap
map map2
scala> rand.map
def map[A, B](s: RNG => (A, fpinscala.state.RNG))(f: A => B): RNG => (B, fpinscala.state.RNG)
scala> rand.map2map2
def map2[A, B, C](ra: RNG => (A, fpinscala.state.RNG), rb: RNG => (B, fpinscala.state.RNG))(f: (A, B) => C): RNG => (C, fpinscala.state.RNG)
scala> rand.map2()R)N)G),) )R)N)G)
<console>:12: error: type mismatch;
found : fpinscala.state.RNG.type
required: rand.Rand[?]
(which expands to) fpinscala.state.RNG => (?, fpinscala.state.RNG)
rand.map2(RNG, RNG)
^
<console>:12: error: type mismatch;
found : fpinscala.state.RNG.type
required: rand.Rand[?]
(which expands to) fpinscala.state.RNG => (?, fpinscala.state.RNG)
rand.map2(RNG, RNG)
^
scala> rand.map2(RNG, RNG)()_) ),) )_)
<console>:12: error: missing parameter type for expanded function ((x$1, x$2) => rand.map2(RNG, RNG)(x$1, x$2))
rand.map2(RNG, RNG)(_ , _)
^
<console>:12: error: missing parameter type for expanded function ((x$1: <error>, x$2) => rand.map2(RNG, RNG)(x$1, x$2))
rand.map2(RNG, RNG)(_ , _)
^
<console>:12: error: type mismatch;
found : fpinscala.state.RNG.type
required: rand.Rand[?]
(which expands to) fpinscala.state.RNG => (?, fpinscala.state.RNG)
rand.map2(RNG, RNG)(_ , _)
^
<console>:12: error: type mismatch;
found : fpinscala.state.RNG.type
required: rand.Rand[?]
(which expands to) fpinscala.state.RNG => (?, fpinscala.state.RNG)
rand.map2(RNG, RNG)(_ , _)
^
scala> rand.map2(RNG, RNG)(_ , _)., RNG)(_ , _)S, RNG)(_ , _)i, RNG)(_ , _)m, RNG)(_ , _)p, RNG)(_ , _)l, RNG)(_ , _)e, RNG)(_ , _)(, RNG)(_ , _)), RNG)(_ , _)4), RNG)(_ , _)2), RNG)(_ , _).)(_ , _)S)(_ , _)I)(_ , _)m)(_ , _)p)(_ , _))(_ , _))(_ , _))(_ , _)i)(_ , _)m)(_ , _)p)(_ , _)l)(_ , _)e)(_ , _)()(_ , _)))(_ , _)4))(_ , _)3))(_ , _)
<console>:12: error: missing parameter type for expanded function ((x$1, x$2) => rand.map2(RNG.Simple(42), RNG.Simple(43))(x$1, x$2))
rand.map2(RNG.Simple(42), RNG.Simple(43))(_ , _)
^
<console>:12: error: missing parameter type for expanded function ((x$1: <error>, x$2) => rand.map2(RNG.Simple(42), RNG.Simple(43))(x$1, x$2))
rand.map2(RNG.Simple(42), RNG.Simple(43))(_ , _)
^
<console>:12: error: type mismatch;
found : fpinscala.state.RNG.Simple
required: rand.Rand[?]
(which expands to) fpinscala.state.RNG => (?, fpinscala.state.RNG)
rand.map2(RNG.Simple(42), RNG.Simple(43))(_ , _)
^
<console>:12: error: type mismatch;
found : fpinscala.state.RNG.Simple
required: rand.Rand[?]
(which expands to) fpinscala.state.RNG => (?, fpinscala.state.RNG)
rand.map2(RNG.Simple(42), RNG.Simple(43))(_ , _)
^
scala>  (reverse-i-search)`':  (reverse-i-search)`r': rand.map2(RNG.Simple(42), RNG.Simple(43))(_ , _) (reverse-i-search)`ra': rand.map2(RNG.Simple(42), RNG.Simple(43))(_ , _) (reverse-i-search)`ran': rand.map2(RNG.Simple(42), RNG.Simple(43))(_ , _) (reverse-i-search)`rand': rand.map2(RNG.Simple(42), RNG.Simple(43))(_ , _) (reverse-i-search)`rand': rand.map2(RNG, RNG)(_ , _) (reverse-i-search)`rand': rand.map2(RNG, RNG) (reverse-i-search)`rand': rand.int(RNG.Simple(42)) scala> rand.int(RNG.Simple(42)) (reverse-i-search)`':  (reverse-i-search)`v': val rng = new scala.util.Random (reverse-i-search)`va': val rng = new scala.util.Random (reverse-i-search)`val': val rng = new scala.util.Random (reverse-i-search)`val ': val rng = new scala.util.Random (reverse-i-search)`val r': val rng = new scala.util.Random (reverse-i-search)`val ra': val rand = RNG (reverse-i-search)`val ran': val rand = RNG (reverse-i-search)`val rand': val rand = RNG scala> val rand = RNG[Int]
<console>:10: error: object RNG does not take type parameters.
val rand = RNG[Int]
^
scala> val rand = RNG[Int]] = RNG = RNG = RNG = RNG: = RNG = RNGR = RNGa = RNGn = RNGd = RNG
<console>:10: error: not found: type Rand
val rand: Rand = RNG
^
scala> [val rand: Rand = RNGval rand: Rand = RNG = RNG[Int]: Rand = RNG
<console>:10: error: not found: type Rand
val rand: Rand = RNG
^
scala> val rand: Rand = RNG[ = RNGI = RNGn = RNGt = RNG] = RNG
<console>:10: error: not found: type Rand
val rand: Rand[Int] = RNG
^
scala> val rand: Rand[Int] = RNGval rand: Rand = RNG = RNG[Int]rand.map2(RNG.Simple(42), RNG.Simple(43))(_ , _)
<console>:12: error: missing parameter type for expanded function ((x$1, x$2) => rand.map2(RNG.Simple(42), RNG.Simple(43))(x$1, x$2))
rand.map2(RNG.Simple(42), RNG.Simple(43))(_ , _)
^
<console>:12: error: missing parameter type for expanded function ((x$1: <error>, x$2) => rand.map2(RNG.Simple(42), RNG.Simple(43))(x$1, x$2))
rand.map2(RNG.Simple(42), RNG.Simple(43))(_ , _)
^
<console>:12: error: type mismatch;
found : fpinscala.state.RNG.Simple
required: rand.Rand[?]
(which expands to) fpinscala.state.RNG => (?, fpinscala.state.RNG)
rand.map2(RNG.Simple(42), RNG.Simple(43))(_ , _)
^
<console>:12: error: type mismatch;
found : fpinscala.state.RNG.Simple
required: rand.Rand[?]
(which expands to) fpinscala.state.RNG => (?, fpinscala.state.RNG)
rand.map2(RNG.Simple(42), RNG.Simple(43))(_ , _)
^
scala> rand.map2(RNG.Simple(42), RNG.Simple(43))(_ , _)NG.Simple(42), RNG.Simple(43))(_ , _)G.Simple(42), RNG.Simple(43))(_ , _).Simple(42), RNG.Simple(43))(_ , _)Simple(42), RNG.Simple(43))(_ , _)imple(42), RNG.Simple(43))(_ , _)mple(42), RNG.Simple(43))(_ , _)ple(42), RNG.Simple(43))(_ , _)le(42), RNG.Simple(43))(_ , _)e(42), RNG.Simple(43))(_ , _)(42), RNG.Simple(43))(_ , _)42), RNG.Simple(43))(_ , _)2), RNG.Simple(43))(_ , _)), RNG.Simple(43))(_ , _), RNG.Simple(43))(_ , _)r, RNG.Simple(43))(_ , _)a, RNG.Simple(43))(_ , _)n, RNG.Simple(43))(_ , _)d, RNG.Simple(43))(_ , _)., RNG.Simple(43))(_ , _) , RNG.Simple(43))(_ , _)R , RNG.Simple(43))(_ , _) , RNG.Simple(43))(_ , _)Rand)()4)2), rand.Rand()4343)).()_),)_)
<console>:12: error: missing parameter type for expanded function ((x$1, x$2) => rand.map2(rand.<Rand: error>(42), rand.<Rand: error>(43))(x$1, x$2))
rand.map2(rand.Rand(42), rand.Rand(43))(_,_)
^
<console>:12: error: missing parameter type for expanded function ((x$1: <error>, x$2) => rand.map2(rand.<Rand: error>(42), rand.<Rand: error>(43))(x$1, x$2))
rand.map2(rand.Rand(42), rand.Rand(43))(_,_)
^
scala> rand.map2(rand.Rand(42), rand.Rand(43))(_,_)42), rand.Rand(43))(_,_)42), rand.Rand(43))(_,_)42), rand.Rand(43))(_,_)42), rand.Rand(43))(_,_)42), rand.Rand(43))(_,_)(42), rand.Rand(43))(_,_)43))(_,_)43))(_,_)43))(_,_)43))(_,_)43))(_,_)43))(_,_)(43))(_,_)(42), rand(43))(_,_)
<console>:12: error: missing parameter type for expanded function ((x$1, x$2) => rand.map2(rand(42), rand(43))(x$1, x$2))
rand.map2(rand(42), rand(43))(_,_)
^
<console>:12: error: missing parameter type for expanded function ((x$1: <error>, x$2) => rand.map2(rand(42), rand(43))(x$1, x$2))
rand.map2(rand(42), rand(43))(_,_)
^
<console>:12: error: fpinscala.state.RNG.type does not take parameters
rand.map2(rand(42), rand(43))(_,_)
^
<console>:12: error: fpinscala.state.RNG.type does not take parameters
rand.map2(rand(42), rand(43))(_,_)
^
scala>  (reverse-i-search)`':  (reverse-i-search)`v': val rand: Rand[Int] = RNG (reverse-i-search)`va': val rand: Rand[Int] = RNG (reverse-i-search)`val': val rand: Rand[Int] = RNG (reverse-i-search)`val ': val rand: Rand[Int] = RNG (reverse-i-search)`val r': val rand: Rand[Int] = RNG (reverse-i-search)`val ra': val rand: Rand[Int] = RNG (reverse-i-search)`val ran': val rand: Rand[Int] = RNG (reverse-i-search)`val rand': val rand: Rand[Int] = RNG scala> val rand: Rand[Int] = RNGal randl rand randrand()4)2)
<console>:12: error: fpinscala.state.RNG.type does not take parameters
rand(42)
^
scala> rand.
Rand boolean int map2 sequence
_double both intDouble nonNegativeEven toString
_ints double ints nonNegativeInt unit
_map double3 ints2 nonNegativeLessThan
_map2 doubleInt isInstanceOf randDoubleInt
asInstanceOf flatMap map randIntDouble
scala> rand.intint
int intDouble ints ints2
scala> rand.int
res29: rand.Rand[Int] = <function1>
scala> rand.int()4)2)
<console>:12: error: type mismatch;
found : Int(42)
required: fpinscala.state.RNG
rand.int(42)
^
scala> rand.int(42)mapmap
map map2
scala> rand.map2map2()r)a)n)d).)i)n)t),) )r)a)n)d).)i)n)t)()_),) )_)
<console>:12: error: missing parameter type for expanded function ((x$1, x$2) => rand.map2(rand.int, rand.int)(x$1, x$2))
rand.map2(rand.int, rand.int)(_, _)
^
<console>:12: error: missing parameter type for expanded function ((x$1: <error>, x$2) => rand.map2(rand.int, rand.int)(x$1, x$2))
rand.map2(rand.int, rand.int)(_, _)
^
scala> rand.map2(rand.int, rand.int)(_, _) )=)>) )S)m)p)))i)m)p)))))))))()S)i)m)p)l)e)()))4))2))RSimple(42))NSimple(42))DSimple(42)).Simple(42))
<console>:12: error: missing parameter type for expanded function ((x$1, x$2) => rand.map2(rand.int, rand.int)(x$1, x$2)(RND.Simple(42)))
rand.map2(rand.int, rand.int)(_, _)(RND.Simple(42))
^
<console>:12: error: missing parameter type for expanded function ((x$1: <error>, x$2) => rand.map2(rand.int, rand.int)(x$1, x$2)(RND.Simple(42)))
rand.map2(rand.int, rand.int)(_, _)(RND.Simple(42))
^
scala> rand.map2(rand.int, rand.int)(_, _)(RND.Simple(42))rand.map2(rand.int, rand.int)(_, _)(RND.Simple(42)) _)(RND.Simple(42)) _)(RND.Simple(42))+ _)(RND.Simple(42))
<console>:12: error: not found: value RND
rand.map2(rand.int, rand.int)(_ + _)(RND.Simple(42))
^
scala> rand.map2(rand.int, rand.int)(_ + _)(RND.Simple(42)) (reverse-i-search)`':  (reverse-i-search)`S': rand.map2(rand.int, rand.int)(_, _)(RND.Simple(42)) (reverse-i-search)`Si': rand.map2(rand.int, rand.int)(_, _)(RND.Simple(42)) (reverse-i-search)`Sim': rand.map2(rand.int, rand.int)(_, _)(RND.Simple(42))  (reverse-i-search)`Simp': rand.map2(rand.int, rand.int)(_, _)(RND.Simple(42)) (reverse-i-search)`Simpl': rand.map2(rand.int, rand.int)(_, _)(RND.Simple(42)) (reverse-i-search)`Simple': rand.map2(rand.int, rand.int)(_, _)(RND.Simple(42)) scala> rand.map2(rand.int, rand.int)(_, _)(RND.Simple(42))rand.map2(rand.int, rand.int)(_, _)int(42)map2(rand.int, rand.int)(_, _)(RND.Simple(42)) + _)(RND.Simple(42)).Simple(42))G.Simple(42))
res34: (Int, fpinscala.state.RNG) = (-1265320244,Simple(197491923327988))
scala> rand.map2(rand.int, rand.int)(_ + _)(RNG.Simple(42)))(_ + _)(RNG.Simple(42)))(_ + _)(RNG.Simple(42)))(_ + _)(RNG.Simple(42))d)(_ + _)(RNG.Simple(42))o)(_ + _)(RNG.Simple(42))u)(_ + _)(RNG.Simple(42))b)(_ + _)(RNG.Simple(42))l)(_ + _)(RNG.Simple(42))e)(_ + _)(RNG.Simple(42))
res35: (Double, fpinscala.state.RNG) = (1.6159453596735485E7,Simple(197491923327988))
scala> rand.map2(rand.int, rand.double)(_ + _)(RNG.Simple(42)) _)(RNG.Simple(42))- _)(RNG.Simple(42))
res36: (Double, fpinscala.state.RNG) = (1.6159452403264515E7,Simple(197491923327988))
scala> rand.map2(rand.int, rand.double)(_ - _)(RNG.Simple(42))
res37: (Double, fpinscala.state.RNG) = (1.6159452403264515E7,Simple(197491923327988))
scala> rand.map2(rand.int, rand.double)(_ - _)(RNG.Simple(42)) _)(RNG.Simple(42))+ _)(RNG.Simple(42)) _)(RNG.Simple(42)) _)(RNG.Simple(42)), _)(RNG.Simple(42))(_, _)(RNG.Simple(42))_)(RNG.Simple(42))))(RNG.Simple(42))
res38: ((Int, Double), fpinscala.state.RNG) = ((16159453,0.5967354848980904),Simple(197491923327988))
scala> rand.map2(rand.int, rand.double)((_,_))(RNG.Simple(42))
res39: ((Int, Double), fpinscala.state.RNG) = ((16159453,0.5967354848980904),Simple(197491923327988))
scala> rand.map2(rand.int, rand.double)((_,_))(RNG.Simple(42))
res40: ((Int, Double), fpinscala.state.RNG) = ((16159453,0.5967354848980904),Simple(197491923327988))
scala> rand.map2(rand.int, rand.double)((_,_))(RNG.Simple(42))rand.int()r)n)g)
<console>:13: error: type mismatch;
found : scala.util.Random
required: fpinscala.state.RNG
rand.int(rng)
^
scala>  (reverse-i-search)`':  (reverse-i-search)`a': rand.int(rng) (reverse-i-search)`al': val rand: Rand[Int] = RNG (reverse-i-search)`a': rand.int(rng) (reverse-i-search)`':  (reverse-i-search)`v': val rand: Rand[Int] = RNG (reverse-i-search)`va': val rand: Rand[Int] = RNG (reverse-i-search)`val': val rand: Rand[Int] = RNG scala> val rand: Rand[Int] = RNG (reverse-i-search)`':  (reverse-i-search)`v': val rand: Rand = RNG (reverse-i-search)`va': val rand: Rand = RNG (reverse-i-search)`val': val rand: Rand = RNG (reverse-i-search)`val ': val rand: Rand = RNG (reverse-i-search)`val r': val rand: Rand = RNG (reverse-i-search)`val rn': val rng = new scala.util.Random (reverse-i-search)`val rng': val rng = new scala.util.Random scala> val rng = new scala.util.Random (reverse-i-search)`':  (reverse-i-search)`v': rand.nonNegativeLessThan(44)(RNG.Simple(43)) (reverse-i-search)`va': val rand = RNG (reverse-i-search)`val': val rand = RNG (reverse-i-search)`val ': val rand = RNG (reverse-i-search)`val r': val rand = RNG (reverse-i-search)`val rn': val rng = RNG.Simple(42) (reverse-i-search)`val rng': val rng = RNG.Simple(42) (reverse-i-search)`val rng ': val rng = RNG.Simple(42) scala> val rng = RNG.Simple(42)
rng: fpinscala.state.RNG.Simple = Simple(42)
scala> val rng = RNG.Simple(42)rand.int(rng)
res42: (Int, fpinscala.state.RNG) = (16159453,Simple(1059025964525))
scala> List()1).fivList(1)aList(1)lList(1) List(1)aList(1) List(1)=List(1) List(1)
a: List[Int] = List(1)
scala> a.fifi
filter filterNot find
scala> a.fifi
filter filterNot find
scala> a.fill()x))3)()List.
ReusableCBF canBuildFrom fill newBuilder toString
apply concat isInstanceOf range unapplySeq
asInstanceOf empty iterate tabulate
scala> List.fill()3)()2)
res43: List[Int] = List(2, 2, 2)
scala> List.fill(3)(2) (reverse-i-search)`':  (reverse-i-search)`r': rand.int(rng) (reverse-i-search)`ra': rand.int(rng) (reverse-i-search)`ran': rand.int(rng) (reverse-i-search)`rand': rand.int(rng) (reverse-i-search)`rand.': rand.int(rng) (reverse-i-search)`rand.': rand.int(rng) (reverse-i-search)`rand.': rand.map2(rand.int, rand.double)((_,_))(RNG.Simple(42)) scala> rand.map2(rand.int, rand.double)((_,_))(RNG.Simple(42))maseqsequence()
def sequence[A](fs: List[fpinscala.state.RNG.Rand[A]]): RNG => (List[A], fpinscala.state.RNG)
scala> rand.sequence()L)i)s)t)()))r))n))g)).))i))n))t)),)) ))r))n))g)),)))).))i))n))t))
<console>:13: error: value int is not a member of fpinscala.state.RNG.Simple
rand.sequence(List(rng.int, rng.int))
^
<console>:13: error: value int is not a member of fpinscala.state.RNG.Simple
rand.sequence(List(rng.int, rng.int))
^
scala> rand.sequence(List(rng.int, rng.int)) (reverse-i-search)`':  (reverse-i-search)`m': val rng = RNG.Simple(42) (reverse-i-search)`ma': rand.map2(rand.int, rand.double)((_,_))(RNG.Simple(42)) (reverse-i-search)`map': rand.map2(rand.int, rand.double)((_,_))(RNG.Simple(42)) (reverse-i-search)`map2': rand.map2(rand.int, rand.double)((_,_))(RNG.Simple(42)) scala> rand.map2(rand.int, rand.double)((_,_))(RNG.Simple(42))rand.map2(rand.int, rand.double)(_ - _)(RNG.Simple(42))+ _)(RNG.Simple(42))int)(_ + _)(RNG.Simple(42))D.Simple(42))
<console>:12: error: not found: value RND
rand.map2(rand.int, rand.int)(_ + _)(RND.Simple(42))
^
scala> rand.map2(rand.int, rand.int)(_ + _)(RND.Simple(42))sequence(List(rng.int, rng.int)).int, rng.int)).int, rng.int))a.int, rng.int))n.int, rng.int))d.int, rng.int)).int)).int))a.int))n.int))d.int))
res46: rand.Rand[List[Int]] = <function1>
scala> rand.sequence(List(rand.int, rand.int))()r)n)g)
res47: (List[Int], fpinscala.state.RNG) = (List(16159453, -1281479697),Simple(197491923327988))
scala> rand.int()r)n)g)
res48: (Int, fpinscala.state.RNG) = (16159453,Simple(1059025964525))
scala> rand.int(rng)in__
_double _ints _map _map2
scala> rand._nints_ints
def _ints(count: Int): RNG => (List[Int], fpinscala.state.RNG)
scala> rand._ints()5)
res49: rand.Rand[List[Int]] = <function1>
scala> rand._ints(5)()5))r)n)g)
res50: (List[Int], fpinscala.state.RNG) = (List(16159453, -1281479697, -340305902, -2015756020, 1770001318),Simple(115998806404289))
scala>
[success] Total time: 14005 s, completed 2015/07/14 23:58:48
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment