Some readme elaboration, but mostly cons

This commit is contained in:
Ava Hahn 2023-03-09 16:03:06 -08:00
parent 928c9b91ed
commit 001e35755d
Signed by untrusted user who does not match committer: affine
GPG key ID: 3A4645B8CF806069
5 changed files with 31 additions and 29 deletions

View file

@ -31,13 +31,13 @@ pub mod strings;
/// any kind of further configuration data into a symtable
pub fn static_stdlib(syms: &mut SymTable) -> Result<(), String> {
syms.insert(
"append".to_string(),
"cons".to_string(),
Symbol {
name: String::from("append"),
name: String::from("cons"),
args: Args::Infinite,
conditional_branches: false,
docs: append::APPEND_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(append::append_callback)),
docs: append::CONS_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(append::cons_callback)),
},
);

View file

@ -17,10 +17,10 @@
use crate::segment::{Ctr, Seg};
use crate::sym::SymTable;
pub const APPEND_DOCSTRING: &str = "traverses any number of arguments collecting them into a list.
pub const CONS_DOCSTRING: &str = "traverses any number of arguments collecting them into a list.
If the first argument is a list, all other arguments are added sequentially to the end of the list contained in the first argument.";
pub fn append_callback(ast: &Seg, _syms: &mut SymTable) -> Result<Ctr, String> {
pub fn cons_callback(ast: &Seg, _syms: &mut SymTable) -> Result<Ctr, String> {
if let Ctr::Seg(ref s) = *ast.car {
let mut temp = s.clone();
if let Ctr::Seg(ref list) = *ast.cdr {