Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 1

Liste des GroupesRevenir à cl lisp 
Sujet : Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 1
De : enometh (at) *nospam* meer.net (Madhu)
Groupes : comp.lang.lisp
Date : 22. May 2024, 04:43:09
Autres entêtes
Organisation : Motzarella
Message-ID : <m3zfsish1e.fsf@leonis4.robolove.meer.net>
References : 1 2 3
* HenHanna <v2irh1$ndjr$2@dont-email.me> :
Wrote on Tue, 21 May 2024 12:09:22 -0700:
On 5/19/2024 11:36 AM, Joerg Mertens wrote:
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.'
>
>
Another one:
(defun subst-dots (s &optional (pos 0))
   (let ((p (search "." s :start2 pos)))
     (if p
(append
(subst-dots (replace (copy-seq s) "0" :start1 p) (1+ p))
(subst-dots (replace (copy-seq s) "1" :start1 p) (1+ p)))
(list s))))
Regards
Nice... Thanks

so my response to Steve in <m3bk52kmfu.fsf@leonis4.robolove.meer.net> :
on [Sun, 19 May 2024 18:06:53 +0530] where I said "Substitute doesn't
help here" was wrong. You can use SUBSTITUTE here like this

(defun subst-dots (s &optional (pos 0))
   (let ((p (search "." s :start2 pos)))
     (if p
(append
(subst-dots (substitute #\0 #\. s :start p :count 1) (1+ p))
(subst-dots (substitute #\1 #\. s :start p :count 1) (1+ p)))
(list s))))


[Apparently my machine crashed shortly after I sent that message and zfs
didn't help preserve it - I don't have a copy of it under
Mail/archive/sent ]


Date Sujet#  Auteur
18 May 24 * Given string 'a.bc.' -- replace each dot(.) with 0 or 122HenHanna
18 May 24 +- Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 11Kaz Kylheku
18 May 24 +* Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 13Kaz Kylheku
19 May 24 i+- Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 11steve
19 May 24 i`- Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 11Kaz Kylheku
19 May 24 +* Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 14Madhu
19 May 24 i`* Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 13steve
19 May 24 i `* Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 12Madhu
29 May 24 i  `- Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 11steve
19 May 24 +- Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 11steve
19 May 24 +* Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 17Joerg Mertens
21 May 24 i`* Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 16HenHanna
22 May 24 i `* Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 15Madhu
29 May 24 i  `* Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 14steve
29 May 24 i   `* Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 13Lawrence D'Oliveiro
29 May 24 i    `* Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 12Madhu
30 May 24 i     `- Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 11steve
24 May 24 +* Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 13WJ
25 May 24 i+- Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 11HenHanna
26 May 24 i`- Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 11Madhu
24 May 24 +- Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 11Mark Wooding
26 May 24 `- Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 11B. Pym

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal