Skip to content

A discrete mathematics library built in python that holds functions involving the math of sets that the standard python library lacks. Including all properties of Relations in sets. Useful to statisticians.

License

Notifications You must be signed in to change notification settings

jack-script/jackscript-py

Repository files navigation

About JackscriptPy

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.

Documentation:

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

Installation

install jackscript-py pip3 install jackscriptpy

from jackscript import *
How to create a set:

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()
How to create a coordinate(coord):

coordinates are created as so

mycoordinate = coord(1, 2) # this sets x to 1 and y to 2
Advanced...
# 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()
Checking whether a set is a subset of another...
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
Simmilarly we can test if a set is a superset of another
set1 = {2, 5, 6}
set2 = {2, 5, 6, 9}

answer = isSuperset(set2, set1) # returns True 
print(answer) # prints True
Create a cartesian product
#create a cartesian product by calling the createCartesian() function
Check if a product is a relation of another

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

About

A discrete mathematics library built in python that holds functions involving the math of sets that the standard python library lacks. Including all properties of Relations in sets. Useful to statisticians.

Topics

Resources

License

Stars

Watchers

Forks

Languages