Re: Is DSSSL Syntax Tricky?

Subject: Re: Is DSSSL Syntax Tricky?
From: Paul Prescod <papresco@xxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 20 May 1997 14:30:44 -0400 (EDT)
I just realized that it isn't really fair to ask if people were familiar with 
the map idiom because map isn't in Jade. You would have had to already
understand recursion and higher order functions to implement it. Here's the
implementation for those who want to try to start using it:

(define (map func lst)
    (let loop((lst lst))
	(if (null? lst) '()
	    (cons (func (car lst)) (loop (cdr lst))))))

It really is a wonderfully powerful procedure that can take much of the 
sting out of functional programming. Any time you need to do something to
all elements of a list, node-list or string, you can convert it to a list, 
write a little function that does the "thing", use the function as the
first argument and the list as the second, map will return a list. Then you
use "apply" to use that list as the arguments to some function, like
string, string-append or sososo-append. The nature of DSSSL stylesheets 
makes the procedure useful quite often (for iterating over children, for
instance).

Please consider this a feature request, James. =)

 Paul Prescod


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread