Recently code for a word-count program was posted in Python
here on comp.lang.forth.
https://groups.google.com/g/comp.lang.forth/c/jw6yU_yI15E
This was said:
On Thursday, December 30, 2021 at 1:12:23 AM UTC-7, dxforth wrote:
> On 30/12/2021 14:59, Hugh Aguilar wrote:
> > On Tuesday, December 28, 2021 at 8:07:01 PM UTC-7, dxforth wrote:
> >> On 29/12/2021 01:44, Andy Valencia wrote:
> >> > ...
> >> > I could write this in Forth, but I don't want to. It would be tedious
> >> > and take a LOT more time than these four lines of Python.
> >
> > Andy Valencia doesn't want to do this program in Forth because he doesn't know
> > Forth very well and hence even simple programs seem tedious and difficult to him.
> > A program such as this is trivial given my novice-package which is ANS-Forth.
> > ASSOCIATION.4TH can be used to collect all of the distinct words. Each node's key
> > would be the string and it would have one datum tacked on which would be the count.
> > STRING-STACK.4TH can be used to parse out the words from the text.
> > STRING-STACK.4TH has pretty good pattern-matching and sub-string extraction
> > capability, so it could use a much more sophisticated definition of what a word is
> > than just a blank-delimited string --- no word-count program has been so crude as to
> > use blank-delimited strings since the early 1970s --- that is kindergarten-level programming.
> >
> >> "We choose to go to the Moon [...] and do the other things, not because
> >> they are easy, but because they are hard; because that goal will serve
> >> to organize and measure the best of our energies and skills"
> >>
> >> The de-skilling of people that has occurred over the last 40 years because
> >> subsequent govts chose the easy way, has made us all dumb and vulnerable.
> >
> > DXforth says this as if he had skill --- but he doesn't --- he is all talk and no programming
> > beyond kindergarten-level programming such as his END macro.
> >
> END - easy to remember, easy to use and no shortage of ELSE to eliminate.
> It doesn't get better than that. It'll do me as an epitaph.
I was patient with DXforth (the idiot previously known as HAA) and his
kindergarten-level Forth programming. I even included his much-hyped
END macro in the novice-package:
-----------------------------------------------------------------------------------------------
\ END was HAA's idea:
\
https://groups.google.com/forum/#!topic/comp.lang.forth/MdGWDMEbKIA
macro: end ( -- )
exit then ;
macro: ?exit ( -- ) \ like END but even less useful
if exit then ;
-----------------------------------------------------------------------------------------------
Of course, DXforth doesn't have MACRO: because that kind of programming
is way beyond his skill-level, so he would have to write END like this:
-----------------------------------------------------------------------------------------------
: end ( -- ) postpone exit postpone then ; immediate
-----------------------------------------------------------------------------------------------
I am not patient with DXforth anymore because he attacked me by
using the term "disambiguifier" for some idiotic nonsense that he was
blathering about. He was mocking me and my disambiguifiers (that are
required for MACRO: to work) --- this insult will not be forgiven.
Anyway, getting back to the subject of a word-count program,
this is trivial for me to write given the novice package. I post this challenge
now though, that the Forth experts of comp.lang.forth should attempt this.
The first part of the challenge is to parse distinct "words" out of the
text stream. This is the hard part. Counting distinct words is trivial
given ASSOCIATION.4TH or something similar.
Here is my definition of a "word" (I just thought this up off the top
of my head; the definition may need some revision).
Punctuation is defined as one of: . , : ; ! ? ( )
Punctuation delimits words, as does whitespace.
The ' is an apostrophe. The 's is removed and only the prefix is used.
Any word with an @ in it is assumed to be an email address and is
left as is (not broken apart on the dot character).
Numbers are left as is (not broken apart on the dot character).
I'll worry about the hyphen later --- what I have above is enough for now.
Testing chars for punctuation can be done by DXforth using his END
macro. He would have a colon word with a series of IF ... END statements
testing for each character. This is not how I will do it though
(I have my <SWITCH ... FAST-SWITCH> construct).
So, comp.lang.forth experts --- prove that you haven't been de-skilled!