Documentation
¶
Index ¶
- Constants
- Variables
- func AssertOp(t *testing.T, s string, st *Stack, fs ...float64)
- func Eval(a any, st *Stack) error
- func EvalAll(as []any, st *Stack) error
- func Input() (string, error)
- func Main()
- func Output(s string, as ...any)
- func Parse(s string) (any, error)
- func ParseAll(s string) ([]any, error)
- func Prompt(s string) (string, error)
- type OperFunc
- type Operator
- type Stack
Constants ¶
View Source
const VersionDate = "2022-08-27"
VersionDate is SSCal's current version date.
View Source
const VersionNumber = "0.2.0"
VersionNumber is SSCal's current version number.
Variables ¶
View Source
var Banner = fmt.Sprintf("SSCal version %s (%s).", VersionNumber, VersionDate)
Banner is SSCal's interactive banner string.
View Source
var Operators = map[string]*Operator{ "-": Op2(func(a, b float64) float64 { return a - b }), "*": Op2(func(a, b float64) float64 { return a * b }), "/": Op2(func(a, b float64) float64 { return a / b }), "+": Op2(func(a, b float64) float64 { return a + b }), "ceil": Op1(math.Ceil), "floor": Op1(math.Floor), "sqrt": Op1(math.Sqrt), "%": Op2(math.Mod), "**": Op2(math.Pow), "max": Op2(math.Max), "min": Op2(math.Min), "dupe": NewOperator(1, func(st *Stack) error { st.Push(st.Peek()) return nil }), "swap": NewOperator(2, func(st *Stack) error { a, b := st.Pop(), st.Pop() st.Push(a) st.Push(b) return nil }), }
Operators is a map of all available Operators.
View Source
var Reader = bufio.NewReader(os.Stdin)
Reader is SSCal's default standard input Reader.
View Source
var Writer = bufio.NewWriter(os.Stdout)
Writer is SSCal's default standard input Writer.
Functions ¶
Types ¶
type Operator ¶
type Operator struct {
// Size is the minimum Stack size the Operator needs.
Size int
// Func is the Operator's callable function.
Func OperFunc
}
Operator is a callable Stack operator.
func NewOperator ¶
NewOperator returns a pointer to a new Operator.
Click to show internal directories.
Click to hide internal directories.