(use magic-pipes) (use args) (use ports) (use chicken-syntax) (receive (options operands before-exprs after-exprs usage) (parse-mp-args (command-line-arguments) '() "predicate-expr" "Read s-expressions from standard input, applies the procedure-expr to them, and writes the s-expressions to standard output if the predicate returned a true value.") (unless (= (length operands) 1) (usage)) (let* ((expr (parse-code (car operands))) (ec (make-eval-context before-exprs (list expr) after-exprs)) (closure (eval-context-handler-closure ec 0))) (for-each-input-datum (lambda (input) (when (without-ports (lambda () (closure input))) (data-write input) (newline)))) (without-input-port (eval-context-end-closure ec))))