Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #371: Incorrectly configured static routes on the corerouters.


comp / comp.lang.lisp / Re: Another code review perhaps?

SubjectAuthor
o Re: Another code review perhaps?B. Pym

1
Subject: Re: Another code review perhaps?
From: B. Pym
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Thu, 27 Jun 2024 12:19 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (B. Pym)
Newsgroups: comp.lang.lisp
Subject: Re: Another code review perhaps?
Date: Thu, 27 Jun 2024 12:19:40 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <v5jlcr$2ns7o$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Thu, 27 Jun 2024 14:19:41 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="b7883a0965441765745abdd310047411";
logging-data="2879736"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/meaIfVJplSHcoAH+Kundm"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:t0aGqe272eS0Id0B1v3pRfNFr4M=
View all headers

Wolfhard Buss wrote:

> * Martin Pomije with an exercise from Paul Grahams ACL:
>
> > Define iterative and recursive versions of a function that takes an
> > object and a list, and returns a new list in which the object appears
> > between each pair of elements in the original list:
> >
> > > (intersprerse '- '(a b c d))
> > (A - B - C - C)
>
>
> The iterative variant (loop-less):
>
> (defun intersperse (object list)
> (let ((result (and list (list (first list)))))
> (dolist (item (rest list) (nreverse result))
> (setq result (list* item object result)))))
Gauche Scheme

(use srfi-1) ;; circular-list

(define (intersperse x xs)
(cdr (append-map list
(circular-list x)
xs)))

(intersperse '- '(b c d j))
===>
(b - c - d - j)

1

rocksolid light 0.9.8
clearnet tor