- Perl 6 Deep Dive
- Andrew Shitov
- 100字
- 2021-07-03 00:05:54
Complex numbers
In Perl 6, there is the Complex built-in type to present complex numbers.
Complex numbers have two parts, real and imaginary, and use the following syntax:
my $x = 3+4i;
my $y = -5i;
It is not necessary to explicitly spell out the real part, but the output always contains it:
say $x; # 3+4i
say $y; # -0-5i
say $z; # 0+1i
An alternative way to create a Complex number is to call a constructor (we will talk about constructors in Chapter 8, Object-Oriented Programming), as follows:
my $n = Complex.new(4, 5);
say $n; # 4+5i
推薦閱讀
- Bootstrap Site Blueprints Volume II
- Designing Hyper-V Solutions
- TypeScript實戰指南
- Nginx Essentials
- INSTANT OpenNMS Starter
- Mastering Ext JS
- Advanced Oracle PL/SQL Developer's Guide(Second Edition)
- Python Data Analysis Cookbook
- BeagleBone Black Cookbook
- Python語言實用教程
- 時空數據建模及其應用
- INSTANT Silverlight 5 Animation
- Learning Modular Java Programming
- Everyday Data Structures
- Application Development with Swift