Deutsch English Français Italiano |
<87o792ibjk.fsf@gmail.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: local-4.nntp.ord.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Sun, 19 May 2024 06:03:01 +0000 From: steve <sgonedes1977@gmail.com> Newsgroups: comp.lang.lisp Subject: Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 1 References: <v29p14$2mr5l$2@dont-email.me> Date: Sun, 19 May 2024 02:02:55 -0400 Message-ID: <87o792ibjk.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:DxPeNg3t98aKd55/ydN1euNy1zE= MIME-Version: 1.0 Content-Type: text/plain Lines: 24 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-sy5/7EjzhUPtIQYjv14XUe3P/l3ltQHNXWhoC0nu6GpgPX/GMrYvBNKO3X4nhMKfIUdQZUmVr+5WvPl!y8o89CD9oQnfwWHuXMAeFGMMlQvR7a9Dnn7Xa85KQoH01A== 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: 1730 HenHanna <HenHanna@devnull.tb> writes: > 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.' ; SLIME 2.26.1 CL-USER> (defun replace-dots (str) (declare (string str)) (substitute #\1 #\. str)) REPLACE-DOTS CL-USER> (replace-dots "this.a.bd.") "this1a1bd1" CL-USER>