www.delorie.com/gnu/docs/calc/calc_71.html   search  
 
Buy the book!


GNU Emacs Calc 2.02 Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.7.37 Types Tutorial Exercise 5

Let's suppose it's January 14, 1991. The easiest thing to do is to keep trying 13ths of months until Calc reports a Friday. We can do this by manually entering dates, or by using t I:

 
1:  <Wed Feb 13, 1991>    1:  <Wed Mar 13, 1991>   1:  <Sat Apr 13, 1991>
    .                         .                        .

    ' <2/13> RET       DEL    ' <3/13> RET             t I

(Calc assumes the current year if you don't say otherwise.)

This is getting tedious--we can keep advancing the date by typing t I over and over again, but let's automate the job by using vector mapping. The t I command actually takes a second "how-many-months" argument, which defaults to one. This argument is exactly what we want to map over:

 
2:  <Sat Apr 13, 1991>     1:  [<Mon May 13, 1991>, <Thu Jun 13, 1991>,
1:  [1, 2, 3, 4, 5, 6]          <Sat Jul 13, 1991>, <Tue Aug 13, 1991>,
    .                           <Fri Sep 13, 1991>, <Sun Oct 13, 1991>]
                               .

    v x 6 RET                  V M t I

Et voila, September 13, 1991 is a Friday.

 
1:  242
    .

' <sep 13> - <jan 14> RET

And the answer to our original question: 242 days to go.


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003