Re: New EEP draft: Pinning operator ^ in patterns

"Michael P." <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <20210127224826.0c4ebea0@aesop>
On Thu, 14 Jan 2021 13:13:54 -0500
Leonard B <[email protected]> wrote:

> IE, if a variable is previously assigned within the outer scope use
> that variable within the inner scope.
> This, in my addled mind, makes more sense
>
> EG:
> %% X is from outer scope, L is from outer scope, V is local to comprehension
> X = 5.
> L = [1,2,3,4,5].
> [V || {X, V} <- L].

Done?

```
Eshell V10.2.4  (abort with ^G)
1> X = 5.
5
2> L = [1,2,3,4,5].
[1,2,3,4,5]
3> [V || {X, V} <- L].
[]
4> [{X, V} || V <- L, V /= X].
[{5,1},{5,2},{5,3},{5,4}]

5> Lt = [{1, 2}, {2, 3}, {4, 5}, {5, 6}, {6, 7}, {5, 8}].
[{1,2},{2,3},{4,5},{5,6},{6,7},{5,8}]
6> [V || {X, V} <- Lt].
[2,3,5,6,7,8]
7> [V || {Selector, V} <- Lt, Selector == X].
[6,8]
```
Names should be swapped (X, Selector).

Naming is a burden; but also an opportunity.

~M

--

Corporation-independent Public Broadcasting is the best innovation
since someone said, that the volcano will erupt anyway or not, no
matter how many virgins are thrown into it or not.

Unternehmensunabhängiger Öffentlich-rechtlicher Rundfunk ist
die beste Innovation, seit jemand sagte, dass der Vulkan eh
ausbricht oder nicht, egal wieviele Jungfrauen man da reinwirft
oder nicht.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.