Journal(2005) | Blog(2006) | RandomLink | WhoAmI | LiveBookmark | HomePage

<<Previous: ppt for PM Shanghai meeting  >>Next: Google Print

Perl6 | Examples & 9 ^ junction

Category: Perl6   Keywords: junction Perl6

Preface

junction, 中文可以翻译成结。强大得你会立刻爱上它。

Examples

先举几个例子:

详细描述

junction 其实是将一些数据值叠加,表现为一个数据值。junction 有四种形式:

列表操作符中缀(infix)操作符关系简单解释
all&AND所有的值必须都为 true
any|OR至少有一个值为 true
one^XOR有且仅有一个值为 true
noneNOT所有的值都得为 flase

注意中缀操作符是列表相关("list-associative")的:

$a | $b | $c 与 any($a,$b,$c) 同,而不是 any(any($a,$b),$c)
$a & $b & $c 与 all($a,$b,$c) 同,而不是 all(all($a,$b),$c)
$a ^ $b ^ $c 与 one($a,$b,$c) 同,而不是 one(one($a,$b),$c)

junction 与 向量操作符 有点类似。不同的是 junction 大多运行在判断正确与否里。

我们还是用例子来说明 junction 的运算:
$junc = any(1, 2);
$junc += 5; # $junc is now any(6, 7)

use junction;

have fun, guys.

<<Previous: ppt for PM Shanghai meeting  >>Next: Google Print

Options: +Del.icio.us

Related items Created on 2005-05-26 12:35:29, Last modified on 2005-05-26 12:59:33
Copyright 2004-2005 All Rights Reserved. Powered by Eplanet && Catalyst 5.62.