Added list and unit test for it.
This commit is contained in:
parent
06e87f09fa
commit
3abebe937c
5 changed files with 58 additions and 2 deletions
|
|
@ -236,6 +236,7 @@ int main( int argc, char *argv[] ) {
|
|||
bind_function( L"hashmap", lisp_make_hashmap );
|
||||
bind_function( L"inspect", &lisp_inspect );
|
||||
bind_function( L"keys", &lisp_keys );
|
||||
bind_function( L"list", &lisp_list);
|
||||
bind_function( L"mapcar", &lisp_mapcar );
|
||||
bind_function( L"meta", &lisp_metadata );
|
||||
bind_function( L"metadata", &lisp_metadata );
|
||||
|
|
|
|||
|
|
@ -1453,6 +1453,19 @@ struct cons_pointer lisp_mapcar( struct stack_frame *frame,
|
|||
return result;
|
||||
}
|
||||
|
||||
struct cons_pointer lisp_list( struct stack_frame *frame,
|
||||
struct cons_pointer frame_pointer,
|
||||
struct cons_pointer env ) {
|
||||
struct cons_pointer result = frame->more;
|
||||
|
||||
for ( int a = nilp(result) ? frame->args - 1: args_in_frame - 1;
|
||||
a >= 0; a-- ) {
|
||||
result = make_cons(fetch_arg(frame, a), result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Function; print the internal representation of the object indicated by `frame->arg[0]` to the
|
||||
// * (optional, defaults to the value of `*out*` in the environment) stream indicated by `frame->arg[1]`.
|
||||
|
|
|
|||
|
|
@ -211,4 +211,8 @@ struct cons_pointer lisp_append( struct stack_frame *frame,
|
|||
struct cons_pointer lisp_mapcar( struct stack_frame *frame,
|
||||
struct cons_pointer frame_pointer,
|
||||
struct cons_pointer env );
|
||||
|
||||
struct cons_pointer lisp_list( struct stack_frame *frame,
|
||||
struct cons_pointer frame_pointer,
|
||||
struct cons_pointer env );
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue