Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

U NORTH AMERICAN UNIVERSITY 0X x COMP 3320 - Programming Languages Chapter 2 - Language Design Criteria Chapter 3 - Functional Languages Assignment 1 1

image text in transcribedimage text in transcribed

U NORTH AMERICAN UNIVERSITY 0X x COMP 3320 - Programming Languages Chapter 2 - Language Design Criteria Chapter 3 - Functional Languages Assignment 1 1 x Name: Due Date: February 7, 2021 19 X 5 -x a 2 3 x b. (1 12 (34) (5)) Chapter 2 1. Languages such as Lisp and Python are dynamically typed, whereas languages such as C++ and Java are statically typed. Discuss the costs and benefits of each kind of typing. (maximum 100 words) Answer: Dynamic typed languages checks the typed error at run time. So even if our code contains some compilation error it will compille. Unline C and java where until and unless we removed all compilation error we cannot compile the code Examples of static typed language In java: intimo i=5; So here first I declared i as int then assigned the value of 5 to i. So compiler knows at compilation time itself that I will have only int value so if try to assign other value it will show error. Now in dynamically typed languages. let name; name=3 name = myName. So here compiler not aware of type name at compile time. so if we assign wrong value to it we will not be able to find it at compile time. so C and C++ java code will fail to compile until the errors have been fixed. It has the following benefits. Code compilation will be good. In IDE when working on statically typed languages. We will get some code hints already while typing. It's easy to find error in the code. On the other side dynamically typed language has the following benefits. No need to worry about variable type declartion. Its will map automatically at run time. Code will be less verbose and code changes is easy. 4 2. Represent the following elements as car/cdr expressions of the lists of the previous exercise a. a of the first list b. 3 of the second list answer to this question Hint: cas - tiuat item ods - second and all subsequent items in liat casi 2 3 4) - 2 cas (2) 34) - (2 od=( 2 3 4) - 34 ods (2) 3 4) -34 de( (2) (3) (4) ) - (a) (4) Chapter 3 1. Draw box and pointer diagrams for the following Scheme lists: 2. Represent the following elements as car/cdr expressions of the lists of the previous exercise. a. a of the first list b. 3 of the second list Hint: car = first item cdr = second and all subsequent items in list Example: car( 2 3 4) = 2 car( (2) 3 4) = (2) cdr ( 2 3 4) = 3 4 cdr( (2) 3 4) = 3 4 cdr( (2) (3) (4) ) = (3) (4) U NORTH AMERICAN UNIVERSITY 0X x COMP 3320 - Programming Languages Chapter 2 - Language Design Criteria Chapter 3 - Functional Languages Assignment 1 1 x Name: Due Date: February 7, 2021 19 X 5 -x a 2 3 x b. (1 12 (34) (5)) Chapter 2 1. Languages such as Lisp and Python are dynamically typed, whereas languages such as C++ and Java are statically typed. Discuss the costs and benefits of each kind of typing. (maximum 100 words) Answer: Dynamic typed languages checks the typed error at run time. So even if our code contains some compilation error it will compille. Unline C and java where until and unless we removed all compilation error we cannot compile the code Examples of static typed language In java: intimo i=5; So here first I declared i as int then assigned the value of 5 to i. So compiler knows at compilation time itself that I will have only int value so if try to assign other value it will show error. Now in dynamically typed languages. let name; name=3 name = myName. So here compiler not aware of type name at compile time. so if we assign wrong value to it we will not be able to find it at compile time. so C and C++ java code will fail to compile until the errors have been fixed. It has the following benefits. Code compilation will be good. In IDE when working on statically typed languages. We will get some code hints already while typing. It's easy to find error in the code. On the other side dynamically typed language has the following benefits. No need to worry about variable type declartion. Its will map automatically at run time. Code will be less verbose and code changes is easy. 4 2. Represent the following elements as car/cdr expressions of the lists of the previous exercise a. a of the first list b. 3 of the second list answer to this question Hint: cas - tiuat item ods - second and all subsequent items in liat casi 2 3 4) - 2 cas (2) 34) - (2 od=( 2 3 4) - 34 ods (2) 3 4) -34 de( (2) (3) (4) ) - (a) (4) Chapter 3 1. Draw box and pointer diagrams for the following Scheme lists: 2. Represent the following elements as car/cdr expressions of the lists of the previous exercise. a. a of the first list b. 3 of the second list Hint: car = first item cdr = second and all subsequent items in list Example: car( 2 3 4) = 2 car( (2) 3 4) = (2) cdr ( 2 3 4) = 3 4 cdr( (2) 3 4) = 3 4 cdr( (2) (3) (4) ) = (3) (4)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions