Tuesday, January 8, 2013

Cost of crime

Baba says that "There was no avatar in 'Satyug' as all were honest and truthful. In 'Tretayug', the world was divided into two parts : good and evil. Lord Ram travelled to a distant part of the world to destroy the demons of the time. By the time 'Dwaperyug' started, the good and evil were living together and therefore Lord Krishna had to segregate them in two groups and destroyed the 'Kaurvas' group. In 'Kalyug', both the attributes have gone inside the individuals. A man is both good and bad i.e. the person is good for himself and bad for others. So you will have to kill all to kill the evil. Therefore, the only path left is - 'Updeasha' i..e.counselling" 

The evil part has dominated so much that now a person is not afraid of committing crime but only evaluates its cost before its execution. For instance, I asked a fellow passenger "why do you travel without ticket? Are you not afraid?. He said "My calculation is simple - Travel without ticket and save Rs. 1500/= per month. Pay the fine  of Rs. 200/=  as and when you are caught, the probability of which is only once in a month. So the saving is Rs. 1300/= per month. The fellow is impertinent and unashamed.

When I was studying at UOR, Roorkee, I read a news item in the local paper. The news was that - At Purkaji, a bus was looted in the night. The decoits snatched the costly items and jewellery  from the passengers and alighted the bus. After sometimes, one of them came back and  distributed the looted items back to their owners. After the distribution he kind of requested the passengers not to report the matter. After inquiry, he replied, "The cost of the looted material is far less than the amount they have promised to pay  for this crime". So the cost of crime was more than the profit.

The cost of jumping of red light at crossing is just Rs. 400/=, and that of ramming your car into others vehicle is only abuses, and if it happens in the parking area it is absolutely free i.e. not even the abuses. Stalking a girl,  costs nothing but harassment to the prey by the mugger.
In general the rape incidences are not reported and if a brave one reports the incidence, the conviction rate is very poor. In fact, there is no witness in these cases because the only witness is the victim herself. For the culprit the cost is minimal but the victim suffers both physically and mentally throughout her life.

The irony is that the world passes by and nobody bothers for nobody.



The recent incidence of rape in the bus has jolted Delhi like never before. Damini's dead body is being brought back tonight from Singapore. May be tomorrow morning she will be hurriedly cremated. I hope Delhi does not go back to its routine. Let us join hands together to maintain the pressure on these dumb and deaf politicians lest they as usual brush this ghastly act under the carpet and move on. Not only the culprits be punished in severest way possible but effective laws must be enacted so that the cost of committing the crime becomes prohibitive for the sinners.

A Delhiet

Thought to ponder....

Do not think of tomorrow and do not think of yesterday. Live in the present, live in the moment, and thus live in the existence. Then you will be happy.

Bhagwan Sri Satya Sai Baba


Wednesday, November 7, 2012

Object Oriented Programming



The programming process has evolved through many phases. The journey started with programmers who would write programs which some how worked without giving any importance to readability of the program. The languages like FORTRAN and BASIC neither enforced any discipline nor were the programmers trained to write user centric programs. The result was unstructured understandable programs susceptible to bugs acting as time bombs like Y2K problem. The major problem was that the programs were not maintainable.

The structured programming techniques did enforce some discipline on the programmers by way of shunning the use of ‘goto’ statements and encouraging the programmers to use ‘easy to read and difficult to write’ style of code statements i.e. choosing long and meaningful names for the variables, functions, procedures, modules etc. The major emphasis was to use block structures in the program. For instance any code enclosed between a pair of curly braces or the pair of begin – end was termed as a block. Pascal and ‘C’ supported blocks like compound statements, loops, functions, procedures, files etc. This technique worked good for hard core programmers who were able to write large and complex programs using structured programming techniques. Unix operating system was written using ‘C’. Then there were always few hard core programmers available in the market.

Nevertheless, the importance was given to procedures as to how to solve the problem at hand. The algorithm development consumed more time of the developer and least importance was given to the data. So, a program was virtually a collection of decomposed components i.e. interacting functions or modules exchanging data and data structures among them. Such data, especially the global data, was vulnerable to inadvertent corruption by the fellow programmers.

The remedy to the above mentioned drawbacks is that we put more emphasis on data and try to create reusable software components. The reusable components can further be combined to get bigger and more powerful software.

For example, in our day to day life we compose bigger objects from smaller objects. The desktop computer is made up many smaller objects like: mother board, RAM, HDD, SMPS, mouse, keyboard etc. We use the services offered by these objects and never bother as to how they work or who made them?

When we look around then we find that we are surrounded by nothing but objects only. You & I, books, pen, paper, laptop etc. are all objects. In fact any real world program has to be a collection objects. A program about a University would involve objects like students, professors, clerks, class rooms, books, chalk, mark sheets etc. Then why not write programs using objects which would be very natural way of creating useful software comprising of interacting objects.

Object Oriented Programming (OOP) is a paradigm shift in programming which defines, creates, and manipulates objects to develop a reusable software. C++ is an imperative language developed to support OOP components and features like: classes, objects, abstraction, encapsulation, inheritance, polymorphism etc.

A. K. Sharma

Thought to ponder...

True education is that destroys narrow-mindedness,
develops equality and ultimately leads to world peace.

Bhagwan Sri Satya Sai Baba

Sunday, November 4, 2012

बस ऐसे ही


अरनब गोस्वामी  की  इंतज़ार लंबी लगती है 
                  बहरे राजनितीगों पर बहस और भी लंबी लगती है 
 लंबी  लंबी बातें सोचता   हुं 
                  खुली आँखों से ये रात बहुत लंबी  लगती है

सुबह  सुबह की भाग  दौड़  लंबी लगती है
                  दिन  के 9 से 5 की  दूरी और भी लंबी लगती है
 लंबी  लंबी क्लास लेता हुं 
                  सियासत से भरी ये नोकरी बहुत लंबी लगती है

तन्खवाह की इन्तेजार लंबी  लगती है
                 इन्क्रीमेंट की पावत और भी लंबी  लगती है
 लंबी  लंबी  डी ए की किश्त लगती हैं
                   मुझे तो ये महेंगाई  बहुत लंबी लगती है

क्रासिंग की बत्ती लंबी लगती है
                   हर  सड़क और भी लंबी लगती है
 लंबी  लंबी यात्राऐं करता  हूँ
                   मुझे तो ये जिंदगी बहुत लंबी लगती है

अशोक

Thought to ponder...

Your very speech should be soft. Not only soft but also truthful.

Bhagwan Sri Satya Sai Baba

Friday, October 26, 2012

Renaissance - YMCA University News letter

YMCA University of Sc. & Tech. is coming out with 2nd edition of its news letter called "Renaissance" It is edited by Prof. Divya Jyoti Singh. Its link is given below:

www.renaissanceymcaust.blogspot.com

Monday, October 22, 2012

Some Important PROLOG Predicates

Some popular and important PROLOG predicates are given below for the readers. These were discussed in a class of Artificial Intelligence.



1. /*Sum of a list of numbers*/
domains
list=integer*
predicates
sum(list,integer)
clauses
sum([],0).
sum([H|T],R):-sum(T,S),R=S+H.

2. /*Compare 2 Lists of numbers*/
domains
list=integer*
predicates
ifEqual(list,list)
clauses
ifEqual([],[]).
ifEqual([H1|T1],[H2|T2]):-H1=H2,ifEqual(T1,T2).

3. /*Find the last element of a list*/
domains
list=integer*
predicates
last(list,integer)
clauses
last([X],X).
last([H|T],L):-last(T,L).

4. /*delete last the last element of a list */
domains
list=integer*
predicates
deleteLast(list,list)
clauses
deleteLast([X],[]).
deleteLast([H|T],[H|NT]):-deleteLast(T,NT).


5. /*Separate positive and negative numbers from a list and put them in two separate lists*/
domains
list=integer*
predicates
separate(list,list,list)
clauses
separate([],[],[]).
separate([H|T],[H|PL],NL):-H>0,separate(T,PL,NL).
separate([H|T],PL,[H|NL]):-H<0 br="br" separate="separate">
6. /*Partition a list into two lists lessX and GreatX which contains elements less than X and greater than X respectively*/
domains
list=integer*
predicates
partition(integer,list,list,list)
clauses
partition(X,[],[],[]).
partition(X,[H|T],[H|LX],GX):-H<=X,partition(X,T,LX,GX).
partition(X,[H|T],LX,[H|GX]):-H>X,partition(X,T,LX,GX).

7. /*Find the smallest in a given list*/
domains
list=integer*
predicates
smallest(list,integer)
clauses
smallest([X],X).
smallest([H|T],X):-smallest(T,X),X smallest([H|T],H):-smallest(T,X),H
8. /*Find wheather a given number X is a member of a list or not */
domains
list=integer*
predicates
member(integer,list)
clauses
member(X,[X]).
member(X,[H|T]):-X=H.
member(X,[H|T]):-X<>H,member(X,T).

9. /*Create union of two given lists*/
domains
list=integer*
predicates
member(integer,list)
union(list,list,list)
clauses
member(X,[X]).
member(X,[H|T]):-X=H.
member(X,[H|T]):-X<>H,member(X,T).
union([],L2,L2).
union(L1,[],L1).
union([H|T],L2,[H|NL]):-NOT(member(H,L2)),union(T,L2,NL).
union([H|T],L2,NL):-member(H,L2),union(T,L2,NL).

10. /* Create intersection of two given lists*/
domains
list=integer*
predicates
member(integer,list)
intersection(list,list,list)
clauses
member(X,[X]).
member(X,[H|T]):-X=H.
member(X,[H|T]):-X<>H,member(X,T).
intersection([],L2,[]).
intersection(L1,[],[]).
intersection([H|T],L2,NL):-NOT(member(H,L2)),intersection(T,L2,NL).
intersection([H|T],L2,[H|NL]):-member(H,L2),intersection(T,L2,NL).

11. /*Give ListA minus ListB*/
domains
list=integer*
predicates
member(integer,list)
AminusB(list,list,list)
clauses
member(X,[X]).
member(X,[H|T]):-X=H.
member(X,[H|T]):-X<>H,member(X,T).
AminusB([],L2,[]).
AminusB(L1,[],L1).
AminusB([H|T],L2,[H|NL]):-NOT(member(H,L2)),AminusB(T,L2,NL).
AminusB([H|T],L2,NL):-member(H,L2),AminusB(T,L2,NL).

12. /*concatenate two lists */
domains
list=integer*
predicates
concatenation(list,list,list)
clauses
concatenation([],L2,L2).
concatenation(L1,[],L1).
concatenation([H|T],L2,[H|NL]):-concatenation(T,L2,NL).

13. /*replace X by Y of all occurrences of X in a list*/
domains
list=integer*
predicates
replace(integer,integer,list,list)
clauses
replace(X,Y,[],[]).
replace(X,Y,[H|T],[Y|NL]):-H=X,replace(X,Y,T,NL).
replace(X,Y,[H|T],[H|NL]):-H<>X,replace(X,Y,T,NL).

14. /*Reverse a given list */
domains
list=integer*
predicates
Reverse(list,list)
append(list,list,list)
clauses
append([],L2,L2).
append(L1,[],L1).
append([H|T],L2,[H|NL]):-append(T,L2,NL).
Reverse([],[]).
Reverse([H|T],NL):-Reverse(T,RL),append(RL,[H],NL).

15. /*Determine whether a list is palindrome or not*/
domains
list=integer*
predicates
palindrome(list)
last(list,integer)
deleteLast(list,list)
clauses
last([X],X).
last([H|T],L):-last(T,L).
deleteLast([X],[]).
deleteLast([H|T],[H|NT]):-deleteLast(T,NT).
palindrome([]).
palindrome([X]).
palindrome([H|T]):-last(T,L),H=L,deleteLast(T,NT),palindrome(NT).

16. /*merge two co sequential lists into a third list*/
domains
list=integer*
predicates
merge(list,list,list)
clauses
merge([],L2,L2).
merge(L1,[],L1).
merge([H1|T1],[H2|T2],[H1|NL]):-H1<=H2,merge(T1,[H2|T2],NL).
merge([H1|T1],[H2|T2],[H2|NL]):-H2


17. / *Quick sort a given list of numbers*/

domains
list=integer*
predicates
partition(integer,list,list,list)
append(list,list,list)
quickSort(list,list)
clauses
partition(X,[],[],[]).
partition(X,[H|T],[H|LX],GX):-H<=X,partition(X,T,LX,GX).
partition(X,[H|T],LX,[H|GX]):-H>X,partition(X,T,LX,GX).
append(L1,[],L1).
append([],L2,L2).
append([H|T],L2,[H|NT]):-append(T,L2,NT).
quickSort([],[]).
quickSort([H|T],FL):-partition(H,T,LH,GH),quickSort(LH,LSL),quickSort(GH,GSL),append(LSL,[H|GSL],FL).


18. /*merge sort a given list of numbers*/
domains
list=integer*
predicates
merge(list,list,list)
divide(list,list,list)
append(list,list,list)
mergeSort(list,list)
last(list,integer)
deleteLast(list,list)
clauses
last([X],X).
last([H|T],L):-last(T,L).
deleteLast([X],[]).
deleteLast([H|T],[H|NT]):-deleteLast(T,NT).
divide([],[],[]).
divide([H|T],[H|NT1],NL):-last([H|T],L),deleteLast(T,NT),divide(NT,NT1,NT2),append(NT2,[L],NL).
merge([],L2,L2).
merge(L1,[],L1).
merge([H1|T1],[H2|T2],[H1|NL]):-H1<=H2,merge(T1,[H2|T2],NL).
merge([H1|T1],[H2|T2],[H2|NL]):-H2


append(L1,[],L1).
append([],L2,L2).
append([H|T],L2,[H|NT]):-append(T,L2,NT).
mergeSort([],[]).
mergeSort([H],[H]).
mergeSort(L,FL):-d(L,L1,L2),mergeSort(L1,SL1),mergeSort(L2,SL2),merge(SL1,SL2,FL).

19. /* Sort a given list of numbers using selection sort*/
domains
list=integer*
predicates
selectionSort(list,list)
smallest(list,integer)
replace(integer,integer,list,list)
clauses
smallest([X],X).
smallest([H|T],X):-smallest(T,X),X smallest([H|T],H):-smallest(T,X),H replace(X,Y,[],[]).
replace(X,Y,[H|T],[Y|T]):-H=X.
replace(X,Y,[H|T],[H|NT]):-H<>X,replace(X,Y,T,NT).
selectionSort([],[]).
selectionSort([H],[H]).
selectionSort([H|T],[S|SL]):-smallest(T,S),H>S,replace(S,H,T,RL),selectionSort(RL,SL).
selectionSort([H|T],[H|SL]):-smallest(T,S),S>H,selectionSort(T,SL).

20. /* Sort a given list of numbers using insertion sort*/
domains
list=integer*
predicates
insert(integer,list,list)
append(list,list,list)
insertionSort(list,list)
clauses
insert(X,[],[X]).
insert(X,[H|T],NL):-X<=H,append([X],[H|T],NL).
insert(X,[H|T],[H|NT]):-X>H,insert(X,T,NT).
append(L1,[],L1).
append([],L2,L2).
append([H|T],L2,[H|NT]):-append(T,L2,NT).
insertionSort([],[]).
insertionSort([H|T],SL):-insertionSort(T,NT),insert(H,NT,SL).




Thought to ponder....

The sanctification of the five senses is the way to truth.

Bhagwan Sri Satya Sai Baba 

Monday, September 3, 2012

The Programming Paradigms


The programming process has evolved through many phases. The journey started with programmers who would write programs which some how worked without giving any importance to readability of the program. The languages like FORTRAN and BASIC neither enforced any discipline nor were the programmers trained to write user centric programs. The result was unstructured understandable programs susceptible to bugs acting as time bombs like Y2K problem. The major problem was that the programs were not maintainable.

The structured programming techniques did enforce some discipline on the programmers by way of shunning the use of ‘goto’ statements and encouraging the programmers to use ‘easy to read and difficult to write’ style of code statements i.e. choosing long and meaningful names for the variables, functions, procedures, modules etc. The major emphasis was to use block structures in the program. For instance any code enclosed between a pair of curly braces or the pair of begin – end was termed as a block. Pascal and ‘C’ supported blocks like compound statements, loops, functions, procedures, files etc. This technique worked good for hard core programmers who were able to write large and complex programs using structured programming techniques. Unix operating system was written using ‘C’. Then there were always few hard core programmers available in the market.

Nevertheless, the importance was given to procedures as to how to solve the problem at hand. The algorithm development consumed more time of the developer and least importance was given to the data. So, a program was virtually a collection of decomposed components i.e. interacting functions or modules exchanging data and data structures among them. Such data, especially the global data, was vulnerable to inadvertent corruption by the fellow programmers.

The remedy to the above mentioned drawbacks is that we put more emphasis on data and try to create reusable software components. The reusable components can further be combined to get bigger and more powerful software.

For example, in our day to day life we compose bigger objects from smaller objects. The desktop computer is made up many smaller objects like: mother board, RAM, HDD, SMPS, mouse, keyboard etc. We use the services offered by these objects and never bother as to how they work or who made them?

When we look around then we find that we are surrounded by nothing but objects only. You & I, books, pen, paper, laptop etc. are all objects. In fact any real world program has to be a collection objects. A program about a University would involve objects like students, professors, clerks, class rooms, books, chalk, mark sheets etc. Then why not write programs using objects which would be very natural way of creating useful software comprising of interacting objects.

Object Oriented Programming (OOP) is a paradigm shift in programming which defines, creates, and manipulates objects to develop a reusable software. C++ is an imperative language developed to support OOP components and features like: classes, objects, abstraction, encapsulation, inheritance, polymorphism etc.

A. K. Sharma

Thought to ponder...

We should realize that man has not only a mind which conceives thoughts,
but also a heart which can put them into practice

Bhagwan Sri Satya Sai baba