mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2025-12-06 16:57:04 +08:00
These demonstrate the global scope of namespaces, defining functions and variables within namespaces, and namespace nesting by copy or reference.
7 lines
189 B
ChaiScript
7 lines
189 B
ChaiScript
namespace("math")
|
|
|
|
math.square = fun(x) { x * x }
|
|
math.sum_squares = fun(x, y) { math.square(x) + math.square(y) }
|
|
|
|
assert_equal(16, math.square(4))
|
|
assert_equal(29, math.sum_squares(2, 5)) |