所以我们可以用一个对象来初始化一个 map,就像这样:
So we can initialize a map from an object like this
如果需要转换的多重价值观,可以使用 map:
If you need to convert multiple values, you can use map
当我们需要遍历并返回每个元素的数据时 - 我们可以使用 map。
When we need to iterate and return the data for each element - we can use map.
因此,map 工作线程无需等待创建新任务。
Hence, map workers do not need to wait for new tasks to be created.
让我们使用匿名函数重写 map 那个例子。
Let's rewrite the map example and have it use an anonymous function
我们将会使用排序后字母的变量作为 map 的键,为每一个键仅保存一个值:
We'll use the letter-sorted variants as map keys to store only one value per each key
在很多函数式编程语言中能找到的map 函数是高阶函数的一个例子。
The map function, found in many functional programming languages, is one example of a higher-order function.
Hashtable提供了一种易于使用的、线程安全的、关联的map功能,这当然也是方便的。
Hashtable provided an easy-to-use, thread-safe, associative map capability, and it was certainly convenient.
如果要在 map 里使用循环,可以使用以下三个方法:
For looping over a map, there are 3 methods
下一步, 我们使用 map 这个高阶函数并传递给它两个参数, 一个子例程和一个数组。
Next, we used map, a higher order function, and gave it two arguments, the squared subroutine and an array.
map 函数将使用字典更新数据集中的每个元素(行 ) 。
The map function updates each elem (line) in the dataset with the dict.
/ 但是记录依旧在 map 中,我们需要清理它!
/ but it's still in the map, we need to clean it!
map 是 高阶函数, 它接收另外一个函数作为参数。
map is a higher order function, it can accept another function as an argument.