Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #54008 > unrolled thread
| Started by | "Robert L." <No_spamming@noWhere_7073.org> |
|---|---|
| First post | 2017-01-14 18:35 +0000 |
| Last post | 2017-01-14 18:35 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.forth
Rosetta: Compare a list of strings "Robert L." <No_spamming@noWhere_7073.org> - 2017-01-14 18:35 +0000
| From | "Robert L." <No_spamming@noWhere_7073.org> |
|---|---|
| Date | 2017-01-14 18:35 +0000 |
| Subject | Rosetta: Compare a list of strings |
| Message-ID | <o5dr21$qtp$1@gioia.aioe.org> |
Given a list of arbitrarily many strings, show how to:
test if they are all lexically equal
test if every string is lexically less than the one after it
(i.e. whether the list is in strict ascending order)
Ruby:
def all_equal( array )
array.uniq.size < 2
end
all_equal []
==>true
all_equal ["i"]
==>true
all_equal ["i","i","i"]
==>true
all_equal ["i","i","i","o"]
==>false
def ascending( array )
array.each_cons(2).all?{|a,b| a<b}
end
ascending( [] )
==>true
ascending( ['a'] )
==>true
ascending( ['a','a'] )
==>false
ascending( ['a',"b"] )
==>true
ascending( ['a',"b","c"] )
==>true
ascending( ['a',"b","c","c"] )
==>false
ascending( ['a',"b","c","d"] )
==>true
ascending( ['a',"b","c","d","d"] )
==>false
In Forth?
--
The major media are controlled and run by Jews. They want White people dead,
replaced, mixed, and immigrated and migrated and refugeed out of existence.
Telling the truth about racially-motivated attacks on Whites by Blacks does not
fit their agenda.
nationalvanguard.org/2016/10/how-can-we-stop-the-mystery-attacks/
Back to top | Article view | comp.lang.forth
csiph-web