1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
galben [10]
3 years ago
15

Develop a program that computes the scalar product of two vectors. The program must not accept vectors having different size (in

such a case print an error message) For example:
>(scalar-product '# (1 2 3) '#(2 1 1))
7
>(scalar-product '#(1 2 3) '#(1 2 3 4 5))
ERROR: Different sizes of vectors!
>

a) Write the program in iterative style using the DO loop
b) Write the program using recursion.
Engineering
1 answer:
Jobisdone [24]3 years ago
4 0

Answer:

Explanation:

a) using DO loop, we have the following code:

(define (scalar-product-1 list1 list2)

(do ((remainingList1 list1 (cdr remainingList1))

(remainingList2 list2 (cdr remainingList2))    

(final-answer 0 (+ final-answer (* (car remainingList1) (car remainingList2)))))

((null? remainingList1) final-answer)

))

(define (scalar-product list1 list2) (if (= (length list1) (length list2)) (scalar-product-1 list1 list2) (display "ERROR: Different sizes of vectors\n"))

b) using recursion, we have the following code

(define (scalar-product list1 list2)

(cond ((not(= (length list1)(length list2))) "ERROR: Different sizes of Vectors")

((null? list1) 0)    

(else (+(* (car list1) (car list2)) (scalar-product (cdr list1) (cdr list2))))

))

You might be interested in
Assuming that the following three variables have already been declared, which variable will store a Boolean value after these st
Yuki888 [10]

Answer:

C

Explanation:

Boolean Algebra deals with either a one or a zero and how to manipulate them in computers or elsewhere. The "choice" option may not work, since for text it must be enclosed in quotation marks, usually. For "again," it's text and not a 1 or 0. So, the answer is C, since this is a 0.

5 0
3 years ago
The density of a certain type of steel is 8.1 g/cm3. What is the mass of a 100 cm3 chunk of this steel
irina1246 [14]

Answer:

  810 g

Explanation:

Mass is the product of density and volume:

  m = ρV

  m = (8.1 g/cm³)(100 cm³) = 810 g

The mass of the chunk is 810 grams.

4 0
2 years ago
Very thin films are usually deposited under vacuum conditions to prevent contamination and ensure that atoms can fly directly fr
katrin [286]

Answer:

a. 9947 m

b. 99476 times

c. 2*10^11 molecules

Explanation:

a) To find the mean free path of the air molecules you use the following formula:

\lambda=\frac{RT}{\sqrt{2}\pi d^2N_AP}

R: ideal gas constant = 8.3144 Pam^3/mol K

P: pressure = 1.5*10^{-6} Pa

T: temperature = 300K

N_A: Avogadros' constant = 2.022*10^{23}molecules/mol

d: diameter of the particle = 0.25nm=0.25*10^-9m

By replacing all these values you obtain:

\lambda=\frac{(8.3144 Pa m^3/mol K)(300K)}{\sqrt{2}\pi (0.25*10^{-9}m)^2(6.02*10^{23})(1.5*10^{-6}Pa)}=9947.62m

b) If we assume that the molecule, at the average, is at the center of the chamber, the times the molecule will collide is:

n_{collision}=\frac{9947.62m}{0.05m}\approx198952\  times

c) By using the equation of the ideal gases you obtain:

PV=NRT\\\\N=\frac{PV}{RT}=\frac{(1.5*10^{-6}Pa)(\frac{4}{3}\pi(0.05m)^3)}{(8.3144Pa\ m^3/mol\ K)(300K)}=3.14*10^{-13}mol\\\\n=(3.14*10^{-13})(6.02*10^{23})\ molecules\approx2*10^{11}\ molecules

5 0
3 years ago
Nơi nào có điện tích thì xung quanh điện tích đó có :
maksim [4K]

Explanation:

sory sorry sorry sorrysorrysorry

4 0
3 years ago
The present worth of income from an investment that follows an arithmetic gradient is projected to be $475,000. The income in ye
Nikitich [7]

Answer:

G = $37,805.65

Explanation:

I found this on another site:

475,000 = 25,000(P/A,10%,6) + G(P/G,10%,6)

475,000 = 25,000(4.3553) + G(9.6842)

9.6842G = 366,117.50

G = $37,805.65

4 0
3 years ago
Other questions:
  • Technician A says ASE certification is mandatory in all 50 states before performing an automotive repair for pay. Technician B s
    12·1 answer
  • For a steel alloy it has been determined that a carburizing heat treatment of 7 hour duration will raise the carbon concentratio
    12·1 answer
  • Disconnecting means shall be capable of being locked in the open position. The provisions for locking do not have to reamin in p
    14·1 answer
  • Shear modulus is analogous to what material property that is determined in tensile testing? (a)- Percent reduction of area (b) Y
    11·1 answer
  • calculate the magnitude of the force acting on the pin at D. Pin C is fixed in DE and bears against the smooth slot in the trian
    9·1 answer
  • A(n) ____ is an exact representation of an object projected onto a plane from a specific position.
    14·1 answer
  • Cual es la definición de la distribución de las instalaciones?
    13·2 answers
  • Select the correct answer. The most frequent maintenance task for a car is: A. Oil changes B. Tire replacements C. Coolant chang
    10·2 answers
  • Technician A says that the low level brake fluid switch on a master cylinder will turn on the brake warning light when the syste
    9·1 answer
  • In-------process the hot drawn bar or rod is pulled through the die.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!