Subject: Re: Q 4 LISP GURUs: EED retreival Date: Wed, 29 Jan 1997 00:00:00 GMT From: vnestr@netvision.net.il (Vladimir Nesterovsky) Organization: IDAN Computers Newsgroups: comp.cad.autocad Morten -- I don't want '( "(" "data" ")" ) instead of '( "{" "data" "}" ). Of what purpose would it be? I want to rebuild list in its original form, like '("data") OK? But now that we're spea..well, writing, may be it really can be done with plain recursion. What had stopped me probably, was the enourmose amount of appends we gonna need here. Let's see. If originally it was '( 1 2 3 (4.4 "5.5") 6) [1] then converted it turns to be '( "{" 1 2 3 "{" 4.4 "5.5" "}" 6 "}" ) [2] and this can easily be stored in EED. Now, try to convert [2] back into [1]. Ha! I've got it. We need to split each list into three: Before the first "{", Inside, and After the last "}" And then to combine them together. On Tue, 28 Jan 1997 18:53:53 +0100 Morten Warankov wrote: >My suggestion for how to solve it: >In plain recursion (I need to sleep on it to include mapcar and >lambda :) ) >(defun chbr (a / ) > (if (= (car a) "{") > (setq a (append '("(") (cdr a))) > ) > ;;I suppose this could be done without an 'if' statement. > ;;depending on how sure you are about the first element. > (while (member "{" a) > (setq a (append (sub a (member "{" a)) > '("(") > (cdr (member "{" a)) > ) > ) > ) > (while (member "}" a) > (setq a (append (sub a (member "}" a)) > '(")") > (cdr (member "}" a)) > ) > ) > ) >The only thing you miss is the 'sub' function as posted by Reini: > > (defun sub (in out) > (cond ((null in) nil) > ((member (car in) out) > (sub (cdr in) out)) > (T (cons (car in) (sub (cdr in) out))))) >Solved in lisp, with plain recursion. >Pleased to have helped, >Mortenw -- Vladimir Nesterovsky ADS/LISP/C/C++ etc IDAN Computers Ltd.