much stdlib docs

This commit is contained in:
Aidan 2020-07-19 14:37:20 -07:00
parent b941df68e1
commit ee39de01fd
No known key found for this signature in database
GPG key ID: 327711E983899316
9 changed files with 228 additions and 74 deletions

View file

@ -29,7 +29,13 @@ import (
// perhaps we simply write out arithmetic routines that operate on the strings
// then we need not worry about storage length.
func num_cast(in *ast.Token, a ast.VarTable, f ast.FuncTable) *ast.Token {
/* Takes 1 argument (must be a string)
* will attempt to cast it to a number.
* will return nil if cast fails
*
* Example: (number "3.4")
*/
func NumCast(in *ast.Token, a ast.VarTable, f ast.FuncTable) *ast.Token {
in = in.Eval(f, a, false)
if in.Tag != ast.STRING {
log.Log(log.ERR,
@ -50,7 +56,7 @@ func num_cast(in *ast.Token, a ast.VarTable, f ast.FuncTable) *ast.Token {
return out
}
func add(in *ast.Token, a ast.VarTable, f ast.FuncTable) *ast.Token {
func Add(in *ast.Token, a ast.VarTable, f ast.FuncTable) *ast.Token {
var res float64
in = in.Eval(f, a, false)