chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Parsing HTML, best practice with Chicken


From: mfv
Subject: Re: [Chicken-users] Parsing HTML, best practice with Chicken
Date: Mon, 29 Dec 2014 19:37:44 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Hey!

> Sxml-transform and other sxml related eggs can certainly help you here,
> but I don’t know them really well so I can’t help you with that.

thanks, I will look into that. 

> 
> 
> > ;; saving function
> > (define (savedata somedata filename)
> >   (call-with-output-file filename
> >     (lambda (p)
> >       (let f ((ls somedata))
> >     (unless (null? ls)
> >       (display (car ls) p)   ; changed: display->write
> >       (newline p)
> >       (f (cdr ls)))))))
> 

> Here you can simply use `write` instead of your big function. `pp` can
> also be useful if you want to read the resulting file with a text
> editor.

Oh, so you do not mean just to replace 'display' with 'write'? As I
remember, I need to open a port anyway, or am I mistaken? That is why I
wrote that big function, actually. 

> > ;; --- member? returns #t if elemnt x is in list lst.
> This function already exists, it’s called `member` and is in the srfi-1
> library.

Bugger. You are right. I should check chickadee more often. 
 
> 
> > ;; --- string-contains/m returns #t if all strings of list lsstr are in
> > (define (string-contains/m str lsstr)
> >   (if (string? str) 
> >       (if (not (member? #f (map (lambda (x) (string-contains-ci str x))
> > lsstr))) #t)))
> 
> This looks wrong to me, your function can return an unspecified value,
> try with this:

And again: Bingo. I had lots of undefined values, and I really wondered
where they came from. 

I am still puzzled how undefined is generated. It can not come from the 

  (if (string? str) ...

clause. Or does it? I understand that you used 'and' and remove one
redundant check with if. But what form produced the #undefined output?


> I hope this will help you.

Yes, thank you very much. Your function worked perfectly fine!

Cheers, 

  Piotr



reply via email to

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