| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- #nop vim: set filetype=tt:;
- /*
- 本文件属于 PaoTin++ 的一部分。
- PaoTin++ © 2020~2022 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 享有并保留一切法律权利
- 你可以在遵照 GPLv3 协议的基础之上使用、修改及重新分发本程序。
- */
- #function {filter} {
- #local table {%1};
- #local cond {%2};
- #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}
- };
- #function {filterMap} {
- #local table {%1};
- #local cond {%2};
- #local body {%3};
- #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}
- };
- #function {mapIf} {
- #local table {%1};
- #local cond {%2};
- #local body {%3};
- #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}
- };
- #function {map} {
- #local table {%1};
- #local body {%2};
- #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}
- };
|