29 lines
612 B
Plaintext
29 lines
612 B
Plaintext
$ cat sum.cf
|
|
bundle agent main
|
|
{
|
|
vars:
|
|
"line_count" int => readintarray(
|
|
"input",
|
|
"${this.promise_dirname}${const.dirsep}input.txt",
|
|
"#[^\n]*",
|
|
" ",
|
|
"inf",
|
|
"inf"
|
|
);
|
|
"indices" slist => getindices( "input" );
|
|
reports:
|
|
"${with}" with => format( "%d", eval( "${input[${indices}][0]} + ${input[${indices}][1]}" ));
|
|
DEBUG::
|
|
"line_count is ${line_count}";
|
|
"input is ${with}" with => storejson( "input" );
|
|
"input[${indices}] is ${with}" with => storejson( "input[${indices}]" );
|
|
}
|
|
|
|
$ cat input.txt
|
|
2 3
|
|
2 2
|
|
|
|
$ cf-agent -KIf ./sum.cf
|
|
R: 5
|
|
R: 4
|