Skip to main content

Arity

rascal-0.34.0

Synopsis

The number of arguments of an operator differ from what is required.

Description

Various operators like composition, transitive closure and reflexive transitive closure expect binary relations or tuples as arguments.

Examples

This composition is correct:

rascal>{<1,10>, <2,20>} o {<10,100>, <20, 200>};
rel[int,int]: {
<1,100>,
<2,200>
}

This is not, since the first argument has arity 3:

rascal>{<1,5,10>, <2,6,20>} o {<10,100>, <20, 200>};
|prompt:///|(39,3,<1,39>,<1,42>): Expected arity : 2, unequal to 3
Advice: |https://www.rascal-mpl.org/docs/Rascal/Errors/CompileTimeErrors/Arity|
ok

These transitive closures are correct:

rascal>{<1,2>, <2,3>,<4,5>}+
rel[int,int]: {
<2,3>,
<4,5>,
<1,3>,
<1,2>
}
rascal>{<1,2>, <2,3>,<4,5>}*
rel[int,int]: {
<5,5>,
<3,3>,
<1,1>,
<1,3>,
<1,2>,
<2,3>,
<2,2>,
<4,5>,
<4,4>
}

But these are incorrect:

rascal>{<1,2,3>, <2,3,4>,<4,5,6>}+
|prompt:///|(23,1,<1,23>,<1,24>): Expected arity : 2, unequal to 3
Advice: |https://www.rascal-mpl.org/docs/Rascal/Errors/CompileTimeErrors/Arity|
ok
rascal>{<1,2,3>, <2,3,4>,<4,5,6>}*
|prompt:///|(23,1,<1,23>,<1,24>): Expected arity : 2, unequal to 3
Advice: |https://www.rascal-mpl.org/docs/Rascal/Errors/CompileTimeErrors/Arity|
ok