Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #49145
| From | Rod Pemberton <NoHaveNotOne@bcczxcfrze.cam> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Book? |
| Date | 2016-07-14 02:35 -0400 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <20160714023508.7ae38dca@_> (permalink) |
| References | <nm5usm$e5g$1@news.albasani.net> <nm691o$n6o$1@dont-email.me> |
On Wed, 13 Jul 2016 20:41:33 -0000 (UTC)
"WJ" <w_a_x_man@yahoo.com> wrote:
> Ruby:
>
> text = "
> Suppose some fellow (probably a reckless
> fool) wanted to read an introductory book on
> Forth, what would you recommend? He has
> programmed in such languages as C, Modula-2,
> PL/M, ..., but not in Forth.
> Made weak by time and fate, but strong in will
> To strive, to seek, to find, and not to yield."
>
> words = text.scan(/\w+/).values_at(17,44,50,34,36)
> words.first.capitalize!
> words.last << "."
> words.join(" ")
> ===>
> "You will find Forth weak."
>
In ANSI C:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
char text[]="Suppose some fellow (probably a reckless fool) wanted to
read an introductory book on Forth, what would you recommend? He has
programmed in such languages as C, Modula-2, PL/M, ..., but not in
Forth. Made weak by time and fate, but strong in will To strive, to
seek, to find, and not to yield.";
int main(void)
{
int i=0;
char *p=text,*a[256];
while(p!=NULL){i++;p=strpbrk(p," ,.()?");if(p!=NULL){*p='\0';p++;a[i]=p;}};
p=a[20];*p=toupper(*p);
printf("%s %s %s %s %s.\n",a[20],a[58],a[66],a[45],a[49]);
return(0);
}
Output:
You will find Forth weak.
If the best that Ruby can do is to shave a few setup lines from C, it
really doesn't seem to me to be all that amazing. Note that this is
ANSI C or C89 which was standardized in 1989, and not ISO C99.
I'd really like to see a Forth version. I'm a bit unsure as to how
string processing such as this is handled in Forth.
Rod Pemberton
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Book? Peter Percival <peterxpercival@hotmail.com> - 2016-07-13 18:48 +0100
Re: Book? Alex Dowad <alexinbeijing@gmail.com> - 2016-07-13 10:50 -0700
Re: Book? rickman <gnuarm@gmail.com> - 2016-07-13 13:53 -0400
Re: Book? Syd Rumpo <usenet@nononono.co.uk> - 2016-07-13 19:30 +0100
Re: Book? hughaguilar96@gmail.com - 2016-07-13 11:51 -0700
Re: Book? Peter Percival <peterxpercival@hotmail.com> - 2016-07-13 23:09 +0100
Re: Book? Syd Rumpo <usenet@nononono.co.uk> - 2016-07-14 08:51 +0100
Re: Book? "Elizabeth D. Rather" <erather@forth.com> - 2016-07-13 09:26 -1000
Re: Book? hughaguilar96@gmail.com - 2016-07-13 17:50 -0700
Re: Book? "WJ" <w_a_x_man@yahoo.com> - 2016-07-13 20:41 +0000
Re: Book? Rod Pemberton <NoHaveNotOne@bcczxcfrze.cam> - 2016-07-14 02:35 -0400
Re: Book? Julian Fondren <julian.fondren@gmail.com> - 2016-07-14 00:36 -0700
Re: Book? Julian Fondren <ayrnieu@gmail.com> - 2016-07-13 15:21 -0700
Re: Book? hughaguilar96@gmail.com - 2016-07-13 18:41 -0700
Re: Book? rickman <gnuarm@gmail.com> - 2016-07-13 22:36 -0400
Re: Book? "WJ" <w_a_x_man@yahoo.com> - 2016-07-14 06:18 +0000
Re: Book? Mark Wills <markwills1970@gmail.com> - 2016-07-14 03:16 -0700
Re: Book? Cecil Bayona <cbayona@cbayona.com> - 2016-07-14 09:09 -0500
Re: Book? endlessboomcapitalism@gmail.com - 2016-07-14 09:47 -0700
Re: Book? "HAA" <someone@microsoft.com> - 2016-07-17 16:59 +1000
csiph-web