Computer Science > QUESTIONS & ANSWERS > CS 342 Principles of Programming Languages<Homework: FuncLang (Part II)> (All)
Questions: 1. (20 pt) Goal of the question is to understand the semantics and implementation of conditional expressions by extending the interpreter to support other features like equality on all dat ... a types. Current implementation of Funclang allows equality check only for the numeric values. Comparing two string values, Boolean values or list values results in DynamicError. For example, following transcript shows the result of comparing two Strings $ (= "name" "name") funclang.Value$StringVal cannot be cast to funclang.Value$NumVal Extend the Funclang language and its implementation such that the equality operator works for each kind of value supported by the language. For example, $ (= "abc" "abc") #t $ (= "abc" "abcdef") #f $ (= #t #t) #t $ (= #t #f) #f Two list values are considered equal if they have the same size and each element of the list is equal to corresponding element in the other list. $ (= (list) (list)) #t $ (= (list 1 2 3 4) (list 1 2 3 4)) #t $ (= (list 1 2 3 4) (list 1 2 3 4 5)) #f $ (= (list 1 2 3 4 5) (list 1 2 3 4)) #f $ (= (list 1 2 3 4 (list)) (list 1 2 3 4 (list))) #t $ (= (car (list 1 2 3)) 1) #t $ (= (car (list 1 2 3)) 2) #f $ (= (cdr (list 1 2 3)) 2) #f $ (= (cdr (list 1 2 3)) (list 2 3)) #t Fall 2016 page 1 of 4CS 342 Principles of Programming Languages Homework 5 $ (= (cdr (list 1 2 3)) (cdr (list 4 2 3))) #t $ (= (cons 0 (list 1 2)) (list 0 (list 1 2))) #f $ (= (cons 0 (list 1 2)) (list 0 1 2)) #t Two function values are only considered equal, if they point to the same FunVal object. $ (define test (lambda (x) x)) $ (define test1 (lambda (y) y)) $ (= test test1) #f $ (= test test) #t [Show More]
Last updated: 3 years ago
Preview 1 out of 10 pages
Buy this document to get the full access instantly
Instant Download Access after purchase
Buy NowInstant download
We Accept:
Can't find what you want? Try our AI powered Search
Connected school, study & course
About the document
Uploaded On
Apr 15, 2021
Number of pages
10
Written in
All
This document has been written for:
Uploaded
Apr 15, 2021
Downloads
0
Views
98
Scholarfriends.com Online Platform by Browsegrades Inc. 651N South Broad St, Middletown DE. United States.
We're available through e-mail, Twitter, Facebook, and live chat.
FAQ
Questions? Leave a message!
Copyright © Scholarfriends · High quality services·