Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Simple newbie list processing troubble
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Marco Antoniotti  
View profile  
 More options Sep 28 2002, 1:09 pm
Newsgroups: comp.lang.lisp
From: Marco Antoniotti <marc...@cs.nyu.edu>
Date: 28 Sep 2002 13:10:33 -0400
Local: Sat, Sep 28 2002 1:10 pm
Subject: Re: Simple newbie list processing troubble

pyda...@ec.auckland.ac.nz (Peder Y) writes:
> Say I have a function foo that is supposed to take a list as input (A
> B C D...). The function will then traverse the list looking for an
> element, and change that element. That's basically it.

> For example, say, the function shall set all elements of lst to 'A:
> Why is this wrong?

> (defun foo (lst)
>   (loop for x in lst do
>              (setf (car x) 'A)))

The above will not necessarily work because you are changing the list
as you are traversing it.  This is specifically mentioned in the
language standard.

To do that kind of things you should look to the standard functions
SUBSTITUTE and NSUBSTITUTE.

Cheers

--
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group        tel. +1 - 212 - 998 3488
715 Broadway 10th Floor                 fax  +1 - 212 - 995 4122
New York, NY 10003, USA                 http://bioinformatics.cat.nyu.edu
                    "Hello New York! We'll do what we can!"
                           Bill Murray in `Ghostbusters'.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.