silq
silq copied to clipboard
Functions on arrays?
Amazing job guys. Any reason the first snippet can't be written as the second one?
1:
for k in [0..n) { cand[k] := H(cand[k]);
2:
cand := H(cand);
It's done in other languages like Python for example. Also your example for Grover's algorithm already does this in the circuit diagram! There's just one wire going into Hⁿ
:
So it would only be logical to implement in this language too, as Silq definitely attempts in giving a higher level of abstraction than building circuits and directly manipulating single bit registers. Again, great job on this, and I'll be eagerly waiting for when this language can export to some circuit format so we could play around with it on different systems, even maybe real ones.
I do agree that there should be some shorthand for this as it is very common. However, it is not fully clear to me what is the best way to do it.
Implicit mapping has some drawbacks, for example, it is ambiguous for some generic functions:
def twice[a:*](const x:a)⇒(x,x);
def main()⇒twice(1,2); // ((1,2),(1,2)) or ((1,1),(2,2))?