#!/usr/bin/env python
"""
CS 350 Lab 9

Execute with:

     ./lab09.py lab09.data

lab09.data is structured like this:

      10
      15
      20
      0
      17
"""

from sys import argv

"""  
my_map takes a function and a list, and returns the result of the
function applied to the every element in the list; e.g.,

    my_map(lambda x: x + 1, [1, 2, 3]) 

returns [2, 3, 4]
"""

def my_map(func, list):
  new_list = []
  for item in list:
    new_list.append(func(item))
  return new_list

if len(argv) < 2:
  print "Usage: %s <filename>" % argv[0]
else:
  input = file(argv[1])
  values = []
  for line in input:
     values.append(int(line))

  print values 
  squared = my_map(lambda x: x * x, values)
  print squared
  successor = my_map(lambda x: x + 1, values)
  print successor
 
