首页 > 其他分享 >无涯教程-Erlang - get函数

无涯教程-Erlang - get函数

时间:2023-12-06 17:32:54浏览次数:45  
标签:Map erlang Lst1 get 无涯 start 返回值 Erlang

此方法用于获取映射中特定键的值。

get - 语法

get(key,map)
  • key     -  这是需要为其返回值的键。

  • Map   -  这是需要在其中搜索键的Map。

get - 返回值

如果在Map上找到键,则返回值。

-module(helloLearnfk). 
-export([start/0]). 

start() ->   
   Lst1=[{"a",1},{"b",2},{"c",3}], 
   Map1=maps:from_list(Lst1), 
   io:fwrite("~p~n",[maps:get("a",Map1)]).

上面程序的输出如下。

1

参考链接

https://www.learnfk.com/erlang/erlang-get.html

标签:Map,erlang,Lst1,get,无涯,start,返回值,Erlang
From: https://blog.51cto.com/u_14033984/8707459

相关文章

  • 无涯教程-Erlang - find函数
    此方法用于查找Map中是否存在特定键。find-语法find(key,map)key  - 这是需要转换为Map的列表。Map- 这是需要在其中搜索键的Map。find-返回值如果在Map上找到键,则返回值。-module(helloLearnfk).-export([start/0]).start()->Lst1=[{"a",1},{"b"......
  • 无涯教程-Erlang - list_to_atom函数
    此方法用于将列表项转换为原子。list_to_atom-语法list_to_atom(listvalue)listvalue - 这是需要转换为原子的列表值。list_to_atom-返回值基于列表值输入的原子。-module(helloLearnfk).-export([start/0]).start()->io:fwrite("~p~n",[list_to_atom("a......
  • 无涯教程-Erlang - is_atom函数
    此方法用于确定术语是否确实是原子。is_atom-语法is_atom(term)term - 这是需要判断其是否为原子的值。is_atom-返回值如果条件值是一个原子,则返回true,否则将返回false。-module(helloLearnfk).-export([start/0]).start()->io:fwrite(atom1),io:fw......
  • 无涯教程-Erlang - is_dir函数
    此方法用于确定目录是否确实是目录,此方法是filelib库的一部分。is_dir-语法is_dir(directoryname)directoryname - 这是目录名,是否为目录名。is_dir-返回值是的,如果目录存在并且确实是目录。-module(helloLearnfk).-export([start/0]).start()->io:fwrit......
  • 无涯教程-Erlang - copy函数
    此方法用于复制现有文件。copy-语法copy(source,destination)source     - 需要复制的源文件的名称。destination -文件的目标路径和名称。copy-示例-module(helloworld).-export([start/0]).start()->file:copy("Newfile.txt","Duplicate.......
  • 无涯教程-Erlang - write函数
    此方法用于将内容写入文件。write-语法write(FileHandler,text)FileHandler-这是文件的句柄。该句柄是使用file:open操作时将返回的句柄。text        - 需要添加到文件中的文本。write-示例-module(helloLearnfk).-export([start/0]).sta......
  • 无涯教程-Erlang - file_read函数
    有一种方法可以允许一次读取文件的所有内容,这是通过file_read方法完成的。语法file_read(filename)参数filename-这是需要读取的文件名。返回值文件的全部内容。-module(helloLearnfk).-export([start/0]).start()->Txt=file:read_file("Newfile.txt"),i......
  • 无涯教程-Erlang - sort函数
    对元素列表进行排序。sort-语法sort(lst)Lst - 需要排序的元素列表。sort-返回值返回元素的排序列表。-module(helloLearnfk).-import(lists,[sort/1]).-export([start/0]).start()->Lst1=[5,6,4],io:fwrite("~p~n",[sort(Lst1)]).当我们运行......
  • 无涯教程-Erlang - reverse函数
    反转元素列表。reverse-语法reverse(lst)Lst  - 需要反转的元素列表。reverse-返回值返回元素的反向列表。-module(helloLearnfk).-import(lists,[reverse/1]).-export([start/0]).start()->Lst1=[1,2,3],io:fwrite("~p~n",[reverse(Lst1)]).......
  • 无涯教程-Erlang - merge函数
    返回通过合并ListOfLists的所有子列表形成的排序列表。merge-语法merge(ListsofLists)ListsofLists -需要合并的列表集合。merge-返回值返回元素的合并列表。-module(helloLearnfk).-import(lists,[merge/1]).-export([start/0]).start()->io:fwri......