INTRODUCTION TO RPAL Module 10 1 COP 4020
- Slides: 13
INTRODUCTION TO RPAL Module 10. 1 COP 4020 – Programming Language Concepts Dr. Manuel E. Bermudez
TOPICS The RPAL Language No assignment No sequencing No iteration No “memory” Only expressions: every RPAL program is an expression. To run an RPAL program is to evaluate it. “Turing complete”
RPAL IS A SUBSET OF PAL • PAL: Pedagogic Algorithmic Language. • Developed by J. Wozencraft and A. Evans at MIT, early 70's. • R(ight-reference)PAL ⊂ L(eft-reference)PAL ⊂ J(ump) PAL • Intellectual ancestor of Scheme, (Guy Steele, mid-70's) – Steele (Sun Microsystems): principal contributor to Java. – Google: 'Guy Steele Scheme‘. • Why Study RPAL ? – Generic, “plain vanilla” functional language. – Unknown language (to you) – Paradigm shift !!
SIMPLE ONE-LINE RPAL PROGRAMS 3 //comment: value is 3, print nothing (3+1)*4**2 // arithmetic: value is 64, prints nothing ’Hello World’ // value is ’Hello World’ Print(’Hello World’) // Prints ’Hello World’, value is dummy Print(Conc ’Hello ’ ’World’) // same 4*6 < 27 // value is true (not ’true’) 2 < 0 -> 3 | 6 // conditional (like the ? : operator) true or false // value is true & false // value is false, & is the ‘and’ operator
DATA TYPES AND OPERATORS • Integer operations: +, -, *, /, **, eq, ne, ls, <, gr, >, le, <=, ge, >= • Truthvalue (boolean) operations: or, &, not, eq, ne • String operations: eq, ne, Stem S, Stern S, Conc S T • Conditional operator: -> | • Elementary values: <int>, <id>, true, false
OPERATOR PRECEDENCE Operator Precedence -> or & not gr ge le ls eq ne + - (unary and binary) * / ** () Elements: Low High Associativity Right Left None Left Right Embedded <id>, <int>, <str>, true, false, dummy
NEW DATA TYPE: FUNCTION (FN X. B) Has a ’bound variable’ (parameter), and a body. Example: fn X. Print(X**2) It’s value: “Nameless, typeless function with typeless parameter X, that prints X squared. ” fn N. N ls 0 -> -N | N Value: “Nameless, typeless function with typeless parameter N, that returns |N|. ” fn x. fn y. x+y fn x y. x+y or, equivalently Value: “Nameless, typeless function that takes typeless parameter x, and returns nameless, typeless function that take typeless parameter y, and returns x+y. ”
FUNCTION APPLICATION Function application is by juxtaposition. Example: (fn X. Print(X**2)) 3 Function is applied to 3. 3 replaces X in expression Print(X**2), yielding Print(3**2), yielding Print(9), yielding dummy (and prints 9).
FUNCTION APPLICATION Example: (fn N. N ls 0 -> -N | N) (-3) replaces N in (N ls 0 -> -N | N), yielding ((-3) ls 0 -> -(-3)|(-3)) ), yielding –(-3) = 3 Function application is left associative: Example: (fn x. fn y. x+y) 3 2 (fn y. 3+y) 2 3+2 5 yielding
TYPE IDENTIFICATION FUNCTIONS • Intrinsic functions. • Applied to a value, return true or false: • Isinteger x • Istruthvalue x • Isstring x • Istuple x • Isfunction x • Isdummy x
RPAL CONSTRUCTS • Operators • Function definitions • Constant definitions (parameterless function) • Conditional expressions • Function application • Recursion
RPAL HAS SIX DATA TYPES: • Integer • Truthvalue (boolean) • String • Tuple (coming soon) • Function • Dummy (value: dummy) • RPAL is dynamically typed: – the type of an expression is determined at run-time. – Example: let Funny = (B -> 1 | ’January’) in Print(Funny)
SUMMARY RPAL Language of expressions To run it, evaluate it. Arithmetic, boolean, string operations. New data type: function. New operation: function application.
- Good cop bad cop interrogation
- Cop 1 cop 2
- Contoh surat bayaran balik emolumen
- As nzs 4020
- Center for army analysis
- C device module module 1
- Introduction to power tools module 4
- Module 5 introduction to construction drawings
- Nccer introduction to construction drawings
- Operations module
- Dr carlson advises his depressed patients
- Module 00103 exam introduction to hand tools
- 00102-15 introduction to construction math
- 00105-15 introduction to construction drawings