predicate-def ( obj -- quot ) - Factor Documentation

predicate-def ( obj -- quot )


Vocabulary
classes

Inputs
obj a type object


Outputs
quot a quotation with stack effect ( obj -- ? )


Word description
Outputs a quotation that can be used to check if objects are an instance of the given type.

Examples
USING: classes math prettyprint ; fixnum predicate-def .
[ fixnum? ]


Definition
IN: classes

GENERIC: predicate-def ( obj -- quot )


Methods
USING: accessors classes classes.algebra.private kernel ;

M: anonymous-complement predicate-def
class>> [ over [ instance? not ] [ 2drop t ] if ] curry ;


USING: accessors classes classes.algebra.private
classes.intersection.private ;

M: anonymous-intersection predicate-def
participants>> intersection-predicate-quot ;


USING: accessors classes classes.algebra.private kernel ;

M: anonymous-predicate predicate-def
[ class>> ] [ predicate>> ] bi
[ [ [ dup ] ] dip [ instance? ] curry compose ] dip
[ [ drop f ] if ] curry compose ;


USING: accessors classes classes.algebra.private
classes.union.private ;

M: anonymous-union predicate-def
members>> union-predicate-quot ;


USING: accessors classes classes.maybe kernel ;

M: maybe predicate-def
class>> predicate-def [ [ t ] if* ] curry ;


USING: classes kernel ;

M: object predicate-def [ instance? ] curry ;


USING: classes words ;

M: word predicate-def "predicate" word-prop ;

AltStyle によって変換されたページ (->オリジナル) /