RE: (dsssl) simple loop question

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

(define wrap-with-mi (lambda (#!optional (nl (children (current-node))))
    (let loop ((n nl) (result empty-sosofo))
        (if (node-list-empty? n)
        (let* ((cn (node-list-first n))   (c (node-property 'class-name
                (node-list-rest n)
                    (if (equal? 'data-char c)
                        (make element gi: "mi"
                            (literal (string (node-property 'char cn))))
                        (process-node-list cn)
            ); loop

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

(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


 DSSSList info and archive:

Current Thread