Principles 2024 – 2025 CSCI-2041
Midterm 1 Exam Review Questions
with Verified Solutions | 100% Pass
Guaranteed | Graded A+ |
Administrator
[COMPANY NAME] [Company address]
, # Midterm 1 Practice Questions
*CSci 2041: Advanced Programming Principles, Fall 2015*
These are some examples of questions similar to those that will
appear on the first midterm.
##1. Types and values
For each of the following expressions, indicate whether the expression
is correct and give its type, or will cause a type error when compiled
with no preceding bindings. If the expression is correct, explain why
you derived the type, and if it will cause a type error, explain the
nature of the type error.
```
let x = 5 in
let z y = x+y in z
```
```
let rec funny = fun x -> funny (x+1)
```
```
let z = (4,6) in
let (a,_) = z in (string_of_int z) ^ "!"
```
```
function
| [] -> []
| x::xs -> Some x
```
```
function
| (_,0) -> 1
| (s,n) -> n * (String.length s)
```
```
let d = 0.5 in
let (e,f) = (1, 2.4) in (d+e) *. f
```
```
let (@@) f x = (f x)
```
```
let rec my x l = match (x,l) with
| (0,_) | (_,[]) -> []
| (_, h::t) -> my (x-1) t
```
```
let rec tr ky = function
| [] -> ky
| h::t -> tr h^ky t
```
```
https://www.coursehero.com/file/13271012/midterm1-practicemd/