Skip to content

Perfrom Actions such as Union, Subtraction, Intersection & Symmetric Difference On Sets You design yourself

License

Notifications You must be signed in to change notification settings

Itai-Arnon/SetTheory-Calculator

Repository files navigation

Overview

This C program performs set theory operations such as union, symmetric difference, subtraction, and intersection. The program prompts the user to enter commands, which it then parses, checks if its correct. If correct the commands is executed. If the syntax of the commands is incorrect, the program will render an error message. The program utilizes an abstract syntax tree (AST). A struct that represents and embodies the entire language the parser uses. The sets in use can hold the numbers 0 to 127. They are implemented by using 16 chars data types put together, turning the first bit for example represents 0. The 10th bit turned on represents 9 and so forth.

Features

  • Union: Combines all elements from two sets.
  • Symmetric Difference: Returns elements that are in either of the sets but not in their intersection.
  • Subtraction: Returns elements from the first set that are not in the second set.
  • Intersection: Returns elements that are common to both sets.
  • Error Handling: Detects and reports syntax errors in user commands.

Example input

Welcome to The Set Caluculator Please Enter Your Command (Make Sure To Obide All Syntax Rules)

read_set SETA ,1,2,3,4,-1

read_set SETB,1,2,3,4,5,6,-1

union_set SETA,SETB,SETC

print_set SETC

stop

Output

Output that follows describes the value of each bit int an 128 bit array

Bits were used to reperesent the number as since it spends significantly less memory than a standard C int array

Bit 82 means 81 in in the array , Bit 128 means 127 in the array and so forth

bit 0= 0
bit 1= 1 bit 2= 1 bit 3= 1 bit 4= 1 bit 5= 1 bit 6= 1 bit 7= 0 bit 8= 0 bit 9= 0 bit 10= 0 bit 11= 0 bit 12= 0 bit 13= 0 bit 14= 0 bit 15= 0 bit 16= 0 bit 17= 0 bit 18= 0 bit 19= 0 bit 20= 0
bit 21= 0 bit 22= 0 bit 23= 0 bit 24= 0 bit 25= 0 bit 26= 0 bit 27= 0 bit 28= 0 bit 29= 0 bit 30= 0 bit 31= 0 bit 32= 0 bit 33= 0 bit 34= 0 bit 35= 0 bit 36= 0 bit 37= 0 bit 38= 0 bit 39= 0 bit 40= 0
bit 41= 0 bit 42= 0 bit 43= 0 bit 44= 0 bit 45= 0 bit 46= 0 bit 47= 0 bit 48= 0 bit 49= 0 bit 50= 0 bit 51= 0 bit 52= 0 bit 53= 0 bit 54= 0 bit 55= 0 bit 56= 0 bit 57= 0 bit 58= 0 bit 59= 0 bit 60= 0
bit 61= 0 bit 62= 0 bit 63= 0 bit 64= 0 bit 65= 0 bit 66= 0 bit 67= 0 bit 68= 0 bit 69= 0 bit 70= 0 bit 71= 0 bit 72= 0 bit 73= 0 bit 74= 0 bit 75= 0 bit 76= 0 bit 77= 0 bit 78= 0 bit 79= 0 bit 80= 0
bit 81= 0 bit 82= 0 bit 83= 0 bit 84= 0 bit 85= 0 bit 86= 0 bit 87= 0 bit 88= 0 bit 89= 0 bit 90= 0 bit 91= 0 bit 92= 0 bit 93= 0 bit 94= 0 bit 95= 0 bit 96= 0 bit 97= 0 bit 98= 0 bit 99= 0 bit 100= 0
bit 101= 0 bit 102= 0 bit 103= 0 bit 104= 0 bit 105= 0 bit 106= 0 bit 107= 0 bit 108= 0 bit 109= 0 bit 110= 0 bit 111= 0 bit 112= 0 bit 113= 0 bit 114= 0 bit 115= 0 bit 116= 0 bit 117= 0 bit 118= 0 bit 119= 0 bit 120= 0
bit 121= 0 bit 122= 0 bit 123= 0 bit 124= 0 bit 125= 0 bit 126= 0 bit 127= 0

Stopped the Service, Thank You. Come Back Soon

About

Perfrom Actions such as Union, Subtraction, Intersection & Symmetric Difference On Sets You design yourself

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published