[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: HOW: Read character from a term

William James

5/3/2015 4:21:00 AM

Barry Margolin wrote:

> >> (example-function '(?Z A B))
> >(Z)
> >
> >I want the function to print out the terms starting with the question mark
> >"?".
>
> (defun example-function (symbols)
> (loop for s in symbols
> for name = (symbol-name s)
> when (char= #\? (char name 0))
> collect (intern (subseq name 1))))

Gauche Scheme:

(use srfi-42 :only (list-ec))
(use gauche.sequence)

(define (example-function symbols)
(list-ec
(: s symbols)
(:let name (symbol->string s))
(if (#/^\?/ name))
(string->symbol (subseq name 1))))


(example-function '(?Z A B))
===>
(Z)

--
As Helle "Hamas" Klein, political editor of Sweden's largest newspaper
Aftonbladet, boasts: "If the debate is going to be about whether there are
problems with immigrants, we don't want it". Welcome to Sweden, the country
where the media doesn't even pretend to champion freedom of speech, but openly
brags about censorship.
fjordman.blogspot.ca/2005/05/is-swedish-democracy-collapsing.html