Erlang完整示例
发布日期:2021-06-29 17:24:15 浏览次数:2 分类:技术文章

本文共 508 字,大约阅读时间需要 1 分钟。

-module(ch3).

-export([format_temps/1]).

%% Only this function is exported

format_temps([])-> % No output for an empty list
ok;
format_temps([City | Rest]) ->
print_temp(convert_to_celsius(City)),
format_temps(Rest).

convert_to_celsius({Name, {c, Temp}}) -> % No conversion needed

{Name, {c, Temp}};
convert_to_celsius({Name, {f, Temp}}) -> % Do the conversion
{Name, {c, (Temp - 32) * 5 / 9}}.

print_temp({Name, {c, Temp}}) ->

io:format("~-15w ~w c~n", [Name, Temp]).
在这里插入图片描述

在这里插入图片描述

百度搜索:Erlang完整示例----W3cSchool—Erlang完整示例

转载地址:https://blog.csdn.net/m0_38127487/article/details/113766747 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Ruby中式编程----之客户篇
下一篇:美国男子睡梦中误吞下自己的苹果 AirPod:卡在食道里

发表评论

最新留言

路过,博主的博客真漂亮。。
[***.116.15.85]2024年04月06日 02时13分40秒