diff options
author | Rob Browning <rlb@defaultvalue.org> | 2024-07-16 23:30:05 -0500 |
---|---|---|
committer | Rob Browning <rlb@defaultvalue.org> | 2024-07-30 18:54:45 -0500 |
commit | c62d2962d43b746643d52c2f57867f990f216449 (patch) | |
tree | f44ae0d3d85df27f4e9fd24a65a3d2de947a1917 /module/srfi/srfi-1.scm | |
parent | a816b2484bae69edaf78ae2b0cb0c8f6005e0a8b (diff) | |
download | guile-c62d2962d43b746643d52c2f57867f990f216449.tar.gz |
srfi-1 concatenate concatenate!: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_concatenate, scm_srfi1_concatenate_x): delete.
* libguile/srfi-1.h (scm_srfi1_concatenate, scm_srfi1_concatenate_x): delete.
* module/srfi/srfi-1.scm: add concatenate and concatenate!.
Diffstat (limited to 'module/srfi/srfi-1.scm')
-rw-r--r-- | module/srfi/srfi-1.scm | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/module/srfi/srfi-1.scm b/module/srfi/srfi-1.scm index 8d0a603cd..a5308b403 100644 --- a/module/srfi/srfi-1.scm +++ b/module/srfi/srfi-1.scm @@ -445,6 +445,25 @@ a list of those after." ;;; Miscelleneous: length, append, concatenate, reverse, zip & count +(define (concatenate lists) + "Construct a list by appending all lists in @var{lists}. + +@code{concatenate} is the same as @code{(apply append @var{lists})}. +It exists because some Scheme implementations have a limit on the number +of arguments a function takes, which the @code{apply} might exceed. In +Guile there is no such limit." + (apply append lists)) + +(define (concatenate! lists) + "Construct a list by appending all lists in @var{lists}. Those +lists may be modified to produce the result. + +@code{concatenate!} is the same as @code{(apply append! @var{lists})}. +It exists because some Scheme implementations have a limit on the number +of arguments a function takes, which the @code{apply} might exceed. In +Guile there is no such limit." + (apply append! lists)) + (define (zip clist1 . rest) (let lp ((l (cons clist1 rest)) (acc '())) (if (any null? l) |