Family Day update

This commit is contained in:
Ingy döt Net 2020-02-17 23:21:07 -08:00
parent aac6731f2c
commit 9ad63ea473
2442 changed files with 39761 additions and 8255 deletions

View file

@ -0,0 +1,20 @@
( ( compose
= f g
. !arg:(?f.?g)&'(.($f)$(($g)$!arg))
)
& compose
$ ( (=.flt$(!arg,2))
. compose$((=.!arg*5/9).(=.!arg+-32))
)
: (=?FahrenheitToCelsius)
& ( FahrenheitToCelsiusExample
= deg
. chu$(x2d$b0):?deg
& out
$ ( str
$ (!arg " " !deg "F in " !deg "C = " FahrenheitToCelsius$!arg)
)
)
& FahrenheitToCelsiusExample$0
& FahrenheitToCelsiusExample$100
)

View file

@ -0,0 +1,23 @@
# Contents of `pip install compositions'
class Compose(object):
def __init__(self, func):
self.func = func
def __call__(self, x):
return self.func(x)
def __mul__(self, neighbour):
return Compose(lambda x: self.func(neighbour.func(x)))
# from composition.composition import Compose
if __name__ == "__main__":
# Syntax 1
@Compose
def f(x):
return x
# Syntax 2
g = Compose(lambda x: x)
print((f * g)(2))