Skip to content

Instantly share code, notes, and snippets.

@douglasmiranda
Created July 26, 2011 01:47
Show Gist options
  • Save douglasmiranda/1105758 to your computer and use it in GitHub Desktop.
Save douglasmiranda/1105758 to your computer and use it in GitHub Desktop.
Comparison operations. Python & Erlang //Useful for beginners, like me :)
Python Erlang Description Erlang Example
--------+--------+-----------------------+----------------
< < strictly less than
--------+--------+-----------------------+----------------
<= =< less than or equal
--------+--------+-----------------------+----------------
> > strictly greater than
--------+--------+-----------------------+----------------
>= >= greater than or equal
--------+--------+-----------------------+----------------
!= /= not equal
--------+--------+-----------------------+----------------
== == equal 1> 1 == 1.
true
2> 1 == 1.0.
true
--------+--------+-----------------------+----------------
=:= exactly equal to 1> 1 =:= 1.
true
2> 1 =:= 1.0.
false
--------+--------+-----------------------+----------------
=/= exactly not equal to
--------+--------+-----------------------+----------------
is object identity
--------+--------+-----------------------+----------------
is not negated obj identity
#Arithmetic operations
Python Python Desc. Erlang Erlang Desc. Example
--------+--------------------+---------+--------------+--------------------
x % y remainder X rem Y integer >>> 7 % 3
of x / y remainder 1
of X / Y >>> 7.0 % 3
1.0
1> 7 rem 3.
1
1> 7.0 rem 3.
=ERROR REP..
--------+--------------------+---------+--------------+--------------------
x / y quotient X / Y floating >>> 7 / 3
of x and y point 2
division >>> 7.0 / 3
2.3333333333333335
1> 7 / 3.
2.33333
--------+--------------------+---------+--------------+--------------------
x // y (floored) quotient X div Y integer >>> 7 // 3
of x and y, division 2
integer division >>> 7.5 // 3
(result type is 2.0
not forced to be
int) 1> 7 div 3.
2
#Originally from: http://ruslanspivak.com/2007/09/16/erlang-for-python-programmers-part-ii/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment