= arr { case (a, b) => a + b } val out = for { a <- z_1 -< in b <- plus -< (in, a) c <- z_1 -< a d <- plus -< (b, c) } yield d + z-1 ʋ(´ʔʆ)ϊಡΊΔಡΊΔ a b c d in
߹ͤͣݺͿ 21772.108 ± 154.944 val f1: Int => Int = { x => x + 1 } val f2: Int => Double = { x => x + 10.0 } val f3: Double => Int = { x => (x * 100).toInt } val f4: Int => Double = { x => x + 1.5 } val f5: Double => Double = { x => x * 0.01 } val f6: Double => Double = { x => x - 200.0 } val f7: Double => Int = { x => x.toInt } val f8: Int => Int = { x => x + 10 } ! val baseline = { def F(x: Int) = f8(f7(f6(f5(f4(f3(f2(f1(x)))))))) x: Int => F(F(F(F(x)))) } ! val standardF = { def F = f1 andThen f2 andThen f3 andThen f4 andThen f5 andThen f6 andThen f7 andThen f8 F andThen F andThen F andThen F }
ΛݺͿ w $ίϯετϥΫλͷҾͰ͋Δ͖ w ͱ͍͏͜ͱΛɺϑΟʔϧυͷͱ֤Ϋϥεఆ͔ٛΒٻΊΔ class A(val x: Int) class B(val y: Int) extends A(1) class C(val x: Int) extends B(x) ! optimize(new C(1))
$PNNFOTBM$PNQJMFS֓೦ w .FUIPE)BOEMFͷݩωλ w ੴ࡚Ұ໌ࢯͷ֤छࢿྉ w +7.͕࠾༻͍ͯ͠Δ࠷దԽख๏ʹ͍ͭͯͷوॏͳࢿྉ w લʹॻ͔ΕͨͷͰ͕͢ɺ+*5ίϯύΠϥͷॲཧʹͭ ͍ͯॻ͔Εͨࢿྉຊʹগͳ͍ͷͰوॏ w (JPSHJE[F (FPSHF.PEVMBS4ZOUIFTJ[FS1SPHSBNNJOHJO)BTLFMM%JTT.4D%JTTFSUBUJPO %FQBSUNFOUPG$PNQVUFS4DJFODFBOE&OHJOFFSJOH %JWJTJPOPG$PNQVUJOH4DJFODF $IBMNFST 6OJWFSTJUZPG5FDIOPMPHZBOE5IF6OJWFSTJUZPG(PUIFOCVSH (PUIFOCVSH 4XFEFO w )BLFMM :BNQBͰϞδϡϥʔγϯη࡞Δ