February 1st, 2010 Add Your Comments

Written in Python :D

See http://failboat.me/2009/cute-functions-creating-pseudo-operators-in-python/ for more details.

#Hello World

class Operator(object):
    def __init__(self, func, count=2):
        self._func_ = func
        self._args_ = []
        self._count_ = count
    def __ror__(self, first_arg):
        self._args_.append(first_arg)
        return self
    def __or__(self, arg):
        self._args_.append(arg)
        if len(self._args_) >= self._count_:
            return self(*self._args_)
        else:
            raise RuntimeError("Incorrect number of parameters")
    def __call__(self, *args, **kwargs):
        self._args_ = []
        return self._func_(*args, **kwargs)

def alpha(letter):
    @Operator
    def _alpha(a,b):
        return a+letter+b
    return _alpha

for c in range(65, 122):
    globals()[chr(c)] = alpha(chr(c))

print "H"|e|"l"|l|"o","W"|o|"r"|l|"d"