Last active
August 29, 2015 14:01
-
-
Save ravinggenius/c6085942364d064891bf to your computer and use it in GitHub Desktop.
Literal syntaxes for different types of number in Rip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Constants | |
System.Math.i # square root of -1 | |
System.Math.PI # 5 decimal points (same as `System.Math.PI_to(5)`, but only calculated once) | |
System.Math.PI_to # lambda that calculates a decimal to `n` decimal points | |
## | |
# Real Numbers | |
System.Integer #=> 1 | |
System.Decimal #=> 3.14 | |
System.Rational #=> 2 / 3 | |
# would love to implement division in such a way that if the number can | |
# divide evenly, it just returns the integer, otherwise a rational | |
## | |
# Imaginary Numbers | |
# access the dynamic property `i` on real numbers for their imaginary counterparts | |
# (same as multiplying the real number by System.Math.i) | |
System.Integer #=> 1.i | |
System.Decimal #=> 3.14.i | |
System.Rational #=> (2 / 3).i | |
## | |
# Complex Numbers | |
# literal syntax is <real, imaginary> | |
System.Complex #=> <42, 3.i> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment