diff options
| author | Keith Packard <keithp@keithp.com> | 2017-12-10 16:51:25 -0800 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2017-12-11 12:20:25 -0800 | 
| commit | b72638e60b6636b479b79bbf0047cf7409f58820 (patch) | |
| tree | 9cf0575f5d0105aca311d41171a340d303a41604 /src/scheme/ao_scheme_builtin.c | |
| parent | 7517da1646fc30faaa9ee1c969cfa35ae1a17423 (diff) | |
altos/scheme: add list-copy
A lot easier as a built-in; the obvious scheme version is recursive.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/scheme/ao_scheme_builtin.c')
| -rw-r--r-- | src/scheme/ao_scheme_builtin.c | 13 | 
1 files changed, 13 insertions, 0 deletions
| diff --git a/src/scheme/ao_scheme_builtin.c b/src/scheme/ao_scheme_builtin.c index 397ce032..6f9e1390 100644 --- a/src/scheme/ao_scheme_builtin.c +++ b/src/scheme/ao_scheme_builtin.c @@ -198,6 +198,19 @@ ao_scheme_do_length(struct ao_scheme_cons *cons)  }  ao_poly +ao_scheme_do_list_copy(struct ao_scheme_cons *cons) +{ +	struct ao_scheme_cons *new; + +	if (!ao_scheme_check_argc(_ao_scheme_atom_length, cons, 1, 1)) +		return AO_SCHEME_NIL; +	if (!ao_scheme_check_argt(_ao_scheme_atom_length, cons, 0, AO_SCHEME_CONS, 1)) +		return AO_SCHEME_NIL; +	new = ao_scheme_cons_copy(ao_scheme_poly_cons(ao_scheme_arg(cons, 0))); +	return ao_scheme_cons_poly(new); +} + +ao_poly  ao_scheme_do_quote(struct ao_scheme_cons *cons)  {  	if (!ao_scheme_check_argc(_ao_scheme_atom_quote, cons, 1, 1)) | 
