<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2794053408421760491</id><updated>2011-04-21T21:59:24.373-07:00</updated><category term='sicp c++ functional weima'/><category term='sicp c++ functional programming weima'/><title type='text'>SICP++</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sicp-plus-plus.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2794053408421760491/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://sicp-plus-plus.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>weima</name><uri>http://www.blogger.com/profile/13250647442722796831</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2794053408421760491.post-7404374368961655120</id><published>2008-06-23T13:55:00.000-07:00</published><updated>2008-06-23T14:23:26.412-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sicp c++ functional programming weima'/><title type='text'>question: find the 2nd highest number</title><content type='html'>Hi,&lt;br /&gt;&lt;br /&gt;Here is  a question requiring use of functional programming in C++&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Question 1: &lt;/span&gt;write a function in c++ which takes as input 5 integers and returns the 2nd highest inegers.&lt;br /&gt; e.g.  func(10, 13, 2, 8, 23) returns 13&lt;br /&gt; &lt;span style="color: rgb(204, 0, 0);"&gt;The constraint&lt;/span&gt; is that the C++ function should &lt;span style="color: rgb(153, 0, 0);"&gt;not use any kind of variables&lt;/span&gt; (local or global) what-so-ever.&lt;br /&gt; This has to be done in purely functional way.&lt;br /&gt; Also the solution should be easily extendable to a function with say 10 or 20 parameters.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Question 2: &lt;/span&gt;Change the above function such that the function returns 2nd highest, 3rd highest ... number   based on an extra argument which is, say, the last argument to the function.&lt;br /&gt;  e.g.  func(10, 13, 2, 8, 23, 2) returns 13&lt;br /&gt;          func(10, 13, 2, 8, 23, 3) returns 10&lt;br /&gt;          func(10, 13, 2, 8, 23, 1) returns 23&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Question 3&lt;/span&gt;: Since the above can be computed at compile time, do the above exercises at compile time.&lt;br /&gt;&lt;br /&gt;Please share your answers in the comments below.&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;weima&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;PS: And if you find the question too stupid, please say so in the comments. :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2794053408421760491-7404374368961655120?l=sicp-plus-plus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sicp-plus-plus.blogspot.com/feeds/7404374368961655120/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2794053408421760491&amp;postID=7404374368961655120' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2794053408421760491/posts/default/7404374368961655120'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2794053408421760491/posts/default/7404374368961655120'/><link rel='alternate' type='text/html' href='http://sicp-plus-plus.blogspot.com/2008/06/question-find-2nd-highest-number.html' title='question: find the 2nd highest number'/><author><name>weima</name><uri>http://www.blogger.com/profile/13250647442722796831</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2794053408421760491.post-2693808744510219132</id><published>2008-06-23T13:45:00.000-07:00</published><updated>2008-06-23T13:53:14.001-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sicp c++ functional weima'/><title type='text'>why sicp++</title><content type='html'>Hi,&lt;br /&gt;&lt;br /&gt;Here i want to do a few selected exercises from &lt;a style="font-weight: bold;" href="http://mitpress.mit.edu/sicp/full-text/book/book.html"&gt;sicp&lt;/a&gt; in C++. My aim is to be able to take the concepts taught in sicp, and apply it to my C++ programs.&lt;br /&gt;&lt;br /&gt;I want to focus mainly on the chapters&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;b&gt;&lt;a name="%_toc_%_chap_1" href="http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-9.html#%_chap_1"&gt;Building Abstractions with Procedures&lt;/a&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;a name="%_toc_%_chap_2" href="http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-13.html#%_chap_2"&gt;Building Abstractions with Data&lt;/a&gt;&lt;/b&gt;&lt;/li&gt;&lt;/ol&gt;I hope the concepts in these chapters help me immensly.&lt;br /&gt;&lt;br /&gt;regards,&lt;br /&gt;weima&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2794053408421760491-2693808744510219132?l=sicp-plus-plus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sicp-plus-plus.blogspot.com/feeds/2693808744510219132/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2794053408421760491&amp;postID=2693808744510219132' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2794053408421760491/posts/default/2693808744510219132'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2794053408421760491/posts/default/2693808744510219132'/><link rel='alternate' type='text/html' href='http://sicp-plus-plus.blogspot.com/2008/06/why-sicp.html' title='why sicp++'/><author><name>weima</name><uri>http://www.blogger.com/profile/13250647442722796831</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
