Same ⟨pattern variable⟩ apparing two or more times Amirouche (26 Dec 2022 11:44 UTC)
Re: Same ⟨pattern variable⟩ apparing two or more times Marc Nieper-Wißkirchen (26 Dec 2022 12:47 UTC)
Re: Same ⟨pattern variable⟩ apparing two or more times Marc Nieper-Wißkirchen (26 Dec 2022 16:12 UTC)

Re: Same ⟨pattern variable⟩ apparing two or more times Marc Nieper-Wißkirchen 26 Dec 2022 16:11 UTC

Am Mo., 26. Dez. 2022 um 16:48 Uhr schrieb Amirouche <xxxxxx@hyper.dev>:
>
> > (match '(42 42 nothing)
> > ((,a1 ,a2 . rest) (guard (= a1 a2)) a1))
> >
> > This also circumvents the problem of which equivalence predicate to choose.
> >
> > PS A cata variable can coincide with a pattern variable, but not with
> > another cata variable.
>
> I am uncertain if I understand. What the following yields:
>
>
>  (match '(a (a))
>   ((,a . ,(a)) a)
>   (() '()))
>
> Will the cata variable shadow the pattern variable?

Yes; see the specification of `match`: the cata variables are bound in
an environment extending the environment in which the pattern
variables are bound.