def gridToValue(grid, memo): rows = [] for row in grid.grid: cols = [] for col in row: if col is None: v = linda.Nil() v.sum_pos = 1 else: v = linda.Value(col) v.sum_pos = 0 cols.append(v) rows.append(tuple(cols)) return linda.Value(tuple(rows))
def squareToValue(sq, memo): if sq.val is None: v = linda.Nil() v.sum_pos = 0 else: v = linda.Value(sq.val) v.sum_pos = 1 return v
#!/usr/bin/python import linda linda.connect() t = linda.Type("a :: (long * long);") v = linda.Value((1, 2), t) linda.uts._out((v, )) print linda.uts._in((t, ))
def gridToValue(grid, memo): return linda.Value(grid.rows)
def rowToValue(row, memo): return linda.Value(row.row)
#!/usr/bin/python import linda linda.connect() t1 = linda.Type("t1 :: int * (int * int);") t2 = linda.Type("t2 :: (int * int) * int;") t3 = linda.Type("t3 :: int * int * int;") v = linda.Value((1, (2, 3)), t1) linda.uts._out((v, )) print linda.uts._rd((t1, )) print linda.uts._rd((t2, )) print linda.uts._in((t3, ))
#!/usr/bin/python import linda linda.connect() type = linda.Type("inttype :: int;") value = linda.Value(1, type) linda.uts._out((value, )) print linda.uts._rd((value, )) print linda.uts._rd((type, ))
#!/usr/bin/python import linda linda.connect() t = linda.Type("a :: ((int * int) * bool);") v = linda.Value(((1, 1), True), t) linda.uts._out((v, )) t2 = linda.Type("b :: int * int;") t3 = linda.Type("c :: (b * bool);") print linda.uts._in((t3, ))
#!/usr/bin/python import linda linda.connect() type = linda.Type("intlist :: Nil + (int * intlist);") print type value = linda.Value(None, type) value.setSumPos(0) linda.uts._out((value, )) value = linda.Value(None) value.setSumPos(0) value = linda.Value((3, value)) value.setSumPos(1) value = linda.Value((2, value)) value.setSumPos(1) value = linda.Value((1, value), type) value.setSumPos(1) # end result is (1, (2, (3, None))) linda.uts._out((value, )) print linda.uts._in((type, )) print linda.uts._in((type, ))
#!/usr/bin/python import linda linda.connect() t = linda.Type("a :: int;") v = linda.Value(1, t) linda.uts._out((v, )) print linda.uts._in((t, ))
#!/usr/bin/python import linda linda.connect() t1 = linda.Type("t1 :: int * int * int;") t2 = linda.Type("t2 :: int * (int * int);") print len(t1), len(t2) v = linda.Value((1, 2, 3), t1) print v linda.uts._out((v, )) print linda.uts._in((t2, ))[0]
#!/usr/bin/python import linda linda.connect() ptr1 = linda.Type("ptr1 :: int * ptr(ptr2);") ptr2 = linda.Type("ptr2 :: int;") value2 = linda.Value(1, ptr2) value = linda.Value((1, linda.Ptr(value2)), ptr1) linda.uts._out((value, )) print linda.uts._in((value, ))
def IntPairToValue(pair, memo): return linda.Value((pair.a, pair.b))