--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/relpipe-data/examples/guile-file-count-size-sum.sh Thu Feb 07 16:24:21 2019 +0100
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+# argument: directory path
+# prints file count and sum of file sizes
+
+find "$1" -type f -print0 \
+ | relpipe-in-filesystem \
+ --file path \
+ --file size \
+ | relpipe-tr-guile \
+ --relation 'f.*' \
+ --output-attribute 'count' integer \
+ --output-attribute 'sum' integer \
+ --before-records '
+ (define $sum 0)
+ (define $count 0)
+ (define return-sum #f)' \
+ --for-each '
+ (set! $sum (+ $sum $size) )
+ (set! $count (+ $count 1 ) )' \
+ --where '#f' \
+ --after-records '(set! return-sum #t)' \
+ --has-more-records '
+ (if return-sum
+ (begin (set! return-sum #f) #t)
+ #f
+ )' \
+ | relpipe-out-tabular