propagate scalar ops, tweaks
This commit is contained in:
parent
b1a4f2bd3c
commit
4204db0c32
|
@ -24,7 +24,7 @@ $ go run f.go
|
||||||
=> 2573.1 33632.0
|
=> 2573.1 33632.0
|
||||||
/ 6 8
|
/ 6 8
|
||||||
=> 368.4 4893.5
|
=> 368.4 4893.5
|
||||||
/ 60 60
|
/ 60
|
||||||
=> 6.1 81.6
|
=> 6.1 81.6
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ $ sed -u "s|#.*||" | sed -u 's|M|000000|g' | go run f.go
|
||||||
=> 2573.1 33632.0
|
=> 2573.1 33632.0
|
||||||
/ 6 8 # hours a day in which piano tuners work
|
/ 6 8 # hours a day in which piano tuners work
|
||||||
=> 368.4 4893.5
|
=> 368.4 4893.5
|
||||||
/ 60 60 # minutes to an hour
|
/ 60 # minutes to an hour
|
||||||
=> 6.1 81.6
|
=> 6.1 81.6
|
||||||
# ^ piano tuners in Chicago
|
# ^ piano tuners in Chicago
|
||||||
```
|
```
|
||||||
|
|
27
f.go
27
f.go
|
@ -42,19 +42,26 @@ func combineBounds(old_low, old_high, new_low, new_high float64) (float64, float
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
reader := bufio.NewReader(os.Stdin)
|
reader := bufio.NewReader(os.Stdin)
|
||||||
input, _ := reader.ReadString('\n')
|
|
||||||
|
var old_low, old_high float64
|
||||||
|
var input string
|
||||||
|
var err1, err2 error
|
||||||
|
for {
|
||||||
|
input, _ = reader.ReadString('\n')
|
||||||
input = strings.TrimSpace(input)
|
input = strings.TrimSpace(input)
|
||||||
words := strings.Split(input, " ")
|
words := strings.Split(input, " ")
|
||||||
error_msg_start := "Please enter two floats separated by a space, like: 1 10"
|
|
||||||
if len(words) != 2 {
|
if len(words) != 2 {
|
||||||
fmt.Println(error_msg_start)
|
fmt.Println("Please enter two floats separated by a space, like: 1 10")
|
||||||
return
|
continue
|
||||||
}
|
}
|
||||||
old_low, err1 := strconv.ParseFloat(words[0], 64)
|
old_low, err1 = strconv.ParseFloat(words[0], 64)
|
||||||
old_high, err2 := strconv.ParseFloat(words[1], 64)
|
old_high, err2 = strconv.ParseFloat(words[1], 64)
|
||||||
if err1 != nil || err2 != nil {
|
if err1 != nil || err2 != nil {
|
||||||
fmt.Println(error_msg_start)
|
fmt.Println("Please enter two floats separated by a space, like: 1 10")
|
||||||
return
|
continue
|
||||||
|
}
|
||||||
|
break
|
||||||
|
|
||||||
}
|
}
|
||||||
fmt.Printf("=> %.1f %.1f\n", old_low, old_high)
|
fmt.Printf("=> %.1f %.1f\n", old_low, old_high)
|
||||||
|
|
||||||
|
@ -68,8 +75,6 @@ EventForLoop:
|
||||||
words := strings.Split(strings.TrimSpace(input), " ")
|
words := strings.Split(strings.TrimSpace(input), " ")
|
||||||
|
|
||||||
var new_low, new_high float64
|
var new_low, new_high float64
|
||||||
var err1, err2 error
|
|
||||||
err1, err2 = nil, nil
|
|
||||||
|
|
||||||
switch words[0] {
|
switch words[0] {
|
||||||
case "*":
|
case "*":
|
||||||
|
@ -107,7 +112,7 @@ EventForLoop:
|
||||||
fmt.Println(error_msg_cont)
|
fmt.Println(error_msg_cont)
|
||||||
continue EventForLoop
|
continue EventForLoop
|
||||||
case 2:
|
case 2:
|
||||||
single_float, err1 := strconv.ParseFloat(words[0], 64)
|
single_float, err1 := strconv.ParseFloat(words[1], 64)
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
fmt.Println("Trying to divide by a scalar, but scalar is not a float")
|
fmt.Println("Trying to divide by a scalar, but scalar is not a float")
|
||||||
fmt.Println(error_msg_cont)
|
fmt.Println(error_msg_cont)
|
||||||
|
|
15
more/f.sh
15
more/f.sh
|
@ -1,9 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#while IFS= read -r line; do echo "$line" | sed 's| //.*||' | go run main.go
|
|
||||||
|
|
||||||
# while IFS= read -r line; do echo "$line" | sed 's|//.*||'; done | go run main.go
|
function f(){
|
||||||
|
sed -u "s|#.*||" |
|
||||||
|
sed -u "s|//.*||" |
|
||||||
|
sed -u 's|K|000|g' |
|
||||||
|
sed -u 's|M|000000|g' |
|
||||||
|
sed -u 's|B|000000000|g' |
|
||||||
|
/usr/bin/f
|
||||||
|
}
|
||||||
|
|
||||||
|
# f
|
||||||
sed -u 's|//.*||' | go run main.go
|
|
||||||
# ^ sed unbuffered.
|
|
||||||
# cat | tee -a log.f | sed -u 's|//.*||' | go run main.go | tee -a log.f
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
1 10
|
|
||||||
2 20
|
|
|
@ -4,6 +4,6 @@
|
||||||
/ 48 52 # weeks a year that piano tuners work for
|
/ 48 52 # weeks a year that piano tuners work for
|
||||||
/ 5 6 # days a week in which piano tuners work
|
/ 5 6 # days a week in which piano tuners work
|
||||||
/ 6 8 # hours a day in which piano tuners work
|
/ 6 8 # hours a day in which piano tuners work
|
||||||
/ 60 60 # minutes to an hour
|
/ 60 # minutes to an hour
|
||||||
# ^ piano tuners in Chicago
|
# ^ piano tuners in Chicago
|
||||||
|
|
||||||
|
|
|
@ -4,4 +4,4 @@
|
||||||
/ 48 52
|
/ 48 52
|
||||||
/ 5 6
|
/ 5 6
|
||||||
/ 6 8
|
/ 6 8
|
||||||
/ 60 60
|
/ 60
|
||||||
|
|
Loading…
Reference in New Issue
Block a user