add asciicast

This commit is contained in:
NunoSempere 2024-05-13 23:26:31 +01:00
parent 69b3681697
commit b319e29be8
2 changed files with 25 additions and 5 deletions

View File

@ -49,6 +49,10 @@ $ sed -u "s|#.*||" | sed -u 's|M|000000|g' | go run f.go
# ^ piano tuners in Chicago
```
You can see a recording in action here:
[![asciicast](https://asciinema.org/a/fygBtg0XDc1iVajArdQn9b9CA.svg)](https://asciinema.org/a/fygBtg0XDc1iVajArdQn9b9CA)
## Installation
```

24
f.go
View File

@ -46,22 +46,38 @@ func main() {
var old_low, old_high float64
var input string
var err1, err2 error
InitialForLoop:
for {
input, _ = reader.ReadString('\n')
input = strings.TrimSpace(input)
words := strings.Split(input, " ")
if len(words) != 2 {
fmt.Println("Please enter two floats separated by a space, like: 1 10")
continue
switch len(words) {
case 1:
single_float, err1 := strconv.ParseFloat(words[0], 64)
if err1 != nil {
fmt.Println("Trying to initialize with a scalar, but scalar is not a float")
continue InitialForLoop
}
old_low = single_float
old_high = single_float
case 2:
old_low, err1 = strconv.ParseFloat(words[0], 64)
old_high, err2 = strconv.ParseFloat(words[1], 64)
if err1 != nil || err2 != nil {
fmt.Println("Trying to initialize with a distribution, but distribution is not specified as two floats")
continue InitialForLoop
}
default:
fmt.Println("Please enter two floats separated by a space, like: 1 10")
continue InitialForLoop
}
if err1 != nil || err2 != nil {
fmt.Println("Please enter two floats separated by a space, like: 1 10")
continue
}
break
}
fmt.Printf("=> %.1f %.1f\n", old_low, old_high)