aboutsummaryrefslogtreecommitdiffstats
path: root/const.go
blob: ff0d09cd293d33eefd0387f48fdeea98025baa1d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package main

import "math"

// parseConstant returns nil if s is not a valid constant.
func parseConstant(s string) *float64 {
	switch s {
	case "pi":
		// Assign to variable because can't take address of constant.
		var pi float64 = math.Pi
		return &pi
	case "e":
		var e float64 = math.E
		return &e
	}
	return nil
}