slavapestov/factor — Issue #355: lmap stack effect declaration does not match implementation
Author: bremac
Created: 2011-11-06 07:40:29+00:00
State: open

Though lmap has a stack effect of `( ... list quot: ( ... elt -- ... newelt ) -- ... result )`, it actually accumulates results on the stack, which means that it is only safe to use it as `( list quot: ( elt -- newelt ) -- result )`.

As a contrived example, `1 { 3 3 3 } sequence>list [ dupd + ] lmap list>array nip` produces `{ 4 7 10 }` instead of `{ 4 4 4 }`.

The only working version I've been able to produce so far is

```factor
: lmap ( ... list quot: ( ... elt -- ... newelt ) -- ... result )
[ nil ] dip [ rot [ call ] dip cons ] curry foldl lreverse ; inline
```