Introduction to RPAL Module 10.1 COP4020 – Programming Language Concepts Dr. Manuel E. Bermudez.

Slides:



Advertisements
Similar presentations
Programming Languages and Paradigms The C Programming Language.
Advertisements

Getting started with ML ML is a functional programming language. ML is statically typed: The types of literals, values, expressions and functions in a.
Lambda Calculus and Lisp PZ03J. Lambda Calculus The lambda calculus is a model for functional programming like Turing machines are models for imperative.
Racket Introduction CSC270 Pepper major portions credited to
Types and Arithmetic Operators
CS 355 – PROGRAMMING LANGUAGES Dr. X. Apply-to-all A functional form that takes a single function as a parameter and yields a list of values obtained.
1 CS150 Introduction to Computer Science 1 Relational Operators and the If Statement 9/22/08.
1 MATERI PENDUKUNG OPERATOR Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.
Imperative Programming
Intro to Programming Problem 1: Computers have to be told exactly what do to. Problem 2: Computers only understand “Machine language”. Problem 3: Machine.
CIS Computer Programming Logic
Expressions creating information. topics  operators: precedence, associativity, parentheses, overloading  operands: side-effects, coercion  arithmetic,
Chapter 2: Basic Elements of Java J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Chapter 2 Basic Elements of Java. Chapter Objectives Become familiar with the basic components of a Java program, including methods, special symbols,
CS 330 Programming Languages 11 / 21 / 2006 Instructor: Michael Eckmann.
ISBN Chapter 7 Expressions and Assignment Statements.
1 CSE1301 Computer Programming Lecture 5: Components of a C Program (Part 1) Linda M c Iver.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
Introduction to Programming Languages S1.3.1Bina © 1998 Liran & Ofir Introduction to Programming Languages Programming in C.
CSC 110 Using Python [Reading: chapter 1] CSC 110 B 1.
The RPAL Functional Language Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Concepts Lecture 12.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Department of Electronic & Electrical Engineering Expressions operators operands precedence associativity types.
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
Department of Electronic & Electrical Engineering Lecture 3 IO reading and writing variables scanf printf format strings "%d %c %f" Expressions operators.
ISBN Chapter 7 Expressions and Assignments Statements.
What will each of the following lines print? System.out.println("number" ); number645 System.out.println("number" + (6 + 4)+ 5); number105 System.out.println(6.
CS314 – Section 5 Recitation 9
Expressions and Assignment Statements
Functional Programming
Information and Computer Sciences University of Hawaii, Manoa
Expressions and Assignment Statements
Relational Operator and Operations
CS314 – Section 5 Recitation 10
The Machine Model Memory
CSC 352– Unix Programming, Spring 2016, Final Exam Guide
Expressions and Assignment Statements
Topic: Python’s building blocks -> Statements
Tuples Module 11.1 COP4020 – Programming Language Concepts Dr. Manuel E. Bermudez.
Types and Values.
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Expressions and Assignment Statements
RPAL Function definitions
Java Programming: From Problem Analysis to Program Design, 4e
Racket Introduction CSC270 Pepper
Expressions and Assignment Statements
Lecture 5 from (Chapter 4, pages 73 to 96)
Expressions and Assignment Statements
Chapter 2: Basic Elements of Java
An aggregation mechanism
FP Foundations, Scheme In Text: Chapter 14.
CSE 341 Section 5 Winter 2018.
Summary Two basic concepts: variables and assignments Basic types:
CSE-321 Programming Languages Introduction to Functional Programming
The RPAL Functional Language
Engineering Problem Solving with C++ An Object Based Approach
Engineering Problem Solving with C++ An Object Based Approach
Recursion and Rpal’s synTax
Operator precedence and AST’s
Programming Language Principles
6.001 SICP Interpretation Parts of an interpreter
Paradigms and paradigm shifts
Operator Precedence and Associativity
Chapter 15 Functional Programming 6/1/2019.
DATA TYPES AND OPERATIONS
Expressions and Assignment Statements
INTRODUCTION to PERL PART 1.
Introduction to Python
Introduction to Python
Presentation transcript:

Introduction to RPAL Module 10.1 COP4020 – Programming Language Concepts Dr. Manuel E. Bermudez

Topics The RPAL Language “Turing complete” 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 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 Associativity -> Low Right or Left & Left not None gr ge le ls eq ne None + - (unary and binary) Left * / Left ** Right () High Embedded Elements: <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 or, equivalently fn x y.x+y 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) (-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 yielding (fn y.3+y) 2 yielding 3+2 yielding 5

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.