much stdlib docs
This commit is contained in:
parent
b941df68e1
commit
ee39de01fd
9 changed files with 228 additions and 74 deletions
|
|
@ -23,8 +23,12 @@ import (
|
|||
)
|
||||
|
||||
/* eval N forms. return the last one
|
||||
*
|
||||
* Example:
|
||||
* (progn (print "hello") (print "world") (+ 1 2))
|
||||
* This example will print "hello world" to stdout and return 3
|
||||
*/
|
||||
func shs_progn(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
||||
func ShsProgn(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
||||
var res *ast.Token
|
||||
for iter := in; iter != nil; iter = iter.Next {
|
||||
res = iter.Eval(ft, vt, false)
|
||||
|
|
@ -34,8 +38,13 @@ func shs_progn(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
|||
}
|
||||
|
||||
/* return one evaluated form or another based on the boolean statement
|
||||
* arg 1 is a boolean cond, arg 2 is evaluated if the cond is true, arg 3 is evaluated if cond is not true
|
||||
* in total it takes 3 arguments
|
||||
*
|
||||
* Example:
|
||||
* (if (eq (number "3") 3) (print "test passed") (print "test failed"))
|
||||
*/
|
||||
func shs_if(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
||||
func ShsIf(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
||||
cond := in
|
||||
t := cond.Next
|
||||
f := t.Next
|
||||
|
|
@ -66,8 +75,14 @@ func shs_if(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
|||
}
|
||||
|
||||
/* continually eval n forms while element #1 evals to T
|
||||
* has rather progn like behavior in that it returns the result of the last form to be evaluated
|
||||
*
|
||||
* Example:
|
||||
* (export cond F)
|
||||
* (while cond (export cond T) (print "will only be printed once") (+ 1 2))
|
||||
* loop will iter one time, print "will only be printed once" and return 3
|
||||
*/
|
||||
func shs_while(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
||||
func ShsWhile(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
||||
cond := in
|
||||
forms := in.Next
|
||||
in.Next = nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue