]> gitweb.factorcode.org Git - factor.git/commitdiff
flatland: add 'within?'
authorEduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Wed, 10 Dec 2008 19:54:22 +0000 (13:54 -0600)
committerEduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Wed, 10 Dec 2008 19:54:22 +0000 (13:54 -0600)
extra/flatland/flatland.factor

index c98c5a6c574f22ebd1a628b7a035af1c2ce71e3e..72d9e50a9d8d6bbb816fbc5613b67823e60dbc9f 100644 (file)
@@ -2,6 +2,7 @@
 USING: accessors arrays fry kernel math math.vectors sequences
        math.intervals
        multi-methods
+       combinators.short-circuit
        combinators.cleave.enhanced
        multi-method-syntax ;
 
@@ -218,3 +219,16 @@ USING: locals combinators ;
   cond
 
   2array ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+GENERIC: within? ( a b -- ? )
+
+METHOD: within? ( <pos> <rectangle> -- ? )
+  {
+    [ left   to-the-right-of? ]
+    [ right  to-the-left-of?  ]
+    [ bottom above?           ]
+    [ top    below?           ]
+  }
+  2&& ;