[Haskell-cafe] #haskell works
Don Stewart
dons at galois.com
Sat Dec 15 15:28:00 EST 2007
dons:
> bulat.ziganshin:
> > Hello Don,
> >
> > Saturday, December 15, 2007, 10:57:02 PM, you wrote:
> >
> > > Do you have the single loop C program, btw? I'd be curious to see if
> > > this is really "feasible". It would have to do the buffering, tokenising
> > > and accumulating in one go. I'd imagine it is a bit hairy.
> >
> > for (int n; n = read (0, buf, 32768);) {
> > for (char *p=buf,*end=buf+n;;)
> > while (*p++==' ') if(p==end) goto end;
> > while (*p++!=' ') if(p==end) goto end;
> > words++;
> > }
> > end:;
> > }
>
Oh, this isn't the original program, either. You need to find the
longest word and print it. Not count the words.
-- Don
More information about the Haskell-Cafe
mailing list