AnthonyPerez5886 AnthonyPerez5886
  • 18-10-2019
  • Computers and Technology
contestada

Write a function negateOdds that takes a list of integers and returns a list of integers with all of the odd integers negated. negateOdds :: [Integer] -> [Integer]

example: [1,2,3,4,5] should return [-1,2,-3,4,-5]

Respuesta :

bergintonatcapot18z8
bergintonatcapot18z8 bergintonatcapot18z8
  • 18-10-2019

Is this computer science?

If so, then the function you would need for your code is this...

_____

if (someValue%2 != 0) {

 value *= -1;

        }

_____

//basically number%2 == 0 means even so "!" means false so "not even" meaning "odd."

Assuming you are doing an array list (given a set value) or a for-loop with an

int someValue = Integer.parseInt(args[i]); inside (not given a set value and not restricted)

Otherwise ignore me....lol

Answer Link

Otras preguntas

the underline phrase in the sentce above serves as a/an​
Your mother wants to get a new television but she would like to have an older model with an aspect ratio of 4:3 she is looking at a 32 inch television. what is
5/2 year = (blank) months​
How would you compare Locke's ideas about government with Rousseau​
What is the total resistance of the two resistors connected in parallel, as shown in the diagram, when R1 = 46 Ohms and R2 = 52 Ohms?
The president of the U.S lives and works in which building?
Should you obey rules and laws that you feel are unfair or unjust? What are the implications of disobeying rules and laws in society? Explain both answers.
What are the uses of steam
What process adds oxygen to ocean water? A) tides B) oxidation C) respiration D) photosynthesis
A current of 0.92 A flows past a point in a circuit? How much charge, in units of Coulombs, passes that point in one minute?