From e5030c26073a63425b9a7058ec5d76f702f231aa Mon Sep 17 00:00:00 2001 From: Isaac Good Date: Sat, 7 Nov 2026 08:14:21 -0800 Subject: [PATCH] Make `docs/SIGN_UP_SNIPPET.txt` idiomatic --- docs/SIGN_UP_SNIPPET.txt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/SIGN_UP_SNIPPET.txt b/docs/SIGN_UP_SNIPPET.txt index 33df817..5cbcad1 100644 --- a/docs/SIGN_UP_SNIPPET.txt +++ b/docs/SIGN_UP_SNIPPET.txt @@ -1,10 +1,15 @@ -function most_common_word(text, words, counts, n, i, best) { - n = split(tolower(text), words, " ") +BEGIN { best = "" - for (i = 1; i <= n; i++) { - counts[words[i]]++ - if (counts[words[i]] > counts[best]) - best = words[i] +} +{ + for (i = 1; i <= NF; i++) { + word = tolower($i) + counts[word]++ + if (counts[word] > counts[best]) { + best = word + } } - return sprintf("\"%s\" appears %d times", best, counts[best]) +} +END { + printf "'%s' appears %d times\n", best, counts[best] }