Chapter 3 Daily 08

Given information: information from the periodic table stored in tuple (String name, String symbol, Int atomic number, Float atomic mass).

    periodic_table = [("Hydrogen","H",1,1.008),("Helium","He",2,4.002),
                      ("Lithium","Li",3,6.941),("Beryllium","Be",4,9.012),
                      ("Boron","B",5,10.81),("Carbon","C",6,12.011),
                      ("Nitrogen","N",7,14.007),("Oxygen","O",8,15.999),
                      ("Fluorine","Fl",9,18.998),("Neon","Ne",10,20.180),
                      ("Sodium","Na",11,22.990),("Magnesium","Mg",12,24.305),
                      ("Aluminum","Al",13,26.981),("Silicon","Si",14,28.085),
                      ("Chlorine","Cl",17,35.45)]
    pt = periodic_table
  1. (letfind) Find all of the elements with the given letter in their name. Case matters.

     letfind :: Char -> [String]
     check1 = (letfind 'i' == ["Helium","Lithium","Beryllium","Nitrogen","Fluorine","Sodium","Magnesium","Aluminum","Silicon","Chlorine"])
    
  2. (mass) Write a function to find the mass of a molecule. Write “H2O” as [("H",2),("O",1)].

     mass :: [(String,Int)] -> Float
     mass [("Na",1),("Cl",1) == 22.990 + 35.45