Path: csiph.com!aioe.org!.POSTED!not-for-mail From: Rod Pemberton Newsgroups: comp.lang.forth Subject: Re: Book? Date: Thu, 14 Jul 2016 02:35:08 -0400 Organization: Aioe.org NNTP Server Lines: 62 Message-ID: <20160714023508.7ae38dca@_> References: NNTP-Posting-Host: n4wpt9zq8xR26Ttf9mo2BA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: Claws Mail 3.13.1 (GTK+ 2.24.13; x86_64-unknown-linux-gnu) Xref: csiph.com comp.lang.forth:49145 On Wed, 13 Jul 2016 20:41:33 -0000 (UTC) "WJ" 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 #include #include 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