41 lines
719 B
Plaintext
41 lines
719 B
Plaintext
|
|
# example.snip — demonstrates the Snippet language
|
||
|
|
|
||
|
|
snippet init
|
||
|
|
set x = 5
|
||
|
|
set y = 10
|
||
|
|
print x
|
||
|
|
print y
|
||
|
|
|
||
|
|
snippet adjust_x
|
||
|
|
# If x is small, bump it up; otherwise pull it back down
|
||
|
|
if x < 8
|
||
|
|
increase x
|
||
|
|
increase x
|
||
|
|
increase x
|
||
|
|
if x > 6
|
||
|
|
increase x
|
||
|
|
else
|
||
|
|
decrease x
|
||
|
|
else
|
||
|
|
decrease x
|
||
|
|
print x
|
||
|
|
|
||
|
|
snippet adjust_y
|
||
|
|
if y > 8
|
||
|
|
decrease y
|
||
|
|
if y > 5
|
||
|
|
decrease y
|
||
|
|
decrease y
|
||
|
|
else
|
||
|
|
increase y
|
||
|
|
else
|
||
|
|
increase y
|
||
|
|
print y
|
||
|
|
|
||
|
|
snippet final
|
||
|
|
# Both snippets share variables — x and y from above are visible here
|
||
|
|
if x > 7
|
||
|
|
print x
|
||
|
|
else
|
||
|
|
print y
|