Subject: RE: (dsssl) simple loop question From: Miroslaw Prywata <Miroslaw.Prywata@xxxxxxxxxx> Date: Fri, 11 Apr 2003 09:41:32 +0200 |
> -----Original Message----- > From: Ian Zimmerman [mailto:itz@xxxxxxxxxxxxx] > Sent: Thursday, April 10, 2003 6:13 PM > To: dssslist@xxxxxxxxxxxxxxxxxxxxxx > Subject: Re: (dsssl) simple loop question > Mirek> Hi, I have simple problem with processing node list in loop. I [....] > DSSSL is a functional language, so use recursion instead of iteration, Yes that's right, and I am so used to stuctural and objective way o thniking :-)) In the meantime I checked some DSSSL docs on the Internet and rewrite the code: (define wrap-with-mi (lambda (#!optional (nl (children (current-node)))) (let loop ((n nl) (result empty-sosofo)) (if (node-list-empty? n) result (let* ((cn (node-list-first n)) (c (node-property 'class-name cn))) (loop (node-list-rest n) (sosofo-append (if (equal? 'data-char c) (make element gi: "mi" (literal (string (node-property 'char cn)))) (process-node-list cn) )) ); loop );let );if );let )) It almost works. because it does not process all elements (?). > or even better, use higher order functions. I haven't checked your > code for anything else, but this should convey the idea: > > (define wrap-with-mi (lambda (#!optional (nl (children > (current-node)))) > (map (lambda (n) (if (equal? 'data-char > (node-property 'class-name n)) > (make element gi: "mi" > (literal (string (node-property > 'char n)))))) > nl))) > (process-node-list cn) IMHO you menat sth like that (it's better to see it as two distinct functions): (define mi-or-char (lambda (n) (if (equal? 'data-char (node-property 'class-name n)) (make element gi: "mi" (literal (string (node-property 'char n)))) (process-node-list n)) )) (define wrap-with-mi (lambda (#!optional (nl (children (current-node)))) (map mi-or-char nl) )) But it does not work. I get: 1st argument for primitive "car" of wrong type: "#<unknown object 137347808>" not a pair It's strange, because node-list should be list of nodes, so why is this problem? Mirek DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: (dsssl) simple loop question, Holger Klawitter | Thread | RE: (dsssl) simple loop question, Miroslaw Prywata |
Re: (dsssl) simple loop question, tmcd | Date | RE: (dsssl) simple loop question, Miroslaw Prywata |
Month |