PROGRAMMING LANGUAGES: PROLOG, CLOJURE, F# Jared Wheeler.

Slides:



Advertisements
Similar presentations
Intro to Scala Lists. Scala Lists are always immutable. This means that a list in Scala, once created, will remain the same.
Advertisements

Introduction to Recursion and Recursive Algorithms
Software Development Languages and Environments. Programming languages High level languages are problem orientated contain many English words are easier.
Programming Languages and Paradigms
CS162 Week 2 Kyle Dewey. Overview Continuation of Scala Assignment 1 wrap-up Assignment 2a.
1 Programming Languages (CS 550) Lecture Summary Functional Programming and Operational Semantics for Scheme Jeremy R. Johnson.
Getting started with ML ML is a functional programming language. ML is statically typed: The types of literals, values, expressions and functions in a.
Simple Introduction to Clojure with Analysis By: Shannon Birchell.
True or false A variable of type char can hold the value 301. ( F )
Advanced Package Concepts. 2 home back first prev next last What Will I Learn? Write packages that use the overloading feature Write packages that use.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
VBA Modules, Functions, Variables, and Constants
ML: a quasi-functional language with strong typing Conventional syntax: - val x = 5; (*user input *) val x = 5: int (*system response*) - fun len lis =
Chapter 15 Other Functional Languages. Copyright © 2007 Addison-Wesley. All rights reserved. Functional Languages Scheme and LISP have a simple syntax.
© The McGraw-Hill Companies, 2006 Chapter 5 Arrays.
Topics of Lecture Structural Model Procedures Functions Overloading.
28-Jun-15 Recursion. 2 Definitions I A recursive definition is a definition in which the thing being defined occurs as part of its own definition Example:
Computer Science II Exam I Review Monday, February 6, 2006.
COMP s1 Computing 2 Complexity
Clojure 3 Recursion, Higher-order-functions 27-Aug-15.
Sequence Control Chapter 6. 2 l Control structures: the basic framework within which operations and data are combined into programs. Sequence control.
Analysis of Algorithm Lecture 3 Recurrence, control structure and few examples (Part 1) Huma Ayub (Assistant Professor) Department of Software Engineering.
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
A Computer Science Tapestry 1 Recursion (Tapestry 10.1, 10.3) l Recursion is an indispensable technique in a programming language ä Allows many complex.
 The design of the imperative languages is based directly on the von Neumann architecture  Efficiency is the primary concern  Low-level specifications:
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
 2005 Pearson Education, Inc. All rights reserved Searching and Sorting.
 Pearson Education, Inc. All rights reserved Searching and Sorting.
APCS Java AB 2004 Review of CS1 and CS2 Review for AP test #1 Sources: 2003 Workshop notes from Chris Nevison (Colgate University) AP Study Guide to go.
S2008Final_part1.ppt CS11 Introduction to Programming Final Exam Part 1 S A computer is a mechanical or electrical device which stores, retrieves,
1 © 2002, Cisco Systems, Inc. All rights reserved. Arrays Chapter 7.
CSC 580 – Theory of Programming Languages, Spring, 2009 Week 9: Functional Languages ML and Haskell, Dr. Dale E. Parson.
Clojure 2 Feb 7,
Chapter 8 More On Functions. "The Practice of Computing Using Python", Punch & Enbody, Copyright © 2013 Pearson Education, Inc. First cut, scope.
Functional Programming With examples in F#. Pure Functional Programming Functional programming involves evaluating expressions rather than executing commands.
Chapter Fifteen: Functional Programming Languages Lesson 12.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
Python Functions.
Logic Programming CSC 358/ Outline Pattern matching Unification Logic programming.
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
CS162 Week 1 Kyle Dewey. Overview Basic Introduction CS Accounts Scala survival guide.
Introduction to Prolog. Outline What is Prolog? Prolog basics Prolog Demo Syntax: –Atoms and Variables –Complex Terms –Facts & Queries –Rules Examples.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Milos Hauskrecht (PDF) Hieu D. Vu (PPT) LISP PROGARMMING LANGUAGE.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Error Example - 65/4; ! Toplevel input: ! 65/4; ! ^^ ! Type clash: expression of type ! int ! cannot have type ! real.
Basic Introduction to Lisp
Written by: Dr. JJ Shepherd
In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction.
CS190/295 Programming in Python for Life Sciences: Lecture 6 Instructor: Xiaohui Xie University of California, Irvine.
1 FP Foundations, Scheme In Text: Chapter Chapter 14: FP Foundations, Scheme Mathematical Functions Def: A mathematical function is a mapping of.
Ada, Scheme, R Emory Wingard. Ada History Department of Defense in search of high level language around Requirements drafted for the language.
Today Review passing by reference and pointers. null pointers. What is an Object? Winter 2016CMPE212 - Prof. McLeod1.
CSI 3125, Data Types, page 1 Data types Outline Primitive data types Structured data types Strings Enumerated types Arrays Records Pointers Reading assignment.
Information and Computer Sciences University of Hawaii, Manoa
Functional Programming Languages
CSC 222: Object-Oriented Programming
Important Concepts from Clojure
Important Concepts from Clojure
FP Foundations, Scheme In Text: Chapter 14.
CSE 341 Section 5 Winter 2018.
Python Tutorial for C Programmer Boontee Kruatrachue Kritawan Siriboon
Dan Grossman / Eric Mullen Autumn 2017
Recursion, Higher-order-functions
Important Concepts from Clojure
Clojure 2 22-Apr-19.
CSE 341 Lecture 11 b closures; scoping rules
„Lambda expressions, Optional”
Introduction to Computer Science
Presentation transcript:

PROGRAMMING LANGUAGES: PROLOG, CLOJURE, F# Jared Wheeler

Prolog  1972 Development  Declarative Language  No Algorithms  Define the Problem  It finds the answer

Parts  Knowledge Base  Facts Basic Assertions  Rules Inferences about Facts  Queries

Naming  constant  Variable or _variable  List – [1, 2, 3]  Tuple – (1, 2, 3)  Fixed Length

Unification  No Assignments  Prolog tries to make variables and constants equal  If succeeds, an inference can be made

Results  Yes  No  Answers unasked question of if execution completed

Recursion  Call Rule from within Rule  Tail-Recursion Optimization  Put Recursive call at End  Prolog keeps memory use steady

Uses  Solving Systems within Constraints  Puzzles  Natural Language Processing  AI

Weaknesses  Utility  Scaling to Large Data Sets  Depth First Search for Answers  Learning Curve

Prolog Demo  Knowledge Base File  Execution

Clojure  Lisp for JVM  Scheme, lisp-1, not Common Lisp, lisp-2  Difference in namespacing functions and data  Data As Code

Variables  (def variableName item)  Prefix notation  (let value variableBound)  Temporary binding of value to a variable

Data Structures  List – Ordered Collection ()  Hold Code  First element is always executed as a function  Vector – Ordered Collection []  Hold Data  Map – Key-value Pairs {}  Clojure allows comma delimitations  Keys can be used as functions to retrieve the value  Set – Unordered Collection #{}  Can be used as a function to find if an item is included

Functions  (defn name [parameters] body)  Parameters within a vector  (fn [parameters] body)  Anonymous function

Recursion  No Tail-Recursion Optimization  Working around JVM too much  (loop [parameter1 boundVariable, …] (recur (parameter1In)))

Sequences  Common Parent to Most Data Structures  Comes with many default functions  every?, some?, filter, map, reduce, sort  (for [x seq] function) Binds each member of the seq to x one at a time

Lazy Evaluation  (repeat 1)  Repeats 1 until the process is killed  (take 5 (repeat 1))  Repeats 1 five times  Lazy Evaluation means infinite sets can be computed Evaluations only occur once needed

Concurrency  Software Transactional Memory  Inspired by database transactions  (def reference (ref “some gives “some data” Cannot change without a dosync function

Interfaces  defprotocol  Define a contract  defrecord  Implements the protocol  Records are immutable

Macros  Two stages of Clojure Execution  Macro Expansion  Execution  defmacro to Create

Strengths  Powerful and Flexible  Use of JVM  Lisp minus parenthesis and reader macros  Concurrency  Lazy Evaluations

Weaknesses  Complex  Prefix Notation  Readability  Complex Recursion Optimization  Compared to other Functional Languages

Clojure Demo  General Form

F#  Built by Microsoft Research  Runs on the.NET Framework

Variables  Assignments by Let statements  Immutable unless ‘modifiable’ attribute at declaration  Statically Typed  Strong Type Inferencing

Functions  Let functionName Parameters = body  Whitespace-sensitive  Parameters have type inferencing  Sometimes require (variableName:type)  Functions can be Passed as Parameters

Anonymous Functions  Lambda Expressions  (fun params -> body)

Lists  [ 1; 2; 3] = [1..4]  Ranges allowed  List.map (function) listName  Applies a function to all members  List.filter (function) listName  Returns members that the function returns true for

Array  [| 1; 2; 3|]

Record  Grouped Data with Member Names  Immutable  Defines data types  Keyword type to define  Mutate using with  Members can be optional

Discriminating Joins  Enumeration Type object = | Option1 | Option2

Forward Pipe Operator List.sum (List.map (fun x -> x * 2) (List.filter (fun x -> x % 2 = 0) [0..100]))  Into this: [0..100] |> List.filter (fun x -> x % 2 = 0) |> List.map (fun x -> x * 2) |> List.sum

Currying  Functions Have One Parameter  Return a function asking for the next  Repeats until all parameters are accounted for  Parameter order matters  Allows for New Operators Easier  Also allows for different form of overloading

Operators  Overload Only a Select set of Operators  Otherwise overwrites  Unless done within a type  Define new Operator For One Parameter  Works due to currying

Sublanguages  Active Patterns  Pattern Matching  Customizable  Allows labels within a pattern to call a function  Quotations  Stores code fragments  Type Checks, but no execution F# 3.0 has Type Provider that can execute  Together, they allow Sublanguages or Cross-Compilation

F# Demo  General Form  Record Creation  Record Mutation