Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 4146

How to shorten the code? - Def()

$
0
0

What is the most effective method for rewriting this code in a manner that is both concise and elegant?

def xy():
    xset = {x for x in range(-4, 6)}
    yset = {y for y in range(-3, 4)}
    A = {(x, y) for x in xset for y in yset if 2*x - y == 0}
    B = {(x, y) for x in xset for y in yset if 3*x + y == 0}
    return A&B, A|B

print(xy())

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 4146

Trending Articles