File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
sbt-dotty/sbt-test/sbt-dotty/quoted-example-project/src/main/scala/hello Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -30,17 +30,17 @@ object Main {
30
30
assert(Math .pow(3 , 4 ) == toTheFourth(3 ))
31
31
}
32
32
33
- def stagedPower (n : Int ): Double => Double = {
33
+ def stagedPower (n : Int ): Double => Double = run {
34
34
// Code representing the labmda where the recursion is unrolled based on the value of n
35
35
val code = ' { (x : Double ) => $ {powerCode(n, ' {x})}}
36
36
37
37
code.show
38
38
39
39
// Evaluate the contents of the code and return it's value
40
- code.run
40
+ code
41
41
}
42
42
43
- def powerCode (n : Int , x : Expr [Double ]): Expr [Double ] =
43
+ def powerCode (n : Int , x : Expr [Double ]) given QuoteContext : Expr [Double ] =
44
44
if (n == 0 ) ' {1.0 }
45
45
else if (n == 1 ) x
46
46
else if (n < 0 ) throw new Exception (" Negative powers not implemented. Left as a small exercise. Dont be shy, try it out." )
You can’t perform that action at this time.
0 commit comments