Showing posts with label tip. Show all posts
Showing posts with label tip. Show all posts

Monday, July 9, 2012

Tip: traversing arrays in C-Shell

Below I have described two methods to traverse arrays in C-Shell - one uses the foreach loop and other while loop.
In both cases, the important thing to note is that array index in C-shell starts with '1' instead of '0' as in most programming languages, like C, C++, Java, Perl.


set a = (1 2 3 4)
set b = (5 6 7 8)
 

Method 1 - using the foreach loop, iterating on one array as the foreach index, and the accessing the other array inside the loop body using the index operator "[]"
set i = 1
foreach x ( `echo $a` )
  echo "x = $x b = $b[$i]"
  @ i = $i + 1
end
 

Output: 
x = 1 b = 5
x = 2 b = 6
x = 3 b = 7
x = 4 b = 8

Method 2 - using the while loop. Iterating on the size of array and accessing both the arrays inside the loop body using the index operator "[]"


set i = 1
while ($i <= 4)
  echo "a = $a[$i] b = $b[$i]"
  @ i = $i + 1
end
 

Output:
a = 1 b = 5
a = 2 b = 6
a = 3 b = 7
a = 4 b = 8




Wednesday, November 2, 2011

Accomplishment is important

Not losing focus is the key. It’s about switching your focus from quantity to quality, and making sure that you use your productivity for a greater good: reaching your goals. Wonderful insights at http://workawesome.com/productivity/being-productive/

Tips for remembering and organizing ideas

Use a pocket recorder and record the thoughts. Musicians do it all the time.

Tuesday, December 15, 2009

Using Outlook's After Sending rules

Found this interesting post to configure Outlook to complete the thread view. By default the thread does not show your mails. So in effect it has a lot of information missing.

Using Outlook's After Sending rules

Wednesday, July 11, 2007

Sleep Your Way to Better Fitness - lifehack.org

Recently read this interesting article on fitnees at lifehack.org: Sleep Your Way to Better Fitness - lifehack.org
This makes an interesting read for especially a person like me who is not into a fitness program, regular or irregular, but I do give a lot of stress on sleeping and eating right. Maybe that is the reason why I have been able to maintain my weight at nearly the same levels for the past 5 years. I think a weight of around 66-70 kgs is good for a body of 5' 5".

But that is not to say that exercise is not to be done. At times I do feel that some exercise is required for the body so that the muscles do not become hard.