Path: Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Sun, 19 May 2024 06:05:13 +0000 From: steve Newsgroups: comp.lang.lisp Subject: Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 1 References: <20240518140005.921@kylheku.com> Date: Sun, 19 May 2024 02:05:13 -0400 Message-ID: <87jzjqibfq.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:4kzxCBkqJortSrAVJe9yhdn6wqc= MIME-Version: 1.0 Content-Type: text/plain Lines: 31 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-PenhfpygdPQ4BpMgHYE10/SC946Imatn/6qbiVi0DszLggg9zyEI8Ra8um6Lfm7Y6UUZaD9AtM+gxDi!2P+qbrAXGNpKM2EaesRXL8sJSih3gFyK5Fw/Wg9gVcJwng== X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 Bytes: 1971 Kaz Kylheku <643-408-1753@kylheku.com> writes: > On 2024-05-18, HenHanna wrote: < > < > How can i write this function simply? (in Common Lisp) < > < > -- Given a string 'a.bc.' -- replace each dot(.) with 0 or 1. < > < > -- So the value is a list of 4 strings: < > ('a0bc0' 'a0bc1' 'a1bc0' 'a1bc1') < > < > -- The order is not important. < > If the string has 3 dots, the value is a list of length 8. < > < > If the program is going to be simpler, < > pls use, e.g. (a $ b c $) rather than 'a.bc.' > > TXR Lisp: > > (defun bindots (str) > (let* ((s (copy str)) > (ixs (where (op eql #\.) s)) > (n (len ixs))) > (collect-each ((digs (rperm '(#\0 #\1) n))) > (set [s ixs] digs) > (copy s)))) where is collect-each in common lisp? set [x] is no good! not in lisp