Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #34696 > unrolled thread

Re: Epic failure (was Epic Fail)

Started by"WJ" <w_a_x_man@yahoo.com>
First post2014-11-29 20:13 +0000
Last post2014-12-02 04:54 +0100
Articles 20 on this page of 24 — 14 participants

Back to article view | Back to comp.lang.forth

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Epic failure (was Epic Fail) "WJ" <w_a_x_man@yahoo.com> - 2014-11-29 20:13 +0000
    Re: Epic failure (was Epic Fail) C G Montgomery <cgm@physics.utoledo.edu> - 2014-11-29 17:15 -0500
    Re: Epic failure (was Epic Fail) Pablo Hugo Reda <pabloreda@gmail.com> - 2014-11-29 14:20 -0800
    Re: Epic failure awegel@arcor.de (Alexander Wegel) - 2014-11-29 23:35 +0100
    Re: Epic failure (was Epic Fail) Bernd Paysan <bernd.paysan@gmx.de> - 2014-11-30 00:31 +0100
    Re: Epic failure (was Epic Fail) Julian Fondren <julian.fondren@gmail.com> - 2014-11-29 17:41 -0800
      Re: Epic failure (was Epic Fail) mhx@iae.nl - 2014-11-30 00:04 -0800
        Re: Epic failure (was Epic Fail) mhx@iae.nl - 2014-11-30 00:09 -0800
          Re: Epic failure (was Epic Fail) Bernd Paysan <bernd.paysan@gmx.de> - 2014-11-30 17:22 +0100
    Re: Epic failure (was Epic Fail) "WJ" <w_a_x_man@yahoo.com> - 2014-11-30 02:13 +0000
      Re: Epic failure (was Epic Fail) Julian Fondren <julian.fondren@gmail.com> - 2014-11-29 18:55 -0800
      Re: Epic failure (was Epic Fail) albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-11-30 16:50 +0000
        Re: Epic failure (was Epic Fail) Bernd Paysan <bernd.paysan@gmx.de> - 2014-12-01 01:22 +0100
          Re: Epic failure (was Epic Fail) Melzzzzz <mel@zzzzz.com> - 2014-12-02 06:00 +0100
            Re: Epic failure (was Epic Fail) Melzzzzz <mel@zzzzz.com> - 2014-12-02 06:37 +0100
              Re: Epic failure (was Epic Fail) albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-12-02 12:28 +0000
              Re: Epic failure Paul Rubin <no.email@nospam.invalid> - 2014-12-02 18:03 -0800
          Re: Epic failure (was Epic Fail) the_gavino_himself <visphatesjava@gmail.com> - 2014-12-05 10:10 -0800
            Re: Epic failure (was Epic Fail) rickman <gnuarm@gmail.com> - 2014-12-05 16:23 -0500
              Re: Epic failure (was Epic Fail) Jason Damisch <jasondamisch@yahoo.com> - 2014-12-05 13:46 -0800
      Re: Epic failure (was Epic Fail) "WJ" <w_a_x_man@yahoo.com> - 2014-12-01 07:54 +0000
        Re: Epic failure awegel@arcor.de (Alexander Wegel) - 2014-12-01 14:02 +0100
          Re: Epic failure hughaguilar96@gmail.com - 2014-12-01 15:04 -0800
            Re: Epic failure awegel@arcor.de (Alexander Wegel) - 2014-12-02 04:54 +0100

Page 1 of 2  [1] 2  Next page →


#34696 — Re: Epic failure (was Epic Fail)

From"WJ" <w_a_x_man@yahoo.com>
Date2014-11-29 20:13 +0000
SubjectRe: Epic failure (was Epic Fail)
Message-ID<m5d9cn$o3s$1@dont-email.me>
The phrase "epic fail" is meaningless. "Fail" is not a noun.
You know very little about the English language and very little
about programming languages.


> Why did Forth fail so badly?
> 
> I mean the win of Java VS the fail of Forth is so
> absolute as to be mind boggling.  I'd like to hear
> a real answer, and not that "Forth Sucks"  because
> I think that Forth is a darn good mousetrap.  It
> is still quite usable and is extremely flexible.

I broke your lines for you.  Anyone who knows anything about
usenet knows that he must limit the length of his lines.

You should have written "the failure of Forth".
You will find it easier to communicate if you learn a
human language.

Forth is an extremely low-level and crude language, suitable only
for programming embedded controllers.

Gauche Scheme:

(use srfi-42)
(let1 table (make-hash-table)
  (dolist (ch (filter #[a-z]  (string->list
                  "The Wikipedia article on Java states that in 2014
                  Java is the most popular programming language with
                  9 million developers.  How many developers do you
                  think actually make money programming in Forth?
                  Probably about 9!")))
    (hash-table-update! table ch (pa$ + 1) 0))
  (do-ec (: ch #\a #\z)
    (print ch " " (make-string (hash-table-get table ch 0) #\*))))


a *******************
b ***
c **
d ****
e **************
f
g ******
h ******
i *************
j
k ***
l **********
m *********
n **********
o ***************
p *******
q
r **********
s ******
t ************
u *****
v ****
w **
x
y *****
z

Now struggle to program the equivalent in Forth.

[toc] | [next] | [standalone]


#34697

FromC G Montgomery <cgm@physics.utoledo.edu>
Date2014-11-29 17:15 -0500
Message-ID<m5dgi2$iqu$1@dont-email.me>
In reply to#34696
WJ w_a_x_man@yahoo.com wrote:

> ...
> Forth is an extremely low-level and crude language, suitable only
> for programming embedded controllers
When used only by low-level and crude programmers.

cgm

[toc] | [prev] | [next] | [standalone]


#34698

FromPablo Hugo Reda <pabloreda@gmail.com>
Date2014-11-29 14:20 -0800
Message-ID<1da2cefa-edcb-4d81-bff9-1549200b44dc@googlegroups.com>
In reply to#34696
El sábado, 29 de noviembre de 2014 17:13:29 UTC-3, WJ  escribió:
> The phrase "epic fail" is meaningless. "Fail" is not a noun.
> You know very little about the English language and very little
> about programming languages.
> 
> 
> > Why did Forth fail so badly?
> > 
> > I mean the win of Java VS the fail of Forth is so
> > absolute as to be mind boggling.  I'd like to hear
> > a real answer, and not that "Forth Sucks"  because
> > I think that Forth is a darn good mousetrap.  It
> > is still quite usable and is extremely flexible.
> 
> I broke your lines for you.  Anyone who knows anything about
> usenet knows that he must limit the length of his lines.
> 
> You should have written "the failure of Forth".
> You will find it easier to communicate if you learn a
> human language.
> 
> Forth is an extremely low-level and crude language, suitable only
> for programming embedded controllers.
> 
> Gauche Scheme:
> 
> (use srfi-42)
> (let1 table (make-hash-table)
>   (dolist (ch (filter #[a-z]  (string->list
>                   "The Wikipedia article on Java states that in 2014
>                   Java is the most popular programming language with
>                   9 million developers.  How many developers do you
>                   think actually make money programming in Forth?
>                   Probably about 9!")))
>     (hash-table-update! table ch (pa$ + 1) 0))
>   (do-ec (: ch #\a #\z)
>     (print ch " " (make-string (hash-table-get table ch 0) #\*))))
> 
> 
> a *******************
> b ***
> c **
> d ****
> e **************
> f
> g ******
> h ******
> i *************
> j
> k ***
> l **********
> m *********
> n **********
> o ***************
> p *******
> q
> r **********
> s ******
> t ************
> u *****
> v ****
> w **
> x
> y *****
> z
> 
> Now struggle to program the equivalent in Forth.

|-----------------------------------------------------------------
^r4/lib/gui.txt

#str "The Wikipedia article on Java states that in 2014 Java is the most popular programming language with 9 million developers.  How many developers do you think actually make money programming in Forth? Probably about 9!"
#hist )( 1024

:main
	'str ( c@+ 1? )( 1 swap 2 << 'hist + +! ) 2drop
 	show clrscr
	$61 ( $7b <? )(
		dup emit
		dup 2 << 'hist + @ ( 1? )( "*" print 1- ) drop
		cr 1+ ) drop
	'exit >esc<
	;

: main ;

|-----------------------------------------------------------------

Please change forum!! 

[toc] | [prev] | [next] | [standalone]


#34699 — Re: Epic failure

Fromawegel@arcor.de (Alexander Wegel)
Date2014-11-29 23:35 +0100
SubjectRe: Epic failure
Message-ID<1lvwbpa.rbxhcwn016mcN%awegel@arcor.de>
In reply to#34696
WJ <w_a_x_man@yahoo.com> wrote:

> You will find it easier to communicate if you learn a
> human language.

Deer Mr WankJob, you will find it easier to communicate if you stop
being an arrogant arse.
BTW: You seem to be the only one around having this comprehension
problem (and if you didn't notice: Fail *is* a noun these days).

gfys(&ym)

[toc] | [prev] | [next] | [standalone]


#34700

FromBernd Paysan <bernd.paysan@gmx.de>
Date2014-11-30 00:31 +0100
Message-ID<m5dkvt$uo$1@dont-email.me>
In reply to#34696
WJ wrote:
> Forth is an extremely low-level and crude language, suitable only
> for programming embedded controllers.

Well, only idiots struggle with Forth.

> Gauche Scheme:
> 
> (use srfi-42)
> (let1 table (make-hash-table)
>   (dolist (ch (filter #[a-z]  (string->list
>                   "The Wikipedia article on Java states that in 2014
>                   Java is the most popular programming language with
>                   9 million developers.  How many developers do you
>                   think actually make money programming in Forth?
>                   Probably about 9!")))
>     (hash-table-update! table ch (pa$ + 1) 0))
>   (do-ec (: ch #\a #\z)
>     (print ch " " (make-string (hash-table-get table ch 0) #\*))))
[...]
> Now struggle to program the equivalent in Forth.

$100 cells buffer: chist
: stars ( n -- )  0 ?DO  '*' emit  LOOP ;
: .hist-az ( -- )  'z' 1+ 'a' DO
  cr i emit space chist i cells + @ stars  LOOP ;
: hist ( addr u -- )
  bounds ?DO  1 i c@ cells chist + +!  LOOP ;
s" The Wikipedia article on Java states that in 2014 Java is the most 
popular programming language with 9 million developers.  How many developers 
do you think actually make money programming in Forth? Probably about 9!" 
hist .hist-az

Written, did run first try without debugging, and produced the same result 
as your program.  And it's all Forth 200x without any library.

a *******************
b ***
c **
d ****
e **************
f 
g ******
h ******
i *************
j 
k ***
l **********
m *********
n **********
o ***************
p *******
q 
r **********
s ******
t ************
u *****
v ****
w **
x 
y *****
z

One question: Why didn't you write the code in Java, but in Scheme instead?  
You did even use a library, while I only used very basic Forth stuff, core 
words only, stuff you may find on any controller.  Scheme is certainly just 
about as obscure as Forth.  If you want to make money, use Java instead.

And even though you did use a library, you have the same line count in your 
Scheme program.  One of the lines just loading the library...  Well, I'd say 
that is really pathetic.

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/

[toc] | [prev] | [next] | [standalone]


#34703

FromJulian Fondren <julian.fondren@gmail.com>
Date2014-11-29 17:41 -0800
Message-ID<c9e7f2f8-2214-43db-81d6-285593dbbcfd@googlegroups.com>
In reply to#34696
On Saturday, November 29, 2014 2:13:29 PM UTC-6, WJ wrote:
> Now struggle to program the equivalent in Forth.

How could you possibly think that this is a difficult task?  All
this time, with your presenting Ruby or whatever code for the
subject under discussion, I thought that you had at least learned
Forth at some point.

You can improve your challenge by:

1. requiring some Unicode handling.

2. requiring more than a 26-element array's worth of information.

3. requiring numbers or data structures of unbounded size.

4. using regexes or list comprehensions or lisp macros or complex
s-expressions as program data, which a Forth version must either
'struggle' to recreate or 'struggle' on without.

Paul Graham excluded Forth from http://www.paulgraham.com/accgen.html
for the single reason that it didn't have bignums without a
library.  You can at least be that clever about attacking Forth.

And your Scheme turns a string into a list of characters, loops
through them (probably) to create a second temporary list of
lowercase letters, which it then loops to sum them up in a hash
table.

You could do that, exactly, fail by fail, in Forth, but you never
would.  Create a list, just to throw it away, just to iterate
through a string?  You can see that Bernd didn't even bother to
limit himself to lowercase letters; rather than strip them out,
or test for lowercase-ness each time, he just counts all ASCII
values and then asks for just the lowercase letters later on.

And he doesn't clear CHIST at any point because he knows he's
going to run HIST once :-)

And where's the *benefit* from this crazy waste of resources?  The
code isn't smaller or faster or more succinct or more
understandable for it.  What you want to do is count lowercase
letters in a string.  If your language encourages you to think of
this task in terms of creating and then filtering intermediate
lists, then maybe it's not high level so much as wrong level -- a
tower of Pisa language, extending in a direction that's useful to
to neither man nor computer.

-- Julian

[toc] | [prev] | [next] | [standalone]


#34706

Frommhx@iae.nl
Date2014-11-30 00:04 -0800
Message-ID<53212bbf-bb4d-4531-b784-20452bd0eddb@googlegroups.com>
In reply to#34703
On Sunday, November 30, 2014 2:41:52 AM UTC+1, Julian Fondren wrote:
> On Saturday, November 29, 2014 2:13:29 PM UTC-6, WJ wrote:
> > Now struggle to program the equivalent in Forth.
> 
[..] 
> And he doesn't clear CHIST at any point because he knows he's
> going to run HIST once :-)
[..] 
Actually that is a bug (iForth is still printing stars), because 
chist could be/will be filled with trash the first time it is run.

create chist $100 cells allot chist $100 cells erase
fixes that, in the way you describe (run once).

-marcel

[toc] | [prev] | [next] | [standalone]


#34707

Frommhx@iae.nl
Date2014-11-30 00:09 -0800
Message-ID<abca6c7a-56b2-4157-94b0-6bed847e02ad@googlegroups.com>
In reply to#34706
On Sunday, November 30, 2014 9:04:59 AM UTC+1, m...@iae.nl wrote:
> On Sunday, November 30, 2014 2:41:52 AM UTC+1, Julian Fondren wrote:
> > On Saturday, November 29, 2014 2:13:29 PM UTC-6, WJ wrote:
> > > Now struggle to program the equivalent in Forth.
> > 
> [..] 
> > And he doesn't clear CHIST at any point because he knows he's
> > going to run HIST once :-)
> [..] 
> Actually that is a bug (iForth is still printing stars), because 
> chist could be/will be filled with trash the first time it is run.
> 
> create chist $100 cells allot chist $100 cells erase
> fixes that, in the way you describe (run once).

I am assuming that buffer: doesn't initialize its contents to zero,
its behavior when initially discussed.

[toc] | [prev] | [next] | [standalone]


#34715

FromBernd Paysan <bernd.paysan@gmx.de>
Date2014-11-30 17:22 +0100
Message-ID<m5fg85$mrr$1@dont-email.me>
In reply to#34707
mhx@iae.nl wrote:

> On Sunday, November 30, 2014 9:04:59 AM UTC+1, m...@iae.nl wrote:
>> On Sunday, November 30, 2014 2:41:52 AM UTC+1, Julian Fondren wrote:
>> > On Saturday, November 29, 2014 2:13:29 PM UTC-6, WJ wrote:
>> > > Now struggle to program the equivalent in Forth.
>> > 
>> [..]
>> > And he doesn't clear CHIST at any point because he knows he's
>> > going to run HIST once :-)
>> [..]
>> Actually that is a bug (iForth is still printing stars), because
>> chist could be/will be filled with trash the first time it is run.
>> 
>> create chist $100 cells allot chist $100 cells erase
>> fixes that, in the way you describe (run once).
> 
> I am assuming that buffer: doesn't initialize its contents to zero,
> its behavior when initially discussed.

Yes, a standard-conforming program is responsible for initializing this 
region - though I would expect that on a reasonable operating system all 
this freshly allocated content is zeroed out anyways.  I would probably make 
a separate word to clear the historgram, as it might be useful to 
incrementally feed strings into the historgram function and look at the 
overall statistics.

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/

[toc] | [prev] | [next] | [standalone]


#34704

From"WJ" <w_a_x_man@yahoo.com>
Date2014-11-30 02:13 +0000
Message-ID<m5dufq$vcm$1@dont-email.me>
In reply to#34696
WJ wrote:

> The phrase "epic fail" is meaningless. "Fail" is not a noun.
> You know very little about the English language and very little
> about programming languages.
> 
> 
> > Why did Forth fail so badly?
> > 
> > I mean the win of Java VS the fail of Forth is so
> > absolute as to be mind boggling.  I'd like to hear
> > a real answer, and not that "Forth Sucks"  because
> > I think that Forth is a darn good mousetrap.  It
> > is still quite usable and is extremely flexible.
> 
> I broke your lines for you.  Anyone who knows anything about
> usenet knows that he must limit the length of his lines.
> 
> You should have written "the failure of Forth".
> You will find it easier to communicate if you learn a
> human language.
> 
> Forth is an extremely low-level and crude language, suitable only
> for programming embedded controllers.
> 
> Gauche Scheme:
> 
> (use srfi-42)
> (let1 table (make-hash-table)
>   (dolist (ch (filter #[a-z]  (string->list
>                   "The Wikipedia article on Java states that in 2014
>                   Java is the most popular programming language with
>                   9 million developers.  How many developers do you
>                   think actually make money programming in Forth?
>                   Probably about 9!")))
>     (hash-table-update! table ch (pa$ + 1) 0))
>   (do-ec (: ch #\a #\z)
>     (print ch " " (make-string (hash-table-get table ch 0) #\*))))
> 
> 
> a *******************
> b ***
> c **
> d ****
> e **************
> f
> g ******
> h ******
> i *************
> j
> k ***
> l **********
> m *********
> n **********
> o ***************
> p *******
> q
> r **********
> s ******
> t ************
> u *****
> v ****
> w **
> x
> y *****
> z
> 
> Now struggle to program the equivalent in Forth.

I apologize creating a challenge that's far too easy.
This one is a bit harder.

(use srfi-13)
(let1 table (make-hash-table 'string=?)
  (dolist (word (string-tokenize (string-downcase
    "How badly did we fail?   Well, out of the
    Billions and Billions of cellphones which
    have ever been produced, not a single one
    has been programmed in Forth or uses Forth
    as an operating system! 99.99% of them are
    programmed in Java?  Why?  I mean I had a
    $15 cell phone.  The hardware is probably
    more powerful than my old Atari ST.  It has
    a faster processor and more RAM.  There are
    only about 5 games for it, and they are all
    programmed in Java.  Truth be known, these
    games are so slow as to be nearly
    unplayable.  It would be undoable to put
    Llamatron on the thing, not because of the
    small screen size, but because it just
    couldn't use a Java library to push around a
    sufficient number of sprites very well. I
    know that all of you I.T. people in here are
    just going to say buy a more expensive
    phone, but that's not my point.")  #[a-zA-Z']))
    (hash-table-update! table word (pa$ + 1) 0))
  (let* ((words (sort
                  (filter (^x (> (cdr x) 1)) (hash-table->alist table))
                  (^(a b) (if (= (cdr a) (cdr b))
                            (string<? (car a) (car b))
                            (> (cdr a) (cdr b))))))
         (word-size (apply max (map (.$ string-length car) words))))
    (dolist (word words)
      (format #t "~va ~a\n" word-size (car word) (make-string (cdr word) #\*)))))

a          ******
of         ******
are        *****
i          ****
in         ****
it         ****
the        ****
to         ****
and        ***
be         ***
java       ***
more       ***
not        ***
programmed ***
all        **
as         **
because    **
been       **
billions   **
but        **
forth      **
games      **
has        **
just       **
my         **
phone      **
well       **

[toc] | [prev] | [next] | [standalone]


#34705

FromJulian Fondren <julian.fondren@gmail.com>
Date2014-11-29 18:55 -0800
Message-ID<99180690-b10d-4a49-b1dc-c99ad9f18de1@googlegroups.com>
In reply to#34704
On Saturday, November 29, 2014 8:13:31 PM UTC-6, WJ wrote:
> I apologize creating a challenge that's far too easy.
> This one is a bit harder.

Only a bit.  It adds sorting, data indexed by a string,
and more interesting iteration over the input.  Scheme's
intermediate data structures make more sense this time
around.

Why don't you grab gforth, run through the crash course,
and give it a try?  If you'd rather balk at rolling
your own alternative to the alist Scheme uses, then grab
the Forth Foundation Library from
http://soton.mpeforth.com/flag/ffl/index.html

This is not something to struggle with.  It's My First
Forth Program level stuff.

>   (let* ((words (sort
>                   (filter (^x (> (cdr x) 1)) (hash-table->alist table))
>                   (^(a b) (if (= (cdr a) (cdr b))
>                             (string<? (car a) (car b))
>                             (> (cdr a) (cdr b))))))
>          (word-size (apply max (map (.$ string-length car) words))))

Perl had a pretty good idea with implicit arguments to its grep and sort.


-- Julian

[toc] | [prev] | [next] | [standalone]


#34719

Fromalbert@spenarnc.xs4all.nl (Albert van der Horst)
Date2014-11-30 16:50 +0000
Message-ID<547b4ac0$0$15842$e4fe514c@dreader35.news.xs4all.nl>
In reply to#34704
In article <m5dufq$vcm$1@dont-email.me>, WJ <w_a_x_man@yahoo.com> wrote:
>WJ wrote:
>
>
>I apologize creating a challenge that's far too easy.
>This one is a bit harder.

Apparently the challenge is to reconstruct a specification
from an undocumented program in a non-Forth language.
That is a far greater challenge then writing a Forth program
would, but I will not waste my time with it.

<SNIPPED some gibberish>

Groetjes Albert
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

[toc] | [prev] | [next] | [standalone]


#34729

FromBernd Paysan <bernd.paysan@gmx.de>
Date2014-12-01 01:22 +0100
Message-ID<m5gcc4$66b$1@dont-email.me>
In reply to#34719
Albert van der Horst wrote:

> In article <m5dufq$vcm$1@dont-email.me>, WJ <w_a_x_man@yahoo.com> wrote:
>>WJ wrote:
>>
>>
>>I apologize creating a challenge that's far too easy.
>>This one is a bit harder.
> 
> Apparently the challenge is to reconstruct a specification
> from an undocumented program in a non-Forth language.
> That is a far greater challenge then writing a Forth program
> would, but I will not waste my time with it.

It's just by-word and prints a sorted histogram.

The real question is: After all, WJ promotes Java in his troll test cases, 
and then writes Scheme programs to challenge us Forthers.  Of couse, Scheme 
is a much better language than Java: Scheme is interactive, Scheme allows 
metaprogramming, and Scheme has a very simple, prefix syntax (with 
parenthesis), which makes parsing Scheme easy.  Just as Forth has a simple, 
postfix syntax (without parenthesis), which is even simpler to parse.  
Scheme requires no boilerplate, just like Forth.

Actually, Lisp was one of the inspirations which led to Forth, and several 
Forth-like programming languages like PostScript or Factor are back in the 
functional programming realm; i.e. Forth is a not too close relative to 
Scheme.  While Java is a member of that ugly, warty, Algol family.

Dear WJ: You had your challenge, and you lost.  Now shut up.  We are bored 
by your easy challenges.  Of course, the first by-character challenge was 
particularly easy, because to solve it, you only had to use core words, 
nothing more.  No libraries (WJ's example uses a library), no fancy non-core 
words; just the words available on every tiny embedded controller running 
Forth.  Controllers which certainly can't run Scheme, or even Java!

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/

[toc] | [prev] | [next] | [standalone]


#34741

FromMelzzzzz <mel@zzzzz.com>
Date2014-12-02 06:00 +0100
Message-ID<20141202060029.7480750d@maxa-pc>
In reply to#34729
On Mon, 01 Dec 2014 01:22:40 +0100
Bernd Paysan <bernd.paysan@gmx.de> wrote:

> Albert van der Horst wrote:
> 
> > In article <m5dufq$vcm$1@dont-email.me>, WJ <w_a_x_man@yahoo.com>
> > wrote:
> >>WJ wrote:
> >>
> >>
> >>I apologize creating a challenge that's far too easy.
> >>This one is a bit harder.
> > 
> > Apparently the challenge is to reconstruct a specification
> > from an undocumented program in a non-Forth language.
> > That is a far greater challenge then writing a Forth program
> > would, but I will not waste my time with it.
> 
> It's just by-word and prints a sorted histogram.

Hm, it is not clear what string-tokenize does, that is, how is string
tokenized.

[toc] | [prev] | [next] | [standalone]


#34742

FromMelzzzzz <mel@zzzzz.com>
Date2014-12-02 06:37 +0100
Message-ID<20141202063730.63d23f65@maxa-pc>
In reply to#34741
On Tue, 2 Dec 2014 06:00:29 +0100
Melzzzzz <mel@zzzzz.com> wrote:

> On Mon, 01 Dec 2014 01:22:40 +0100
> Bernd Paysan <bernd.paysan@gmx.de> wrote:
> 
> > Albert van der Horst wrote:
> > 
> > > In article <m5dufq$vcm$1@dont-email.me>, WJ <w_a_x_man@yahoo.com>
> > > wrote:
> > >>WJ wrote:
> > >>
> > >>
> > >>I apologize creating a challenge that's far too easy.
> > >>This one is a bit harder.
> > > 
> > > Apparently the challenge is to reconstruct a specification
> > > from an undocumented program in a non-Forth language.
> > > That is a far greater challenge then writing a Forth program
> > > would, but I will not waste my time with it.
> > 
> > It's just by-word and prints a sorted histogram.
> 
> Hm, it is not clear what string-tokenize does, that is, how is string
> tokenized.
> 
> 

I think following go program closely resembles what OP does and is 
clear and readable.

package main

import (
 "fmt"
 "strings"
 "sort"
 "unicode"
)

func main() {
  s := strings.ToLower(
       `How badly did we fail?   Well, out of the
        Billions and Billions of cellphones which
        have ever been produced, not a single one
        has been programmed in Forth or uses Forth
        as an operating system! 99.99% of them are
        programmed in Java?  Why?  I mean I had a
        $15 cell phone.  The hardware is probably
        more powerful than my old Atari ST.  It has
        a faster processor and more RAM.  There are
        only about 5 games for it, and they are all
        programmed in Java.  Truth be known, these
        games are so slow as to be nearly
        unplayable.  It would be undoable to put
        Llamatron on the thing, not because of the
        small screen size, but because it just
        couldn't use a Java library to push around a
        sufficient number of sprites very well. I
        know that all of you I.T. people in here are
        just going to say buy a more expensive
        phone, but that's not my point.`)

 words := make(map[string]string)
 for _,v := range strings.FieldsFunc(s,func (c rune)bool {
   return !unicode.IsLetter(c) && c != '\''
  }) {
    words[v]+="*"
 }
 arr := make(Sorted,0)
 for k,v := range words {
  if len(v) > 1 {
   arr = append(arr,F{k,v})
  }
 }
 sort.Sort(arr)
 fmt.Print(arr)
}

type F struct { k,v string }

type Sorted []F

func (this Sorted) Len() int {
 return len(this)
}

func (this Sorted) Swap(i,j int) {
 this[i],this[j] = this[j],this[i]
}

func (this Sorted) Less(i,j int)bool {
 rc :=  len(this[i].v)>len(this[j].v)
 if !rc { 
  if len(this[i].v) == len(this[j].v) {
     return this[i].k < this[j].k 
  }
 }
 return rc
}

func (this Sorted) String()(rc string){
 for i,v := range this {
  rc += fmt.Sprintf("%05d %-20s%s\n",i,v.k,v.v)
 }
 return
}

[toc] | [prev] | [next] | [standalone]


#34750

Fromalbert@spenarnc.xs4all.nl (Albert van der Horst)
Date2014-12-02 12:28 +0000
Message-ID<547db06e$0$6898$e4fe514c@dreader36.news.xs4all.nl>
In reply to#34742
In article <20141202063730.63d23f65@maxa-pc>, Melzzzzz  <mel@zzzzz.com> wrote:
>On Tue, 2 Dec 2014 06:00:29 +0100
>Melzzzzz <mel@zzzzz.com> wrote:
>
>> On Mon, 01 Dec 2014 01:22:40 +0100
>> Bernd Paysan <bernd.paysan@gmx.de> wrote:
>>
>> > Albert van der Horst wrote:
>> >
>> > > In article <m5dufq$vcm$1@dont-email.me>, WJ <w_a_x_man@yahoo.com>
>> > > wrote:
>> > >>WJ wrote:
>> > >>
>> > >>
>> > >>I apologize creating a challenge that's far too easy.
>> > >>This one is a bit harder.
>> > >
>> > > Apparently the challenge is to reconstruct a specification
>> > > from an undocumented program in a non-Forth language.
>> > > That is a far greater challenge then writing a Forth program
>> > > would, but I will not waste my time with it.
>> >
>> > It's just by-word and prints a sorted histogram.
>>
>> Hm, it is not clear what string-tokenize does, that is, how is string
>> tokenized.
>>
>>
>
>I think following go program closely resembles what OP does and is
>clear and readable.
>
>package main
>
>import (
> "fmt"
> "strings"
> "sort"
> "unicode"
>)
>
>func main() {
>  s := strings.ToLower(
>       `How badly did we fail?   Well, out of the
>        Billions and Billions of cellphones which
>        have ever been produced, not a single one
>        has been programmed in Forth or uses Forth
>        as an operating system! 99.99% of them are
>        programmed in Java?  Why?  I mean I had a
>        $15 cell phone.  The hardware is probably
>        more powerful than my old Atari ST.  It has
>        a faster processor and more RAM.  There are
>        only about 5 games for it, and they are all
>        programmed in Java.  Truth be known, these
>        games are so slow as to be nearly
>        unplayable.  It would be undoable to put
>        Llamatron on the thing, not because of the
>        small screen size, but because it just
>        couldn't use a Java library to push around a
>        sufficient number of sprites very well. I
>        know that all of you I.T. people in here are
>        just going to say buy a more expensive
>        phone, but that's not my point.`)
>
> words := make(map[string]string)
> for _,v := range strings.FieldsFunc(s,func (c rune)bool {
>   return !unicode.IsLetter(c) && c != '\''
>  }) {
>    words[v]+="*"
> }
> arr := make(Sorted,0)
> for k,v := range words {
>  if len(v) > 1 {
>   arr = append(arr,F{k,v})
>  }
> }
> sort.Sort(arr)
> fmt.Print(arr)
>}
>
>type F struct { k,v string }
>
>type Sorted []F
>
>func (this Sorted) Len() int {
> return len(this)
>}
>
>func (this Sorted) Swap(i,j int) {
> this[i],this[j] = this[j],this[i]
>}
>
>func (this Sorted) Less(i,j int)bool {
> rc :=  len(this[i].v)>len(this[j].v)
> if !rc {
>  if len(this[i].v) == len(this[j].v) {
>     return this[i].k < this[j].k
>  }
> }
> return rc
>}
>
>func (this Sorted) String()(rc string){
> for i,v := range this {
>  rc += fmt.Sprintf("%05d %-20s%s\n",i,v.k,v.v)
> }
> return
>}
>

THANK YOU ;-)

Another challenge to reconstruct a specification
from an undocumented program in a non-Forth language.

Groetjes Albert
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

[toc] | [prev] | [next] | [standalone]


#34763 — Re: Epic failure

FromPaul Rubin <no.email@nospam.invalid>
Date2014-12-02 18:03 -0800
SubjectRe: Epic failure
Message-ID<7xy4qp1oc4.fsf@ruckus.brouhaha.com>
In reply to#34742
Melzzzzz <mel@zzzzz.com> writes:
> I think following go program closely resembles what OP does and is 
> clear and readable.

Looks pretty verbose and cumbersome.  Here's a Python version:
================================================================

import re
from collections import defaultdict

msg = """How badly did we fail?   Well, out of the
         Billions and Billions of cellphones which
         have ever been produced, not a single one
         has been programmed in Forth or uses Forth
         as an operating system! 99.99% of them are
         programmed in Java?  Why?  I mean I had a
         $15 cell phone.  The hardware is probably
         more powerful than my old Atari ST.  It has
         a faster processor and more RAM.  There are
         only about 5 games for it, and they are all
         programmed in Java.  Truth be known, these
         games are so slow as to be nearly
         unplayable.  It would be undoable to put
         Llamatron on the thing, not because of the
         small screen size, but because it just
         couldn't use a Java library to push around a
         sufficient number of sprites very well. I
         know that all of you I.T. people in here are
         just going to say buy a more expensive
         phone, but that's not my point."""

def main():
    d = defaultdict(int)
    for w in (re.sub('[^a-z]','',w.lower()) for w in msg.split()):
        if w: d[w] += 1
    for w,n in sorted(d.items(),key=lambda(k,v):v,reverse=True):
        print "%-20s %s"%(w,'*'*n) 

[toc] | [prev] | [next] | [standalone]


#34798

Fromthe_gavino_himself <visphatesjava@gmail.com>
Date2014-12-05 10:10 -0800
Message-ID<d186b225-e951-4bd7-99fc-2118a56f444c@googlegroups.com>
In reply to#34729
On Sunday, November 30, 2014 7:22:45 PM UTC-5, Bernd Paysan wrote:
> Albert van der Horst wrote:
> 
> > In article <m5dufq$vcm$1@dont-email.me>, WJ <w_a_x_man@yahoo.com> wrote:
> >>WJ wrote:
> >>
> >>
> >>I apologize creating a challenge that's far too easy.
> >>This one is a bit harder.
> > 
> > Apparently the challenge is to reconstruct a specification
> > from an undocumented program in a non-Forth language.
> > That is a far greater challenge then writing a Forth program
> > would, but I will not waste my time with it.
> 
> It's just by-word and prints a sorted histogram.
> 
> The real question is: After all, WJ promotes Java in his troll test cases, 
> and then writes Scheme programs to challenge us Forthers.  Of couse, Scheme 
> is a much better language than Java: Scheme is interactive, Scheme allows 
> metaprogramming, and Scheme has a very simple, prefix syntax (with 
> parenthesis), which makes parsing Scheme easy.  Just as Forth has a simple, 
> postfix syntax (without parenthesis), which is even simpler to parse.  
> Scheme requires no boilerplate, just like Forth.
> 
> Actually, Lisp was one of the inspirations which led to Forth, and several 
> Forth-like programming languages like PostScript or Factor are back in the 
> functional programming realm; i.e. Forth is a not too close relative to 
> Scheme.  While Java is a member of that ugly, warty, Algol family.
> 
> Dear WJ: You had your challenge, and you lost.  Now shut up.  We are bored 
> by your easy challenges.  Of course, the first by-character challenge was 
> particularly easy, because to solve it, you only had to use core words, 
> nothing more.  No libraries (WJ's example uses a library), no fancy non-core 
> words; just the words available on every tiny embedded controller running 
> Forth.  Controllers which certainly can't run Scheme, or even Java!
> 
> -- 
> Bernd Paysan
> "If you want it done right, you have to do it yourself"
> http://bernd-paysan.de/

When will you write a gforth for students and beginners book?
Then a gforth webserver for blog book?

[toc] | [prev] | [next] | [standalone]


#34805

Fromrickman <gnuarm@gmail.com>
Date2014-12-05 16:23 -0500
Message-ID<m5t7o1$35d$2@dont-email.me>
In reply to#34798
On 12/5/2014 1:10 PM, the_gavino_himself wrote:
>
> When will you write a gforth for students and beginners book?
> Then a gforth webserver for blog book?

gForth for students and beginners should be written by a beginner who 
documents his own journey.  I think once the memory of the journey 
starts to fade it becomes harder to think like a beginner and so 
understand what the real issues are.

So you should lead by example!

-- 

Rick

[toc] | [prev] | [next] | [standalone]


#34807

FromJason Damisch <jasondamisch@yahoo.com>
Date2014-12-05 13:46 -0800
Message-ID<4765aa85-2f06-4311-aaab-666b1e420e81@googlegroups.com>
In reply to#34805
On Friday, December 5, 2014 1:23:31 PM UTC-8, rickman wrote:

> So you should lead by example!

A personal sacrifice of ones time may be considered as something
to have fed the tree of Wisdom.

Perhaps

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.forth


csiph-web