Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

I'll say it again for the logic impaired. -- Larry Wall


devel / comp.lang.lisp / .Re: Using mapcar with fewer lists than function arguments

SubjectAuthor
o .Re: Using mapcar with fewer lists than function argumentsRobert L.

1
.Re: Using mapcar with fewer lists than function arguments

<sus87r$al1$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16904&group=comp.lang.lisp#16904

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!aioe.org!eYeqBzNjiJ3ACJwkx5pzXw.user.46.165.242.75.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (Robert L.)
Newsgroups: comp.lang.lisp
Subject: .Re: Using mapcar with fewer lists than function arguments
Date: Sun, 20 Feb 2022 02:15:26 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <sus87r$al1$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Info: gioia.aioe.org; logging-data="10913"; posting-host="eYeqBzNjiJ3ACJwkx5pzXw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: XanaNews/1.18.1.6
X-Notice: Filtered by postfilter v. 0.9.2
 by: Robert L. - Sun, 20 Feb 2022 02:15 UTC

Pascal J. Bourguignon wrote:

> Barry Margolin <barmar@alum.mit.edu> writes:
>
> > In article <e1760ede-f833-4724-aeb3-069ed3c77497@googlegroups.com>,
> > grmann1123@gmail.com wrote:
> >
> >> Then I want to mapcar foo over lists of x's (xlst) and z's (zlst), but use
> >> the same value for y and bar every time. I've been using this, which works
> >> but looks ugly:
> >> (mapcar #'(lambda (a b) (foo a y b :bar baz)) xlst zlst)
> >>
> >> It seems like either there should be a built in macro for that or I should be
> >> able to write my own, but I'm not sure how to make it look better than what
> >> it's replacing.
> >
> > Use a circular list for the constant arguments. Unfortunately, CL
> > doesn't have a built-in function for creating circular lists.
>
> That's not the most unfortunate in this situation. What's the most
> unfortunate, is that none of the common CL function is specified to deal
> with circular lists. It may just happen in some or most
> implementations, but there's no guarantee your calls will terminate or
> whatever when you pass a circular list.
>
> All the functions on the mapcar hyperspace page take proper lists, and
> so do all the functions that take sequences.
>
>
> > It's easy to write one:
> >
> > (defun circular-list (&rest elements)
> > (let ((backbone (copy-list elements)))
> > (nconc backbone backbone)))
> >
> > (mapcar #'foo xlist (circular-list something) ylist)
>
> Blam! Or did you rewrite mapcar to be sure it deals sanely with
> circular lists?
>
>
> > You can also use #n=/#n# notation if the repeated value is a literal:
> >
> > (mapcar #'foo xlist '#1=(something . #1#) ylist)
>
> Finger crossed, this is not conforming code.

Gauche Scheme:

(require srfi/1) ; circular-list

(map
string-append
'("hi" "low")
(circular-list "-")
'("ho" "ball"))

===>
("hi-ho" "low-ball")


devel / comp.lang.lisp / .Re: Using mapcar with fewer lists than function arguments

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor