unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* srfi-13 string-any tail call
@ 2004-12-06 21:08 Kevin Ryde
  2004-12-22 16:54 ` Marius Vollmer
  0 siblings, 1 reply; 4+ messages in thread
From: Kevin Ryde @ 2004-12-06 21:08 UTC (permalink / raw)


I'm thinking of the following wrapper around the string-any C code to
get a tail call on the last pred test, per the srfi-13 spec.  It's not
too pretty, but at least it'll be right.  I guess in the head it could
tie into eval now that string-any is in the core.

(define (string-any char_pred s . rest)
  (let ((start (if (null? rest)
                   0 (car rest)))
        (end   (if (or (null? rest) (null? (cdr rest)))
                   (string-length s) (cadr rest))))
    (if (and (procedure? char_pred)
             (> end start)
             (<= end (string-length s))) ;; let c-code handle range
             error
        (or (string-any-c-code char_pred s start (1- end))
            (char_pred (string-ref s (1- end))))
        (string-any-c-code char_pred s start end))))


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-12-23  4:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-06 21:08 srfi-13 string-any tail call Kevin Ryde
2004-12-22 16:54 ` Marius Vollmer
2004-12-22 21:30   ` Kevin Ryde
2004-12-23  4:16     ` Marius Vollmer

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).