Files
marqdo/tests/lib/foreign-json.mq.md
T
cflmy e32ff8f6b3 feat(foreign): structured invoke, presets, probe and config
F0/F1: safe execution core (exec gate, bounded IO, process-group timeout), structured invoke records, run options, 15 language presets, register/unset/probe/config, view stderr/exit/ms, and node/bash gold tests.
2026-10-18 01:26:53 +08:00

583 B


title: foreign invoke JSON input import foreign:lib/foreign.mq.md

main

数值表 =

数值
1
2
3
4

统计 =

let s = "";
process.stdin.on("data", d => { s += d; });
process.stdin.on("end", () => {
  const xs = JSON.parse(s);
  console.log(JSON.stringify({ n: xs.length, sum: xs.reduce((a, b) => a + b, 0) }));
});

记录 = > foreign.invoke code=统计 input=数值表 output="json" 统计结果 = result

print text=ok print text=n print text=sum