What about this?

10 { [ 1 + ] [ 2 + ] [ 3 + ] } [ call( x -- y ) ] with map

The 'with' combinator gets rid of the dupd/drop pattern.

Your snippet doesn't compile because it applies 'call' to a
runtime-computed value; using call( gets around that by explicitly
declaring a stack effect for the quotation being called.

Slava

On Fri, Aug 27, 2010 at 7:34 PM, Kyle Cordes <k...@kylecordes.com> wrote:
> Hello. Warning, Factor neophyte with a bit of long-forgotten Forth 
> experience...
>
> I picked up the notion, on a web page that I cannot find at the
> moment, that good style in Factor is to get rid of stack manipulation
> words, and use quots and combinators instead. I've been pushing bits
> of code around, trying to learn to do that. Here is a tiny snippet:
>
> 10 { [ 1 + ] [ 2 + ] [ 3 + ] } [ dupd call ] map . drop
>
> ... in which I'm trying to map from an array of quots to their result,
> but with a stack value (perhaps more than one?) available to the
> quots. I've done so here with the bludgeon of dupd and drop. It seems
> like a need something that is somewhat like map and somewhat like
> cleave.
>
> How should I do this? Is there another combinator that I am overlooking?
>
> --
> Kyle Cordes
> http://kylecordes.com
>
> ------------------------------------------------------------------------------
> Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
> Be part of this innovative community and reach millions of netbook users
> worldwide. Take advantage of special opportunities to increase revenue and
> speed time-to-market. Join now, and jumpstart your future.
> http://p.sf.net/sfu/intel-atom-d2d
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>

------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to