Acsl Contest 2 Notes - Prefix 2finfix 2fpostfix Bit String Flicking Lisp 1
Acsl Contest 2 Notes - Prefix 2finfix 2fpostfix Bit String Flicking Lisp 1
H ow
ACSL
Contest #2
Contest 2 Topics
Intermediate and Senior:
Prefix/Infix/Postfix-2
Bit String Flicking-2
LISP-1
Prefix/Infix/Postfix
There are three ways to write an expression such as
Infix is the way you usually see it: A-B/(C+D).
To evaluate a function in infix, you must use order of
operations (PEMDAS) and look at parentheses
The other two formats are Prefix and Postfix
Prefix
The operands are written before the two terms they pertain to
A-B would be written as -AB.
Once two terms get an operator, think of them as a single term and apply the next
operator to that single term and the next term in line, so
/+ABC would be translated to (A+B)/C
is used for exponents, so AB would be A^B
It might help to put parentheses after two terms that have been operated on
Ex. To solve /-AB+CD
1. Apply the operand to the following two terms and put parentheses around
two terms /(A-B)(C+D)
2. Apply the remaining operator to the simplified terms to get (A-B) / (C+D)
Postfix
Follows all same rules except operator is after the two terms it
pertains to
AB+ would equal A+B
ABC-/ would equal A / (B-C)
AB-CD/+ would equal (A-B)+(C/D)
More Practice
The best way to approach simplifying a large prefix/infix/postfix
expression is apply 1 or 2 operands at a time and then keep
working from the simplified expression
Senior Division
Bit String Flicking
Bit String - a sequence of bits (0s and 1s)
e.g. 001001
OR | if either is 1, return 1 0 1 1
else 0
SET sets the first argument to the second argument , like setting a variable to a value
If the second argument has an before, it is not evaluated (similar to putting quotes)
SETQ is same as SET except you dont need before first argument
LISP-Statements
defines a new function called SECOND which operates on a single parameter named parms. SECOND will take
the CDR of the parameter and then the CAR of that result. So, for example:
(SECOND (a b c d e))
would first CDR the list (yielding (b c d e)) and then CAR the result. So the value would be the single character b.
LISP Practice