Section 12
Want more of a challenge? View in
iconic
form (
experimental
)
# MATH demonstrate existence of memory
[
hear
]
(define forty-something 42);
[
hear
]
(= 42
(forty-something)
);
# now introduce a function
[
hear
]
(assign square
(? x / *
(x)
(x)
)
/
= 25
(square 5)
);
[
hear
]
(assign square
(? x / *
(x)
(x)
)
/
= 0
(square 0)
);
[
hear
]
(assign square
(? x / *
(x)
(x)
)
/
= 25
(square 5)
);
[
hear
]
(assign square
(? x / *
(x)
(x)
)
/
= 9
(square 3)
);
# show that functions can be remembered across statements
[
hear
]
(define square / ? x / *
(x)
(x)
);
[
hear
]
(=
(square 5)
25);
[
hear
]
(=
(square 4)
16);
[
hear
]
(=
(square 9)
81);
[
hear
]
(=
(square 3)
9);
[
hear
]
(define plusone / ? x / +
(x)
1);
[
hear
]
(=
(plusone 4)
5);
[
hear
]
(=
(plusone 9)
10);
[
hear
]
(=
(plusone 4)
5);
[
hear
]
(=
(plusone 3)
4);