summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2026-04-02 10:59:18 -0400
committerSam Anthony <sam@samanthony.xyz>2026-04-02 10:59:18 -0400
commit8bd3d98cb03e0be26084ca94224b8ef4e1e15a71 (patch)
tree9ff7b5ab23901f4a9934ee4e32c5a0c253632c5c
parent1343ef5b4c922ed512ae64a86d22970ebff7155d (diff)
downloadmarkov-8bd3d98cb03e0be26084ca94224b8ef4e1e15a71.zip
create module, remove fmtHEADmaster
-rw-r--r--.gitignore1
-rw-r--r--fmt.go34
-rw-r--r--go.mod3
-rwxr-xr-xtest6
4 files changed, 8 insertions, 36 deletions
diff --git a/.gitignore b/.gitignore
index ba9e3e6..c94b1c4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1 @@
markov
-fmt
diff --git a/fmt.go b/fmt.go
deleted file mode 100644
index 1fdee92..0000000
--- a/fmt.go
+++ /dev/null
@@ -1,34 +0,0 @@
-// This program wraps its input into short lines. It is based on fmt.awk from "The
-// Practice of Programming" by Brian Kernighan and Rob Pike (pp. 229).
-package main
-
-import (
- "bufio"
- "fmt"
- "os"
-)
-
-const maxWidth = 80 // maximum number of characters per line
-
-func main() {
- input := bufio.NewScanner(os.Stdin)
- input.Split(bufio.ScanWords)
- width := 0
- for input.Scan() {
- word := input.Text()
-
- if width+1+len(word) > maxWidth {
- fmt.Println()
- width = 0
- }
-
- if width == 0 {
- fmt.Print(word)
- width += len(word)
- } else {
- fmt.Printf(" %s", word)
- width += 1 + len(word)
- }
- }
- fmt.Println()
-}
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..42f9a01
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,3 @@
+module git.samanthony.xyz/markov
+
+go 1.25.8
diff --git a/test b/test
index 2ae88b5..d365413 100755
--- a/test
+++ b/test
@@ -1,4 +1,6 @@
-#!/usr/bin/sh
+#!/bin/sh
+
+set -e
# Check boundary conditions with small files. Output should match input.
for f in empty a ab abc abcd; do
@@ -20,3 +22,5 @@ rm out
# Check that the output has a similar ratio of c's and d's to test randomness of
# suffix selection.
./markov <tests/stats | freq -c | awk -f tests/stats.awk
+
+echo ok