ruby-scheme代写: 600_s1

1) KNOW AND REMEMBER EVERYTHING about First Class Objects

  • Literally you need to know the definition and the example

2) Know how to write a Histogram except this time it’s for sine function

  • a) Define a function f, where f returns f(x)
    • – he’ll give you the function f(x) to define (this is a little easier than the rest of the problems)
  • b) Write a function that maps a list to function f. Basically we’re
  • c) Write a function that DISPLAYS the sin histogram
  • d) Write a function that shows exactly HOW to write the histogram

I can’t write a SINE function but think of it as two big round hills going down vertically.

 

For 2b, you’re supposed to map a list of numbers to the function f(x) and I guess you can do this with the map function in scheme.

 

something like, (map (f(list))…something like that I think.

 

Basically once you get to the next question you’ll use this map function to create a sin function.

 

3) Know Ruby functions collect, select, and reject (you may have to use them for this problem. – you’ll be writing a function that checks for two prime numbers that make up an even number, it’s suppose to be a rule. (ie. 4 = 2 + 2, 6 = 2 + 3, or 8 = 3+ 5)

  • a) write a function prime?(n) where it takes in an argument ‘n’ and returns true if it’s prime, else false
  • b) write a function arrayPrime(n) where it takes in an array and determines if they are prime using the prime?(n) function you previously wrote
  • c) write a function that takes in a an argument ‘even’ and returns two prime numbers from it using arrayPrime(n)
  • d) write a main function that displays the following:
    • 2 = 1 + 1
    • 4 = 2 + 2
    • 6 = 2 + 3
    • 8 = 3 + 5
    • 10 = 5 + 5
    • 12 = 5 + 7
    • 14 = 3 + 11
    • 16 = 3 + 13
    • 18 = 5 + 13
    • 20 = 7 + 13
    • 22 = 3 + 19
    • 24 = 5 + 19

4) Write both a recursive and iterative version of the following:

  • 1 + 1/1! + 1/2! + 1/3! + … + 1/n!
  • It’s easier than you may think actually. It’s essentially the exact same as the final prep except we use (!) instead

5) Know Ruby classes, inheritance, super, and user input. You’ll be writing classes that use other classes and may even write a function in one of the classes that gets the input of the user to define instance variables of the object. 

1) KNOW AND REMEMBER EVERYTHING about First Class Objects

  • Literally you need to know the definition and the example

2) Know how to write a Histogram except this time it’s for sine function

  • a)Define a function f, where f returns f(x)
    • – he’ll give you the function f(x) to define (this is a little easier than the rest of the problems)
  • b)Write a function that maps a list to function f. Basically we’re
  • c)Write a function that DISPLAYS the sin histogram
  • d)Write a function that shows exactly HOW to write the histogram

I can’t write a SINE function but think of it as two big round hills going down vertically.

 

3) Know Ruby functions collect, select, and reject (you may have to use them for this problem. – you’ll be writing a function that checks for two prime numbers that make up an even number, it’s suppose to be a rule. (ie. 4 = 2 + 2, 6 = 2 + 3, or 8 = 3+ 5)

  • a)write a function prime?(n) where it takes in an argument ‘n’ and returns true if it’s prime, else false
  • b)write a function arrayPrime(n) where it takes in an array and determines if they are prime using the prime?(n) function you previously wrote
  • c)write a function that takes in a an argument ‘even’ and returns two prime numbers from it using arrayPrime(n)
  • d)write a main function that displays the following:
    • 2 = 1+ 1
    • 4 = 2+ 2
    • 6 = 2+ 3
    • 8 = 3+ 5
    • 10 = 5+ 5
    • 12 = 5+ 7
    • 14 = 3 + 11
    • 16 = 3+ 13
    • 18 = 5+ 13
    • 20 = 7+ 13
    • 22 = 3+ 19
    • 24 = 5+ 19

4) Write both a recursive and iterative version of the following:

  • 1+ 1/1!+ 1/2! + 1/3! + … + 1/n!
  • It’s easier than you may think actually. It’s essentially the exact same as the final prep except we use (!) instead

5) Know Ruby classes, inheritance, super, and user input. You’ll be writing classes that use other classes and may even write a function in one of the classes that gets the input of the user to define instance variables of the object. 

 

 

 

Sorry, I forgot to explain question – 2B

 

For 2b, you’re supposed to map a list of numbers to the function f(x) and I guess you can do this with the map function in scheme.

 

something like, (map (f(list))…something like that I think.