set-n allows dynamic variable assigning in outer scopes

db4
Sam Anklesaria 2009-06-04 21:24:25 -05:00
parent b74b8478f3
commit acf9159f31
1 changed files with 5 additions and 0 deletions

5
extra/set-n/set-n.factor Normal file
View File

@ -0,0 +1,5 @@
USING: assocs kernel math namespaces sequences ;
IN: set-n
: get* ( var n -- val ) namestack swap tail-slice* assoc-stack ;
: set* ( val var n -- ) 1 + namestack [ length swap - ] keep nth set-at ;