guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wikid 0.6


From: Dale P. Smith
Subject: Re: wikid 0.6
Date: Sun, 30 Dec 2001 02:27:16 -0500

Miroslav Silovic wrote:
> 
> Thien-Thi Nguyen <address@hidden> writes:
> 
> > wiki w/ guile anyone?  all hail the goddess procrastes!
> >
> > WIKID is free software, provided under GNU GPL, with ABSOLUTELY NO
> > WARRANTY.  see file COPYING for more details.
> >
> > thi
> 
> A style comment: I noticed you use a lot of string-appends. There's a
> trick that both simplifies your code and increases performance (and it
> was discussed on this list some time ago).
> 
> First, define this function:
> 
> (define (flatten-write v)
>   (if (not (null? v))
>       (if (pair? v)
>           (begin
>             (flatten-write (car v))
>             (flatten-write (cdr v)))
>           (display v))))
> 
> (replacing 'display' with whatever is needed to output to HTML port).
> 
> Now you can use lists instead of strings:

This reminds me of SRV:send-reply:
 
                ; Output the 'fragments'
                ; The fragments are a list of strings, characters,
                ; numbers, thunks, #f -- and other fragments.
                ; The function traverses the tree inorder, writes out
                ; strings and characters, executes thunks, and ignores
                ; #f and '()
                ; The function returns #t if anything was written at all;
                ; otherwise the result is #f
(define (SRV:send-reply . fragments)
  (let loop ((fragments fragments) (result #f))
    (cond
      ((null? fragments) result)
      ((not (car fragments)) (loop (cdr fragments) result))
      ((null? (car fragments)) (loop (cdr fragments) result))
      ((pair? (car fragments))
        (loop (cdr fragments) (loop (car fragments) result)))
      ((procedure? (car fragments))
        ((car fragments))
        (loop (cdr fragments) #t))
      (else
        (display (car fragments))
        (loop (cdr fragments) #t)))))

See: http://srfi.schemers.org/srfi-13/mail-archive/msg00072.html
And: http://okmij.org/ftp/Scheme/eval-Scheme-to-XML.txt

-Dale

-- 
Dale P. Smith
Treasurer, Cleveland Linux Users Group http://cleveland.lug.net
Senior Systems Consultant, Altus Technologies Corporation
address@hidden
440-746-9000 x339



reply via email to

[Prev in Thread] Current Thread [Next in Thread]