473,387 Members | 1,492 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,387 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 1731
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.