From 08c386f5345c7654d7fd529e87ac1ac7ea69a0bf Mon Sep 17 00:00:00 2001 From: Sam Anklesaria Date: Sun, 21 Jun 2009 21:07:16 -0500 Subject: [PATCH] dynamic lambdas --- extra/set-n/set-n.factor | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/extra/set-n/set-n.factor b/extra/set-n/set-n.factor index 97aa95199d..04731b0e27 100644 --- a/extra/set-n/set-n.factor +++ b/extra/set-n/set-n.factor @@ -1,5 +1,9 @@ -USING: assocs kernel math namespaces sequences ; +USING: accessors assocs fry generalizations kernel math +namespaces parser sequences words ; IN: set-n -: get* ( var n -- val ) namestack swap tail-slice* assoc-stack ; +: get* ( var n -- val ) namestack dup length rot - head assoc-stack ; -: set* ( val var n -- ) 1 + namestack [ length swap - ] keep nth set-at ; \ No newline at end of file +: set* ( val var n -- ) 1 + namestack [ length swap - ] keep nth set-at ; + +! dynamic lambda +SYNTAX: :| (:) dup in>> dup length [ spin '[ _ narray _ swap zip _ bind ] ] 2curry dip define-declared ; \ No newline at end of file