Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #57637 > unrolled thread
| Started by | "Robert L." <No_spamming@noWhere_7073.org> |
|---|---|
| First post | 2017-04-20 08:32 +0000 |
| Last post | 2017-04-20 02:08 -0700 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.forth
.Re: Using Loops to track user input "Robert L." <No_spamming@noWhere_7073.org> - 2017-04-20 08:32 +0000
Re: .Re: Using Loops to track user input Julian Fondren <julian.fondren@gmail.com> - 2017-04-20 02:08 -0700
| From | "Robert L." <No_spamming@noWhere_7073.org> |
|---|---|
| Date | 2017-04-20 08:32 +0000 |
| Subject | .Re: Using Loops to track user input |
| Message-ID | <od9rm2$1iu5$1@gioia.aioe.org> |
> Not to neglect the 1-liner:
>
> import operator; reduce(operator.add,[int(raw_input("Number>")) for i in
> range(10)])
(0..9).map{print "Number>"; gets().to_i}.reduce &:+
In Forth?
--
There were even reports of Germans being expelled from their apartments to make
room for the invaders. Other YouTube videos showed Moslems molesting bathers,
male and female, at public pools and defecating in the water.
www.thepoliticalcesspool.org/jamesedwards/understanding-invasion-europe/
[toc] | [next] | [standalone]
| From | Julian Fondren <julian.fondren@gmail.com> |
|---|---|
| Date | 2017-04-20 02:08 -0700 |
| Message-ID | <9f99d7d2-4936-4a9d-b83d-0f9741c3d0c1@googlegroups.com> |
| In reply to | #57637 |
On Thursday, April 20, 2017 at 3:32:06 AM UTC-5, Robert L. wrote:
> > Not to neglect the 1-liner:
> >
> > import operator; reduce(operator.add,[int(raw_input("Number>")) for i in
> > range(10)])
>
> (0..9).map{print "Number>"; gets().to_i}.reduce &:+
>
> In Forth?
variable last-depth
: numbers ( -- ) depth last-depth ! ;
: sum ( ... -- n ) depth 0 swap last-depth @ - 0 max 0 ?do + loop ;
numbers 1 2 3 4 5 6 sum . \ output: 21
Something very similar was done with postfix lispy words: ( # # # # # +)
The user experience of your Ruby sucks just as hard as the Python.
This isn't a remotely serious interface. This is something you'd see
in a tutorial book because the author doesn't want to distract from
some other point. Even in a nongraphical app, you'd rather accept the
numbers as commandline arguments than trap the user in such a loop.
The Forth gives you an interface as nice as whatever the system
normally provides, and depending on the search order would let the
user correct mistakes on already-entered values, perform interim
calculations, see the entered numbers, and so on.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.forth
csiph-web