Example #1
0
func cdr(s *scheme.Scope, args []scheme.Sexpr) (scheme.Sexpr, error) {
	if len(args) != 1 {
		return nil, scheme.ProcError("cdr requires exactly 1 argument")
	}
	if !scheme.IsCons(args[0]) {
		return nil, scheme.ProcError("cdr requires a cons argument")
	}
	return args[0].(*scheme.Cons).Cdr, nil
}
Example #2
0
func setcdr(s *scheme.Scope, args []scheme.Sexpr) (scheme.Sexpr, error) {
	if len(args) != 2 {
		return nil, scheme.ProcError("set-cdr! requires exactly 2 arguments")
	}
	pair := args[0]
	value := args[1]
	if !scheme.IsCons(pair) {
		return nil, scheme.ProcError("set-cdr! requires a cons argument")
	}
	pair.(*scheme.Cons).Cdr = value
	return scheme.Nil, nil
}