effekt-lang / effekt-lang/effekt
Appending lists in the standard library
- Dominant language
- Scala
- Stars
- 469
- Forks
- 41
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 23
Description
_Extracted from [a discussion](https://github.com/effekt-lang/effekt/pull/830/files/2186b0de6bda9589aa2fc072fcc0416b3c28031c..27642ac6623b7e13dca85b13655126f2ec584abe#diff-964dff611f6e694c69447acd3d4c732c4f950266ad48f01adcf5e633a0f71921) in #830_
The implementation of `append` in the `list` module reverses stuff twice instead of doing the naive thing:
```
def append[A](l: List[A], other: List[A]): List[A] = l match {
case Nil() => other
case Cons(a, rest) => Cons(a, append(rest, other))
}
```
This implementation is faster on the LLVM backend but slower on the JS backend for the following program:
```
def main() = {
val l1 = fill(100000, 1)
val l2 = l1.append(l1).append(l1).append(l1).append(l1)
println(l2.sum)
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.