From: ����
Subject: recursive function
Date: 
Message-ID: <0CoA5.3983$Bu.8055@news2.bora.net>
help me......please!!!

Write a recursive function EXIFY that takes any S-expression and converts it
to a new on ein which all atoms other than NIL have been replaced by X. Thus
(EXIFY '(A (B C) X Y NIL Z)) should produce (X (X X) X X NIL X).

help me.........thanks.......

From: Sunil Mishra
Subject: Re: recursive function
Date: 
Message-ID: <39D22D78.5090100@everest.com>
���� wrote:

> help me......please!!!
> 
> Write a recursive function EXIFY that takes any S-expression and converts it
> to a new on ein which all atoms other than NIL have been replaced by X. Thus
> (EXIFY '(A (B C) X Y NIL Z)) should produce (X (X X) X X NIL X).
> 
> help me.........thanks.......


(subst-if 'x #'(lambda (x) (and (atom x) x)) '(a (b) nil))
=> (x (x) nil)
From: Eugene Zaikonnikov
Subject: Re: recursive function
Date: 
Message-ID: <6ywvfx4v3l.fsf@localhost.localdomain>
* "someone" == ����  <········@lycos.co.kr> writes:

someone>  help me......please!!!  Write a recursive function EXIFY
someone>  that takes any S-expression and converts it to a new on ein
someone>  which all atoms other than NIL have been replaced by X. Thus
someone>  (EXIFY '(A (B C) X Y NIL Z)) should produce (X (X X) X X NIL
someone>  X).

Show us what you've done so far and where you stuck, and we will help
you.
BTW, please adjust your 'From' line when posting to an international
newsgroup; many of us don't have Korean fonts installed.

-- 
  Eugene
From: Stig Hemmer
Subject: Re: recursive function
Date: 
Message-ID: <ekv7l7x64wd.fsf@epoksy.pvv.ntnu.no>
"����" <········@lycos.co.kr> writes:
> Write a recursive function EXIFY that takes any S-expression and
> converts it to a new on ein which all atoms other than NIL have been
> replaced by X. Thus (EXIFY '(A (B C) X Y NIL Z)) should produce (X
> (X X) X X NIL X).

Sure:

(defun atom-not-nil (elem)
   (and (atom elem) elem))

(defun exify (list)
   (subst-if 'x #'atom-not-nil list))

Oops.  Forgot to make the function recursive:

(defun exify (list &optional really-do-it)
   (if really-do-it
      (subst-if 'x #'atom-not-nil list)
      (exify list t)))

There you go.  Hope this helps.

Stig Hemmer,
Jack of a Few Trades.
From: Tim Bradshaw
Subject: Re: recursive function
Date: 
Message-ID: <ey3vgvha9th.fsf@cley.com>
* ����  wrote:
> help me......please!!!
> Write a recursive function EXIFY that takes any S-expression and converts it
> to a new on ein which all atoms other than NIL have been replaced by X. Thus
> (EXIFY '(A (B C) X Y NIL Z)) should produce (X (X X) X X NIL X).


(defgeneric exify (form))

(defmethod exify ((form cons))
  (cons (exify (car form))
	(exify (cdr form))))

(defmethod exify ((form null))
  nil)

(defmethod exify ((form t))
  'x)

--tim
From: Friedrich Dominicus
Subject: Re: recursive function
Date: 
Message-ID: <87lmwdygzu.fsf@q-software-solutions.com>
"����" <········@lycos.co.kr> writes:

> help me......please!!!
> 
> Write a recursive function EXIFY that takes any S-expression and converts it
> to a new on ein which all atoms other than NIL have been replaced by X. Thus
> (EXIFY '(A (B C) X Y NIL Z)) should produce (X (X X) X X NIL X).
> 
> help me.........thanks.......
Where's you code? What is your problem?

Regards
Friedrich

-- 
for e-mail reply remove all after .com 
From: Martti Halminen
Subject: Re: recursive function
Date: 
Message-ID: <39D22021.3D6774D7@solibri.com>
"����" wrote:

> Write a recursive function EXIFY that takes any S-expression and converts it
> to a new on ein which all atoms other than NIL have been replaced by X. Thus
> (EXIFY '(A (B C) X Y NIL Z)) should produce (X (X X) X X NIL X).


Is this perhaps homework? You might take a look with dejanews on the
discussions re homework on this newsgroup in last two weeks...

Here's one implementation, a little censored, though: invent something
to put in place of all the ***'s:



(defun exify (item)
     (cond ((**** item) nil)
           ((**** item) 'x)
           ((**** item) (**** #'exify item))
           (T (warn "odd item ~A" item)))) ;; should never get here...

--