-
Notifications
You must be signed in to change notification settings - Fork 0
/
01_Keyword_let_Association.olly
50 lines (42 loc) · 1.54 KB
/
01_Keyword_let_Association.olly
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
##############################################################
Term and expression association can also be performed
using the prefix 'let' operator. Instead of the postfix
'assign' operator.
##############################################################
#! NO_EXCEPT = false
let x = '42'
let y = '8'
"x + y = " << (x + y) << endl
# Multiple associations can be done at the same time with let.
# The requirement is that both sides must be expressions.
# If both sides are not equal in size, and extra right hand
# expressions are lost, and any extra left hand associations
# default to nothing.
let (x, y) = ('2', '3', '6')
"x / y = " << (x / y) << endl
"x = " << x << endl
"y = " << y << endl
# The 'let' keyword will also allow expressions to be passed
# through the '+' operator, and assigned to a symbol.
let f = +((x + (x / y)) * x)
"f = " << f << endl
endl
# Now let us assign two symbolic expressions at the same time.
let (f, g) = :
+((x + (x / y)) * x)
+("f = " << f <<)
;
# Notice there is a 'Deque underflow.' error.
# This error is admited when an operator pull a term from
# the deque, and the deque is empty. Here the term 'g'
# calls the term 'f', but 'g' itself does not evaluate
# to anything. Instead it is specified to another
# expression which is then evaluated. Resulting in nothing
# being left on the deque to evaluate.
"g = (" << g << ")" << endl
# The corrected form would be.
"g = (" << g ")" << endl
# To make this more readable it has been
# wrapped inside another expression.
"g = (" << (g ")") << endl
endl