Python  

The Ultimate

Object-Oriented MetaFunctional Programming Language

Object  Oriented....

class Quad:
  def __init__(self, *vals):
    self.x = [vals[0], vals[1]]
    self.y = [vals[2], vals[3]]
  
  def matrix():
    return [self.x, self.y]

class Rect(Quad):
  def __init__(self, width, height):
    self.x = [0, width]
    self.y = [0, height]

  def area():
    return (self.x[1] - self.x[0]) * (self.y[1] - self.y[0])

Meta...

class Quad:
  def __init__(self, *vals):
    self.x = [vals[0], vals[1]]
    self.y = [vals[2], vals[3]]
  @property
  def matrix(self):
    return [self.x, self.y]
  
class Rect(Quad):
  def __init__(self, width, height):
    self.x = [0, width]
    self.y = [0, height]
  # meta decorations
  @property
  def area(self):
    return (self.x[1] - self.x[0]) * (self.y[1] - self.y[0])

# Meta addition
def width(self):
  return self.x[1] - self.x[0]
Rect.width = width

Meta Functional..

from functools import wraps

def confuse(fn):
    @wraps(fn)
    def wrapped(*args, **kwargs):
        return " O.o " + fn(*args, **kwargs)
    return wrapped

def smile(fn):
    @wraps(fn)
    def wrapped(*args, **kwargs):
        return " ^.^ " + fn(*args, **kwargs)
    return wrapped

@confuse
@smile
def hello():
    return "hello world"

@smile
@confuse
def log(s):
    return s

Functional..

# factorial
import functools as ft
n = get_n()
ft.reduce(lambda x, y: x * y, range(1, n))

Thank You!

twitter/github   $>    @swarnimarun

reddit/telegram $>     minraws

Python: Ultimate Object Oriented MetaFunctional Programming Language

By Swarnim Arun

Python: Ultimate Object Oriented MetaFunctional Programming Language

  • 495