473,396 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Re: Intelligent stack?


<jo**********@post.czwrote in message
news:fc**********************************@p25g2000 hsf.googlegroups.com...
Hello,

I've came across an article at http://www.relisoft.com/Win32/olerant.html
from which is the citation below:
>Long, long time ago, when computer languages were still in their infancy,
the wizards of C were trying to implement a stack. They
....

However from this excerpt I do not understand how such a stack
actually works. Could anyone please provide an explanation of the
stack being described by the author?

I've no idea about the sort of stack being described. But implemented
something similar isn't that difficult I don't think. I put together this
code containing functions push() and pop() that require no housekeeping by
the caller:

#include <stdio.h>
#include <stdlib.h>

typedef int T; /* Must specify what data type to store */

typedef struct sstackelem{
T value;
struct sstackelem *next;
} stackelem;

stackelem *stack=NULL;

int push(T x) {
stackelem *new;

new=malloc(sizeof(stackelem));
if (new==NULL) return 0; /* Fail */

new->value=x;
new->next=stack;
stack=new;
return 1; /* OK */
}

T pop(void) {
T x;
stackelem *old;

if (stack==NULL) return 0;
x=stack->value;
old=stack;
stack=stack->next;
free(old);
return x;
}

int main(void) {
T x;
#define marker -1

if (!push(marker)) exit(0);

push(100);
push(200);
push(300);
push(400);

while((x=pop())!=marker)
printf("%d\n",x);
}

--
Bartc
Jun 27 '08 #1
1 1732
In article <Xy*****************@text.news.virginmedia.com>,
Bartc <bc@freeuk.comwrote:
>However from this excerpt I do not understand how such a stack
actually works. Could anyone please provide an explanation of the
stack being described by the author?
No. There isn't any explanation. It's a *joke*. It's meant to
be ridiculous.

It seems to be a rather verbose example of the "programming koan",
cf http://catb.org/jargon/html/koans.html#id3141202

From the context it's supposed to be an obviously-absurd parallel
with something in OLE, but since I don't know anything about OLE
I don't get it.

-- Richard
--
In the selection of the two characters immediately succeeding the numeral 9,
consideration shall be given to their replacement by the graphics 10 and 11 to
facilitate the adoption of the code in the sterling monetary area. (X3.4-1963)
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Steve Moyer | last post by:
The MetaMind ( http://metamind.us ) is a new kind of search engine which lets you enter links directly. You can easily extract links from files on your computer or web pages on the net. You can...
1
by: Stephen | last post by:
I am unable to get intelligent font matching to work. I used a @font-face with a Panose-1 descriptor. I tried it with both Internet Explorer 6 and Firefox on Windows 98 SE. The Panose numbers are...
0
by: Conference Secretary | last post by:
CALL FOR PAPERS International Conference on Intelligent Agents, Web Technologies and Internet Commerce http://www.ise.canberra.edu.au/conferences/iawtic05/ Jointly with International...
39
by: Noticedtrends | last post by:
Can inference search-engines narrow-down the number of often irrelevant results, by using specific keywords; for the purpose of discerning emerging social & business trends? For example, if...
2
by: Joe | last post by:
Hi, I have a newsletter subscribe page. A user enters email address and clicks Subscribe button. That email address is added to database. Say this is a career newsletter. Is it possible to...
1
by: Amé | last post by:
Hi, I am new to DB2 - Intelligent miner and I would like to perform some mining on data. My problem is that I have transactions of the following form Transaction ClientID Unit Article...
21
by: sirimanna | last post by:
hello, is any one can tell me how to create a small artificial intelligent programme using vb06. Can i creatre a artificial intelligent programme using vb6. is that vb06 support to creat a...
0
by: Ben Bacarisse | last post by:
johnywalkyra@post.cz writes: | Long, long time ago, when computer languages were still in their | infancy, the wizards of C were trying to implement a stack. <snip> No, it does not tell...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.