changeset 4:6842199d5e26

update to clojure 1.4
author Robert McIntyre <rlm@mit.edu>
date Mon, 30 Apr 2012 03:23:12 -0500
parents 44f31e2126fa
children 66396e76dab9
files org/man-years.org
diffstat 1 files changed, 31 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/org/man-years.org	Thu Oct 20 07:35:52 2011 -0700
     1.2 +++ b/org/man-years.org	Mon Apr 30 03:23:12 2012 -0500
     1.3 @@ -5,23 +5,19 @@
     1.4  #+keywords: man-year man-month man-hour universe human experience philosophy
     1.5  #+setupfile: ../../aurellem/org/setup.org
     1.6  #+include: ../../aurellem/org/level-0.org
     1.7 -#+babel: :results output :exports both
     1.8  
     1.9  * What is a Man-Hour?
    1.10 -
    1.11  A [[http://en.wikipedia.org/wiki/Man-hour][/Man-Hour/]] is a term from the field of Management.  It is one hour
    1.12  of work by one person for a certain task. 
    1.13  
    1.14 -For example, if I have a nine-to-five programming job at Initrode, but
    1.15 +For example, if I have a nine-to-five programming job at [[http://www.imdb.com/title/tt0151804/quotes][Initrode]], but
    1.16  I slack off most of the time and only /actually/ work from
    1.17  10:00-11:00, then I only put in one man-hour of work a day.
    1.18  
    1.19  If my task is simply existing, then I put in 24 man-hours of work
    1.20  every day.
    1.21  
    1.22 -
    1.23  * Experience
    1.24 -
    1.25  I've often wondered what it would feel like to have more than one
    1.26  body, and to experience the same day from different perspectives. 
    1.27  
    1.28 @@ -40,15 +36,13 @@
    1.29  tomb]] and live to see [[http://www.burjkhalifa.ae/][Burj Khalifa]] and they would accrue the same
    1.30  amount of experience as the MIT class of '82 did in one year.
    1.31  
    1.32 -
    1.33  * Forever in a Day
    1.34 -
    1.35  How many man-years does everyone experience in a day? There are almost
    1.36  7 billion people around today, according to [[http://www.census.gov/main/www/popclock.html][www.census.gov]]. 
    1.37  
    1.38 -#+begin_src clojure
    1.39 +#+begin_src clojure :results output :exports both
    1.40  (ns lifespan)
    1.41 -(use '[clojure.contrib [pprint :only [cl-format]]])
    1.42 +(use '[clojure [pprint :only [cl-format]]])
    1.43  
    1.44  (cl-format *out* "Man-years per day: \n ~R"
    1.45             (* 6969492979 ;; people on Earth
    1.46 @@ -65,9 +59,7 @@
    1.47  A week in the lives of the people of Earth is enough to reach back to
    1.48  the age of the dinosaurs.
    1.49  
    1.50 -
    1.51  * The Infinite Stories of Humanity
    1.52 -  
    1.53  How many man-years is the sum total of human experience? That is, how
    1.54  many man-years has every human who has ever lived experienced?  
    1.55  
    1.56 @@ -75,12 +67,13 @@
    1.57  average human lifespans through the ages found [[http://en.wikipedia.org/wiki/Life_expectancy][here]], I get the
    1.58  following:
    1.59  
    1.60 -#+begin_src clojure 
    1.61 +#+begin_src clojure :results output :exports both
    1.62  (in-ns 'lifespan)
    1.63 -(use '[clojure.contrib [def :only [defvar]]])
    1.64  
    1.65 -(defvar
    1.66 +(def
    1.67    time-periods
    1.68 +  "The time periods under question.
    1.69 +    'start' here is taken to be 50,000BC"
    1.70    [:start-8000BC
    1.71     :8000BC-1    
    1.72     :1-1200      
    1.73 @@ -90,29 +83,29 @@
    1.74     :1850-1900   
    1.75     :1900-1950   
    1.76     :1950-1995   
    1.77 -   :1995-2011]
    1.78 -  "The time periods under question.
    1.79 -    'start' here is taken to be 50,000BC")
    1.80 +   :1995-2011])
    1.81  
    1.82 -(defvar births
    1.83 +(def births
    1.84 +  "number of people who existed in the given time periods"
    1.85    (zipmap
    1.86     time-periods
    1.87     [ 1137789769  ;; \
    1.88      46025332354  ;;  | 
    1.89      26591343000  ;;  |
    1.90      12782002453  ;;  |
    1.91 -     3171931513  ;;  | -- from the video at:
    1.92 -     4046240009  ;;  | http://www.prb.org/Articles/2002/
    1.93 -     2900237856  ;;  |    HowManyPeopleHaveEverLivedonEarth.aspx
    1.94 -     3390198215  ;;  |
    1.95 -     5427305000  ;;  |
    1.96 -     2130327622]);; /
    1.97 -  "number of people who existed in the given time periods")
    1.98 +    3171931513   ;;  | -- from the video at:
    1.99 +    4046240009   ;;  | http://www.prb.org/Articles/2002/
   1.100 +    2900237856   ;;  |    HowManyPeopleHaveEverLivedonEarth.aspx
   1.101 +    3390198215   ;;  |
   1.102 +    5427305000   ;;  |
   1.103 +    2130327622]));; /
   1.104 +  
   1.105  
   1.106  ;; Confirm that the sum of people agrees with that in the video.
   1.107  (assert (= 107602707791 (reduce + (vals births))))
   1.108  
   1.109 -(defvar lifespans
   1.110 +(def lifespans
   1.111 +  "lifespans in years from birth for the various time periods"
   1.112    (zipmap
   1.113     time-periods
   1.114     [33   ;; start-8000BC  \
   1.115 @@ -127,28 +120,27 @@
   1.116      70   ;; 1995-2011-------> form:  
   1.117           ;;   http://www.prb.org/DataFinder/Topic/
   1.118           ;;      Rankings.aspx?ind=6&loc=241
   1.119 -    ])
   1.120 -  "lifespans in years from birth for the various time periods")
   1.121 +    ]))
   1.122  
   1.123  
   1.124 -
   1.125 -
   1.126 +;;; ----------------------------------------
   1.127 +;;;         And now for the result!
   1.128  
   1.129  ;; This section is just here to make the result look pretty.
   1.130  (dorun
   1.131   (map println
   1.132 -      (clojure.contrib.string/split
   1.133 -       #"," 
   1.134 +      (clojure.string/split
   1.135         (cl-format 
   1.136          nil "years of human experience: \n ~R years"
   1.137 -;; Multiply each time-period's total number of people
   1.138 -;; by those people's average lifespan in years to get
   1.139 -;; the total number of man-years experienced during
   1.140 -;; that period, then add them together.
   1.141 +        ;; Multiply each time-period's total number of people
   1.142 +        ;;  by those peoples' average lifespan in years to get
   1.143 +        ;;  the total number of man-years experienced during
   1.144 +        ;;  that period, then add them together.
   1.145          (reduce + 
   1.146                  (map *
   1.147                       (map births time-periods)
   1.148 -                     (map lifespans time-periods)))))))
   1.149 +                     (map lifespans time-periods))))
   1.150 +       #",")))
   1.151  
   1.152  #+end_src
   1.153  
   1.154 @@ -160,7 +152,5 @@
   1.155  :  five hundred ninety-five thousand
   1.156  :  one hundred eighty-one years
   1.157  
   1.158 -
   1.159 -
   1.160 -Humans have already collectively lived far longer than the age of the
   1.161 -universe.
   1.162 +Humans have already collectively lived about two-hundred times longer
   1.163 +than the age of the universe.