-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsfunctions.py
47 lines (26 loc) · 941 Bytes
/
sfunctions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from math import sqrt
from functools import wraps
################################################################################
# Functions
################################################################################
def quad(*args):
"""Add in quadrature"""
if not len(args): return 0
if isinstance(args[0], list):
return sqrt(sum(float(x)**2 for x in args[0]))
return sqrt(sum(float(x)**2 for x in args))
def product(*args):
"""Make product of all arguments"""
if not len(args): return 0
if isinstance(args[0], list):
return reduce(lambda x, y: x*y, args[0])
return reduce(lambda x, y: x*y, args)
def depth(lst):
count = 0
for item in lst:
if isinstance(item, list):
count += depth(item)
return count + 1
################################################################################
if __name__ == "__main__":
"""TEST"""