<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-1369853434158175571</atom:id><lastBuildDate>Fri, 01 Nov 2024 13:00:35 +0000</lastBuildDate><category>common lisp</category><category>Programming</category><category>SLIME</category><category>Arc</category><category>Diophantine Equation</category><category>Elisp</category><category>JavaScript</category><category>Lambda Calculus</category><category>Mathematics</category><category>SBCL</category><category>Windows</category><category>general</category><category>macro</category><category>mvn</category><category>opensocial</category><category>personal</category><category>shindig</category><title>Samik&#39;s Restless Rants</title><description>Randomization of thoughts and programming</description><link>http://lispsamik.blogspot.com/</link><managingEditor>noreply@blogger.com (samik chakraborty)</managingEditor><generator>Blogger</generator><openSearch:totalResults>35</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-4225931704264590349</guid><pubDate>Fri, 04 May 2012 05:26:00 +0000</pubDate><atom:updated>2012-05-03T22:27:29.903-07:00</atom:updated><title>Code aging:Can a computer program age?</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Aging is a life phenomenon. A life always age from birth to the
day it ends. A computer program also dies; we in software industry like to
replace a piece of code with completely a new one. We do it by rewriting the
software. Here is what happens for software:&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;Birth:&lt;/b&gt; We write the software with a purpose.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;Growth:&lt;/b&gt; We find some bugs in the behavior of the software;
we fix the bug. We do it again and again.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
One fine day we feel the software is bulky to fix bugs or
the purpose has grown to such an extent that we need to rewrite the software.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;Death:&lt;/b&gt; We rewrite the software and replace the old one with
the new.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
How a code age? Here is how it happens (IMHO):&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Software gets fat by added code all the time. We add code to
fix bugs, to add feature etc.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Code becomes complex. As in life, with time, code also
becomes complex by code complexity (like if –else –then). It so happens, that
code becomes complex by overloaded methods, multiple entry points, more than one
way to do one thing, etc. With time it becomes hard for the developer to
understand the code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
The code can also age due to library it uses has aged and
being replaced with newer one. Even the programming language may have morphed. Like
in case of Java, concurrency, generics, etc. are making some code look old.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
The other indicator of old code is its interfaces and deprecation.
If an interface is filled with same methods with just parameter or return type
mismatch (overloads), I suspect the code has aged.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
That’s all that I can think. If you know any others please
share.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
You may also like: &lt;a href=&quot;http://lispsamik.blogspot.in/2011/02/why-is-it-harder-to-read-code-than.html&quot;&gt;Why is it harder to read the code thanwriting it&lt;/a&gt;.&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;</description><link>http://lispsamik.blogspot.com/2012/05/code-agingcan-computer-program-age.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-3303061988454062439</guid><pubDate>Wed, 25 Apr 2012 15:49:00 +0000</pubDate><atom:updated>2012-04-25T08:49:32.610-07:00</atom:updated><title>Why I Code or note to my first love?</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
I am a programmer. I code every day. Why I code? Here is my answer.&lt;br /&gt;
&lt;br /&gt;
Coding is an activity where I can write a program and computer will execute it. It started with very basic use of computer. I gave a command: date and it printed out the date. It was amazing. I was four years old and I started thinking how it came to know today’s date. Some years fast forward, I got into the computer lab of my school (no computer was not a subject for a 12 year old in my school, it was just luck that I was able to go inside my school computer lab), a senior was coding in Basic. I asked him what he is doing. He showed me what he was doing. I said to him can I do a simple multiplication? He said why not so I wrote (under his instruction) a program that multiplied two numbers. My first love started.&lt;br /&gt;
&lt;br /&gt;
The feeling was something like a master and slave. I am your master and commander you follow my orders. This is my first understanding of coding. I understood that if I code it right it will do what I want it do. So computer gave me my first feeling of being master of something. I was not so popular among kids so I had time to play with school computer. It gave me opportunity to learn how to tell computers what to do. So then I coded so I can tell my pet what to do, and that was the reason I used to code that time.&lt;br /&gt;
&lt;br /&gt;
Late in teenage, I realized that people around me were getting their friends. I mean someone special in their life. They used to spend a lot of time with them, talk to them. College was full of people who were dating. I was not even a cool guy in college. So I needed something to hold on. In our college lab we used get access to computers during college hours. So I started to show up in lab in the morning and screw all classes. I used to code. I used to code in C. I felt like I am at last in peace with the world. &amp;nbsp;I felt like I am in conversation with computer. So now I started coding to communicate to the computer as a friend. A friend who will be with me, always. My first love.&lt;br /&gt;
&lt;br /&gt;
Next I joined a company as a programmer. Where I saw and met a lot of programmers in the company. They are all amazing people. I started working on code. I came to know that you do not write code from scratch you take others’ code and maintain them. I used to see code comments with bug ids, I used to go to the bug tracker pull up those bug ids and saw the names of people who worked on them. The code was talking to me, some of them were so clear as if I have coded them. Some of them were a bit awkward, hard to understand. Then I realized that I was talking to them, in space time continuum I was there sitting with them in conversation with other programmers. I was debugging the code – also trying to map their mind for a sorting logic, searching technique or a trivial account money transfer between two currencies. In all this I understood that why it is a programming language. The value of code readability, the value of lambda calculi or Turing Machine, all of that I came together so that we programmers can talk a time apart. Computer became a paper, programming be the language. My first love metamorphosed to me again.&lt;br /&gt;
&lt;br /&gt;
So why I code my love, is it because I love to code or is it I want to communicate to some unknown programmer in the future. I code because I love you. I want to remain with you and discover you in my old age that I have reached a position where I can say, I know why I loved you for so long. My guess you will guide me to my nirvana. I will rest then at peace.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;</description><link>http://lispsamik.blogspot.com/2012/04/why-i-code-or-note-to-my-first-love.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-3082201109226714126</guid><pubDate>Tue, 27 Mar 2012 05:06:00 +0000</pubDate><atom:updated>2012-03-26T22:34:34.364-07:00</atom:updated><title>Needed a better Twitter so we made one for ourself</title><description>Yeah! We are out of our mind, or may be not. We felt a lot of things can be improved in twitter or micro-blogging for that matter. So what all things that we wanted to improve in a micro-blogging service:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Posting:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Give some more characters darn it. Have you ever felt like that you just need that extra 10,20 or so characters in your tweet. If so read on.&lt;br /&gt;&lt;br /&gt;Why the hell I need to go to another service to shorten my URL. That&#39;s pretty basic. A micro-blogging site should do it automatically for you.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Following:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Why not follow my interests - in a wholesome way. So following people gives me a lot of sh*t. I have to wait for my meat. I will jump on to a conversation, if I find it interesting. One more thing about interest is it&#39;s not always people but tags. Some tags are interesting enough to follow and get a stream in.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Tagging:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This brings me to tagging. Tags are meta data not data. Please don&#39;t clutter my post with #FOO and #BAR. I should be able to add tags separately.&lt;br /&gt;&lt;br /&gt;Can you help with suggesting some tags for a link. So we wanted an auto-tagging system, it need not to be perfect (as long as I can remove suggested tags which does not make sense), but give me something.&lt;br /&gt;&lt;br /&gt;All this can be done. We need to do it for us. So we did it. If you are interested take a look at: &lt;a href=&quot;http://www.scoopspot.com/&quot;&gt;ScoopSpot&lt;/a&gt;.</description><link>http://lispsamik.blogspot.com/2012/03/better-twitter-are-you-out-of-your-mind.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-6806985270001382062</guid><pubDate>Sat, 24 Mar 2012 03:33:00 +0000</pubDate><atom:updated>2012-03-23T20:48:52.593-07:00</atom:updated><title>How we made a social news service with machine learning from scratch</title><description>&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;How do &lt;span style=&quot;font-size: 100%; &quot;&gt;you get to n&lt;/span&gt;&lt;span style=&quot;font-size: 100%; &quot;&gt;ews which interests you in Hacker News or TechCrunch or The Next Web or the ReadWriteWeb? I mean when you go to a news website do you read all articles or do you scan the arti&lt;/span&gt;&lt;span style=&quot;font-size: 100%; &quot;&gt;cle titles and try to guess which ones to read based on your interests?&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;In my &lt;span style=&quot;font-size: 100%; &quot;&gt;case I h&lt;/span&gt;&lt;span style=&quot;font-size: 100%; &quot;&gt;ave noticed that I am looking for the news which interests me. Like startup news, Java or Ruby programming language news. So it beg the question can I build a system which scans through all the news and then classifies, indexes all relevant terms and serve to me so that I can get a stream of news which I would like to know and read about.&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;So we&lt;span style=&quot;font-size: 100%; &quot;&gt;(my frien&lt;/span&gt;&lt;span style=&quot;font-size: 100%; &quot;&gt;d and I) started building a system which when given a website link does the following:&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt;margin-left:10px; &quot;&gt;       &lt;/span&gt;&lt;!--[endif]--&gt;It tries to get the relevant content from the page. &lt;/p&gt;  &lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; &quot;&gt;       &lt;/span&gt;&lt;!--[endif]--&gt;It uses natural language processing to understand a bunch of things like: sentences, parts of speech etc. We score the word relevance in the article.&lt;/p&gt;  &lt;p class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;  &quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; &quot;&gt;       &lt;/span&gt;&lt;!--[endif]--&gt;We also do classification and clustering with bunch of statistical methods of the article to find out which category an article belongs to. Like is it a technical or scientific or law related article.&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;Once &lt;span style=&quot;font-size: 100%; &quot;&gt;we got the meat of the document we tag it with the terms that we have identified with the above steps.&lt;/span&gt;&lt;span style=&quot;font-size: 100%; &quot;&gt;Now w&lt;/span&gt;&lt;span style=&quot;font-size: 100%; &quot;&gt;e were faced with the challenge that how can we make it available to us. We needed a web site which will allow us to see the content in stream. We should also be able to customize the stream to user’s choice. So we thought of creating a micro-blogging site, after all, we just needed to put a post with article title, URL and the tags. Here is how a post looks today in the stream.&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 100%; &quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEif-ecCBfTs5aCrHrRI3mnsddB3nBvHOueqy1FcRmNgftqYNSIuaSPLWcqwzJ3zfg4_vqrAydwk-H0a_74Djs_ueEKV3MPei330egpLYg1IyadsXzwaKPmdEzfXk227HAdIGk_9ZheFRyA/s882/pic1.jpg&quot; border=&quot;0&quot; alt=&quot;&quot; style=&quot;display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; cursor: pointer; width: 482px; height: 53px; &quot; /&gt;&lt;div style=&quot;text-align: left; &quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 100%; &quot;&gt;If you would like to see a full stream:&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 100%; &quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 100%; &quot;&gt;&lt;span&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwBVdGTzgO21z8KCjRGb8GnYZKQH_sZdS9mR7cCFk4YgdKmgkZOhQ-dEzdJXrMjQk8v5WCgynejkgBk_FJ5dTd-Q2a90Xjb_TJ0kDuIdWm_XWAJBKjHSBYrnGkic_PisJhcTELpm4iP9Y/s909/pic2.jpg&quot; border=&quot;0&quot; alt=&quot;&quot; style=&quot;color: rgb(0, 0, 238); text-decoration: underline; display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 459px; height: 241px; &quot; /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;span style=&quot;font-size: 100%; &quot;&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 100%; &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;As you can see here that I am seeing news with startup and java. As I am following news related to java and startup.&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;We noticed that we need more character support than 140 character of Twitter so we increased the character limit to 300. One more choice that we have made is adding tag separately from the actual post. This allowed us to add as many tags as we want. We feel tags are more like meta information so one should not be limited with hash tags.&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;Once we have such a system, we needed a way to get the latest news from Hacker News, TechCrunch, TheNextWeb etc. RSS feed came to our rescue. These websites provides RSS feed which we read periodically. We created an account called news in ScoopSpot which will do the posting in our micro-blogging site. If you would like to see news in action, visit: http://news.scoopspot.com/.&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;So now if a user comes to our web site and post something with an article link we are now able to auto tag it.&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;Here are some links to tag based pages:&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;Ruby: &lt;a href=&quot;http://www.scoopspot.com/Ruby&quot;&gt;http://www.scoopspot.com/Ruby&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;Startup: &lt;a href=&quot;http://www.scoopspot.com/Startups&quot;&gt;http://www.scoopspot.com/Startups&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;Steve Jobs: &lt;a href=&quot;http://www.scoopspot.com/Steve_Jobs&quot;&gt;http://www.scoopspot.com/Steve_Jobs&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;If you are interested to try it out you can visit: &lt;a href=&quot;http://www.scoopspot.com/&quot;&gt;www.scoopspot.com&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;font-family: Georgia, serif; font-size: 100%; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; &quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://lispsamik.blogspot.com/2012/03/how-we-made-social-news-service-with.html</link><author>noreply@blogger.com (samik chakraborty)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEif-ecCBfTs5aCrHrRI3mnsddB3nBvHOueqy1FcRmNgftqYNSIuaSPLWcqwzJ3zfg4_vqrAydwk-H0a_74Djs_ueEKV3MPei330egpLYg1IyadsXzwaKPmdEzfXk227HAdIGk_9ZheFRyA/s72-c/pic1.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-3272513479394005364</guid><pubDate>Thu, 23 Feb 2012 07:05:00 +0000</pubDate><atom:updated>2012-03-27T08:39:20.986-07:00</atom:updated><title>Ten Commandments for How Not to Become a Good Programmer</title><description>&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate=&quot;false&quot; latentstylecount=&quot;156&quot;&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable  {mso-style-name:&quot;Table Normal&quot;;  mso-tstyle-rowband-size:0;  mso-tstyle-colband-size:0;  mso-style-noshow:yes;  mso-style-parent:&quot;&quot;;  mso-padding-alt:0in 5.4pt 0in 5.4pt;  mso-para-margin:0in;  mso-para-margin-bottom:.0001pt;  mso-pagination:widow-orphan;  font-size:10.0pt;  font-family:&quot;Times New Roman&quot;;  mso-ansi-language:#0400;  mso-fareast-language:#0400;  mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;ol style=&quot;margin-top: 0in; font-weight: bold; font-family: arial; &quot; start=&quot;1&quot; type=&quot;1&quot;&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list:l0 level1 lfo1;tab-stops:list .5in&quot;&gt;thy      should never waste time in reading about code&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list:l0 level1 lfo1;tab-stops:list .5in&quot;&gt;thy      should always respect your IDE and carry it all the time with you (in a      USB key)&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list:l0 level1 lfo1;tab-stops:list .5in&quot;&gt;thy      should always find a non-existing requirement in mind and code for it&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list:l0 level1 lfo1;tab-stops:list .5in&quot;&gt;thy      should never write a comment&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list:l0 level1 lfo1;tab-stops:list .5in&quot;&gt;thy should      show your karate in all obfuscating syntax&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list:l0 level1 lfo1;tab-stops:list .5in&quot;&gt;thy      should show no interest in algorithm and its implications&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list:l0 level1 lfo1;tab-stops:list .5in&quot;&gt;thy      should always be shy away from mathematics&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list:l0 level1 lfo1;tab-stops:list .5in&quot;&gt;thy      should never test your code extensively; those who do are weak&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;thy      should write in abbreviation it will communicate more in less characters&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot;&gt;  &lt;span style=&quot;font-size: 12pt;&quot;&gt;thy should use GOTO always&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;span style=&quot;font-family: arial; &quot;&gt;That&#39;s all I have.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 12pt; font-family: arial;&quot; &gt;&lt;/span&gt;&lt;div style=&quot;font-family: Georgia, serif; &quot;&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span &gt;&lt;a href=&quot;http://lispsamik.blogspot.in/2012/03/better-twitter-are-you-out-of-your-mind.html&quot;&gt;Want to know better micro-blogging platform read on&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;</description><link>http://lispsamik.blogspot.com/2012/02/ten-commandments-for-how-not-to-become.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-1663051781028055399</guid><pubDate>Fri, 17 Feb 2012 06:36:00 +0000</pubDate><atom:updated>2012-02-16T23:20:05.433-08:00</atom:updated><title>REST will stay – you can wash your SOAP away</title><description>&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate=&quot;false&quot; latentstylecount=&quot;156&quot;&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable  {mso-style-name:&quot;Table Normal&quot;;  mso-tstyle-rowband-size:0;  mso-tstyle-colband-size:0;  mso-style-noshow:yes;  mso-style-parent:&quot;&quot;;  mso-padding-alt:0in 5.4pt 0in 5.4pt;  mso-para-margin:0in;  mso-para-margin-bottom:.0001pt;  mso-pagination:widow-orphan;  font-size:10.0pt;  font-family:&quot;Times New Roman&quot;;  mso-ansi-language:#0400;  mso-fareast-language:#0400;  mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;REST web services will stay. It is a bad thing to predict future of technology. But I am ready to bet on this one. REST will stay. It will stay because of multiple reasons, and today I am going to give you mine.&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt; &lt;/p&gt;  &lt;ol style=&quot;margin-top:0in&quot; start=&quot;1&quot; type=&quot;1&quot;&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list:l0 level1 lfo1;tab-stops:list .5in&quot;&gt;REST      is simple. You can create a RESTful web service easily. I mean very, very easily.      Actually you have been doing it all along if you are in web development. Every      page in a web site is an example of REST web services (hold your concern a      bit more), the only difference is your client is a web browser.&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list:l0 level1 lfo1;tab-stops:list .5in&quot;&gt;REST      is succinct. You can do almost everything in REST. If you cannot do      something in REST chances are you do not know how to do it yet. It’s      succinctness is so powerful that you can do some great magic.&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list:l0 level1 lfo1;tab-stops:list .5in&quot;&gt;REST      is easy to learn. If you know web development you know rest. If you need      to expose your database to the web – you just need to provide a URL (with      all query string and HTTP headers). Whatever is running in the background      for your web server (or app server) can return the data using JSON or XML.      That’s it.&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list:l0 level1 lfo1;tab-stops:list .5in&quot;&gt;REST      is scalable. If the dang thing supported the Internet to scale to what it      is today – it can scale your web site also. Even if you have more data      than Wikipedia.&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list:l0 level1 lfo1;tab-stops:list .5in&quot;&gt;REST      teaches you a lot more than anything else. With other web service      standards – you are limited with the framework you are working with. But not      with REST. It does not impose you anything – no configuration, no heavy      tricks, no non-sense. Follow the conventions and you are there with your      service. As it does not have any heavy stuff so it push you to think in      simple terms and help you build a system which easy to maintain and      consume.&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list:l0 level1 lfo1;tab-stops:list .5in&quot;&gt;REST      service is ready to be consumed anywhere. I mean as long as your server is      reachable. So you need no fancy pant client library to work with.&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list:l0 level1 lfo1;tab-stops:list .5in&quot;&gt;REST      will stay – you can wash your SOAP away. If you are not with REST of us      and with some other stuff. Think about the future where everyone will have      a handheld try to access your service. They will have different architecture      and software stack which you do not know. You will have to serve data to      all of them and your SOAP will wash away.&lt;/li&gt;&lt;/ol&gt;  &lt;p class=&quot;MsoNormal&quot;&gt; &lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;That’s all I had in my mind. What do you think?&lt;/p&gt;</description><link>http://lispsamik.blogspot.com/2012/02/rest-will-stay-you-can-wash-your-soap.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-3392328385834196523</guid><pubDate>Tue, 17 May 2011 07:18:00 +0000</pubDate><atom:updated>2011-05-19T23:25:01.678-07:00</atom:updated><title>Lets Un-Uncomplicate</title><description>The world is a beautiful place if you can see things simply. But once you are in the software it becomes ugly and you start seeing things in a completely different way. I have seen thing happening so may times – that I felt like writing this one out.&lt;br /&gt;&lt;br /&gt;Its story time here – so enjoy!&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;The “Hello! World”&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You must have written a “hello world” program in your life. It’s the simplest program that you can write in a programming language . So I will tell you a story with “Hello! World”.&lt;br /&gt;&lt;br /&gt;In a software company, “ComplicateSoft” (henceforth called as “CS” – for simplification!), there was a requirement from a customer to write a program which will print “Hello! World”. But as with any customer, there is a catch – they did not know where will it be getting printed or how many times will it be getting printed. So they said the “Archie” of “CS” make something generic. Actually the customer said “make something which will do the job in most cases”, the “Archie” documented it as “generic”.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;The Dev-Archie meet&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;“We will do it the proper way”, said Archie.&lt;br /&gt;&lt;br /&gt;Dev guy, “Yeah, makes sense – cool.”&lt;br /&gt;&lt;br /&gt;So the dev guy wrote a good old Java class, which has a simple method which prints “Hello! World”.&lt;br /&gt;&lt;br /&gt;Dev was happy as he never got a easier project than this. So he even wrote it in TDD.&lt;br /&gt;&lt;br /&gt;Archie came along and saw that piece of code and said, “Okay, but that’s not generic enough. Dude, make the string “Hello! World” externalized”.&lt;br /&gt;&lt;br /&gt;So the dev guy, did.&lt;br /&gt;&lt;br /&gt;Next, Archie said, “Dude we do not know where this will get printed no sys-out. Take a output stream instead!”&lt;br /&gt;&lt;br /&gt;Well this should be all. The dev guy did that.&lt;br /&gt;&lt;br /&gt;Next, Archie said, “This class is doesn’t have any state so lets make it a Singleton.”&lt;br /&gt;&lt;br /&gt;The dev guy thought wow! I will implement a design pattern now on this – cool.&lt;br /&gt;&lt;br /&gt;The Archie said, “Now we have to make sure that if someone request this as service over the web, do a WSDL for it and test it with a client.”&lt;br /&gt;&lt;br /&gt;Dev guy did that!!!&lt;br /&gt;&lt;br /&gt;Now Archie thought about the requirement once more and remembered the phrase, “don’t know how many times will it get printed.”&lt;br /&gt;&lt;br /&gt;If it needs to printed multiple times with a distributed file system?&lt;br /&gt;&lt;br /&gt;He asked his dev guy a final thing – “Can you make this class support Hadoop map-reduce”&lt;br /&gt;&lt;br /&gt;The dev guy ….&lt;br /&gt;&lt;br /&gt;The end.&lt;br /&gt;&lt;br /&gt;Hope you enjoyed.</description><link>http://lispsamik.blogspot.com/2011/05/lets-un-uncomplicate.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-609979715580582270</guid><pubDate>Tue, 01 Mar 2011 07:52:00 +0000</pubDate><atom:updated>2011-02-28T23:53:13.802-08:00</atom:updated><title>Why is it harder to read the code than writing it?</title><description>It is harder to read a code than to write it.&lt;br /&gt;&lt;br /&gt;In a meeting where a team is deciding whether to write the code a fresh, this is the reason given in favor of writing it all over again. With this reason we sometimes add seasonings like: we will design it better, we will write in TDD, blah, blah and blah.&lt;br /&gt;&lt;br /&gt;But if you think very closely you will come to know why you are re-writing the code. If you are re-writing a code from language X to Y. There must be some very good reason behind it. Like if you have a old C code which you want to re-write in Java your list of reason could be: portability, multi threading, OOPs design, security etc.&lt;br /&gt;&lt;br /&gt;But if you have decided to re-write the entire code in the same language you are doing so because:&lt;br /&gt;It is harder to read a code than to write it.&lt;br /&gt;&lt;br /&gt;Now stop think about the part:&lt;br /&gt;&lt;br /&gt; It is harder to read a code&lt;br /&gt;&lt;br /&gt;Why is it harder to read the code?&lt;br /&gt;&lt;br /&gt;Answer the following questions:&lt;br /&gt;&lt;br /&gt;1.    Is there a high level documentation to follow the code flow?&lt;br /&gt;&lt;br /&gt;2.    If I put a break point in main (for C/C++/Java – you can think of the name of the entry point method in your project. In a web development you can think of a Servlet also.) can I follow it?&lt;br /&gt;&lt;br /&gt;3.    Are all the “if statements” (even assert statements for debug) is well commented?&lt;br /&gt;&lt;br /&gt;4.    Can I test all the methods for their side effects and returned values?&lt;br /&gt;&lt;br /&gt;5.    Can I look at the output of the program and get to know which paths are involved to produce any part of the output?&lt;br /&gt;&lt;br /&gt;If your answers are mostly “No”. You need re-organization of your code – not a full blown re-write. That re-organization can be: adding comments to full refactoring of the code. But here I will tell you a little bit more about each point that I have mentioned above.&lt;br /&gt;&lt;br /&gt;•    High level program flow is very crucial for understanding of the software. A full-blown call graph tree is perfect. But at least all programmers in a project should be able to draw the high level program flow easily. Now let me tell you that this high level is not a one block with input to output. It has to be at least describes all the major boxes in the system. It should show the interaction with various modules, including internal and third party modules used.&lt;br /&gt;&lt;br /&gt;•    One should be able to go though the whole system effortlessly when she has put a break point at the beginning. Now if you have multiple entry point (one for one feature), one should not look out for an entry point for particular feature more than one documentation file. If you do not have it – do it now.&lt;br /&gt;&lt;br /&gt;•    The branching statements in a code are very important. This is the place where business logic is implemented. So they must be documented – and the documentation is in the code as comments. You do not want your programmer to look for the spec while debugging any feature. Any changes to the business requirement should be tracked in the code comment. If any of the method is going to change the state of some variables or objects which impacts the overall behavior you should document that also, again in the code comment.&lt;br /&gt;&lt;br /&gt;•    Nothing is like a unit testing but that is less for automation and more for human understanding. Any developer in the team should know where the unit test case resides for the method that he is working on. A new developer should start by doing the unit tests first. Sometimes in old code we do not have unit test cases for historic reasons. If that has state changes going around we should provide the developer a way to understand the state and state changes.&lt;br /&gt;&lt;br /&gt;•    This one is important! Look at your output and tell me which code or code path is responsible for this output. Like if you are showing a count of students in a class you should be able to trace that front end to the back end code till the DB.&lt;br /&gt;&lt;br /&gt;If you do all that you should be in a good position to understand the code and work with it rather than dispose it off. If you anyway decide to follow the re-write make sure the documentation points that I have mentioned here. Do the docs for this re-write else you will drop this code some day with the reason:&lt;br /&gt;&lt;br /&gt;It is harder to read a code than to write it.</description><link>http://lispsamik.blogspot.com/2011/02/why-is-it-harder-to-read-code-than.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-1305322756680426065</guid><pubDate>Fri, 18 Feb 2011 06:22:00 +0000</pubDate><atom:updated>2011-02-17T22:29:18.169-08:00</atom:updated><title>10 Things to Keep in Mind while depeloping a Web App</title><description>What should I ensure before I start developing a web application? So here is my humble list of things that I must do (don’t) in the future:&lt;br /&gt;&lt;br /&gt;1.    There is a need for authentication so figure that out first. Use a well know library for it – like if you are using Java use Spring Security.&lt;br /&gt;&lt;br /&gt;2.    Do not write your backend first. Especially for Ajax based web apps. You will need to add or change the API with the page design changes.&lt;br /&gt;&lt;br /&gt;3.    Do not return HTML from any Ajax API ever. Use JSON. [If you do this with # 2 you are doomed]&lt;br /&gt;&lt;br /&gt;4.     In your HTML, JSP (or ASP) or XSLT - do not write the style attribute (in HTML tags) to save time today. Instead add a class in your style.css file. It will save a lot of time in the future. Like if you want to change the color of the whole page you can work with one css file instead of all your ASPs and JSPs.&lt;br /&gt;&lt;br /&gt;5.    Have one entry point for all services – use a dispatcher. What I mean by this is make your web app configuration lean (for Java world it is web.xml).&lt;br /&gt;&lt;br /&gt;6.    Keep the logged in user in a secured URL like HTTPS. Never transport password over HTTP.&lt;br /&gt;&lt;br /&gt;7.     Try to standardize the JSON response. If you need to render something from JSON data this will help you a lot. You can write one helper JS function which will take care of it.&lt;br /&gt;&lt;br /&gt;8.    Follow css box model always. No excuse.&lt;br /&gt;&lt;br /&gt;9.    Divide the web page into multiple parts. Each part should be working fine. I mean as much as possible.&lt;br /&gt;&lt;br /&gt;10.    Build a feature a close it for today’s requirement. Do not jump to a feature without finishing the one in hand – it will bite your ass later.&lt;br /&gt;&lt;br /&gt;10 + 1. Test in a lot of browsers (IE7+, FF, Opera, Chrome)</description><link>http://lispsamik.blogspot.com/2011/02/10-things-to-keep-in-mind-while.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-9057502131343224362</guid><pubDate>Mon, 28 Jun 2010 12:34:00 +0000</pubDate><atom:updated>2010-06-28T05:38:28.680-07:00</atom:updated><title>Reading Cricekt - A Fun full Learning</title><description>Cricket is a game where you play either as a batting side or as a fielding side. Players from batting side try to score runs and the fielding side tries to stop the batsmen by getting them out. It sounds pretty similar to many games that are played worldwide, like baseball. But I am not going to blog about a game that’s played out door. I am blogging about an indoor game that I learnt during my school days. It is an amazing game where cricket is mixed with reading habit. It’s called Reading Cricket – conceptualized and invented by our Bengali language teacher Mr. Tejesh Adhikari.&lt;br /&gt;&lt;br /&gt;This game is very simple to play – especially in a class room situation. So how is it played?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The “Rules”&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;There will be two teams of course. One will bat the other will bowl. But instead of bat and ball they will have the same book. Like the history book that is used by all students in the classroom. The team which is batting will be reading from the book. One of the team members will be reading the book aloud so that the other team can listen. The fun begins now. &lt;br /&gt;&lt;br /&gt;1. If the batsman (the guy who is reading the book) can complete a line (note – a line not a sentence) will be awarded 1 run.&lt;br /&gt;&lt;br /&gt;2. If the line contains just one word which is foreign and is not part of the normal vocabulary of the original language of the book, or is written in a different language alphabet. If the batsman reads that line with proper pronunciation, he will score 2 runs for that line. &lt;br /&gt;&lt;br /&gt;3. Consider the point# 2 for multiple words but not the whole line. In this case the batsman will score 4 runs.&lt;br /&gt;&lt;br /&gt;4. Now consider if the whole line is written in the foreign language – the bats man get 6 runs. &lt;br /&gt;&lt;br /&gt;5. Now for all 2,3 and 4 the batsman should know beforehand and he can declare that he does not know the language. No one can penalize him for that.&lt;br /&gt;&lt;br /&gt;6. So what the fielding team is going to do? They will listen carefully each word of the batsman. If any of the fielders finds that the batsman has mispronounced any one of the word according to the convention learned by the students in the school – he can appeal for an out. If the teacher thinks that the appeal is correct he gets out.&lt;br /&gt;&lt;br /&gt;There were so many other things in it. But the above mentioned are the gist of what I can recall. &lt;br /&gt;&lt;br /&gt;What an effect that it used to have when we used to do it in the school. The guys who never gave attention to anything used to glue to the pages and follow the batsman when they used to field. It is an amazing way to learn how to read, understand and possibly remember. &lt;br /&gt;&lt;br /&gt;Like the best bridge players – who never forget a mistake that he has made in a deal or like a chess player who always remember the blunder that he had made, we used to remember our mistakes while reading.&lt;br /&gt;&lt;br /&gt;I just thought this game might help a lot of people who works with young learners, who are dedicated to bring out the best in our young – if they know about it, they can try it.&lt;br /&gt;&lt;br /&gt;If you try it please let me through your comments. If you want to know more about it – please ask me any question.</description><link>http://lispsamik.blogspot.com/2010/06/reading-cricekt-fun-full-learning.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-7896609208797678895</guid><pubDate>Thu, 25 Mar 2010 06:36:00 +0000</pubDate><atom:updated>2010-03-24T23:38:36.988-07:00</atom:updated><title>Come Back!!!</title><description>“We&#39;re getting close to the end of my blog. After today&#39;s entry, I only have three left to write. After that, I&#39;ll only blog anonymously or (more likely) not at all.” – Steve Yegge&lt;br /&gt;&lt;br /&gt;“programming is rather thankless. you see your works become replaced by superior works in a year. unable to run at all in a few more.” - _why&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So people do like to disappear from the web world. I really do not know why a person like Steve wants to stop blogging; _Why likes to stop contributing to the programming language he loved. &lt;br /&gt;&lt;br /&gt;We all need time to do things that we must, should and have to do. I must spend quality time with my family; I should spend an hour or two with Concrete Mathematics; I have to keep my day job (hey I love my day job – please don’t take it in the other sense.) so that I can pay the bills.  &lt;br /&gt;&lt;br /&gt;But it seems strange that one day one may decide to go in the clouds and never come back. If someone really does that, whom should we blame? Why some people really wanted to know the so called “real” person behind _Why? Some people think that’s may be the reason for the drastic step that _Why took. If you do not agree with what someone has to say about something (like Marijuana) – why do we always have to hit that guy?&lt;br /&gt;&lt;br /&gt;Yeah! We are intelligent beings – and have big fat ego like – I know this stuff better than you and I can show how great I am in…. but hey dude. You are just good at criticizing and nothing else. You know pointless criticism is pointless! FLAT POINTLESS – don’t do it! &lt;br /&gt;&lt;br /&gt;I do not know why the hell these guys disappeared. But I want them to come back. But why should you come back? These thankless people will never stop. They will always come back and hound you guys. I am just thinking about people who really go inspiration from you guys. An email, blog post or code snippet can clarify an air of uncertainty in our mind. For ruthless, restless and may be “I know all” types all you have to do is “ignore” them. They will always be there as their existence depends on it. They will not practice agile for 2 years and come back and say “Hey Steve, you missed out these (or that point) in why Agile suck.”&lt;br /&gt;&lt;br /&gt;You know I am may be just ranting for no reason at all. I know this will not change your mind sets. Just one request to you guys. Do not punish all for a few!</description><link>http://lispsamik.blogspot.com/2010/03/come-back.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-4245507878444005691</guid><pubDate>Wed, 27 Jan 2010 07:22:00 +0000</pubDate><atom:updated>2010-01-26T23:34:40.415-08:00</atom:updated><title>Caveat - The Name has Changed</title><description>After almost three years of blogging, I am changing the title and subtitle of my blog. It will no longer be called as lisp any more. Why? Of late I was not writing enough about (or on) lisp. It is more and more becoming my restless rants that I do out of desperate need to fulfill my alter-ego of creativity. I gave it a long thought and paused for several minutes before I changed it. I was thinking that some people who read this blog may feel that it has changed from what it was previously. Do not worry – it is impossible to change an opinion, let alone a personality.&lt;br /&gt;&lt;br /&gt;My obligation was not only to my reader but also to the people who lands on my blog. They shouldn’t be misguided to a belief that it is a blog purely for Lisp. Hope this will clear some clouds – hope you will enjoy it as before. &lt;br /&gt;&lt;br /&gt;Oh I almost forgot to mention! I will definitely write about lisp and lisp related articles in the future.</description><link>http://lispsamik.blogspot.com/2010/01/caveat-name-has-changed.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-4716631262860168581</guid><pubDate>Wed, 20 Jan 2010 05:21:00 +0000</pubDate><atom:updated>2010-03-08T01:36:37.777-08:00</atom:updated><title>Loooopy</title><description>&lt;b&gt;How Tortoise Taught Recursion to Achilles&lt;/b&gt; &lt;br /&gt;&lt;br/&gt;&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;br /&gt;This post was there with me for quite some time - but couldn&#39;t complete it for almost six months. At last its done! Hope you will enjoy it.&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;One should read the dialog in Lewis Carroll writing or Godel, Escher, Bach.&lt;br /&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/What_the_Tortoise_Said_to_Achilles&quot;&gt;Here is the dialog that I have referred to from Wikipedia.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;[Achilles and Tortoise meet at a coffee shop after a long break.]&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Achilles: It has been long that we have met.&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Tortoise: Yeah! But the good thing is that, here we are together; once again. So what have you been doing all these days?&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Achilles: Nothing! &lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Tortoise: So it must have been boring for you. &lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Achilles: Oh no, no! It was not boring at all. I have learnt programming of late and I was playing with couple of programming languages. Like I was figuring out how I can model all that we have discussed previously. Especially the one that you and I got into endless thousand page ranting on with A, B, C … to prove Z. You remember?&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Tortoise: Yes, I do in fact! That was a fun! I hope you understand that it is very difficult to prove that uh!&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Achilles: You should learn programming and you will come to know that what you did was an infinite loop. You would have understood the loop will go on and on.&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Tortoise: Loop?&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Achilles: Yes my dear friend – loop. &lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Tortoise: So what is this “Loop” is all about?&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;[Achilles smiles and continues, after a sip of cappuccino]&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Achilles: You see loops are very simple. If you want to do something repeatedly you just say that. &lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Tortoise: Elaborate please.&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Achilles: Like say you want to add all the integers from 1 to 10. You start a loop, let x equals to 1 and sum equals 0. Add sum and x and assign the result to sum, after that you increase x by 1 and do this till x is less than 11; you see you want to add all integers till 10. Pretty simple, huh?&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Code snippet:&lt;br /&gt;  int sum = 0;&lt;br /&gt;  for (int x = 0; x &lt; 11 ; x++) {&lt;br /&gt;   sum += x;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt; &lt;/pre&gt;&lt;br /&gt; &lt;br/&gt;&lt;br /&gt;Tortoise: Fine! But looks odd to me!&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Achilles: Why? Is there anything wrong?&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Tortoise: You know my friend; you have learnt a programming language but I am a little handicapped with that, i.e. “programming language”, but I feel I have a different way of understanding this one.&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Achilles: How?&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Tortoise: Do you know the mathematical concept of function? Like F(x, y) = x + y?&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Achilles: Yes I do.&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Tortoise: Great! We can represent the solution like the following function in mathematics:&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;       F(x, y) = y + x; if x = 10   … (RULE 1)&lt;br /&gt;         = F(x+1, y+x); 1 &lt;= x &lt;= 9  … (RULE 2)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;O mighty Achilles! How will you write this in your programming language?&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Achilles: I see! Let me tell you how to do that in programming language. [Achilles shows the code snippet]&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt; public int sum(int x,int y) {&lt;br /&gt;  if (x == 10) {&lt;br /&gt;   return y+x;&lt;br /&gt;  } else {&lt;br /&gt;   return sum(x+1,y+x);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Achilles: I knew this from my advance classes in programming – it is called recursion. But how do you explain this.&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Tortoise: Very simple my friend! The RULE 1 says that if the variable x is equal to 10 you are going to produce the summation of x and sum as result else it will keep on calling itself with an incremented value of x and summation of  x and the y variables. It’s very basic math you see.&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Achilles: But you need to have a termination rule to complete the task! How would you explain that A, B and Z proposition problem with recursion? It was an endless loop right? No terminating condition.&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Tortoise: Really? But I knew that there was a terminating condition there too! It was your last proposition. If I would have accepted it – the so called loop was over. But I did not accept it I just kept on adding one more layer in between the final and penultimate statement. So the final statement was the terminating condition. &lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Achilles: But as you see now, in this example we have a terminating condition as 10…&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Tortoise: That need not to be 10, we can introduce a third variable say z or we can call it terminator if you like it. We can rewrite the function definition as follows:&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;       F(x, y, z) = y + x; if x = z   … (RULE 1)&lt;br /&gt;            = F(x+1, y+x, z); 1 &lt;= x &lt;= 9  … (RULE 2)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;And this one should work for any integer value of z – isn’t it?&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Achilles: Yes it would and the program would look like:&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt; public int sum(int x, int y, int z) {&lt;br /&gt;  if (x == z) {&lt;br /&gt;   return y+x;&lt;br /&gt;  } else {&lt;br /&gt;   return sum(x+1, y+x, z);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;And we could invoke this with something like: sum(1, 0, 10) and it works. But, tortoise, it is still does not create an infinite loop like what you had created.&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Tortoise: Yes, Achilles it can but needs a little imagination. I created something like this:&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;       F(x, y, z) = y + x; if x = z   … (RULE 1)&lt;br /&gt;            = F(x+1, y+x, x+2); 1 &lt;= x &lt;= 9 … (RULE 2)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Look closely, warrior; I have introduced a never reaching fallacy in the RULE 2 function. Instead of z I am passing x+2 as the last argument. This will prevent the condition for RULE 1 and it will remain like that illusive last statement. &lt;br /&gt;&lt;br/&gt;&lt;br /&gt;[Tortoise paused for a moment]&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Tortoise: Now you see it!&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Achilles: Yes.&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Tortoise: I am going home – would you like to join?&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Achilles: No!&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;[Tortoise leaves slowly. Achilles looks at the paper and nods his head in disbelieve.]&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Achilles: Waiter! Get me a java green please.&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;The java code for this never ending recursion would look like:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public class Recursionist {&lt;br /&gt;&lt;br /&gt; /**&lt;br /&gt;  * @param args&lt;br /&gt;  */&lt;br /&gt; public static void main(String[] args) {&lt;br /&gt;  Recursionist r = new Recursionist();&lt;br /&gt;  System.out.println(r.sum(1,0,100));&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public int sum(int x,int sum,int termination) {&lt;br /&gt;  if (x == termination) {&lt;br /&gt;   return sum+x;&lt;br /&gt;  } else {&lt;br /&gt;   return sum(x+1,sum+x,x+2);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;OUTPUT: A stack overflow exception - at some point of time I gusse.&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Moreover you do not do all these for Arithmetic Progression you just use the formula.</description><link>http://lispsamik.blogspot.com/2010/01/loooopy.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-3233522655064655693</guid><pubDate>Sun, 17 Jan 2010 06:53:00 +0000</pubDate><atom:updated>2010-01-19T03:10:24.526-08:00</atom:updated><title>Weekend Programming Excursion - 1</title><description>&lt;p&gt;&lt;br /&gt;  So I have joined a new company on 30th December 2009. I am now working for Thomson-Reuters. As always the blog that I write here will not represent in any manner what so ever my new employer’s views, these are just my technological rants that I always write. I do not even know whether these are read or not, but just in case you are among those people who surf around and read this blog (either occasionally or regularly) be assured that I will eventually write something in here.&lt;br /&gt;  &lt;/p&gt;&lt;p&gt;&lt;br /&gt;So, gosh what new year it was – leaving one company and joining another, I didn’t even got a chance to work on anything (other than all the pending items that I had on my plate with my previous employer, writing a good-bye mail, meeting people who wanted to wish me luck for my new venture and of course the team send off dinner) significant to write. It was all work and no play with my laptop.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;As some of you may have noticed in this blogs that Lisp is not the programming language that I am working now.  I am no longer in those fortunate few who get paid for learning Lisp, working with Lisp and writing Lisp codes. But that said nobody stopped me from learning a new programming language – but as you can guess from my worthless rants that I have not even scratched the surface of it.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;On a boring weekend you usually start the day with your home stuff like laundry. However, if you are a programmer who cannot live without coding something or the other in a day, you also code. That kind of coding I call a “weekend excursion into programming”. Most of the times one tends to lose all the code that you have built over the time. This is especially true for me. So before I forget what I did I would like to put it in here. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;So what was that I did?&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;A class and an interface in Java! Yes you heard it correct just a class and an interface - an interface with one method signature and a class with one method (as of now). That’s it!&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;You must be wondering what the heck! 1 interface, 1 class and 1 method for each of them! &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;You may tell me, “Dude! You are not working hard.”&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;Point taken! No more blah, blah….&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;So here it is what I did.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;b&gt;The &lt;i&gt;One&lt;/i&gt; Interface&lt;/b&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;I bad at naming but I knew that the word “lambda” has to be there for this interface name. So in the kingdom of noun (i.e. Java) I have to use adjective for interfaces so the name of the interface is LambdaService.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;So what is there in this interface? Here is the code for you:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;div style=&quot;border:1px solid #6789B3;background-color:#CFCFCF;&quot;&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;import java.util.List;&lt;br /&gt;public interface LambdaService&lt;T&gt; {&lt;br /&gt;&lt;br /&gt; T lambda(List&lt;T&gt; params );&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Pretty simple, huh! It takes a list of arguments of type T and returns an object of type T. If you are from some functional programming background, you already know this stuff. But for people who do not know how I am going to use it – hold on, you are in for a ride.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;&lt;b&gt;The &lt;i&gt;One&lt;/i&gt; Class&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Let me give you the class definition code also.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;div style=&quot;border:1px solid #6789B3;background-color:#CFCFCF;&quot;&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;import java.util.ArrayList;&lt;br /&gt;import java.util.List;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * @author samikc&lt;br /&gt; *&lt;br /&gt; */&lt;br /&gt;public class Functional&lt;T&gt; {&lt;br /&gt;&lt;br /&gt; public static  &lt;T&gt; List&lt;T&gt; map(LambdaService&lt;T&gt; lambda,&lt;br /&gt;           List&lt;T&gt;... list) {&lt;br /&gt;  List&lt;T&gt; retList = new ArrayList&lt;T&gt;(); &lt;br /&gt;  List&lt;T&gt; params = new ArrayList&lt;T&gt;();&lt;br /&gt;  int iterCount = getShortestListSize(list);&lt;br /&gt;  for (int i = 0;i &lt; iterCount;i++) {&lt;br /&gt;    int paramCounter = 0;&lt;br /&gt;    for (List&lt;T&gt; l : list) {&lt;br /&gt;      params.add(paramCounter, l.get(i));&lt;br /&gt;      paramCounter++;&lt;br /&gt;    }&lt;br /&gt;    retList.add((T) lambda.lambda(params));&lt;br /&gt;  }&lt;br /&gt;  return retList;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; private static &lt;T&gt; int &lt;br /&gt;                getShortestListSize(List&lt;T&gt;... list) {&lt;br /&gt;  List&lt;T&gt; retList = list[0];&lt;br /&gt;  for (List&lt;T&gt; l : list) {&lt;br /&gt;    if (l.size() &lt; retList.size()) {&lt;br /&gt;      retList = l;&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;  return retList.size();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;So what this method map is doing here. Let me try to explain.  &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;In map you provide a lambda service (which is a method at the end of the day) and a list. The lambda service is nothing but a strategy pattern, I am allowing others to provide an option to provide an algorithm which will be applied to each member of the list provided and result will be collated in a &lt;b&gt;different list&lt;/b&gt;. &lt;br /&gt;Notice that I have made “different list” &lt;b&gt;bold&lt;/b&gt;.  Why? As I am applying the algorithm provided I am not changing the anything inside the actual list passed on. So it does not have a side-effect.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;The main is given below without any comments; I feel it’s very simple and intuitive.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;&lt;b&gt;The &lt;i&gt;*main*&lt;/i&gt; Story&lt;/b&gt;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;border:1px solid #6789B3;background-color:#CFCFCF;&quot;&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;import java.util.ArrayList;&lt;br /&gt;import java.util.List;&lt;br /&gt;&lt;br /&gt;public class Main {&lt;br /&gt;  public static void main(String[] args) {&lt;br /&gt;        ArrayList&lt;Integer&gt; il1 = new ArrayList&lt;Integer&gt;();&lt;br /&gt;        il1.add(10);&lt;br /&gt; il1.add(20);&lt;br /&gt; il1.add(30);&lt;br /&gt; ArrayList&lt;Integer&gt; il2 = new ArrayList&lt;Integer&gt;();&lt;br /&gt; il2.add(10);&lt;br /&gt; il2.add(20);&lt;br /&gt; il2.add(30);&lt;br /&gt; il2.add(40);&lt;br /&gt; List&lt;Integer&gt; li = Functional.map(new LambdaService&lt;Integer&gt;() {&lt;br /&gt;  @Override&lt;br /&gt;  public Integer lambda(List&lt;Integer&gt; params) {&lt;br /&gt;    Integer i1 = params.get(0);&lt;br /&gt;    Integer i2 = params.get(1);&lt;br /&gt;    Integer ret = i1 + i2;&lt;br /&gt;    return ret;&lt;br /&gt;  }&lt;br /&gt; }, il1, il2);&lt;br /&gt;  &lt;br /&gt; for (Object o : li) {&lt;br /&gt;  System.out.println(o);&lt;br /&gt; }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Sample output:&lt;br /&gt;20&lt;br /&gt;40&lt;br /&gt;60&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://lispsamik.blogspot.com/2010/01/weekend-programming-excursion-1.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-491987534698402468</guid><pubDate>Tue, 29 Dec 2009 17:22:00 +0000</pubDate><atom:updated>2009-12-29T09:24:23.886-08:00</atom:updated><title>Last Day at Wipro</title><description>After working for almost four and half years I have left Wipro. Tomorrow I will join a new organization (will let you the name tomorrow). &lt;br /&gt;&lt;br /&gt;Great learning experience in Wipro.</description><link>http://lispsamik.blogspot.com/2009/12/last-day-at-wipro.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-23225684285245058</guid><pubDate>Wed, 03 Jun 2009 05:57:00 +0000</pubDate><atom:updated>2009-06-03T22:31:21.233-07:00</atom:updated><title>JSON – Traps and How to Avoid Them</title><description>&lt;hr /&gt;&lt;br /&gt;&lt;i&gt;Disclaimer: This post is suggestive but not complete&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;When you are working with &lt;a href=&quot;http://www.json.org/&quot;&gt;JSON&lt;/a&gt; there are plenty of chances that things may go wrong. We all know that when something can go wrong it will go wrong. JSON never mentions the data type or it does not get validated by existing JS engines that run on the browser – so the onus lies on the developer to make sure that the data that she has received is in correct format and if possible the value is correct.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Any one can think about whole bunch of defensive programming techniques to avoid such a scenario. But it is impossible to guess what all things can go wrong so we should be prepared as much as possible.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Never evaluate a JSON. It is as bad as it can be. Don’t do it. You do not what you have received in the JSON. If it is a malicious code it can do havoc on your DOM and JS environment. It can corrupt your JS name space, steal cookie information or even worse user information.  I know you must be thinking that we have to do it time and again, use &lt;a href=&quot;http://www.json.org/json2.js&quot;&gt;json2.js&lt;/a&gt; library for this purpose – please do not repeat yourself with all the JSON string parsing again.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;JSON data access is where your code will break (I mean eventually). Say you have a JSON structure (produced by the server) like this one:&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;div style=&quot;background-color:#a9a9a9;border:dashed 1px black;&quot;&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;{ name :  {  first : “Joe”, middle : ”Moe” ,  last :  “Doe” },  age :  23 }&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Now you wrote the logic like this:&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;div style=&quot;background-color:#a9a9a9;border:dashed 1px black;&quot;&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;var name = json.name.first + “ “+ json.name.middle +”  “+ json.name.last;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;This look pretty straight forward and you are sure nothing can go wrong with this simple code. But your server works with this logic: If there is a middle name then it adds middle name if it is not there it keeps mum about that. So the JSON comes like this:&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;div style=&quot;background-color:#a9a9a9;border:dashed 1px black;&quot;&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;{ name :  {  first : “Joe” ,  last :  “Doe” },  age :  23 }&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Your code now will not work as expected, the reason being the absence of name.middle object. This is undefined.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;So how do you make sure that it works as expected? Here is how:&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;div style=&quot;background-color:#a9a9a9;border:dashed 1px black;&quot;&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;var name = “unknown”;&lt;br /&gt;If (json.name.first &amp;amp; json.name.middle &amp;amp; json.name.last) {&lt;br /&gt;name = json.name.first + “ “+ json.name.middle +”  “+ json.name.last;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;This is more important when it comes to calling some methods on a JavaScript object. If the object does not exist (i.e., undefined) then it will throw an error and your rest of the script won’t run.  So if you are working with some JSON and you expect some kind of an object check the type of the object before invoking the method on it. Like if you want to split some CSV (comma separated value) string check that the object is of string type.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;div style=&quot;background-color:#a9a9a9;border:dashed 1px black;&quot;&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;if (csvObject instanceof String) {&lt;br /&gt;// Do your stuff here for string&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://lispsamik.blogspot.com/2009/06/json-traps-and-how-to-avoid-them.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-1789524436847917138</guid><pubDate>Mon, 01 Dec 2008 13:25:00 +0000</pubDate><atom:updated>2008-12-01T06:02:27.991-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">mvn</category><category domain="http://www.blogger.com/atom/ns#">opensocial</category><category domain="http://www.blogger.com/atom/ns#">shindig</category><title>Building Shindig 101</title><description>&lt;b&gt;&quot;Proxy&quot; problem:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;While most of the world in enjoying the freedom of non-proxy Internet some people (like me) are behind a proxy server. Whatever, to get Maven working behind a proxy you need to go to your Maven installation folder and edit the file settings.xml in conf folder. What do you put in there?&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;settings&amp;gt;&lt;br /&gt;.&lt;br /&gt;&amp;lt;proxies&amp;gt;&lt;br /&gt; &amp;lt;proxy&amp;gt;&lt;br /&gt;    &amp;lt;active&amp;gt;true&amp;lt;/active&amp;gt;&lt;br /&gt;    &amp;lt;protocol&amp;gt;http&amp;lt;/protocol&amp;gt;&lt;br /&gt;    &amp;lt;host&amp;gt;proxy.somewhere.com&amp;lt;/host&amp;gt;&lt;br /&gt;    &amp;lt;port&amp;gt;8080&amp;lt;/port&amp;gt;&lt;br /&gt;    &amp;lt;username&amp;gt;proxyuser&amp;lt;/username&amp;gt;&lt;br /&gt;    &amp;lt;password&amp;gt;somepassword&amp;lt;/password&amp;gt;&lt;br /&gt;    &amp;lt;nonProxyHosts&amp;gt;proxyhost.somewhere.com&amp;lt;/nonProxyHosts&amp;gt;&lt;br /&gt;  &amp;lt;/proxy&amp;gt;&lt;br /&gt;&amp;lt;/proxies&amp;gt;&lt;br /&gt;.&lt;br /&gt;&amp;lt;/settings&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Building Shindig - The canonical way:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Building shindig (I assume that you know how to get the code using Subversion) the canonical way is simple:&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;cd ~/src/shindig/&lt;br /&gt;mvn&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This should be enough for most of you but if you are unlucky like me. You may get variety of errors:&lt;br /&gt;&lt;br /&gt;1. Too many unapproved licenses: 12&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Some people get a different number (even 0 - see this mail trail: &lt;a href=&quot;http://www.mail-archive.com/shindig-dev@incubator.apache.org/msg07718.html&quot;&gt;http://www.mail-archive.com/shindig-dev@incubator.apache.org/msg07718.html&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. Test failure :&lt;br /&gt;&lt;br /&gt;May be one of the most frustrating thing is the test failures. They are hard to find and resolve sometimes.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So the question is; what are the options that you can try while building Shindig (and if *something* goes wrong - the list is in no particular order):&lt;br /&gt;&lt;br /&gt;1. Delete your .m2/repository folder and retry - This will download all the required jar files once more. If you have missed something in the previous go you may get it (due to downtime to some download location). This is important if you get &quot;Missing Artifacts&quot; kind of an error.&lt;br /&gt;&lt;br /&gt;2. Try : mvn clean install [ This cleans old bad builds and gives you kind of a fresh start]&lt;br /&gt;&lt;br /&gt;3. Checkout or update the code from the Shindig repo once more.&lt;br /&gt;&lt;br /&gt;4. Update the code once more if the build fails badly as this can happen due to unintentional commit mishaps.&lt;br /&gt;&lt;br /&gt;5. If only the test fails and you are not patient enough to debug, use the following to suppress the error:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt; mvn -Dmaven.test.failure.ignore=true&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;6. If you are too brave you can even try:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt; mvn -Dmaven.test.failure.ignore=true -fn&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;[This worked for me when I got *too many unapproved licenses : 12*]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;all the failures are suppressed by this -fn  it will *NEVER* fail the build.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So that&#39;s about it while building Shindig. Hope this helps - if you have any other way of doing this let me know.</description><link>http://lispsamik.blogspot.com/2008/12/building-shindig-101.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-5287455057746351325</guid><pubDate>Sat, 15 Nov 2008 09:55:00 +0000</pubDate><atom:updated>2008-11-19T00:34:31.827-08:00</atom:updated><title>Code and Data Equivalence</title><description>&lt;meta equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;meta name=&quot;ProgId&quot; content=&quot;Word.Document&quot;&gt;&lt;meta name=&quot;Generator&quot; content=&quot;Microsoft Word 11&quot;&gt;&lt;meta name=&quot;Originator&quot; content=&quot;Microsoft Word 11&quot;&gt;&lt;link rel=&quot;File-List&quot; href=&quot;file:///C:%5CDOCUME%7E1%5Csamikc%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C03%5Cclip_filelist.xml&quot;&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate=&quot;false&quot; latentstylecount=&quot;156&quot;&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:&quot;&quot;; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:&quot;Times New Roman&quot;; 	mso-fareast-font-family:&quot;Times New Roman&quot;;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:&quot;Table Normal&quot;; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:&quot;&quot;; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:&quot;Times New Roman&quot;; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;&lt;meta equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;meta name=&quot;ProgId&quot; content=&quot;Word.Document&quot;&gt;&lt;meta name=&quot;Generator&quot; content=&quot;Microsoft Word 11&quot;&gt;&lt;meta name=&quot;Originator&quot; content=&quot;Microsoft Word 11&quot;&gt;&lt;link rel=&quot;File-List&quot; href=&quot;file:///C:%5CDOCUME%7E1%5Csamikc%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C03%5Cclip_filelist.xml&quot;&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate=&quot;false&quot; latentstylecount=&quot;156&quot;&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:&quot;&quot;; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:&quot;Times New Roman&quot;; 	mso-fareast-font-family:&quot;Times New Roman&quot;;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:&quot;Table Normal&quot;; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:&quot;&quot;; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:&quot;Times New Roman&quot;; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;That code and data are equivalent is a common idea in common lisp. However any programmer who has started his programming in any language other than lisp may find this idea alien to him. This happened to me, and it took me some time to understand the concept. This post is all about my understanding about “code data equivalence” in lisp. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;First of all what is code? Code is anything that can be executed in a computer. In other words code is what we write in a programming language. Code is as the text books suggest is a human readable representation of what computers going to execute. Like the famous hello world program that all of us has written at some point of our life.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;Data on the other hand is something which will be processed by the code. So the code will execute on a data and data change from one execution cycle to another. Data can be given to a code from various sources, like input from a user, file or even a program or code. So in our mind there is a difference. For example take the example of a function which will add two numbers passed to it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;&lt;span style=&quot;&quot;&gt;   &lt;/span&gt;int add(int a, int b) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;&lt;span style=&quot;&quot;&gt;   &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;&lt;span style=&quot;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;&quot;&gt; &lt;/span&gt;return a+b;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;&lt;span style=&quot;&quot;&gt;   &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;In mathematics we know that the operation summation will do *something* with two (or more) numbers and will return a result. This result also will be a number. So the operation of addition is important than that of the data that it operates on. This creates a difference of treating data and code. This difference is the underpinning of treating data and code as separate entities which is true for most of the programming languages.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style=&quot;border-style: none none solid; padding: 0in 0in 1pt;&quot;&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;border: medium none ; padding: 0in; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;But in case of lisp this is not true. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;border: medium none ; padding: 0in; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;border: medium none ; padding: 0in; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;In lisp anything that comes to the REPL is s-expression. What is s-expression? Sexp or s-expression is defined in lisp as an atom or list. Atoms are number, string, character etc. So when a input or data come to REPL it evaluates that as any one these alternatives. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;border: medium none ; padding: 0in; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;border: medium none ; padding: 0in; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;The code that we write in lisp is also s-expression. Now as in mathematics we know that:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;border: medium none ; padding: 0in; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;border: medium none ; padding: 0in; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;If A = B and C = B so A = C.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;border: medium none ; padding: 0in; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;border: medium none ; padding: 0in; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;For lisp:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;border: medium none ; padding: 0in; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;border: medium none ; padding: 0in; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;CODE = SEXP and DATA = SEXP so CODE = DATA&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;border: medium none ; padding: 0in; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;border: medium none ; padding: 0in; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;;font-family:&amp;quot;;font-size:10;&quot;  &gt;QED.&lt;/span&gt;&lt;/p&gt;  &lt;/div&gt;    </description><link>http://lispsamik.blogspot.com/2008/11/code-and-data-equivalence.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-4680039936368257803</guid><pubDate>Wed, 18 Jun 2008 11:56:00 +0000</pubDate><atom:updated>2008-06-18T05:12:07.577-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">general</category><category domain="http://www.blogger.com/atom/ns#">Programming</category><title>Why lisp is *Unpopular*</title><description>&lt;p class=&quot;MsoNormal&quot;&gt;Lisp is a great programming language which has lot of power; however it is far from being most popular programming language. If you see lisp from a distance you will find:&lt;/p&gt;  &lt;p class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin-left: 0.75in; text-indent: -0.25in;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;&quot;&gt;1.&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;Orthogonal syntax&lt;/p&gt;  &lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 0.75in; text-indent: -0.25in;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;&quot;&gt;2.&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;Very quick to learn the basics&lt;/p&gt;  &lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 0.75in; text-indent: -0.25in;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;&quot;&gt;3.&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;Very power full when it is used in high level project&lt;/p&gt;  &lt;p class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 0.75in; text-indent: -0.25in;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;&quot;&gt;4.&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;You write less code as it has most powerful macro system&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;But still lisp is not the language of choice. It is a fallacy of programming world. Why? This question has stumped me number of times. &lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;This post is my attempt to understand why it is so.&lt;/p&gt;  &lt;h1&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;Prefix notation&lt;/span&gt;&lt;/h1&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;Lisp is a programming language where prefix notations are used extensively. Prefix notations are good for computer but not for human being. From very old age human civilization and its mathematics is built on top of infix notation. We comprehend mathematical expressions in infix. You can argue with educational system but you cannot ask to change the year old mathematical notation to help a programming language to be understandable. That is simply not possible. This seems to me a perfect road block for lisp and it has to survive with that. &lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;It will not be out of the turn to tell you a story about my friend. She was looking at Practical Common Lisp, and told, “How do you write 4*3+6 in common lisp?”&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;I replied (in writing), “(+ (* 4 3) 6)”.&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;She looked at it and closed the browser which was rendering “Practical Common Lisp”.&lt;/p&gt;  &lt;h1&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;Mathematics behind lisp&lt;/span&gt;&lt;/h1&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;Believe it or not all programmers do not like mathematics. They lie in the pantry, in conferences, in blogs. But the truth is a handful among us really like mathematics and care about it. Moreover it is not necessary to have deep understanding of mathematics to develop programs, or to be a programmer for that matter. &lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;But lisp is an exception to this idea. To have a fair idea about lisp you have to understand some mathematics, like higher order functions. To understand functional programming paradigm one have to devote some weeks to lambda calculus. If one does not understand this he can write programs in lisp but it will be distant from the lisp style. The very idea of Turing machine and lambda calculus is fundamental to computer science but at the real world of software development those ideas do not cross our mind. To be honest with everyone I learnt C programming language without any knowledge of both Turing machine or lambda calculus.&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;There are self educated programmers who are very good in their trade and they care a damn about those theoretical computer science topics. &lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;So lisp (and proper lisp style) is beyond many programmers and the target audience is less.&lt;/p&gt;  &lt;h1&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;Programming language politics&lt;/span&gt;&lt;/h1&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;Politics is pervasive; programming languages are not an exception to it. Big corporation look for development environments which are well supported, backward compatible, developers are available, etc. This is true in all large organizations or profit making corporations. When you decide about writing software you try to find out a middle ground. Lisp is powerful, 100 java average programmers = 10 or 2 great lisp hackers, you write less code to get more out programming language – all of them so very true. But when I was asked, “Show me one problem that I cannot solve with Java/Ruby/C++/Python?” I knew as all of them are Turing complete, so there is no problem that cannot be solved by Java/Ruby/C++/Python. &lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;Although you have to learn more lexical separator in those programming languages than lisp still lisp looses. This is *PLP* - Programming Language Politics, we have to live with it. People will reject our ideas of development in lisp and the reason will never be purely technical; rather techno-political.&lt;/p&gt;  &lt;h1&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;Code – data Equivalence – Hard to understand&lt;/span&gt;&lt;/h1&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;I said, “In lisp code is data and data is code”.&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;Ron said,”What?”&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;People do not understand code data equivalence, because they are tuned by other programming languages. Those programming languages are their bread and butter so the immortal suggestion of “Unlearn “is “Unreal”.&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;This is the bottom line of any lisper. This is *THE BASIS* of lisp macros. And it is so away from all other brick-mortar programming languages that no one understands its power without coding for many months and many macros. I got the feel of the matter when I read first ten chapters of Paul Graham’s “On Lisp”. This adds to another stiff cliff in any newbie’s learning curve. &lt;span style=&quot;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;&quot;&gt; &lt;/span&gt;&lt;/p&gt;  &lt;h1&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;Macros&lt;/span&gt; &lt;/h1&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;Lisp macros are different beast, a beast when under you command do wonderful job for you. As any other programmer, especially *I know all* programmer like me, need some time to understand that lisp macros are really different. &lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;It took me couple of week to realize that, when I realized it I felt like a stupid school kid with all red score card who has been slapped by his father for his exceptional result. Then I understood,”Oh! Yeah lisp macros are different.”&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;It opened my mind about programming as whole. Like when I learnt lisp – I learnt map, list, mapcar and all other cool lisp techniques. Before my lisp journey I was struggling with C++ STL concepts, after I learnt lisp all the things fell into place.&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;But the point here is that lisp macros are the last challenge that one has to understand (if not master).&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;h1&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;Run-of-the-mill programmers&lt;/span&gt;&lt;/h1&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;In many places it has been mentioned that lispers are not *Run-of-the-mill* programmer. They are different (in some cases arrogant), may be programmer elite. But popularity of a programming language depends on the acceptability of the language not on its power. Natural languages evolve out of existing languages to a simpler but verbose form. The same is not true for programming languages. There is no programming linguistic tree which has a common root node for syntax or semantic or paradigm. Lisp’s elite status may be the singular disadvantage to the general programming cloud.&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;We all play the role of *run-of-the-mill* programmer in any given project while it comes to coding and debugging. So *run-of-the-mill* programmers are necessary for any project to succeed and sustain. If your target is not *run-of-the-mill* guys you are bound to lose one day or the other.&lt;/p&gt;  &lt;h1&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;Undermining Microsoft Windows&lt;/span&gt;&lt;/h1&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;Not many lisp software works properly in Microsoft windows. The lion share of desktop application runs on windows box, but many lisp apps do not work. &lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;Lisper world over has to take up the challenge to support Microsoft version of all the application that they are going to release. The word support can be even this one liner: “I do not care about windows. If it works fine else just do not disturb me.” At least some who cares about Microsoft compatibility will not use your stuff in his software.&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;Undermining Microsoft is bad, because Microsoft to computers is like photosynthesis to trees – it is a necessary evil.&lt;/p&gt;</description><link>http://lispsamik.blogspot.com/2008/06/why-lisp-is-unpopular.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>8</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-2023248245823266561</guid><pubDate>Fri, 13 Jun 2008 13:08:00 +0000</pubDate><atom:updated>2008-06-13T06:12:05.221-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">common lisp</category><category domain="http://www.blogger.com/atom/ns#">personal</category><title>Closure II and some future thought</title><description>My last post about closure in my blog and my query in the comp.lang.lisp have created some interesting debate among lispers and my friends. They have sugested their views about my posts. Some of them said that it was required and some said “I do not care about closure”. All in all I felt good about it. At least some people took a notice about closure and what it means.&lt;br /&gt;&lt;BR /&gt;&lt;br /&gt;&lt;br /&gt;To begin the post I must correct one program from my privious post:&lt;br /&gt;&lt;BR /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;(let ((s0 0) (s1 1) (state 0))&lt;br /&gt;  (defun input-action(in)&lt;br /&gt;    (if (eq state in)&lt;br /&gt; (setf state in)&lt;br /&gt;      (if (eq state s0)&lt;br /&gt;         (setf state s1)&lt;br /&gt;       (setf state s0)))))&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;BR /&gt;&lt;br /&gt;I was really busy with my work of late and could not find any time (or topic) to write. I am busy with javascript and I am very happy with that. So I feel that in next couple of blogs I will write about some of JavaScript.  For this I will go back to my school days and write programs which are like stack, queue and linked list. So that I can keep up with my old habits; what is it?&lt;br /&gt;&lt;BR /&gt;&lt;br /&gt;Programming.</description><link>http://lispsamik.blogspot.com/2008/06/closure-ii-and-some-future-thought.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-2023339556689030921</guid><pubDate>Wed, 23 Apr 2008 05:10:00 +0000</pubDate><atom:updated>2008-04-22T22:25:36.317-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">common lisp</category><title>Closure</title><description>A closure can be a very deceptive concept that comes with programming languages like lisp, JavaScript etc. So what is a closure? Definition of closure from Wikipedia is like this:&lt;br /&gt;&lt;br /&gt; “a closure is a function that is evaluated in an environment containing one or more bound variables.” &lt;br /&gt;&lt;br /&gt;In closure we get an environment and a function in that environment. When the function gets evaluated it has the opportunity to play with the environment. In common practice we think that an environment is nothing but the state of execution of a program. Programs, as pointed out in the classic book “How to design Programs”, is variables plus functions. So we can say, in general, environment is nothing but current state of the variables.&lt;br /&gt;&lt;br /&gt;How we create closures? Here is an example:&lt;br /&gt;&lt;br /&gt;[1]&gt; (let ((x 1))&lt;br /&gt;       (defun foo(n)&lt;br /&gt;        (+ n x)))&lt;br /&gt;FOO&lt;br /&gt;&lt;br /&gt;Here x is the bound variable which has a value 1 and this makes the environment for function FOO. FOO will always get x as 1 in its execution. When we call FOO we get:&lt;br /&gt;&lt;br /&gt;[2]&gt; (foo 3)&lt;br /&gt;4&lt;br /&gt;&lt;br /&gt;With this as our base let’s explore a classic example of closure. Yeah! The same old make-adder example, what I am talking about.&lt;br /&gt;&lt;br /&gt;Here is the code for that:&lt;br /&gt;&lt;br /&gt;[4]&gt; (defun make-adder(n)&lt;br /&gt;       #&#39;(lambda(x)(+ x n)))&lt;br /&gt;MAKE-ADDER&lt;br /&gt;&lt;br /&gt;[5]&gt; (setf add1 (make-adder 1))&lt;br /&gt;#&lt;function lambda=&quot;&quot; x=&quot;&quot;&gt;&lt;br /&gt;&lt;br /&gt;[6]&gt; (funcall add1 2)&lt;br /&gt;3&lt;br /&gt;&lt;br /&gt;When we defined make-adder we created a closure with variable n in lambda function with its own variable x. As we call make-adder and store the resultant function in variable add1 we created a closure where we will add 1 to the passed argument. Now that’s OK but how can I use it? This question I faced from many. Here is my use case.&lt;br /&gt;&lt;br /&gt;MOVE&lt;br /&gt;&lt;br /&gt;I (with my friends) developed a simulator for Intel 8085 microprocessor in C. later I tried to redo the code in lisp and found a very interesting application of make-adder closure. By this time I got familiar with IA-32 and Intel family of 80x86 processors where the logic MOVE have not changed but the number of bits (or bytes) to move has changed to match processor register size and architecture. That’s the “Aha!” moment for me. I wrote a function that will create a move as per the bytes to move. Here is the code for that (I have a move function which takes from-reg, to-reg for register purpose and number of bytes to move):&lt;br /&gt;&lt;br /&gt;  (defun make-mover(n)&lt;br /&gt;                  #&#39;(move from-reg to-reg n))&lt;br /&gt;&lt;br /&gt;This solved (I hope) my problem for backward (or forward) compatibility issues as long as Intel does not change its MOVE.&lt;br /&gt;&lt;br /&gt;So now I can get MOVE8, MOVE16 and MOVE32 very easily. I should re-write the whole program like that starting from register class definition.&lt;br /&gt;&lt;br /&gt;STATE MACHINE&lt;br /&gt;&lt;br /&gt;In the beginning we found that closure has close relation with function and its environment. This fact intuitively gives us a ready made case for state machine implementations in closure.&lt;br /&gt;&lt;br /&gt;Consider the following state machine; it has two states S0 (represented as 0) and S1 (represented as 1). Here is the logic that it performs, if the current state of the machine is S0 and input is 0 it remains in S0 else machine goes to state S1. If the current state of the machine is S1 and input is 0 it changes the state to S0 else it remains in state S1. This machine accepts 1 and 0 as input. Also note that this machine initializes at state S0.&lt;br /&gt;&lt;br /&gt;Here is the code:&lt;br /&gt;&lt;br /&gt;(let ((s0 0) (s1 1) (state 0))&lt;br /&gt;        (defun input-action(in)&lt;br /&gt;       (if (eq state in)&lt;br /&gt;            state&lt;br /&gt;           (if (eq state s0)&lt;br /&gt;                s1&lt;br /&gt;                s0))))&lt;br /&gt;&lt;br /&gt;And here is two sample runs:&lt;br /&gt;[19]&gt; (list (input-action 0) (input-action 1) (input-action 0))&lt;br /&gt;(0 1 0)&lt;br /&gt;[20]&gt; (list (input-action 0) (input-action 1) (input-action 0) (input-action 1) (input-action 1))&lt;br /&gt;(0 1 0 1 1)&lt;br /&gt;&lt;br /&gt;That’s all I have understood about closures. Let me know if something wrong or you have better idea of closure and its uses.&lt;br /&gt;&lt;br /&gt;Thanks for reading.&lt;br /&gt;&lt;br /&gt;&lt;/function&gt;</description><link>http://lispsamik.blogspot.com/2008/04/closure.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-565427211243579047</guid><pubDate>Thu, 06 Mar 2008 14:47:00 +0000</pubDate><atom:updated>2008-03-06T07:20:32.630-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">common lisp</category><title>On Parentheses</title><description>People think about lisp parentheses as most hard thing in the world. When I started learning lisp it was a bottleneck for me too. I used to think what you do with these parentheses? Why it is like this. But now when I have started feeling a bit confident about lisp parentheses I felt I should put a note for absolute beginners of the language.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Parentheses while coding lisp&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;While you are coding always use a lisp editor for your parentheses handling. Best option is Emacs or XEmacs. If you are using it in windows please install and configure your Emacs in Windows (for some idea you can see &lt;a href=&quot;http://lispsamik.blogspot.com/2007/09/slime-setup-for-windows.html&quot;&gt;here&lt;/a&gt;). Understand that good editor (like Emacs) will not only help you in coding in lisp but will increase your speed of translating your idea into code.&lt;br /&gt;&lt;br /&gt;Use good key combinations to move around the parentheses as s-expression. Do not waste your time with bad editors which does not support any lisp mode; the faster you unlearn (thoes editors) the better you will be in coding lisp.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Parenthesis while reading lisp codes&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;There is no parentheses in the lisp code when you are reading a code. Yes, it may sound crazy for anyone starting out in lisp but it is true. Here is an example showing the concept:&lt;br /&gt;&lt;br /&gt;(defun show-file(filename)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(let ((in (open filename :if-does-not-exist nil)))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(when in&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(format t &quot;~a~%&quot; (read-line in))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(close in)))&lt;br /&gt;&lt;br /&gt;Here is what you get when you removed all the parentheses:&lt;br /&gt;&lt;br /&gt;defun show-file filename&lt;br /&gt;let in open filename :if-does-not-exist nil&lt;br /&gt;when in&lt;br /&gt;format t “~a~%” read-line in&lt;br /&gt;close in&lt;br /&gt;&lt;br /&gt;It reads like:&lt;br /&gt;&lt;br /&gt;Define function show-file which will take filename as argument&lt;br /&gt;Let in be the file handler with filename; if the file does not exist do nothing&lt;br /&gt;When there is a file handler in “in”&lt;br /&gt;Format output as each line in the file comes&lt;br /&gt;And yes close the file “in” before quitting.&lt;br /&gt;&lt;br /&gt;That’s all! I hope this will help.</description><link>http://lispsamik.blogspot.com/2008/03/on-parenthesis.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-673075168630042232</guid><pubDate>Fri, 29 Feb 2008 08:22:00 +0000</pubDate><atom:updated>2008-03-03T08:31:17.535-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Programming</category><title>Imperative Programming:What is *Wrong*?</title><description>&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;What is *wrong* with the imperative programming? That’s the question that came up in a discussion where I was part; the dicussion group comprised of people from diverse software background and most of them has their lineage to C or C++. The points that came up during that discussion were well spread over the day to day activities of the programmers working in various types of projects. &lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;?xml:namespace prefix = o /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Actually if you see from a distance it is absolutely ok to write a piece of code in your favorite imperative language, but if you take some time and code the software in your favorite functional programming language it feels and looks better; of course your choice of functional programming language has to be good. &lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;FONT-WEIGHT: bold&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Side Effects&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Side effects make lot of problems while coding in imperative languages. Say you have a program that runs into several functions and as imperative language like C does not support higher order functions (in true sense) your functions are dependent on what we know as *GLOBAL VARIABLES*(to preserve the global state). Lets assume that you set an error flag if something has gone wrong in some function. As each function is interlinked in producer-consumer relationship with each other, once a function has done its job you have to see whether there is any error set or not. So your code will be sprinkled with codes like this:&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;center&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;i =&lt;span style=&quot;font-size:+0;&quot;&gt; &lt;/span&gt;fn1();&lt;/span&gt; &lt;p&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;if( !errorset())&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;fn2();&lt;/span&gt;&lt;/p&gt;&lt;/center&gt;&lt;p&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;This is not only bad while typing but also an example how a programmer loose his ability to think. How? As our example goes if you do it in several files and several functions; one fine morning loose the intent to think what may go wrong in simple function which is just checking whether a file exists or not! And I can tell you this happens because this happened with me. &lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Other than this, think about the time that I spent error handling. People might say that this is because you are using a programming language which does not support better error handling mechanisms to help the programmer. I agree, but as we know the imperative programming languages will always depend on Hoare Logic, i.e. it will have the notion of pre and post conditions. If we see both the paradigms of programming (lambda calculi and Turing machines) depends on those conditions but pure functional programming does not have side effects as it does not change (although lisp programs can do that) the values of its parameter. &lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;But when I code in lisp I know that if I need an output from one function to another I will using the first one as a higher order function to the later. Then the second function only need to know what it expected out of the calling function if something goes wrong in the higher function it can handle it then and there and end the execution flow gracefully. &lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;This brings me to next topic execution flow.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;FONT-WEIGHT: bold&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Execution flow: Where am I?&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Yup! This is a nightmare for any programmer in the imperative programming world; a bunch of programmer I knew once wrote a simulation program for Intel 8085 microprocessor but after each cycle of execution they didn’t know from where the program exited. It used to exit with unhandled error each time in Windows. If you think who they were I can tell you I was in that group. It took us some effort to fill that gap.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Now you might say that boy that doesn’t happen in real world! Oh yes that does not happen but we always have way to complete the process and most of the time the process is return-return-return till you come to main and then do simple check up and clean up of your mess with memory and then die by returning 0. No problems with that but think that if an execution starts and you know from the first command line checking itself that the user has made a mistake but you still follow your way of closing after eating some good processor time. &lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;But in lisp you can’t loose your track! Even if you want you can’t, simple. How? If you are creating a properly designed lisp code with functional style you will be calling functions on top of one another so it will go on till the boundary of your hardware! It may fail some times but you will not be loosing your track. Even in error without any extra effort from your side you will be getting messages like: “Debugger invoked on ….”! I say, it’s just cool.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;FONT-WEIGHT: bold&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;LOC – Yeah the greatest enemy of code!&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;I think Steve has given enough reason in his post so I need not prove this. But yes if I look at my C code some times I cry! How much I have typed for so little. Take the famous, old and boring “Hello World” program. In C you have to type at least 5 lines. In lisp REPL it’s only “Hello World”. Even a fancy function will be 2 lines. So you save 60% of typing effort while working with “Hello world” program.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;And as the saying goes with lazy programmer I feel good while I use my “TAB” key for auto complete in XEmacs. &lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;It happens especially if you need to work with raw data. By the time I finish structure filling code in C, I bet will be able to complete a subset of other tasks like some parsing also.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;The crux of the matter is doing more out of less. If this is not good enough for you rethink about becoming a programmer.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;FONT-WEIGHT: bold&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Macros&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;My first impression about C macros was, “Here is subject which I need to learn because I really do not know what is wrong with my code when I use them.” The best macro I have used in my C code:&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;# define&lt;span style=&quot;font-size:+0;&quot;&gt; &lt;/span&gt;PRINTLN&lt;span style=&quot;font-size:+0;&quot;&gt; &lt;/span&gt;printf(“\n”);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;And believe me it worked wonderfully for me. People in that discussion never understood what I was talking about when I said “function returning macro” or “code writing macros”. Because they do not know what a power a macro can have if you are programming lisp.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;(I can go on talking about macros but I should refrain as this is not a sub-topic but requires major effort and can span several posts.)&lt;/span&gt;&lt;/p&gt;</description><link>http://lispsamik.blogspot.com/2008/02/imperative-programmingwhat-is-wrong.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-6487062991548204229</guid><pubDate>Tue, 19 Feb 2008 06:48:00 +0000</pubDate><atom:updated>2012-01-22T10:52:25.897-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">common lisp</category><category domain="http://www.blogger.com/atom/ns#">Diophantine Equation</category><category domain="http://www.blogger.com/atom/ns#">Mathematics</category><title>A Small Mathematical Project</title><description>&lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Some times back I received an invitation to join an online community on Diophantine equations and related mathematical group in my Orkut account. I did not join the group for quite some time as I am very irregular in Orkut. But at last I when I wanted to join the group it is no longer there, this group’s moderator, a student of Indian Institute of Technology, wanted to run the community as complete mathematical community, unfortunately he decided to close the group.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;When I learned about Diophantine equations in little details, I felt that how about writing a small common lisp utility to get going in this field. There were challenges to do that and more for a person like me who likes to work on his own code rather than using library in hobby projects. This post is all about what I felt during that development. I made a point of writing some lines while coding. Not as a comment but as a thought process.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;How can I create a set (list) of values starting from one number and ending at another number? This question came to my mind first and the solution is writing a function which will give me a list like that on demand. It is intuitive that the arguments in this function would be a starting number, an end number and an incremental element which will increment the starting number till the end number or less. Moreover Diophantine equation demands that variables needs to integers.&lt;/span&gt;&lt;/p&gt;&lt;center  style=&quot;font-family:georgia;&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;!--?xml:namespace prefix = o /--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;(defun diophantine-create-set(start end)&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;(loop for n from start to end&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;while(&amp;lt;= n end) collect n))&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/center&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family:georgia;font-size:85%;&quot;&gt;Once I got that I have to think how I can represent a Diophantine equation in common lisp. The first thing that I felt is this has to be small so it will be a two unknown argument equation not an n-unknown Diophantine. At this point my imaginary linear Diophantine looked something like:&lt;/span&gt; &lt;center  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Ax + By = K&lt;br /&gt;&lt;/span&gt;&lt;/center&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;Here I have to get the constant values from the user. That is good enough but another step needs to be done in this, which re-writing the equation,&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;center&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;y = (K – Ax) / B&lt;br /&gt;&lt;/span&gt;&lt;/center&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Once I got this form of the equation I can write something like:&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;center&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;(lambda (x)&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;(/ (- k (* a x)) b))&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/center&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;So now how do I do this? I have come with this macro:&lt;/span&gt;&lt;br /&gt;&lt;center&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;(defmacro diophantine-equation (a b k s e)&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;`(mapcar #&#39;(lambda(x) (/ (- ,k (* ,a x)) ,b)) (diophantine-create-set ,s ,e)))&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/center&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Following are some evaluation of this macro:&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;COLOR: rgb(153,51,102);font-size:85%;&quot; &gt;CL-USER&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt; (diophantine-equation 1 1 10 1 100)&lt;br /&gt;(9 8 7 6 5 4 3 2 1 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;-18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;-37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;-56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;-75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90)&lt;/span&gt;&lt;span style=&quot;COLOR: rgb(153,51,102);font-size:85%;&quot; &gt;&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;COLOR: rgb(153,51,102);font-size:85%;&quot; &gt;CL-USER&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt; (diophantine-equation 2 1 10 1 100)&lt;br /&gt;(8 6 4 2 0 -2 -4 -6 -8 -10 -12 -14 -16 -18 -20 -22 -24 -26 -28 -30 -32 -34 -36&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;-38 -40 -42 -44 -46 -48 -50 -52 -54 -56 -58 -60 -62 -64 -66 -68 -70 -72 -74&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;-76 -78 -80 -82 -84 -86 -88 -90 -92 -94 -96 -98 -100 -102 -104 -106 -108 -110&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;-112 -114 -116 -118 -120 -122 -124 -126 -128 -130 -132 -134 -136 -138 -140&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;-142 -144 -146 -148 -150 -152 -154 -156 -158 -160 -162 -164 -166 -168 -170&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;-172 -174 -176 -178 -180 -182 -184 -186 -188 -190)&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;Looks fine till now but see what you get from the following evaluation:&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;COLOR: rgb(153,51,102);font-size:85%;&quot; &gt;CL-USER&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt; (diophantine-equation 2 5 10 1 100)&lt;br /&gt;(8/5 6/5 4/5 2/5 0 -2/5 -4/5 -6/5 -8/5 -2 -12/5 -14/5 -16/5 -18/5 -4 -22/5&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;-24/5 -26/5 -28/5 -6 -32/5 -34/5 -36/5 -38/5 -8 -42/5 -44/5 -46/5 -48/5 -10&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;-52/5 -54/5 -56/5 -58/5 -12 -62/5 -64/5 -66/5 -68/5 -14 -72/5 -74/5 -76/5&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;-78/5 -16 -82/5 -84/5 -86/5 -88/5 -18 -92/5 -94/5 -96/5 -98/5 -20 -102/5&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;-104/5 -106/5 -108/5 -22 -112/5 -114/5 -116/5 -118/5 -24 -122/5 -124/5 -126/5&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;-128/5 -26 -132/5 -134/5 -136/5 -138/5 -28 -142/5 -144/5 -146/5 -148/5 -30&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;-152/5 -154/5 -156/5 -158/5 -32 -162/5 -164/5 -166/5 -168/5 -34 -172/5 -174/5&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;-176/5 -178/5 -36 -182/5 -184/5 -186/5 -188/5 -38)&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;Now the main aim of diophantine equations is failing, as only the integer solutions are accepted as per Diophantine analysis. In the last evaluation we have some integer solution but this list has both integers as well as fractions. This to me is simply “Not acceptable!”&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Moreover I can bet that it will not be acceptable in mathematics community. &lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;At this point of development I had to put some more code in my diophantine-equation macro, it has to check whether a solution is integer or not. I will map the list and create a list of solutions with integers if it exists. To achieve this I introduced another macro because I wanted to keep diophantine-equation macro as it is. Here is the macro:&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;center&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;(defmacro diophantine-solutions(a b k s e)&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;`(remove nil (mapcar #&#39;(lambda(x)&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;(when (integerp x)&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;x))&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;(diophantine-equation ,a ,b ,k ,s ,e))))&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/center&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;Let’s see what kind of output I have from this macro:&lt;/span&gt; &lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;COLOR: rgb(153,51,102);font-size:85%;&quot; &gt;CL-USER&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt; (diophantine-solutions 2 5 10 1 100)&lt;br /&gt;(0 -2 -4 -6 -8 -10 -12 -14 -16 -18 -20 -22 -24 -26 -28 -30 -32 -34 -36 -38)&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;Now as we have built this basic framework for Diophantine analysis, let’s put this to some test. I know that I may not be able to answer a lot of questions asked in Diophantine analysis. But this small framework can answer a basic question right now. The first question that is asked in Diophantine analysis is, “Are there any solutions?” of course I have to reframe the question as per my framework as “Are there any solution between the range that I have mentioned?” it looks something like this in the REPL.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;COLOR: rgb(153,51,102);font-size:85%;&quot; &gt;CL-USER&amp;gt;&lt;/span&gt; (if (eq nil (diophantine-solutions 2 5 10 1 100))&lt;br /&gt;nil&lt;br /&gt;t)&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;br /&gt;T&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;COLOR: rgb(153,51,102);font-size:85%;&quot; &gt;CL-USER&amp;gt;&lt;/span&gt; (if (eq nil (diophantine-solutions 2 5 10 1 4))&lt;br /&gt;nil&lt;br /&gt;t)&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;NIL&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;COLOR: rgb(153,51,102);font-size:85%;&quot; &gt;CL-USER&amp;gt;&lt;/span&gt; (if (eq nil (diophantine-solutions 2 5 10 1 1))&lt;br /&gt;nil&lt;br /&gt;t)&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;NIL&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;COLOR: rgb(153,51,102);font-size:85%;&quot; &gt;CL-USER&amp;gt;&lt;/span&gt; (if (eq nil (diophantine-solutions 2 5 10 1 10))&lt;br /&gt;nil&lt;br /&gt;t)&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;T&lt;/span&gt; &lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;This utility has only one function and two macros. &lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;I hope you like this blog; however if you think that there is a better way (which I am sure would be) of doing some things that I have done here or if you find any bug please feel free comment on it. &lt;b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Thanks for reading.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:georgia;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;b&gt;Disclaimer: This is a hobby project not for any production use.&lt;span style=&quot;font-size:-0;&quot;&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;</description><link>http://lispsamik.blogspot.com/2008/02/small-mathematical-project.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1369853434158175571.post-1442541543688424747</guid><pubDate>Sat, 16 Feb 2008 11:33:00 +0000</pubDate><atom:updated>2008-02-20T22:24:31.522-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">common lisp</category><category domain="http://www.blogger.com/atom/ns#">Lambda Calculus</category><title>Lambda Calculus and Common Lisp</title><description>&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;Warning: If you do not like mathematics this post may not be interesting to you.&lt;span style=&quot;font-size:+0;&quot;&gt; &lt;/span&gt;&lt;?xml:namespace prefix = o /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;When we talk about lisp or any dialect of it we come across the term &lt;a href=&quot;http://en.wikipedia.org/wiki/Functional_programming&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;functional programming&lt;/span&gt;&lt;/a&gt;. So what is functional programming any way and where it all started? If you ever have thought about such things here is my small attempt to answer some very fundamental questions in functional programming.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;So what are the functions? Here are some basics. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;In mathematics functions is some kind of relation between two things. But wait a minute isn’t functions are some code snippet that does some tasks? After all we programmers know functions that way. Yeah, both are correct and they do not have any difference. Like a function, which increments a variable by one, can be represented in following way:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;f(x) = x + 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;So we can write a lot of functions like this in mathematic and solve them for a value. However there was no such concept as function in the begging of computer science instead there were just Turing machines which used to change state to provide result and solve problems by means of its states; this is such a great system that it can solve all computational problems. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;Then &lt;?xml:namespace prefix = st1 /&gt;&lt;st1:place st=&quot;on&quot;&gt;&lt;st1:placename st=&quot;on&quot;&gt;Alonzo&lt;/st1:placename&gt; &lt;st1:placetype st=&quot;on&quot;&gt;Church&lt;/st1:placetype&gt;&lt;/st1:place&gt; came up with lambda calculus and revolutionizes the whole concept of representing and solving problems. He wanted to solve some mathematical paradox (if you want to know about them see &lt;span style=&quot;COLOR: rgb(51,102,255)&quot;&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Russell&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;http://en.wikipedia.org/wiki/Kleene-Rosser_paradox&quot;&gt;here&lt;/a&gt;&lt;/span&gt;); unfortunately that was not solved but we got our base for functional programming.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;I think its enough of history; let’s start what this post is all about.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;Basic Notations&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;Here is how you can represent the previous function in λ calculus:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;λx.x+1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;And if we want to evaluate for x = 2 we write it as:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;(λx.x+1)2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;Now we can write the same in common lisp as:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;((lambda(x)&lt;br /&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;(+ x 1)) 2)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;Now functional calculus we have learnt another thing which is higher order functions. Higher order functions are nothing but functions whose arguments are also functions (I will not get into the evaluation debate here).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;Like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;Suppose we have a function f(x) = x + 1 and g(x) = x + 2 and we are calling f(x) as f(g(x)). &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;How is it going to be evaluated?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN-LEFT: 0.25in&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;f(g(x)) = g(x) + 1 = x + 2 + 1 = x + 3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN-LEFT: 0.25in&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;So how do we represent it lambda calculus?&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;(λx.x+1)(λx.x+2)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;Now if we want to evaluate this for x = 2 we write it as&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;(λx.x+1)(λx.x+2)2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;In common lisp we write:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;((lambda(x)(+ x 1))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;((lambda(x)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;(+ x 2))2))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;Free or Unbound Variable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;“The variable X is unbound.”&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;How many times you have got this message in your REPL? This comes directly from lambda calculus; here is how. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;Any variable that is not a member of any lambda expression is called a free variable and it does not have any effect on the evaluation of that expression. However in programs we cannot use such variable for evaluation. If we do so we get this error message. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;In lambda calculus a variable in cases like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;λx.(x * y)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;Here the variable y is free. The same happens in common lisp. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;((lambda(x) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;(* x y))1) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;Logical Stuffs&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;In programming we use logical operators every day, the two mostly(or *ONLY*) used of them are *AND* and *OR*. How lambda calculus does it?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;Before I start I want to give the meaning of the following lambda expression:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;λxy.xxy =&gt; λxy. if x then x or y.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;And this expression is the *OR* function in lambda calculus. So we can write it in common lisp as:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:+0;&quot;&gt;&lt;/span&gt;(lambda(x y)&lt;span style=&quot;font-size:+0;&quot;&gt; &lt;/span&gt;(if x x y))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;The *AND* function also look quite similar&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;Lambda Calculus: λxy.xyx&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;Common Lisp: (lambda(x y)&lt;span style=&quot;font-size:+0;&quot;&gt; &lt;/span&gt;(if x y x))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;So that’s all about very ugly comparison of lambda calculus and common lisp. I know that I missed lot of things which include reductions and reduction strategies. But one can read about lambda calculus tutorials to get fair idea on this; here is my choice:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;a&quot;&gt;&lt;span style=&quot;font-size:10;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/www.cs.chalmers.se/Cs/Research/Logic/TypesSS05/Extra/geuvers.pdf&quot;&gt;www.cs.chalmers.se/Cs/Research/Logic/TypesSS05/Extra/geuvers.&lt;b&gt;pdf&lt;/b&gt;&lt;/a&gt;&lt;b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;a&quot;&gt;&lt;span style=&quot;font-size:10;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;a&quot;&gt;&lt;span style=&quot;font-size:10;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/www.utdallas.edu/~gupta/courses/apl/lambda.pdf&quot;&gt;www.utdallas.edu/~gupta/courses/apl/lambda.&lt;b&gt;pdf&lt;/b&gt;&lt;/a&gt;&lt;b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:Georgia;&quot;&gt;Thanks for reading. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;</description><link>http://lispsamik.blogspot.com/2008/02/lambda-calculus-and-common-lisp.html</link><author>noreply@blogger.com (samik chakraborty)</author><thr:total>2</thr:total></item></channel></rss>