@@ -20,6 +20,10 @@ class Scratch3OperatorsBlocks {
2020 operator_subtract : this . subtract ,
2121 operator_multiply : this . multiply ,
2222 operator_divide : this . divide ,
23+ operator_add_extendable : this . addExtendable ,
24+ operator_subtract_extendable : this . subtractExtendable ,
25+ operator_multiply_extendable : this . multiplyExtendable ,
26+ operator_divide_extendable : this . divideExtendable ,
2327 operator_lt : this . lt ,
2428 operator_equals : this . equals ,
2529 operator_gt : this . gt ,
@@ -40,7 +44,7 @@ class Scratch3OperatorsBlocks {
4044 }
4145
4246 checkbox ( ) {
43- return true ;
47+ return true ;
4448 }
4549
4650 add ( args ) {
@@ -58,6 +62,26 @@ class Scratch3OperatorsBlocks {
5862 divide ( args ) {
5963 return Cast . toNumber ( args . NUM1 ) / Cast . toNumber ( args . NUM2 ) ;
6064 }
65+
66+ addExtendable ( args , util ) {
67+ const arr = util . extendableToArray ( args , 'NUMS' , 'NUM' ) ;
68+ return arr . reduce ( ( a , b ) => Cast . toNumber ( a ) + Cast . toNumber ( b ) ) ;
69+ }
70+
71+ subtractExtendable ( args , util ) {
72+ const arr = util . extendableToArray ( args , 'NUMS' , 'NUM' ) ;
73+ return arr . reduce ( ( a , b ) => Cast . toNumber ( a ) + Cast . toNumber ( b ) ) ;
74+ }
75+
76+ multiplyExtendable ( args , util ) {
77+ const arr = util . extendableToArray ( args , 'NUMS' , 'NUM' ) ;
78+ return arr . reduce ( ( a , b ) => Cast . toNumber ( a ) * Cast . toNumber ( b ) ) ;
79+ }
80+
81+ divideExtendable ( args , util ) {
82+ const arr = util . extendableToArray ( args , 'NUMS' , 'NUM' ) ;
83+ return arr . reduce ( ( a , b ) => Cast . toNumber ( a ) / Cast . toNumber ( b ) ) ;
84+ }
6185
6286 lt ( args ) {
6387 return Cast . compare ( args . OPERAND1 , args . OPERAND2 ) < 0 ;
@@ -103,13 +127,9 @@ class Scratch3OperatorsBlocks {
103127 return Cast . toString ( args . STRING1 ) + Cast . toString ( args . STRING2 ) ;
104128 }
105129
106- joinExtendable ( args ) {
107- let string = "" ;
108- const argCount = + args . STRINGS ;
109- for ( let i = 0 ; i < argCount ; i ++ ) {
110- string += Cast . toString ( args [ "STRINGS_" + i + "_STRING" ] ) ;
111- }
112- return string ;
130+ joinExtendable ( args , util ) {
131+ const arr = util . extendableToArray ( args , 'STRINGS' , 'STRING' ) ;
132+ return arr . reduce ( ( a , b ) => a + Cast . toString ( b ) , '' ) ;
113133 }
114134
115135 letterOf ( args ) {
0 commit comments