util.go 448 B

12345678910111213141516171819202122232425262728293031323334
  1. package sexp
  2. import (
  3. "fmt"
  4. )
  5. func panic_if_error(err error) {
  6. if err != nil {
  7. panic(err)
  8. }
  9. }
  10. func number_suffix(n int) string {
  11. if n >= 10 && n <= 20 {
  12. return "th"
  13. }
  14. switch n % 10 {
  15. case 1:
  16. return "st"
  17. case 2:
  18. return "nd"
  19. case 3:
  20. return "rd"
  21. }
  22. return "th"
  23. }
  24. func the_list_has_n_children(n int) string {
  25. switch n {
  26. case 1:
  27. return "the list has 1 child only"
  28. }
  29. return fmt.Sprintf("the list has %d children only", n)
  30. }