Bits of Learning

Learning sometimes happens in big jumps, but mostly in little tiny steps. I share my baby steps of learning here, mostly on topics around programming, programming languages, software engineering, and computing in general. But occasionally, even on other disciplines of engineering or even science. I mostly learn through examples and doing. And this place is a logbook of my experiences in learning something. You may find several things interesting here: little cute snippets of (hopefully useful) code, a bit of backing theory, and a lot of gyan on how learning can be so much fun.

Wednesday, December 02, 2009

Code in the blog articles

This is where you could get your code changed into HTML. However, there seem to
be many glitches. For one, any debugging has to be one-shot. No incremental
debugging will work. The code is generated in one-shot. Hence, any modifications
done to the generated code will lost when it's regenerated.
Moreover, I can see that it doesn't always render code properly as you would expect.
- Wordwrap stops working for the rest of the text on the article. Here, in the current
 text, I am pressing 'enter' to start a new line.
Any suggestions?


1 #include "counter.h"
 2
 3 Counter::Counter (vector <unsigned int> aBases)
 4   : m_Bases (aBases)
 5 {
 6  for (unsigned int i = 0; i < m_Bases.size (); i++)
 7  {
 8   m_Count.push_back (0);
 9  }
10 }
11
12 void
13 Counter::increment (const unsigned int n)
14 {
15  if (m_Count[n] < (m_Bases[n] - 1))
16  {
17   m_Count[n]++;
18  }
19  else
20  {
21   m_Count[n] = 0;
22   if (n < m_Bases.size() - 1)
23   {
24    increment (n + 1);
25   }
26  }
27 }
28
29 void
30 Counter::increment ()
31 {
32   increment (0);
33 }
34
35 vector <unsigned int>
36 Counter::getCount ()
37 {
38   return m_Count;
39 }
40
41 void
42 Counter::print (ostream & fout)
43 {
44   for (unsigned int i = 0; i < m_Count.size (); i++)
45   {
46     fout << m_Count[i] << '\t';
47   }
48   fout << endl;
49 }
50
51 unsigned int
52 Counter::getNumberOfCounts ()
53 {
54   unsigned int Product = 1;
55   for (unsigned int i = 0; i < m_Bases.size (); i++)
56   {
57     Product *= m_Bases[i];
58   }
59
60   return Product;
61 }
62
63 void
64 Counter::reset ()
65 {
66   for (unsigned int i = 0; i < m_Count.size (); i++)
67   {
68     m_Count[i] = 0;
69   }
70 }



Reference:

Using aspell

Here's the aspell command for spell-checking latex file:
aspell --mode=tex --lang=en_GB -c filename