mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
12 lines
243 B
Nim
12 lines
243 B
Nim
discard """
|
|
output: '''-2'''
|
|
"""
|
|
|
|
proc p(x, y: int; cond: bool): int =
|
|
result = if cond: x + y else: x - y
|
|
|
|
template optP{p(x, y, true)}(x, y: expr): expr = x - y
|
|
template optP{p(x, y, false)}(x, y: expr): expr = x + y
|
|
|
|
echo p(2, 4, true)
|