This is a course page of David Casperson |
|
can be found here .
Read Chapter 2 of Learn You a Haskell for Great Good. Then send me an e-mail message explaining what you understand to be the differences between lists and tuples.
How many of these are fair and interesting?
Give examples of syntactic sugar (the more obscure the better) in Java, Haskell, and Scheme.
Write an init
function
in Scheme.
uncurry
that
takes a function of type a → b → c
and returns a function of type (a,b) → c
.
curry
that
takes a two argument function and returns its Curried equivalent.
and
and or
do in Scheme
(or Racket).
let
-style block that returns
three different answer depending on whether one uses
“let
”,
“let*
”, or
“letrec
”.
Write a Haskell tail-recursive function that counts the number of leaves in a
data Tree a =
Leaf a | Branch (Tree a)
(Tree a)
tree by using continuations.
Repeat using another strategy to make the function tail-recursive.
Write a Haskell tail-recursive function that makes an in-order list of the leaf values in a
data Tree a =
Leaf a | Branch (Tree a)
(Tree a)
tree by using continuations.
Repeat using another strategy to make the function tail-recursive.
Suppose that you have a binary tree where every non-leaf has exactly two branches:
data Tree a =
Leaf a | Branch (Tree a)
(Tree a)
[Haskell] Write a program that gives a list of non-negative integers corresponding to depths of the leaves, scanned in in-order.
[Haskell] Make this program tail-recursive.
[Haskell, Scheme] Write a program that given a list of non-negative integers, determines whether or not they could be the outcome of the previous part.
For instance, [1,2,2]
is a possible output,
but [2,1,2]
is not.
Hint: A more general problem is whether or not an initial segment of the list is the set of heights of a sub-branch sitting at depth k.
fall-2024