New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

Programming Languages

by: Alek Haley

Programming Languages CS 4700

Alek Haley
Utah State University
GPA 3.58

Curtis Dyreson

Almost Ready


These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

Curtis Dyreson
Class Notes
25 ?




Popular in Course

Popular in ComputerScienence

This 4 page Class Notes was uploaded by Alek Haley on Wednesday October 28, 2015. The Class Notes belongs to CS 4700 at Utah State University taught by Curtis Dyreson in Fall. Since its upload, it has received 12 views. For similar materials see /class/230443/cs-4700-utah-state-university in ComputerScienence at Utah State University.

Similar to CS 4700 at Utah State University

Popular in ComputerScienence


Reviews for Programming Languages


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 10/28/15
CS 4700 Handouts Scheme Quick Reference Sheet 1 Types Scheme has literals of several primitive types The literals are selfevaluating expressions Which means that they evaluate to the value that they represent 3 integer literal 3 integer literal 43 floating point literal 465e2 floating point literal scientific notation t boolean literal true f boolean literal false quothelloquot string literal quothellonquot string literal note the newline quotI said quothelloquotquot other backslash characters similar to C Scheme has one composite type a list Lists and strings are allocated in the heap and automatically garbage collected just like in Perl So don7t worry too much about the cost of creating new lists use them freely they are the primary data structure in Scheme Note the quote symbol in front of each list it is actually a function call see below i 3 4 a two element list 4 3 3 lists can be nested empty list a one element list the element is the empty list quothiquot 43 quotjoequot lists can be heterogeneous Note that the list elements are not separated by commas Type checking in Scheme is dynamic 2 Builtin Functions A function is a list that is evaluated In general a list Will be evaluated only in some contexts are lists not evaluated such as When it is preceded by a quoteh Each function is in prefix notationl functionname operand1 operand2 operandN Each function returns a value and takes zero or more operandsl 21 Arithmetic Functions max 34 5 7 38 6 gt 38 maximum of the operands min 3 5 5 330 4 24 gt 24 minimum of the operands 3 4 gt 7 addition 4 4 gt 16 multiplication 3 4 gt 1 subtraction 3 gt magnitude magnitude 3 7 7 quotient 35 7 quotient 35 7 quotient 3 quotient modulo 13 modulo 13 remainder remainder gcd 32 4 5 7 35 7 4 4 13 4 13 4 gt 4 gt 7 gt 7 gt 5 gt gt gt 1 gt 3 5 5 gt 1 gt 1 22 Comparison Functions 2 3 gt f eqv quotabsquot quotabsquot gt t eqv a a gt t lt 2 3 gt gt 2 3 gt t f gt 2 3 gt f or f t gt t not f gt 1 and f t gt f integer 2 gt t real 3 gt f string 3 gt f zero 3 0 gt f positive 3 4 5 gt t negative 3 4 5 gt f String quot2quot quot3quot gt f 2 3 List Functions unary subtraction absolute value absolute value div remainder remainder greatest common divisor are all the integer operands equal are all the operands equal are all the operands equal less than greater than greater than or equal to or negation all the operands integers reals strings zero positive negative two strings equal These are by far the most important functions that we Will be using quote a b a b gt a b car a b car car cdr cdr car gt a gt a b gt ERROR car Wrong type in arg1 a b gt a a b gt b gt ERROR car Wrong type in arg1 a a b gt a b quote suspends evaluation of the list quote suspends evaluation of the list get head of list contents of address reg expects a list get head of list could be a list get rest of list contents of address reg expects a list get rest of list put element on head of list build a list build a list from the operands from the operands cons 3 gt 3 cons a b c d gt a b c d cons quotaquot b c gt quotaquot b c list a 7 c gt a 7 c list gt length a b c gt 3 length a b c d e length gt o gt 3 what is the what is the what is the length of a list length of a list length of a list append x y gt X y append a b c d gt a b c d append a b C gt a b c append one list to another reverse a b c gt c b a reverse a list reverse a b c d e f gt e f d b C a null gt t is the list empty null 2 gt f is the list empty append one list to another append one list to another reverse a list 2 4 Miscellaneous Functions While Scheme has several loop functions only the following two functions are often useful if 2 3 t f gt f an if function returns result of evaluating one of the branches if 2 3 2 3 2 3 gt 1 if gt 3 2 if functions can be nested if 2 3 equal gt lt display quothelloquot prints hello display quothellonquot prints hello followed by a newline display 1 3 prints 1 3 exit leave the scheme interpreter 3 Binding Names to Functions or Values ln Scheme each name is bound to a meaning The name is a sequence of letters but could include numbers or special characters such as a question mark or hyphen The meaning is usually either a function or literal The binding between a name and a function is dynamic so the meaning of a name can change during the lifetime of a program The de ne function binds a name to a meaning There are two avours of de ne The rst binds a name to a value define x 23 bind name x to literal 23 x dereference x x 4 gt 27 X gt ERROR define x append x x gt define y quothelloquot bind name y to a string literal define y 4 5 bind name y to the result of evaluating the function 4 5 ie to 9 define y 4 5 bind name y to the list 4 5 define y 4 x bind name y to the result of 4 x will result in an ERROR since x means names are dereferenced whereever they appear 23 is not a functionname bind name x to the empty list The second avour of de ne binds a name to a function and is how we will de ne new functions ln this form of de ne enclose the name being de ned in brackets Add parameter names as necessary within the brackets The scope of each parameter is local to the function de nition define x 23 x gt 23 X gt CLUSURE 23gt define x 4 5 bind functionname x to evaluate to 23 call the function named x dereference x bind functionname x to the function 4 5 x gt 9 call the function named x define add X y x y define a binary add function add 4 5 9 call the add function add 4 to 5 results in 9 define add x y z x y z define a ternary add function add 4 5 7 gt 16 call the add function Note that both operands could be lists but neither is evaluated So this is another context like Within a quote function in Which lists are not evaluated as functions The second avour of bind is actually just syntactic sugar for binding the name to an anonymous function An anonymous function is a function that does not have a name The lambda function can be used to create an anonymous functioni lambda x x 1 ltCLUSURE x x 1gt create a function that adds 1 to its one operand 1ambda x x 1 4 5 use the anonymous function define succ lambda x x 1 bind the name succ succ 4 gt 5 dereference succ to get function define succ x x 1 bind the name succ succ 4 5 dereference succ to get function So in general the second avour of bind is just syntactic sugar for the first avour of bind Always remember that names are usually dereferenced Whenever they are used An exception is When the name is bound in a de ne function 31 Important Function Details Here are some important things to remember about functions 0 In general functions have eager evaluation Which means that the parameters are evaluated prior to invoking the function call however there are exceptions For instance the and cond functions have lazy evaluation Which means that the function is called and the operands are evaluated as needed 0 Functions are first class values They can be passed as parameters and returned from functions 0 Parameter passing is by positional correspondence If the Wrong number of arguments are passed an error Will be generated


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Allison Fischer University of Alabama

"I signed up to be an Elite Notetaker with 2 of my sorority sisters this semester. We just posted our notes weekly and were each making over $600 per month. I LOVE StudySoup!"

Bentley McCaw University of Florida

"I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

Parker Thompson 500 Startups

"It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.