Skip to Content
Raku学习手册
book

Raku学习手册

by brian d foy
October 2020
Beginner to intermediate
499 pages
9h 13m
Chinese
China Electric Power Press Ltd.
Content preview from Raku学习手册
142
6
6.6.2
交叉操作符
X
X
交叉操作符将一个
Positional
的每一个元素与另一个
Positional
的每一个元素
结合:
my @letters = <A B C>;
my @digits = 1, 2, 3;
my @crossed = @letters X @digits;
say @crossed;
输出显示每个字母分别与各个数字成对:
[(A 1) (A 2) (A 3) (B 1) (B 2) (B 3) (C 1) (C 2) (C 3)]
练习
6.13
一副扑克牌有
52
张牌,
4
种花色
♣♡♠♢
,每种花色分别有
13
张牌,
2~10
J
Q
K
A
。使用交叉操作符建立一个
List
List
,每个元素分别表示每张牌。
输出这个扑克牌列表,让同一花色的所有牌显示在同一行上。
6.6.3
超操作符
不是组合
Positional
,还可以处理
Positional
来创建结果的一个
List
。超操作符
hyperoperators
)可以做到这一点。用
<<>>
包围
+
操作符。这会把
@right
的第一
个元素与
@left
的第一个元素完成数值相加。相加的结果成为结果列表的第一个元素。
第二个元素也是这样,然后是第三个元素,依此类推:
my @right = 1, 2, 3;
my @left = 5, 9, 4;
say @left <<+>> @right; # [6 11 7]
可以选择一个不同的操作符,按照同样的过程处理。连接操作符会连接各个元素的
Str
版本:
my @right = 1, 2,
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

可编程网络自动化

可编程网络自动化

Jason Edelman, Scott S. Lowe, Matt Oswalt
程序员学数据结构

程序员学数据结构

Posts & Telecom Press, William Smith
R深度学习权威指南

R深度学习权威指南

Posts & Telecom Press, Joshua F. Wiley
AI工程

AI工程

Chip Huyen

Publisher Resources

ISBN: 9787519848002