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 : sgonedes1977 (at) *nospam* gmail.com (steve)
Groupes : comp.lang.lisp
Date : 19. May 2024, 08:06:15
Autres entêtes
Message-ID : <87frueibe0.fsf@gmail.com>
References : 1 2
User-Agent : Gnus/5.13 (Gnus v5.13)
Madhu <enometh@meer.net> writes:

* HenHanna <v29p14$2mr5l$2@dont-email.me> :
Wrote on Sat, 18 May 2024 01:31:32 -0700:
>
< > 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')
>
(defun adjusted-logbitp (pos num total-width)
  (let* ((int-len (integer-length num))
(i (- pos (- total-width int-len))))
    (if (< i 0)
nil
(logbitp i num))))
>
(defun bindots (str)
  (let* ((indices (loop for c across str for i from 0
       if (eql c #\.) collect i))
(width (length indices)))
    (loop for i below (expt 2 width)
  collect (let ((ret (copy-seq str)))
    (loop for j in indices
  do (setf (aref ret j)
   (if (adjusted-logbitp j i width)
       #\1
       #\0)))
    ret))))

what about substitute? common lisp is not scheme of the week.

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