Пример #1
0
    def equ_numstr(self):
        """( y x -- y=x? )
        push 1 if a number is equal to the sum of the characters in a string"""
        y, x = self.popn()
        if allof(isstr(y), isnum(x)):
            self.push(CatClutter.bool2int(x == CatClutter.strsum(y)))

        elif allof(isnum(y), isstr(x)):
            self.push(CatClutter.bool2int(y == CatClutter.strsum(x)))

        else:
            CatLogger.Crit("unexpected types for equ_numstr")
Пример #2
0
 def add_str(self):
     """( y x -- y+x )
     concatenate two strings"""
     y, x = self.popn()
     if allof(not isnone(y), not isnone(x)):
         self.push(x + y)
Пример #3
0
 def add_num(self):
     """( y x -- y+x )
     add two numbers"""
     y, x = self.popn()
     if allof(not isnone(y), not isnone(x)):
         self.push(x + y)