context function 3: op-for
op-for:
description:
op-for(fn, sp)
op-for(fn, sp1, sp2)
op-for(fn, sp1, sp2, sp3)
apply fn to each of the kets in the given superpositions, using a Cartesian product
NB: if given sequences, they are first cast to superpositions
If you want to use sequences, use op-sfor() instead
examples:
-- for loop over single parameter function:
fn (*) #=> |fn:> __ |__self>
op-for( |op: fn>, split |abcde>)
|fn: a> + |fn: b> + |fn: c> + |fn: d> + |fn: e>
-- for loop over two parameter function:
fn2 (*,*) #=> |fn2(> _ |__self1> _ |, > _ |__self2> _ |)>
op-for( |op: fn2>, split |abc>, split |xyz>)
|fn2(a, x)> + |fn2(a, y)> + |fn2(a, z)> + |fn2(b, x)> + |fn2(b, y)> + |fn2(b, z)> + |fn2(c, x)> + |fn2(c, y)> + |fn2(c, z)>
-- for loop over three parameter function:
fn3 (*,*,*) #=> |fn2(> _ |__self1> _ |, > _ |__self2> _ |, > _ |__self3> _ |)>
op-for( |op: fn3>, split |ab>, split |uv>, split |xy>)
|fn2(a, u, x)> + |fn2(a, u, y)> + |fn2(a, v, x)> + |fn2(a, v, y)> + |fn2(b, u, x)> + |fn2(b, u, y)> + |fn2(b, v, x)> + |fn2(b, v, y)>
see also:
op-sfor
Home