computable-pandoc/tests/pass.lit.complex.md

1.0 KiB

Declarations

-- fn1()
print("I am in stdout")
"Wipes it"

-- fn2()
1 + 2 + 3

-- fn3(n)
#n .. " " .. #n

-- fn4(a, b)
#a * #b

Recursive Declarations

-- fn5(x)
#fn2() * x

-- fn6(y, z)
#y + #fn2($action: "quote") + #z

-- fn7(a) 
#a + #fn4(#a, #fn2())

Calls

Valid calls:

  • fn1($results: "value") gets value of the last expression as result; it is the default setting.
  • fn1($results: "output") gets stdout as result.
  • fn2($action: "shift") shifts call for result.
  • fn2($action: "quote") quotes it instead of calling it.
  • fn3(4, $action: "shift") has arg and rkwarg.
  • fn3($action: "shift", 5) has rkwarg and arg.
  • fn4($action: "shift", a: 1, b: 2) has rkwarg and kwargs.
  • fn4(a: 1, $action: "shift", b: 2) has kwarg, rkwarg and kwarg.
  • fn4(a: 1, b: 2, $action: "shift") has kwargs and rkwarg.
  • fn5(10) calls another function inside.
  • fn6(9, 8) calls another quoted function inside.
  • fn7(fn7(1)) calls several functions.