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 : No_spamming (at) *nospam* noWhere_7073.org (B. Pym)
Groupes : comp.lang.lisp
Date : 26. May 2024, 00:34:43
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v2tp1v$32lms$1@dont-email.me>
References : 1
User-Agent : XanaNews/1.18.1.6
On 5/18/2024, HenHanna wrote:

-- 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.

Gauche Scheme:

(use srfi-13)  ;; string-count
(use util.combinations)  ;; cartesian-product

(define (dot s)
  (let ((b (cartesian-product (make-list (string-count s #\.) '(0 1))))
        (fs (regexp-replace-all "[.]" s "~d")))
    (map (cut apply format fs <>) b)))

(dot "a.b.c")
  ===>
("a0b0c" "a0b1c" "a1b0c" "a1b1c")

(dot "a.b")
  ===>
("a0b" "a1b")

(dot "ab.")
  ===>
("ab0" "ab1")

(dot ".ab")
  ===>
("0ab" "1ab")

(dot "ab")
  ===>
("ab")

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