Esempio n. 1
0
    def __init__(self, a, b):
        self.name = setlx.to_method(self, Test.name, True)
        [a, b] = setlx.copy([a, b])
        self.mA = setlx.copy(a)
        self.mB = setlx.copy(b)
        setlx.print("constructor")

        @setlx.cached_procedure
        def foo(self, x):
            [x] = setlx.copy([x])
            return x + self.mA

        self.foo = setlx.to_method(self, foo)
Esempio n. 2
0
def graph2Dot(relation, start, goal, file):
    [relation, start, goal, file] = setlx.copy([relation, start, goal, file])
    graph = 'graph G {\n'
    graph += '    node [shape = box];\n'
    graph += '    overlap = scale;\n'
    states = setlx.domain(relation) + setlx.range(relation)
    names = setlx.Set([setlx.List([start, 1])])
    graph += f"""    1 [label = "{state2String(start)}", shape = ellipse, color = skyblue, style = filled];
"""
    count = 2
    for s in states:
        if s != start and s != goal:
            graph += f'    {count} [label = "{state2String(s)}"];\n'
            names += setlx.Set([setlx.List([s, count])])
            count += 1
    names += setlx.Set([setlx.List([goal, count])])
    graph += f"""    {count} [label = "{state2String(goal)}", shape = ellipse, color = green, style = filled];
"""
    for [a, b] in relation:
        na = names[a]
        nb = names[b]
        graph += f'    {na} -- {nb};\n'
    graph += '}\n'
    setlx.writeFile(f'{file}.dot', setlx.List([graph]))
    setlx.run(f'neato -Tpdf {file}.dot -o {file}.pdf')
    setlx.run(f'open {file}.pdf')
Esempio n. 3
0
def p(x , y:'rw', z = 1, w = 2):
    [x,z,w] = setlx.copy([x,z,w])
    x[1] = "can write to x"
    y[1] = "can write to y"
    return w+z
Esempio n. 4
0
def t(a,*list):
    [a,list] = setlx.copy([a,list])
    setlx.print(*list)
Esempio n. 5
0
def p(x, y):
    [x,y] = setlx.copy([x,y])
    setlx.print("computed")
    return x+y
Esempio n. 6
0
import setlx

x = 1
y = 3
z = setlx.copy(x)
if x == y or x == z:
    setlx.print("if")
elif x != z:
    setlx.print("else if")
elif x == z:
    setlx.print("else if 2")
else:
    setlx.print("else")
Esempio n. 7
0
 def name(value, self=None):
     [value] = setlx.copy([value])
     if self != None:
         setlx.print("method calls")
     return Test.className
Esempio n. 8
0
 def foo(self, x):
     [x] = setlx.copy([x])
     return x + self.mA
Esempio n. 9
0
def state2String(state):
    [state] = setlx.copy([state])
    if setlx.isList(state):
        return setlx.join(setlx.List([removeQuote(x) for x in state]), '\\\n')
    return removeQuote(state)
Esempio n. 10
0
import setlx

x = 1
bar = "bar"
foo = setlx.copy(bar)

a = b = 1