【原创】Erlang 之 match 和 compare equal
原创 match erlang Compare equal
2023-09-14 08:59:45 时间
在学习 Erlang 过程中,经常会遇到以下两个和比较相关的操作:match 和 compare equal 。现作如下解释:
当两个 Erlang term 拥有完全相同类型和值时,我们称它们 match 。例如:1 match 1 为 true ,但 1 match 1.0 为 false 。
当两个 Erlang term 拥有完全相同类型和值时,或者两者均为数值类型,且可以延伸为相同的值时,我们称它们 compare equal 。例如,1 compare equal 1 为 true,且 1 compare equal 1.0 为 true 。
另外一个比较直观的说法是:
在实际应用中,ETS 中 set 类型的表采用的是 match ,而 ordered_set 类型的表采用的是 compare equal。
原文参考:
Also worth noting is the subtle difference between matching and comparing equal, which is demonstrated by the different table types set and ordered_set. Two Erlang terms match if they are of the same type and have the same value, so that 1 matches 1, but not 1.0 (as 1.0 is a float() and not an integer()). Two Erlang terms compare equal if they either are of the same type and value, or if both are numeric types and extend to the same value, so that 1 compares equal to both 1 and 1.0. The ordered_set works on the Erlang term order and there is no defined order between an integer() and a float() that extends to the same value, hence the key 1 and the key 1.0 are regarded as equal in an ordered_set table.
LeetCode第三题(Longest Substring Without Repeating Characters)三部曲之三:两次优化 本文是《LeetCode第三题(Longest Substring Without Repeating Characters)三部曲》的第二篇,前一篇文章已经列出了完整的解题思路,今天来将此思路转化为具体的Java代码
相关文章
- 原创 | 谷歌JAX 助力科学计算
- 原创|MySQL一个非预期锁等待分析
- 原创 搜索技巧和网页隐患
- 【原创】Mybatis框架
- 【原创】Java编程思想以及类,对象,属性,方法,包的解释
- 【原创】JavaScript中的数据类型以及数据类型的转换
- 这家付费图库巨头率先拥抱AI绘画,还掏钱补偿原创画师
- 原创 | 机器学习在分子动力学领域顶会论文初探
- 【原创】.NET Core应用类型(Portable apps & Self-contained apps)详解编程语言
- 如何搭建原创Redis集群一个完整的教程(原创redis集群教程)
- 手机号码本地检测原创
- 由亿起发(eqifa.com)的页面发现顶部的http://16a.us/8.js想到的js解密原创
- php读取文件内容至字符串中,同时去除换行、空行、行首行尾空格(Zjmainstay原创)