words.go27 lines, 1.1 KB
| 1 | package main |
| 2 | |
| 3 | import "math/rand/v2" |
| 4 | |
| 5 | // Three short lists make a thousand posts that read like people wrote them. |
| 6 | var ( |
| 7 | openers = []string{"Finally,", "Today", "Quick thought:", "Honestly,", |
| 8 | "Small win:", "Note to self:", "This morning", "Somehow", |
| 9 | "Fair warning:", "Plot twist:"} |
| 10 | subjects = []string{"the coffee here is", "my sourdough is", "the train is", |
| 11 | "this book is", "the new build is", "the garden is", "the rain is", |
| 12 | "the cat is", "the playlist is", "a quiet Sunday is"} |
| 13 | endings = []string{"exactly right.", "better than expected.", |
| 14 | "still a mystery.", "worth the wait.", "a little too loud.", |
| 15 | "good enough for now.", "the best part of the day.", |
| 16 | "doing its own thing.", "somehow perfect.", "not what I ordered."} |
| 17 | ) |
| 18 | |
| 19 | // writer returns a function that writes one post after another. It has a |
| 20 | // generator of its own, so the graph and who posts when are what they were. |
| 21 | func writer(seed uint64) func() string { |
| 22 | r := rand.New(rand.NewPCG(seed, 1)) |
| 23 | pick := func(words []string) string { return words[r.IntN(len(words))] } |
| 24 | return func() string { |
| 25 | return pick(openers) + " " + pick(subjects) + " " + pick(endings) |
| 26 | } |
| 27 | } |