Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Attaching a sage script - Sage worksheet works, but its Jupyter notebook version no.

Project: ZMF2018
Views: 123

Attaching Sage script in Sage worksheet

In a file RoundList.sage is the simple following code

def roundlist(xlist, digits): return map(lambda element: round(element,digits), xlist)
# attach, load the Sage script %attach RoundList.sage
da = 1/3.0; da a = [0, da..2]; a
0.333333333333333 [0.000000000000000, 0.333333333333333, 0.666666666666667, 1.00000000000000, 1.33333333333333, 1.66666666666667, 2.00000000000000]
b = roundlist(a,3) b
[0.0, 0.333, 0.667, 1.0, 1.333, 1.667, 2.0]