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

1.4 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($stdout: true) gets stdout instead of evaluation result.
  • fn1($action: "wipe") wipes calls and declarations of this function from source document after all calls.
  • fn2($action: "return") returns result after call.
  • fn2($action: "hide") hides call from source document after call.
  • fn2($action: "quote") quotes it without call.
  • fn2($eval: "fn2.txt", $code: "fn2.fnl", $lua: "fn2.lua") writes evaluation results, Fennel code and Lua code.
  • fn3(4, $action: "return") has arg and rkwarg.
  • fn3($action: "return", 5) has rkwarg and arg.
  • fn3($eval: "fn3-4.txt", $code: "fn3-4.fnl", $lua: "fn3-4.lua") writes in same files than below.
  • fn4(a: 1, b: 2, $action: "return") has kwargs and rkwarg.
  • fn4($action: "return", a: 1, b: 2) has rkwarg and kwargs.
  • fn4(a: 1, $action: "return", b: 2) has kwarg, rkwarg and kwarg.
  • fn4($eval: "fn3-4.txt", $code: "fn3-4.fnl", $lua: "fn3-4.lua") writes in same files than above.
  • fn5(10) calls another function inside.
  • fn6(9, 8) calls another quoted function inside.
  • fn7(fn7(1)) calls several functions.