First clojure examples and Lab 1
Due Friday, February 3rd at 11:59pm
Problem 1 (12 points)
Usde map, reduce, filter, and similar functions and anonymous
functions to compute the following:
- Create a sequence of all non-negative integers between 0 and 100
(inclusive) that are divisible by 3.
-
Create an ordered sequence of all numbers between 0 and 100 that are
not divisible by 3.
-
Given a vector of numbers, create a sequence of all elements of that
vector that are between 1 and 5 (inclusive); preserve their original order.
-
Given a vector of numbers, find the sum of absoulute values of all its
elements.
-
Given a vector of strings, find out how many of these strings start
with an 'a'.
-
Given a vector of strings, find out how many of these strings don't start
with an 'a'.
Problem 2 (6 points)
Write a reverse_list function: a function that takes a sequence and
returns a sequence with all the same elements, but in the opposite order.
If your function is not using reduce
already, write
another function
that does (and behaves the same way).
Problem 3 (3 points)
Write a function that is similar to every-other
in the
in-class examples, but
keeps even-numbered elements instead of odd-numbered ones, i.e.
produces [2, 4, 9] given the list [1 2 3 4 5 9].
UMM CSci 4651