General introduction to Programming Languages ([SCOTT] chapter 1).
Clojure fundamentals.
def
, let
).
+
, +'
, -
, *
, *'
, /
, <
, <=
, =
, not=
, ==
, >
, >=
, boolean
, char
, char?
, dec
, even?
, format
, inc
, keyword?
, neg?
, nil?
, number?
, odd?
, pos?
, quot
, rem
, str
, string?
, symbol?
, and zero?
.
quote
('
) special form.
not
, and
, or
. Short-circuit evaluation.
if
, cond
, case
). Truthy and falsy values.
defn
) and application. Parameters. Multi-arity and variadic functions. Docstrings. Anonymous functions and closures. The apply
function.
loop
/recur
.
Clojure collections.
butlast
, concat
, cons
, count
, cycle
, distinct
, drop
, drop-while
, empty?
, every?
, filter
, first
, interleave
, interpose
, iterate
, last
, map
, mapcat
, nth
, partition
, partition-by
, range
, reduce
, remove
, repeat
, rest
, reverse
, seq
, seq?
, some
, sort
, split-at
, split-with
, take
, and take-while
.
conj
and list
.
assoc
, conj
, get
, nth
, vec
, and vector
.
assoc
, contains?
, dissoc
, frequencies
, get
, keys
, merge
, vals
, and zipmap
.
conj
, contains?
, disj
, get
, and set
.
Parallel programming.
pmap
function.
Finite Automata.
Regular Expressions.
re-matches
, re-find
, and re-seq
.
Context-Free Grammars.
Turing Machines.
Theory of Computation
NOTE: Once the exam starts you are not allowed to share any items with anyone else.
Pen, pencil, eraser, pencil sharpener.
Simple scientific calculator. You are not allowed to use a cell phone, programmable calculator, tablet, computer, or any other electronic device.
Personal cheat sheet with the following characteristics:
|
Write a Clojure function called contains-all-digits?
that takes an integer argument \(n\) and returns true
if \(n\) contains each of the ten digits from 0 to 9 at least once, or false
otherwise.
Examples:
(contains-all-digits 1023456789) => true (contains-all-digits 1236) => false
You are given the following Clojure code:
(defn mystery ([x] (mystery x #(* 2 %) #(inc %))) ([a b c] (c (b a)))) (defn wierd [& t] (let [n (count t)] (cond (zero? n) 1 :else (inc (apply wierd (rest t))))))
What is the result of evaluating the following expressions?
(mystery 5)
(wierd 4 8 15 16 23 42)
(mystery 2 dec inc)
(mystery 10 wierd (fn [z] (* z z)))
You have a sequential program that takes 10 seconds to execute using 1 processor. The parellel version of the same program takes 2 seconds to execute using 8 processors. Calculate its speedup.
What is the difference between an ordinary Turing machine (TM) and a universal Turing machine (UTM)?
Given \(\Sigma = \{ 0, 1 \} \), you want to define a language \( L \) comprised of all strings that start and end with exactly the same symbol. Thus, these strings belong to this language: 0
, 010
, 11001010101
. Yet, these other strings do not: \( \varepsilon \), 01
, 110
, 010010011
.