import edu.rice.cs.mint.runtime.*;

public class DrJavaInteractions {
    public static Code<Integer> makeCodeInt(final int x) { return <| x |>; }
    // public static <T extends CodeFree> Code<T> makeCode(final T x) { return <| x |>; } // BUG: Should compile
    public static separable Code<Integer> spower(Code<Integer> x, int n){
        if (n == 0)
            return <| 1 |>;
        else if (n == 1)
            return x;
        else if (n % 2 == 0)
            return <| let final int y = `x * `x; `(spower( <| y |>, n/2)) |>;
        else
            return <| `x * `(spower(x, n-1)) |>;
//        if (n==0) return <| 1 |>; else return <| `x * `(spower(x, n-1)) |>;
    }
}

