1
0
Fork 0
mirror of synced 2025-09-23 12:18:44 +00:00
ZoKrates/zokrates_cli/examples/book/explicit_generic_parameters.zok
2022-06-28 19:23:45 +02:00

13 lines
No EOL
333 B
Text

// a function to sum the N first powers of a field element
def sum_powers<N>(field a) -> field {
field mut res = 0;
for u32 i in 0..N {
res = res + a ** i;
}
return res;
}
def main(field a) -> field {
// call `sum_powers` providing the explicit generic parameter `N := 5`
return sum_powers::<5>(a);
}