hwch5as_2872696
.pdf
keyboard_arrow_up
School
Cleveland State University *
*We aren’t endorsed by this school
Course
524
Subject
Computer Science
Date
May 5, 2024
Type
Pages
6
Uploaded by CoachFogGazelle16 on coursehero.com
CIS 524 Comparative Programming Language Fall 2023 Homework Chapter 5 Bheem Reddy Gopanpally CSU ID:2872696 bhgopanp@grail.eecs.csuohio.edu 5.8.1 For Section 5.1, syntax of lambda terms 1. Draw the syntax trees for the following terms of lambda calculus. You need to follow the parsing conventions described in Section 5.1, for example to understand that x y x is just less parenthesized notation for ((x y) x) (a)
λx.λy.(x
y) Parenthesize the above term => λx.(λy.(x
y)) => (
λx.(λy.(x
y))) Syntax tree: (b)
λx.x
(λy.y
y) Parenthesize the above term => λx.x
(λy.(yy))
=> λx.(x
(λy.(yy)))
=> (λx.(x
(λy.(yy)))))
Syntax tree: c) x λx.x
y x Parenthesize given term ⟹
x λx.(xy)x
⟹
x λx.((xy)x)
⟹
x(λx.((xy)x))
⟹
(x(λx.((xy)x)))
Syntax tree:
4.
Fully parenthesize the following terms: a)
λx.λy.x
Parenthesized version : ( λx.(λy.x))
b)
x x x Parenthesized version : ((x x) x) c)
x λx.x
x Parenthesized version : (x (λx.(x
x))) 5.
Drop as many parentheses as possible from the following fully parenthe-sized terms, according to the conventions in Section 5.1.1. The resulting term should have the same structure as the original one, but with as few parentheses as possible. a) ((λx.(x
x)) x) =>((λx.
(x x))x) =>(λx.
(x x)) x =>(λx.
x x) x b) ((λy.y)
(λx.(x (x
x)))) =>((λ
y.y )(λ
x.(x(x x)))) =>(λ
y.y )(λ
x.(x(x x))) =>((λ
y.y )λ
x.x (x x) =>(λ
y. y ) λx.
x (x x) c) ((λx.
(λ
y. ((x y) x))) z) =>((λx.(λ
y.((x y)x)))z) =>(λx.(λ
y.((x y)x)))z) =>(λx.
λy.
x y x) z 6.
Rename variables in the following terms so that global variables (i.e., ones free in the term) have different names from local ones (i.e., ones introduced by 𝜆
), and so that different uses of
𝜆
introduce variables with different names. This should be done without changing the names global variables. For example x 𝜆
x.x could be renamed to x 𝜆
y.y, but not y 𝜆
x.x(because we are not allowing global variables to be renamed).
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Fortran, C++ and other languages use the assignment operator form like this: variable := expressions, but ALGOL 58 and Plankalkul used: used expression => variable form. Demonstrate using pseudo code how a C++ "linked" (link list) object would have to be modified to revert to the ALGOL 58 standard. HINT: think private member data, accessors and mutators etc.
A.
&Next <= alpha(A)
B.
alpha A
&A=>&Next
C.
alpha * A;
alpha B;
A = new alpha;
A->setnext(&B);
D.
alpha * Next;
void setNext(alpha A) { &A => Next; }
arrow_forward
Create Code in C++ For String searching algorithms – Boyer-Moore and Aho-Corasick – to find the occurrences of a particular string within a large body of text. For example, you might take a webserver log file and use an appropriate data structure to track how many times each page has been accessed.
arrow_forward
A strongly-typed data type implementation supports strongly-typed data, whereas a loosely-typed data type implementation supports loosely-typed data.
arrow_forward
Computer Science about lambda
expression
Answer the lambda expression with parentheses and the symbol a supplemented as much as
possible
1. ху(Луz.zxy)
2. (Axyz. xy(xz))uvw
arrow_forward
This question should be answered in C++ programming
language. Please answer part 2 of this question as part 1
has already been answered through chegg.
if GPA in the range of 2.5(inclusive) - 3:B
if GPA in the range of 2(inclusive) - 2.5:C
Less than 2: D
> Print_Std_Info() : This function accepts the id of one student and prints out all the
information of that student (all the attributes).
Purpose: The purpose of this project is to allow you practice Object Oriented Design,
Pointers, File /0, Exception Handling, Functions and Arrays.
> Comapre_GPA(): This function compares the GPA of two students and returns the id
of the student who has the higher GPA.
Problem Objective: The objective of this problem is to create a fully functioning system that
handles the records of students at Concordia University. Based on the following narrative,
you need to come up with an Object-Oriented design to represent the different entities in the
system.
Part 2: Faculty Class:
Assume the faculty of…
arrow_forward
In your own words describe what are Lambda expressions and what they are used for
arrow_forward
With code, describe the type of polymorphism.
arrow_forward
Write C# linq syntax to get first student name where age is more then 18 from List<Student>.
Please provide linq syntax only
Student has below properties
Id, Name, Age, Class
arrow_forward
Write a program in c language to store the information of any biological entity in a structure array. Data members in the structure should be of int and char data type with source code. Also includes strings in it. Your program should read the data from user and then store in structure and display in tabular form. Need source code in simple C language.
arrow_forward
Differentiate between structures and unions in C. Consider the following C structure forholding a 3-D vector:typedef struct v3d_tag{float x;float y;float z;} vector3D;Write a C function that takes two vector3D structures as arguments and prints their dotproduct.Note: For two vectors a = (a1,a2,a3) = a1i+a2j+a3k and b = (b1,b2,b3) = b1i+b2j+b3k, where i,j and k are unit vectors, the dot product a⋅b = a1b1+a2b2+a3b3.
arrow_forward
circumstances. The following program shows this
approach:
// Use a generic functional interface with lambda expressions.
Comedebane.
arrow_forward
Write a program to code text editor.
Note: Use DSA C++ Language.
The goal of this program is to implementing and using stacks and linked structures. You should also continue to use object-oriented design.For this program, you will implement a text editor. Your editor will display a string of characters and a cursor. Your program will allow the user to move the cursor and modify the text using the following five operations:
left - move the cursor to the left one character or do nothing if at the end of the line
right - move the cursor to the right one character or do nothing if at the end of the line
rdelete n - delete n characters to the right of the cursor
ldelete n - delete n characters to the left of the cursor
insert c - insert the character c just before the cursor
arrow_forward
Please implement the follwoing problem in C++:
Implement a symbol balance checker function for the Pascal programming language. Pascal allows for the following pairs: {}, (), [], begin end . All programs will begin with the word "begin" and end with the word "end". Your function should receive an ifstream object which is already open and will return true, all of the symbols match, or false, they do not. You do not have to worry about comments in the program but you do have to avoid other parts of the program's code such as assignment statements (x=y) and other expressions.
arrow_forward
Write the function f(x,y) = x2 + 6xy + 9y2 using lambda abstraction. How to represent the redex if you put the value of x equals to 4 and y equal to -1. Evaluate the function using lambda calculus.
arrow_forward
Data structures are defined as: What does the term "abstract data type" refer to? Could you elucidate your response with an example?
arrow_forward
Python Need help with code
A rule has three parts:
•name –a simple name for the rule (e.g., up, left, down, right)
•precondition function –a Boolean function that accepts a state and returns true if the rule is applicable to state
•action function –a function that accepts a state and returns the successor state obtained by applying the rule.
You can use these rules to implement functions such as applicable-rule, which returns a list of the rules applicable to a given state, and successor-state, which returns the successor state for a given state and rule.
Question: Encode the rules for the sliding-tile puzzle. Remember that it is easiest to consider moving the empty space up, left, down, or right. Using these rules, write routines to determine the rules applicable to a state and the successor state given a state and rule to apply. Note that you could implement these as iterators or have them return lists (or vectors) or rules and states.
arrow_forward
Please
arrow_forward
In Lambda expression, what doese the expression ( succ 2 succ 3 ) evaluate to?
arrow_forward
Please help me with this!
Develop a high-quality, menu-driven object-oriented C++ program that creates a small database, using a binary search tree structure to store and process the data. The database will contain the top 100 highest grossing films of 2017.
The C++ object-oriented program must use the BinarySearchTree class . When designing and implementing the program, apply good software engineering principles. Start the analysis and design process by drawing a complete UML class diagram for the program that includes all the classes that are contained in the program, including the classes provided by the textbook and the classes that you create. The UML class diagram will assist you in understanding the components of the project.
Your program must include:
a Film class that stores all the data for a Film and provides appropriate methods to support good software engineering principles,
a FilmDatabase class that stores the binary search tree and provides appropriate methods in…
arrow_forward
Question No.1:
You are supposed to implement lexer
(lexical Analysis). Role of lexer is
to remove extra spaces, comments
from given code. It completely scans
the code and generates tokens from
source code.
You are supposed to implement lexer
to generate token list. C++ language
has following tokens.
Keywords
Identifiers
Constants
• Strings
• Operator
You can use C++ language for
implementation
Note: Paste C++ Code and demo
screen shots.
arrow_forward
Write a C++ program that simulates a two-dimensional random walk along a grid that has M by N function parameters.The walker moves in one of four directions. The walker chooses the direction randomly. The walker cannot move off the grid. The function ends when the walker visits every grid position at least once. The function returns a dynamic structure that is an ordered record of the walker's positions over time. The first element of the structure is the walker's first position. The last element is the walker's last position.
arrow_forward
What is a lambda expression?
arrow_forward
How is data binding affected when working with immutable data structures?
arrow_forward
Study the Java BNF to ensure that you understand the notational conventions used in that BNF. Now, use those notational conventions to write a concise rule to capture the following syntax. That is, write BNF rules that could be added to the given BNF
<zero or more comma separated identifiers>
<one or more space separated identifiers>
arrow_forward
Write a program to code text editor.
Note: code in c++
The goal of this program is to implementing and using stacks and linked structures. You should also continue to use object-oriented design.For this program, you will implement a text editor. Your editor will display a string of characters and a cursor. Your program will allow the user to move the cursor and modify the text using the following five operations:
left - move the cursor to the left one character or do nothing if at the end of the line
right - move the cursor to the right one character or do nothing if at the end of the line
rdelete n - delete n characters to the right of the cursor
ldelete n - delete n characters to the left of the cursor
insert c - insert the character c just before the cursor
A sample run of your program should look as follows:^insert SS^insert ASA^insert MSAM^insert MSAMM^insert YSAMMY^leftSAMM^YleftSAM^MYrdelete 2SAM^insert ISAMI^rightSAMI^leftSAM^Ildelete 3^IYour program should implement a…
arrow_forward
The C struct, Exercise
In C++:
The programming assignment at the end of this module will involve a struct named Square with exactly one attribute representing the length of one of its sides as a numeric data type.
Square objects will have exactly one supporting function to calculate the area and perimeter of a Square object, with two parameters -- an ostream object by reference, and a Square by constant reference.
The function should send to the ostream object: the side's value, labeled without rounding, followed by the area and perimeter, both labeled and rounded to two decimal digits. (Note that this function may be called several times from a main program, and still the side should be output with any formatting removed!)
Write two code blocks -- one for the struct and its supporting function's prototype, and another for the function definition itself.
Assume that all needed library includes have already been made. Do not write a full working program or int main() -- just…
arrow_forward
What is the definition of polymorphism?
arrow_forward
Return a lambda function that takes in multiplier (the multiplier is a number) and returns a lambda function that will take in
another number and will return the new input multiplied by the multiplier.
def higher_order_lambdas():
Return a lambda function that takes in a multiplier and returns a lambda function that given an input
return the input multiplied by the multiplier
>>> hol = higher_order_lambdas ()
doubles = hol(2)
>> doubles (3)
6
>>> hol = higher_order_lambdas()
>> triples
hol(3)
>>> triples (4)
12
=
"*** YOUR CODE HERE ***"
arrow_forward
Please convert the code in C language
#include <bits/stdc++.h>using namespace std;
class Node{ public: int data; //value Node *left; //pointer to left child Node *right; //pointer to right child};
// creating new nodeNode* newnode(int data) { Node* node = (Node*)malloc(sizeof(Node)); node->data = data; node->left = NULL; node->right = NULL; return(node); }
Node* LCA(Node *root, int n1, int n2){while(true){ if((root->data>=n1 && root->data<=n2)||(root->data<=n1 && root->data>=n2)) return root; if(n1<root->data) root=root->left; else root=root->right; }}
int main(){ cout<<"tree is built as per 1st example\n"; Node *root=newnode(8); root->left= newnode(4); root->right= newnode(10); root->right->right=newnode(11); root->right->left=newnode(9); root->left->left=newnode(3);…
arrow_forward
Problem D. Find URLsHTML is a language for representing documents designed to be displayed by a web browser. In
many browsers, you can see the HTML source code by right-clicking somewhere on the page and clicking “View Page Source”.
If you try this on a web page with links to other websites, you’ll notice that the URL of the link is usually formatted in the following way: href="https://some.website.com/subfolder/more_stuff.txt"
Write a function find_url(html) that takes in a string of html text that contains exactly one external link URL formatted as above, and returns just the URL string (in the above example, that would be https://some.website.com/subfolder/more_stuff.txt).
You can assume that the only place in the string where the substring href=" occurs is right before the URL, and that the next quotation mark after that point denotes the end of the URL.
Hints:
● The .find method and string slicing will likely make this easier.
● Remember that in order to use a double quote…
arrow_forward
This should be done in lambda calculus
arrow_forward
Concepts of Programming Language: Lambda Calculus I need help solving the problem below:
Evaluate following lambda term to its normal form:(λx. λz. z x) (λz. zy+y) (λx. xzy+z) 3
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
- Fortran, C++ and other languages use the assignment operator form like this: variable := expressions, but ALGOL 58 and Plankalkul used: used expression => variable form. Demonstrate using pseudo code how a C++ "linked" (link list) object would have to be modified to revert to the ALGOL 58 standard. HINT: think private member data, accessors and mutators etc. A. &Next <= alpha(A) B. alpha A &A=>&Next C. alpha * A; alpha B; A = new alpha; A->setnext(&B); D. alpha * Next; void setNext(alpha A) { &A => Next; }arrow_forwardCreate Code in C++ For String searching algorithms – Boyer-Moore and Aho-Corasick – to find the occurrences of a particular string within a large body of text. For example, you might take a webserver log file and use an appropriate data structure to track how many times each page has been accessed.arrow_forwardA strongly-typed data type implementation supports strongly-typed data, whereas a loosely-typed data type implementation supports loosely-typed data.arrow_forward
- Computer Science about lambda expression Answer the lambda expression with parentheses and the symbol a supplemented as much as possible 1. ху(Луz.zxy) 2. (Axyz. xy(xz))uvwarrow_forwardThis question should be answered in C++ programming language. Please answer part 2 of this question as part 1 has already been answered through chegg. if GPA in the range of 2.5(inclusive) - 3:B if GPA in the range of 2(inclusive) - 2.5:C Less than 2: D > Print_Std_Info() : This function accepts the id of one student and prints out all the information of that student (all the attributes). Purpose: The purpose of this project is to allow you practice Object Oriented Design, Pointers, File /0, Exception Handling, Functions and Arrays. > Comapre_GPA(): This function compares the GPA of two students and returns the id of the student who has the higher GPA. Problem Objective: The objective of this problem is to create a fully functioning system that handles the records of students at Concordia University. Based on the following narrative, you need to come up with an Object-Oriented design to represent the different entities in the system. Part 2: Faculty Class: Assume the faculty of…arrow_forwardIn your own words describe what are Lambda expressions and what they are used forarrow_forward
- With code, describe the type of polymorphism.arrow_forwardWrite C# linq syntax to get first student name where age is more then 18 from List<Student>. Please provide linq syntax only Student has below properties Id, Name, Age, Classarrow_forwardWrite a program in c language to store the information of any biological entity in a structure array. Data members in the structure should be of int and char data type with source code. Also includes strings in it. Your program should read the data from user and then store in structure and display in tabular form. Need source code in simple C language.arrow_forward
- Differentiate between structures and unions in C. Consider the following C structure forholding a 3-D vector:typedef struct v3d_tag{float x;float y;float z;} vector3D;Write a C function that takes two vector3D structures as arguments and prints their dotproduct.Note: For two vectors a = (a1,a2,a3) = a1i+a2j+a3k and b = (b1,b2,b3) = b1i+b2j+b3k, where i,j and k are unit vectors, the dot product a⋅b = a1b1+a2b2+a3b3.arrow_forwardcircumstances. The following program shows this approach: // Use a generic functional interface with lambda expressions. Comedebane.arrow_forwardWrite a program to code text editor. Note: Use DSA C++ Language. The goal of this program is to implementing and using stacks and linked structures. You should also continue to use object-oriented design.For this program, you will implement a text editor. Your editor will display a string of characters and a cursor. Your program will allow the user to move the cursor and modify the text using the following five operations: left - move the cursor to the left one character or do nothing if at the end of the line right - move the cursor to the right one character or do nothing if at the end of the line rdelete n - delete n characters to the right of the cursor ldelete n - delete n characters to the left of the cursor insert c - insert the character c just before the cursorarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education