Deutsch English Français Italiano |
<1048o2l$s1la$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: nntp.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: "B. Pym" <Nobody447095@here-nor-there.org> Newsgroups: comp.lang.lisp,comp.lang.scheme Subject: Merging strings Date: Fri, 4 Jul 2025 14:22:14 -0000 (UTC) Organization: A noiseless patient Spider Lines: 19 Message-ID: <1048o2l$s1la$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Injection-Date: Fri, 04 Jul 2025 16:22:14 +0200 (CEST) Injection-Info: dont-email.me; posting-host="b32ec1f0f009210266c9a7d361c59578"; logging-data="919210"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19H+kWjj9sL5d15e3j1Mv5L" User-Agent: XanaNews/1.18.1.6 Cancel-Lock: sha1:oBn6r/alQS+Lmp4Qi1TimExubhw= You have a list contain both strings and numbers. Generate a new list in which the adjacent strings have been concatenated. Scheme (define (merge-strings List) (reverse (fold (lambda (e accum) (if (and (string? e) (pair? accum) (string? (car accum))) (cons (string-append (car accum) e) (cdr accum)) (cons e accum))) '() List))) (merge-strings '("1" "2" 3 4 "5" "6" 7 8 "9")) ===> ("12" 3 4 "56" 7 8 "9")