@@ -290,6 +290,11 @@ class FormulaEvaluator {
290290 FormulaFunctionDoc ('take' , 'take(list, count)' , 'take(alerts, 3)' ),
291291 FormulaFunctionDoc ('skip' , 'skip(list, count)' , 'skip(alerts, 3)' ),
292292 FormulaFunctionDoc ('keys' , 'keys(map)' , 'keys(snoozed) → [r_black]' ),
293+ FormulaFunctionDoc (
294+ 'concat' ,
295+ 'concat(list, list or value, ...)' ,
296+ 'concat(take(history, 23), [soc]); history + [soc] does the same' ,
297+ ),
293298 FormulaFunctionDoc (
294299 'alpha' ,
295300 'alpha(color, opacity)' ,
@@ -907,6 +912,10 @@ final Map<String, _Function> _functions = {
907912 'alpha' : (a) => _alpha (_arg (a, 0 ), _num (_arg (a, 1 ))),
908913 'take' : (a) => _values (_arg (a, 0 ), null ).take (_intArg (_arg (a, 1 ))).toList (),
909914 'skip' : (a) => _values (_arg (a, 0 ), null ).skip (_intArg (_arg (a, 1 ))).toList (),
915+ 'concat' : (a) => [
916+ for (final Object ? item in a)
917+ if (item is Iterable ) ...item else item,
918+ ],
910919 'keys' : (a) => switch (_arg (a, 0 )) {
911920 final Map m => [for (final key in m.keys) '$key ' ],
912921 _ => < Object ? > [],
@@ -1099,6 +1108,8 @@ class _Binary extends _Node {
10991108 final Object ? b = right.eval (resolve);
11001109 switch (op) {
11011110 case '+' :
1111+ // Lists join, and a list plus a value appends it.
1112+ if (a is Iterable ) return [...a, if (b is Iterable ) ...b else b];
11021113 final num ? na = a is String ? null : _toNum (a);
11031114 final num ? nb = b is String ? null : _toNum (b);
11041115 if (na != null && nb != null ) return _tidy (na + nb);
0 commit comments