#nop vim: set filetype=tt:; /* 本文件属于 PaoTin++ 的一部分。 PaoTin++ © 2020~2022 的所有版权均由担子炮(dzp ) 享有并保留一切法律权利 你可以在遵照 GPLv3 协议的基础之上使用、修改及重新分发本程序。 */ #func {filter} { #local table {%1}; #local cond {%2}; #local key {}; #local value {}; #replace {cond} {KEY} {$$key}; #replace {cond} {VALUE} {$$value}; #local newTable {}; #local key {}; #foreach {*table[]} {key} { #local value {$table[$key]}; #line sub var #if { $cond } { #cat newTable {{$key}{$value}}; }; }; #return {$newTable} }; #func {filterMap} { #local table {%1}; #local cond {%2}; #local body {%3}; #local key {}; #local value {}; #replace {cond} {KEY} {$$key}; #replace {cond} {VALUE} {$$value}; #replace {body} {KEY} {$$key}; #replace {body} {VALUE} {$$value}; #local newTable {}; #local key {}; #foreach {*table[]} {key} { #local value {$table[$key]}; #line sub var #if { $cond } { #cat newTable {{$key}{$body}}; }; }; #return {$newTable} }; #func {mapIf} { #local table {%1}; #local cond {%2}; #local body {%3}; #local key {}; #local value {}; #replace {cond} {KEY} {$$key}; #replace {cond} {VALUE} {$$value}; #replace {body} {KEY} {$$key}; #replace {body} {VALUE} {$$value}; #local newTable {}; #local key {}; #foreach {*table[]} {key} { #local value {$table[$key]}; #line sub var { #if { $cond } { #cat newTable {{$key}{$body}}; }; #else { #cat newTable {{$key}{$value}}; }; }; }; #return {$newTable} }; #func {map} { #local table {%1}; #local body {%2}; #local key {}; #local value {}; #replace {body} {KEY} {$$key}; #replace {body} {VALUE} {$$value}; #local newTable {}; #local key {}; #foreach {*table[]} {key} { #local value {$table[$key]}; #cat newTable {{$key}{$body}}; }; #return {$newTable} };