Open vporton opened 3 months ago
Checked with a newer version of moc
, the same bug:
$ moc --version
Motoko compiler 0.11.1+ (source 7k01snp5-bm3lbckz-84fkkzp5-zqz3gvyv)
Because Array
is not Text
:-) and #=
(as well as #
) applies to Text
.
Background: Text
has a representation of ropes internally and provides O(1) concatenation. Array
s are contiguous, so concatenation is a linear complexity operation. You'll have to implement it in terms of Array.tabulate
.
https://github.com/dfinity/motoko-base/blob/6f49e5f877742b79e97ef1b6f226a7f905ba795c/src/Array.mo#L176 provides Array.append, but we deprecate it because it easily leads to quadratic behaviour.
The above code must be compilable, but: