Parameterizable qlassf
dakk opened this issue · 1 comments
dakk commented
@qlassf
def test(a: Parameter[Qint2], b: Qint2) -> Qint2
return a + b
will produce an object QlassF
(or UnboundQlassF
) that has unbound parameter a. You can get a normal Qlassf
by running:
test.bind(a=2)
And a
will be set as a constant during compilation.
Use case: sudoku checker
@qlassf
def sudoku_check(const_i: Parameter[Tuple[Qint2, Qint2]], m: Qmatrix[bool, 2, 2]) -> bool:
constr = m[const_i[0]][const_i[1]]
sub0 = m[0][0] ^ m[0][1]
sub1 = m[1][0] ^ m[1][1]
sub2 = m[0][0] ^ m[1][0]
sub3 = m[0][1] ^ m[1][1]
return sub0 and sub1 and sub2 and sub3 and constr
dakk commented
If we put parameters as the function parameter, we are able to detect them only on ast parsing in from_function
.