Example #1
0
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))
Example #2
0
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
Example #3
0
#!/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, ))
Example #4
0
def gridToValue(grid, memo):
    return linda.Value(grid.rows)
Example #5
0
def rowToValue(row, memo):
    return linda.Value(row.row)
Example #6
0
#!/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, ))
Example #7
0
#!/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, ))
Example #8
0
#!/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, ))
Example #9
0
#!/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, ))
Example #10
0
#!/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, ))
Example #11
0
#!/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]
Example #12
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, ))
Example #13
0
def IntPairToValue(pair, memo):
    return linda.Value((pair.a, pair.b))