Erlang列表操作里面的变量绑定规则
生活随笔
收集整理的這篇文章主要介紹了
Erlang列表操作里面的变量绑定规则
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
原文如下:
The scope rules for variables which occur in list comprehensions are as follows:
- all variables which occur in a generator pattern are assumed to be "fresh" variables
- any variables which are defined before the list comprehension and which are used in filters have the values they had before the list comprehension
- no variables may be exported from a list comprehension.
譯文:
? ? 列表操作里面的變量的作用域遵循以下原則:
? ? 。所有出現在發生器里面的變量都被假設為“新”變量(也就是未經綁定的變量)。
? ? 。所有定義在列表操作之前的變量,即使在列表過濾條件中使用,也仍然會保存之前綁定的值。(跟第一條是一樣的么,雖然名字相同,其實是一個“新”變量)
? ? 。所有列表操作里面使用的變量都不會被導出,也就是說,列表操作里面的變量作用域僅在列表操作里面,
PS:list?comprehension實在是不知道怎么翻譯,所以翻譯成了“列表操作”,有人知道怎么翻譯可以給我留言。
例子:
? ??
轉載于:https://my.oschina.net/u/1263964/blog/176314
總結
以上是生活随笔為你收集整理的Erlang列表操作里面的变量绑定规则的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ANT 发布项目中 build.xml
- 下一篇: spring中的RowMapper