* srfi-1 length+
@ 2003-07-18 23:54 Kevin Ryde
0 siblings, 0 replies; only message in thread
From: Kevin Ryde @ 2003-07-18 23:54 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 412 bytes --]
A small improvement,
* srfi-1.c, srfi-1.h, srfi-1.scm (length+): Rewrite using scm_ilength.
SCM_DEFINE (scm_srfi1_length_plus, "length+", 1, 0, 0,
(SCM lst),
"Return the length of @var{lst}, or @code{#f} if @var{lst} is\n"
"circular.")
#define FUNC_NAME s_scm_srfi1_length_plus
{
long len = scm_ilength (lst);
return (len >= 0 ? SCM_MAKINUM (len) : SCM_BOOL_F);
}
#undef FUNC_NAME
[-- Attachment #2: lengthplus.test --]
[-- Type: text/plain, Size: 489 bytes --]
;;
;; length+
;;
(with-test-prefix "length+"
(pass-if-exception "too few args" exception:wrong-num-args
(length+))
(pass-if-exception "too many args" exception:wrong-num-args
(length+ 123 456))
(pass-if (= 0 (length+ '())))
(pass-if (= 1 (length+ '(x))))
(pass-if (= 2 (length+ '(x y))))
(pass-if (= 3 (length+ '(x y z))))
(pass-if (not (length+ (circular-list 1))))
(pass-if (not (length+ (circular-list 1 2))))
(pass-if (not (length+ (circular-list 1 2 3)))))
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-07-18 23:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-07-18 23:54 srfi-1 length+ Kevin Ryde
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).