unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Kevin Ryde <user42@zip.com.au>
Subject: srfi-1 concatenate
Date: Sat, 19 Jul 2003 09:53:02 +1000	[thread overview]
Message-ID: <87k7af75pd.fsf@zip.com.au> (raw)

[-- Attachment #1: Type: text/plain, Size: 466 bytes --]

I propose to make a change,

	* srfi-1.c, srfi-1.h, srfi-1.scm (concatenate, concatenate!): Rewrite
	using scm_append and scm_append_x.

which should be smaller and faster.  I think it requires no more than
registering the following, since scm_append and scm_append_x don't
modify their list argument.

SCM_REGISTER_PROC (s_srfi1_concatenate,   "concatenate",  1, 0, 0, scm_append);
SCM_REGISTER_PROC (s_srfi1_concatenate_x, "concatenate!", 1, 0, 0, scm_append_x);


[-- Attachment #2: concatenate.test --]
[-- Type: text/plain, Size: 1138 bytes --]

;;
;; concatenate and concatenate!
;;

(let ()	
  (define (common-tests concatenate-proc unmodified?)
    (define (try lstlst want)
      (let ((lstlst-copy (copy-tree lstlst))
	    (got         (concatenate-proc lstlst)))
	(if unmodified?
	    (if (not (equal? lstlst lstlst-copy))
		(error "input lists modified")))
	(equal? got want)))
    
    (pass-if-exception "too few args" exception:wrong-num-args
      (concatenate-proc))
    
    (pass-if-exception "too many args" exception:wrong-num-args
      (concatenate-proc '() '()))
    
    (pass-if "no lists"
      (try '() '()))
    
    (pass-if (try '((1))       '(1)))
    (pass-if (try '((1 2))     '(1 2)))
    (pass-if (try '(() (1))    '(1)))
    (pass-if (try '(() () (1)) '(1)))
    
    (pass-if (try '((1) (2)) '(1 2)))
    (pass-if (try '(() (1 2)) '(1 2)))
    
    (pass-if (try '((1) 2)           '(1 . 2)))
    (pass-if (try '((1) (2) 3)       '(1 2 . 3)))
    (pass-if (try '((1) (2) (3 . 4)) '(1 2 3 . 4)))
    )
  
  (with-test-prefix "concatenate"
    (common-tests concatenate #t))
  
  (with-test-prefix "concatenate!"
    (common-tests concatenate! #f))
  )

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel

                 reply	other threads:[~2003-07-18 23:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k7af75pd.fsf@zip.com.au \
    --to=user42@zip.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).