From 27d6efb5f5a076f825fe2da1875e0cabaf02b4e7 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 17 Nov 2021 23:03:07 +0800 Subject: + LuaMacro --- Tools/LuaMacro/tests/test-pl-list.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Tools/LuaMacro/tests/test-pl-list.lua (limited to 'Tools/LuaMacro/tests/test-pl-list.lua') diff --git a/Tools/LuaMacro/tests/test-pl-list.lua b/Tools/LuaMacro/tests/test-pl-list.lua new file mode 100644 index 0000000..26641aa --- /dev/null +++ b/Tools/LuaMacro/tests/test-pl-list.lua @@ -0,0 +1,12 @@ +-- Wrapping list comprehensions so that they return a pl.List +-- the trick here is that the L macro will pop its macro stack at the end, +-- if set. Here we want to wrap L{...} so it returns a list, so we have +-- List(L{...}). By pushing ')', L will emit the close parens for us. +require 'pl' +require_ 'macro.forall' + +def_ LL List( _PUSH_('L',')') L + +print(LL{i|i=1,3}..LL{i|i=10,20,5}) + +print( LL{List{k,v} for k,v in pairs{A=1,B=2}} ) -- cgit v1.1-26-g67d0