From 0b05eaa4b5de411437ff82c5b1f7b8fb45e0d4c1 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Sun, 1 Aug 2021 07:09:21 -0700 Subject: [PATCH] document sum --- sh/sum | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sh/sum b/sh/sum index 56c1582..c8e50d0 100644 --- a/sh/sum +++ b/sh/sum @@ -4,6 +4,15 @@ # YES_DASH sum() { ### @- + ### compute the summation of its arguments without forking processes. + ### this relies on the shell's built-in arithmetic operators. + ### + ### ``` + ### $ sum 1 2 3 + ### 6 + ### ``` + ### + ### **TODO:** consider renaming because sum(1) already exists. local sum=0 for i; do : $((sum+=i))