Xah Talk Show 2019-12-23 programable keypad, log your life (heatbeat, sleep, walk, email, keystroks, phone…), polymorphism explained

programable keypad, numpad, program numpad, log your life, polymorphism explained 2019-12-23

ye who suffer from the ills of modernity, cometh, a therapeutic session of melodiousnessness commences on YouTube.

topics talked:

polymorphism is a LANGUAGE FEATURE, where a function can have different behavior depending on the type of argument

def plus(a , b) {
# if a and b are numbers, then
return a + b

# if a and b are vectors or array, then do vector addition
return [a[0] + b[0], a[1] + b[1], ]

# or the a and b can be complex numbers
# or the a and b can be matrixes
# or the a and b can be tree


if a programing language does not let you define a function that has different behavior depending on argument, then, we say, this language do not have the fature of polymorphism. BUT, you can always write it yourself, and this is called ad hoc polymorphism.

def plus_vector(a , b) {
return [a[0] + b[0], a[1] + b[1], ]