Hi Mayson,

In this case it's not necessary to use a variable. Factor's stack is more
than sufficient for a problem like this. There's also a word that will help
you: reduce. Try \ reduce help in the listener and I think you'll find the
problem a lot easier.

If you were using a variable, then at some point you would use either
with-scope or with-variable so that you're not using a global.

Alex

2008/11/19 Mayson Lancaster <[EMAIL PROTECTED]>

> As a Factor newcomer, I'm having some difficulty figuring out how to
> express myself idiomatically.
> Here's an example, my first crack at a word to return the sum of a sequence
> of numbers on the stack.
>
> USING: kernel assocs namespaces math sequences prettyprint ;
> IN: mayson
>
> SYMBOL: mysum
>
> : sequence-sum ( seq -- sum )
> 0 mysum set
>  mysum get [ + mysum set ] curry each mysum get ;
>
> It seems to work, but two things look wrong to me: the (semi-)global
> variable, and the necessity of using a curry.
>
> Are there any reasonably Factorial ways to clean this up?
>
> Mayson
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Factor-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to