Definitions
Types
Coding
Lists
Miscellaneous
100

Functional language computation definition

What is mathematical functions?

100

Expressions are like this

What is statements in imperative languages?

100

State the type of this function:

let rec fact n =

if n = 0 then 1

else n * fact(n -1)

int -> int

100

Describe lists ( length and type)

What is arbitrary length ( linked data structure) and homogeneous ( all elements have the same type)
100

Definition of First-class Function

Functions can be sent as parameters to other functions (higher order) return values, and be stored as data?
200

State of functional language

What is immutable?

200

Every kind of expression has these two things

What are syntax (metavariable e to designate an arbitrary expression) and semantics (type checking rules and evaluation rules)

200

type of foo 4 2

let rec foo n m =

if n >= 9 || n < 0 then m

else n + m + 1

What is int?

200

Method to insert "a" into a list "list"

"a" :: list

200

What ML stands for

What is Meta Language?

300

Properties of functional language

What are higher level of abstraction, easier to develop robust software, immutable state, and easier to reason about software?

300

Definition of value

What is an expression that is final?

Ex: 34 is a value and 34 + 17 is an expression

300

The type of the list: [1.0;2.0;3.0;4.0]

float list

300

How would you view the third element of the list that is guaranteed to have 3 + elements

match lst with

a :: b :: c -> [c]


300

Course name of CMSC 330

Organization of Programming Languages

400

Properties of imperative languages?

What are lower level of abstraction, harder to develop robust software, mutable state, and harder to reason about software?
400

To what value does this expression evaluate

if 22 < 0 then "butterfly" else 1

Has 2 different types, so get a type error

400

Correct use of if statements

if e1 then e2 else e3

e2 and e3 are the same type

400

Are lists immutable or mutable?

Immutable : there is no way to change an element of a list, instead build up new lists out of old.

400

Give an example of a function that has a polymorphic type ('a list -> 'a) and one with a int type (int list -> int)

let fst x y = x

let fst a b = a + b

500

Key features of ML

First-class functions, favors immutability, data types and pattern matching, type inference, parametric polymorphism

500

Role of "=" in n = 0

Infix function that takes two ints and returns a bool

n must be an int to type check

Can only be used between two equal signs

500

Type of following definition :

let f x = 1::[x]

int -> int list

500

_ is

What is a wildcard pattern?

Matches anything, doesn't add any bindings, useful to hold a place but discards the value

500

What is the difference between tuples and lists?

A tuple can have more than one type and you can add to a list.