From 5b65e02851207ae91bde1245562c79ade2eb10ed Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Tue, 1 Apr 2008 17:48:49 -0600 Subject: [PATCH] Project for a new American stack effect --- extra/newfx/newfx.factor | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 extra/newfx/newfx.factor diff --git a/extra/newfx/newfx.factor b/extra/newfx/newfx.factor new file mode 100644 index 0000000000..a5db87ca37 --- /dev/null +++ b/extra/newfx/newfx.factor @@ -0,0 +1,50 @@ + +USING: kernel sequences assocs qualified ; + +QUALIFIED: sequences + +IN: newfx + +! Now, we can see a new world coming into view. +! A world in which there is the very real prospect of a new world order. +! +! - George Herbert Walker Bush + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: nth-at ( seq i -- val ) swap nth ; +: nth-of ( i seq -- val ) nth ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: nth-is ( seq i val -- seq ) swap pick set-nth ; + +: is-nth ( seq val i -- seq ) pick set-nth ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: at-key ( tbl key -- val ) swap at ; +: key-of ( key tbl -- val ) at ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: key-is ( tbl key val -- tbl ) swap pick set-at ; +: is-key ( tbl val key -- tbl ) pick set-at ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: push ( seq obj -- seq ) over sequences:push ; +: push-on ( obj seq -- seq ) tuck sequences:push ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: member? ( seq obj -- ? ) swap sequences:member? ; +: member-of? ( obj seq -- ? ) sequences:member? ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: delete-at-key ( tbl key -- tbl ) over delete-at ; +: delete-key-of ( key tbl -- tbl ) tuck delete-at ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +