Question: ******************USING CLOJURE********* 1. The expression (+ 8 2) has the value 10. It is a compound expression made up of three scalars. For this problem,
******************USING CLOJURE*********
1. The expression (+ 8 2) has the value 10. It is a compound expression made up of three scalars. For this problem, write five other Clojure expressions whose values are also the number ten: a. A scalar b. Another compound expression made up of three scalars. c. A compound expression made up of 4 scalars. d. A compound expression made up of a scalar and two compound subexpressions. e. Any other kind of expression. Task 3Clojure functions 1. Here are some function definitions. For each one, describe the function in English, show a sample invocation, and show the result of that invocation. a. (defn f [x y] (- y x)) b. (defn identity [x] x) c. (defn three [x] 3) Name: ___________________________
d. (defn seven [] 7) e. (defn magic [n] (- (/ (+ (+ (* 3 n) 13) (- n 1)) 4) 3)) 2. Each of the following function definitions has an error of some kind. Say what's wrong and why, and fix it: a. (defn sphere-volume [r] (* (/ 4 3) 3.141592654) (* r r r)) b. (defn incr [x] (x + 1)) c. (defn triangle-area [triangle] (* 0.5 base height))
Define functions in lab2.clj file.
- Define a function square that squares the value of its parameter.
- Define a function fourth that computes the fourth power of its parameter. Do this two waysfirst using the multiplication function, and then using square and not (directly) using multiplication.
- Write a function to convert a temperature from Fahrenheit to Celsius, and another to convert in the other direction. The two formulas are
C=5/9(F32)
F=(9/5C)+32.
- Write a function with two parameters that divides the first number by the second and returns both the quotient and the remainder (in a vector). Hint: the functions you might want are quot and rem.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
