// cash3.exc // Used and explained in // "How to Document a Spreadsheet: an // Exercise with Cash-Flow and Loans", // http://www.j-paine.org/dobbs/loans.html . type time_range = 1:12. table time : time_range -> date. time[ t ] = date( 2009, t, 1 ). table initial_cash : -> currency. table expenses_during_period : time_range -> currency. table total_cash_at_start_of_period : time_range -> currency. table total_cash_at_end_of_period : time_range -> currency. total_cash_at_start_of_period[ 1 ] = initial_cash[]. total_cash_at_start_of_period[ t>1 ] = total_cash_at_end_of_period[ t-1 ]. total_cash_at_end_of_period[ t ] = total_cash_at_start_of_period[ t ] - expenses_during_period[ t ] + actually_borrowed_during_period[ t ]. table want_to_borrow_during_period : time_range -> currency. table actually_borrowed_during_period : time_range -> currency. layout( 'Time' , rows( heading , row( time ) ) ). layout( 'Cash' , rows( heading , row( copy(time) , expenses_during_period , initial_cash, total_cash_at_start_of_period, total_cash_at_end_of_period , want_to_borrow_during_period, actually_borrowed_during_period, first_that_can_supply_wants ) ) ).