Write a program to perform set operations. Your task is to write a program to perform set operations. The operations and arguments are taken from command line in the format program operation [argument]. There are four operations:


1: clears the set. no arguments. exit code 0.
2 integer: adds the integer into the set. exit code 0.
3 integer: removes the integer from the set. exit code 0.
4 integer: queries the set for integer. exit code 0 if integer exists or 1 otherwise.


The integer is a 64-bits integer. Shortest program wins. You can, of course, use a temporary file. However, watch out the space and time limit.

Example:

$ program 1 ; echo $?
0
$ program 2 10 ; echo $?
0
$ program 4 10 ; echo $?
0
$ program 3 10 ; echo $?
0
$ program 4 10 ; echo $?
1
$ program 2 10 ; echo $?
0
$ program 1 ; echo $?
0
$ program 4 10 ; echo $?
1
Bash -- 54 chars

 

case $1 in
1)rm *;w;;
2)&gt;$2;;
3)rm $2;w;;
4)&lt;$2;;
esac


Notes: Outputs to stdout/stderr in some scenarios. Empties working directory when clearing the set. Uses one file for each set element. The purpose of ;w is to exit with status 0.

This appears to comply with all the rules.