unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Kevin Ryde <user42@zip.com.au>
Subject: srfi-13 string-any tail call
Date: Tue, 07 Dec 2004 08:08:23 +1100	[thread overview]
Message-ID: <871xe3yw1k.fsf@zip.com.au> (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


             reply	other threads:[~2004-12-06 21:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-06 21:08 Kevin Ryde [this message]
2004-12-22 16:54 ` srfi-13 string-any tail call Marius Vollmer
2004-12-22 21:30   ` Kevin Ryde
2004-12-23  4:16     ` Marius Vollmer

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=871xe3yw1k.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).