Jackscriptpy is a python math library of sets. It covers a few useful functions involving sets that are otherwise not available in the standard python library.
This README does not cover the entire libraries documentation Read documentation from the https://jackscript.macbase.co.za The github of the documentation website is https://github.com/danielromeo/jackscriptDocs
install jackscript-py
pip3 install jackscriptpy
from jackscript import *
sets are created how you would normally create your set in python; as said earlier This library consnist of a set of functions and doesnt make any new data structures. Therefore all set methods from the python standard library will work like usual
mySet = set()
coordinates are created as so
mycoordinate = coord(1, 2) # this sets x to 1 and y to 2
# add a coordinate to a set, using the coordinate created above:
myset.add(mycoordinate);
# as expected, the standard library methods will work as usual
myset.clear()
print(myset) # returns set()
set1 = {2, 5, 6}
set2 = {2, 5, 6, 9}
Looking at the above code; its clear that set1 should be the subset of set2, we get our answer by calling the function isSubset()
answer = isSubset(set1, set2) # returns True
print(answer) # prints True
set1 = {2, 5, 6}
set2 = {2, 5, 6, 9}
answer = isSuperset(set2, set1) # returns True
print(answer) # prints True
#create a cartesian product by calling the createCartesian() function
The function is called: isRelation()
"""
first create a cartesian product from sets:
there are obviously multiple ways of creating cartesianProducts; we'll use more complicated route to demonstrate the use:
"""
# Create a couple of normal sets
normalset1 = {2, 3, 4} # another way would be: normalset1 = Set([2,3,4])
normalset2 = {2, 3, 4}
normalset3 = {2, 3}
cartesian1 = createCartesian(normalset1, normalset2);
cartesian2 = createCartesian(normalset1, normalset3);
As you can see above; we used normalset1
and normalset3
to create a cartesian2
So technically, cartesianProduct2
should be a relation of cartesian1
. We test this theory in the function below, in continuation of the above code.
print(isRelation(cartesian2, cartesian1)); # returns true