Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Today is the last day of your life so far.


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

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

1
Subject: Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 1
From: HenHanna
Newsgroups: comp.lang.lisp, comp.lang.scheme
Organization: A noiseless patient Spider
Date: Tue, 21 May 2024 19:09 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: HenHanna@devnull.tb (HenHanna)
Newsgroups: comp.lang.lisp,comp.lang.scheme
Subject: Re: Given string 'a.bc.' -- replace each dot(.) with 0 or 1
Date: Tue, 21 May 2024 12:09:22 -0700
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <v2irh1$ndjr$2@dont-email.me>
References: <v29p14$2mr5l$2@dont-email.me>
<87h6et8x94.fsf@jmertens.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 21 May 2024 21:09:22 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="4ee11fe942d496548c5fef5d03dc9b69";
logging-data="767611"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+QQ1SXBL5nJwXXQyk/Jf7YS1irc1yNukE="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:N8XZCcb0ifYhjVNKydnnqLB/cEs=
In-Reply-To: <87h6et8x94.fsf@jmertens.eternal-september.org>
Content-Language: en-US
View all headers

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 !

1

rocksolid light 0.9.8
clearnet tor