예제 #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)
예제 #2
0
class Test(setlx.SetlXClass):
    # static part
    className = "test"
    setlx.print("static")

    @staticmethod
    def name(value, self=None):
        [value] = setlx.copy([value])
        if self != None:
            setlx.print("method calls")
        return Test.className

    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)
예제 #3
0
import setlx

t = "test"

lc = lambda a: setlx.print(a, t)

lc("closure")
예제 #4
0
import setlx

if True:
    setlx.print("true")
elif False:
    setlx.print("false")
else:
    setlx.print("default")
예제 #5
0
import setlx


def t(a,*list):
    [a,list] = setlx.copy([a,list])
    setlx.print(*list)

t(1,2,3)

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

a = setlx.List(["can't write to x"])
b = setlx.List(["can't write to y"])
p(a,b)
setlx.print(a)
setlx.print(b)
예제 #6
0
def t(a,*list):
    [a,list] = setlx.copy([a,list])
    setlx.print(*list)
예제 #7
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")
예제 #8
0
def p(x, y):
    [x,y] = setlx.copy([x,y])
    setlx.print("computed")
    return x+y
예제 #9
0
import setlx
x = setlx.List()
x = setlx.List([1, 2, 3, 'test'])
setlx.print(x[1])
y = x[x[1]]

t = setlx.List(["with_rest", *x])

a = setlx.List(setlx._range(1, 10))
b = setlx.List(setlx._range(1, 10, 3 - 1))
setlx.print(a)
setlx.print(b)
a = setlx.List([x for x in a if x > 2])
a = setlx.List([(c * d) for c in a for d in b if c + d > 2])
setlx.print(a[10:20])
setlx.print(a[1:])
setlx.print(a[:20])
예제 #10
0
import setlx

x = 10
while True:
    setlx.print(x)
    x = x - 1
    if not(x > 0):
        break
예제 #11
0
    # static part
    className = "test"
    setlx.print("static")

    @staticmethod
    def name(value, self=None):
        [value] = setlx.copy([value])
        if self != None:
            setlx.print("method calls")
        return Test.className

    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)


t = Test(1, 2)
setlx.print(Test.name(20))
setlx.print(t.foo(10))
setlx.print(t.name(20))
예제 #12
0
import setlx

x = 2
setlx.print(f"{x}")
setlx.print(f"{x**2} = {x} * {x}")
setlx.print("")
setlx.print("test")
예제 #13
0
import setlx

x = "py"
setlx.print("setlx", 2, x)
예제 #14
0
import setlx

x = 2
exit()
setlx.print("not reachable")
예제 #15
0
import setlx

v = setlx.Vector(1, 2, 3)
y = v + setlx.Vector(0, 1, 0)
setlx.print(2 * y)
예제 #16
0
def test():
    setlx.print('before backtrack')
    raise setlx.BacktrackException()
예제 #17
0
import setlx


def test():
    setlx.print('before backtrack')
    raise setlx.BacktrackException()


try:
    test()
except setlx.BacktrackException:
    setlx.print('after backtrack')

예제 #18
0
import setlx

x = True
y = not (x)
setlx.print(y)
예제 #19
0
 def name(value, self=None):
     [value] = setlx.copy([value])
     if self != None:
         setlx.print("method calls")
     return Test.className
예제 #20
0
import setlx

try:
    setlx.throw(1)
except setlx.UserException as e:
    err = setlx.unpack_error(e)
    setlx.print('user error', err)
except Exception as e:
    err = setlx.unpack_error(e)
    setlx.print('language error', err)
except Exception as e:
    err = setlx.unpack_error(e)
    setlx.print('error', err)
예제 #21
0
import setlx

x = "ab_"
y = "xy_"
for a in x:
    if (a != '_'):
        setlx.print(a)

for [a, b] in setlx.cartesian_product(x, y):
    setlx.print(a, b)

for [a, b] in setlx.cartesian_product(x, y):
    if a != b:
        setlx.print(a, b)