This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
intersection_set _ [] = [] | |
intersection_set [] _ = [] | |
intersection_set (x:xs) ys | |
| element_of_set x ys = x : intersection_set xs ys | |
| otherwise = intersection_set xs ys | |
element_of_set _ [] = False | |
element_of_set x (y:ys) | |
| x == y = True | |
| otherwise = element_of_set x ys |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EXERCISE 1/2 are earlier versions of ex 3 | |
EXERCISE 3. | |
select books.title, stock.retail, stock.stock, books.id AS BOOK_ID, editions.isbn, editions.publisher_id from books left join editions on books.id = editions.book_id left join stock on stock.isbn = editions.isbn where editions.publisher_id = 59; | |
EXERCISE 4. | |
select books.title, stock.retail, stock.stock, books.id AS BOOK_ID, editions.isbn, editions.publisher_id from books left join editions on books.id = editions.book_id left join stock on stock.isbn = editions.isbn where editions.publisher_id = 59 and stock.stock > 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rspec' | |
module Flight | |
def fly | |
puts "I am a #{self.class} and I am flying" | |
end | |
end | |
class Animal | |
def warm_blooded? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### SETUP | |
require 'rspec' | |
RSpec.configure do |config| | |
config.color = true | |
end | |
### LOGIC (fix me) | |
# Returns the average of all the numbers in the array |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def benchmark | |
# Your benchmarking code goes here. | |
beginning_time = Time.now | |
foo = yield | |
end_time = Time.now | |
return end_time - beginning_time | |
end | |
# Be careful, pasting this into IRB will take a long time to print. | |
# It's a loooong string. :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Save this file to your computer so you can run it | |
# via the command line (Terminal) like so: | |
# $ ruby shakil_the_dog.rb | |
# | |
# Your method should wait for user input, which corresponds | |
# to you saying something to your dog (named Shakil). | |
# You'll probably want to write other methods, but this | |
# encapsulates the core dog logic |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Save this file to your computer so you can run it | |
# via the command line (Terminal) like so: | |
# $ ruby shakil_the_dog.rb | |
# | |
# Your method should wait for user input, which corresponds | |
# to you saying something to your dog (named Shakil). | |
# You'll probably want to write other methods, but this | |
# encapsulates the core dog logic | |
def shakil_the_dog |
NewerOlder