From 9553f186847f80bb30bf5d7df83f50f9cb1cb319 Mon Sep 17 00:00:00 2001 From: Jim Pryor Date: Thu, 16 Sep 2010 05:12:05 -0400 Subject: [PATCH] week1: shorthand tweaks Signed-off-by: Jim Pryor --- week1.mdwn | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/week1.mdwn b/week1.mdwn index 815cdf34..a181ea65 100644 --- a/week1.mdwn +++ b/week1.mdwn @@ -154,47 +154,53 @@ Shorthand The grammar we gave for the lambda calculus leads to some verbosity. There are several informal conventions in widespread use, which enable the language to be written more compactly. (If you like, you could instead articulate a formal grammar which incorporates these additional conventions. Instead of showing it to you, we'll leave it as an exercise for those so inclined.) -**Dot notation** Dot means "put a left paren here, and put the right -paren as far the right as possible without creating unbalanced -parentheses". So: +**Parentheses** Outermost parentheses around applications can be dropped. Moreover, applications will associate to the left, so `M N P` will be understood as `((M N) P)`. Finally, you can drop parentheses around abstracts, but not when they're part of an application. So you can abbreviate: - (\x (\y (x y))) + (\x (x y)) -can be abbreviated as: +as: + + \x (x y) - (\x (\y. x y)) +but you should include the parentheses in: + + (\x (x y)) z and: - (\x (\y. (z y) z)) + z (\x (x y)) + -would abbreviate: +**Dot notation** Dot means "put a left paren here, and put the right +paren as far the right as possible without creating unbalanced +parentheses". So: - (\x (\y ((z y) z))) + \x (\y (x y)) -This on the other hand: +can be abbreviated as: - (\x (\y. z y) z) + \x (\y. x y) -would abbreviate: +and that as: - (\x (\y (z y)) z) + \x. \y. x y -**Parentheses** Outermost parentheses around applications can be dropped. Moreover, applications will associate to the left, so `M N P` will be understood as `((M N) P)`. Finally, you can drop parentheses around abstracts, but not when they're part of an application. So you can abbreviate: +This: - (\x. x y) + \x. \y. (x y) x -as: +abbreviates: - \x. x y + \x (\y ((x y) x)) -but you should include the parentheses in: +This on the other hand: - (\x. x y) z + (\x. \y. (x y)) x -and: +abbreviates: + + ((\x (\y (x y))) x) - z (\x. x y) **Merging lambdas** An expression of the form `(\x (\y M))`, or equivalently, `(\x. \y. M)`, can be abbreviated as: -- 2.11.0