Programming Erlang_CHAPTER2_Basic Erlang 学习笔记(1)。

本文介绍了Erlang的基础知识,包括语句结构、数字类型、浮点数、原子及布尔运算等内容。通过本文,读者可以了解Erlang的基本数据类型及其操作方式。

Erlang基础:

每条语句以一个“.”结束。

%是erlang语言的注释,注释从%开始,一直到行尾。一般情况下,erlang源程序中%%做为注释,我想可能是看起来比较显眼。

1.整形(integers)

  1.Erlang中的整形包括全部的数字。

  2.Erlang遵守四则表达式的规则,可以计算很大的数字。

      2#1010为二进制中的10,-16#EA为十六进制中的-234.所以2#表示二进制。

  3.所有的字母都是以ASCII码存储的。

      $a为97,$\n为10,$A为65.

2.浮点型(Floats)

  Erlang中的浮点数为真实地数字。如17.909  ,1.234E-10表示1.234x10(-10次方)。

  数学运算

    +  Unary+

    -  Unary-

    *  Multiplication

    /  Floating-point division

    div  integer remainder

   rem  Integer remainder  余数

     11 div 5. 为2  11 rem 5 .为1  

3.  原子(Atoms)

  1.Erlang中atoms用来表示不同的常量。

  2.atoms是全局性的

  3.atoms以小写字母开头,后面跟上数字,字符,下划线,或“@”。

   4.atoms可以用单引号引起来,使用这种形式后可以创建大写字符开头的atoms,或者包含非数值字符的atoms,例如’Monday’, ’Tuesday’, ’+’, ’*’,    ’an atom with spaces’。

  5.atoms的值只是atom。

4.Booleans

  1.在Erlang中没有独立的booleans类型。所以用原子的true和false来代替booleans。

  2.operation:

    1. and   Returns true only if both arguments are true.

    2.andalso Shortcut evaluation of and:return false if the first argument id false,without evaluating the second.

    3.or      Returns true if either of the arguments is true.

    4.orelse  Shortcut evaluation of or:returns true if the first argument is true,without evaluating the second.

    5.xor   returns true if one of its arguments is true and the other false.

    6.not    Unary negation operator:returns true if its argument is false,and vice versa.

 

 

 

 

 

转载于:https://www.cnblogs.com/wkp4666/archive/2012/05/01/Erlong%e5%ad%a6%e4%b9%a0%e6%af%95%e7%ab%9f.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值