[Haskell-cafe] #haskell works

Don Stewart dons at galois.com
Sat Dec 15 15:26:04 EST 2007


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:;
> }

How many loops is that, Bulat? :)

-- Don


More information about the Haskell-Cafe mailing list