Jump to content

Four sides of square: Difference between revisions

m
→‎Procedural: create separate section; improve comment
(→‎Procedural: added another version showing interesting Python features)
m (→‎Procedural: create separate section; improve comment)
Line 481:
See Raku output.
 
===Elaborate procedural===
 
The following version illustrates several features of Python, such as default arguments, nested functions with lexical scoping, generators, and convenient syntax for creating sets and performing set operations such as intersection.
 
Line 488:
def is_at_border(row, col):
# `&` is set intersection: if the set {row, col} intersects the set
# {0, size-1}, then at least one of (row, col) is either 0 or size-1
return {row, col} & {0, size-1}
 
Cookies help us deliver our services. By using our services, you agree to our use of cookies.