From ea80ebbaacac96f066f985633c3e74ba5a6c8a8c Mon Sep 17 00:00:00 2001 From: KG Date: Tue, 12 Sep 2023 12:19:18 -0400 Subject: [PATCH] Add miscellaneous examples --- examples/misc.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 examples/misc.py diff --git a/examples/misc.py b/examples/misc.py new file mode 100644 index 0000000..352bc5d --- /dev/null +++ b/examples/misc.py @@ -0,0 +1,35 @@ +from tivars import * + + +# Detokenize a program +my_program = TIProgram.open("EXAMPLE.8xp") +code = my_program.string() + + +# Unprotect a program +my_program = TIProtectedProgram.open("EXAMPLE.8xp") +my_program.unprotect() + + +# Turn a real number into a float +my_real = TIReal.open("EXAMPLE.8xn") +value = my_real.float() + + +# Put real numbers into a list +my_reals = TIReal(1), TIReal(2), TIReal(3) +lst = TIRealList(my_reals) + + +# Ungroup a group +my_group = TIGroup.open("EXAMPLE.8xg") +entries = my_group.ungroup() + + +# Put inaccessible tokens into a string +my_string = TIString("αβγ") + + +# Convert an exact number into a real number +my_exact = TIRealRadical.open("EXAMPLE.8xn") +real = TIReal(my_exact.float())