Jul. 31st, 2012

jack: (Default)
That took more fiddling than I'd hoped to get all the modulo operators in the right place, but exactly the same system works for modulo equations:
from pylogram import constrain, default_vars as vars

constrain(   vars.a + 5*vars.b == 22 , mod=17 )
constrain( 2*vars.a +   vars.b == -5 , mod=17 )

print( " >> a , b =", vars.a, ",", vars.b )

#  >> a , b = 8, 13

assert (  8 + 5*13)%17 , (22)%17
assert (2*8 +   13)%17 , (-6)%17
jack: (Default)
I've also added arrays, so you can do:
# Warning, untested
fib = Arr(10,Var)
for a,b,c in fib.adj_objs(3):
 c = a + b
fib[0] = fib[1] = 1
assert fib == (1, 1, 2, 3, 5, 8, 13, 21, 34, 55)

graph = Arr(10,Point)
for x,(pt,f) in enumerate(zip(graph,fib)):
 pt.x = 10 * x
 pt.y = 150 - 2 * f
But I really wanted to give an alternative to the "for ... in" syntax, something like:
 fib_pts = Arr(10,Point)
 fib.each() = fib.prev() + fib.prev(2)
or maybe:
 fib[pyl.idx] = fib[pyl.idx-1] + fib[pyl.idx-2]
jack: (Default)
For people in Cambridgeshire, we now can recycle plastic bottle tops. Apparently.

The fact that they changed the advice hopefully suggests they have some reason for it better that guessing.