Docsity

Lambda Calculus: A Core Language for Programming Concepts, Study notes of Programming Languages

Partial preview of the text

Download Lambda Calculus: A Core Language for Programming Concepts and more Study notes Programming Languages in PDF only on Docsity!

CMSC 330: Organization of

Programming Languages

Lambda Calculus Introduction

Introduction

  • (^) We’ve seen that several language conveniences aren’t strictly necessary - (^) Multi-argument functions: use currying or tuples - (^) Loops: use recursion - (^) Side-effects: we don't need them either
  • (^) Goal: come up with a “core” language that’s as small as possible and still Turing complete - (^) This will give a way of illustrating important language features and algorithms

Intuitive Understanding

  • (^) Before we work more with the mathematical notation of lambda calculus, we’re going to play a puzzle game!
  • (^) From: http://worrydream.com/AlligatorEggs/

Puzzle Pieces

  • (^) Hungry alligators: eat and guard family
  • (^) Old alligators: guard family
  • (^) Eggs: hatch into new family

Puzzle Rule 1: The Eating Rule

  • (^) If families are side-by-side the top left alligator eats the entire family to her right
  • (^) The top left alligator dies
  • (^) Any eggs she was guarding of the same color hatch into what she just ate

Eating Rule Practice

  • (^) What happens to these alligators? Puzzle 1:

Eating Rule Practice

  • (^) What happens to these alligators? Puzzle 1: Puzzle 2: Answer 1: Answer 2:

Puzzle Rule 2: The Color Rule

  • (^) If an alligator is about to eat a family and a color appears in both families then we need to change that color in one of the families. - (^) In the picture below, green and red appear in both the first and second families. So, in the second family, we switch all of the greens to cyan, and all of the reds to blue.
  • (^) If a color appears in both families, but only as an egg, no color change is made.