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


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

Rosetta: Pangram checker

Started by"Robert L." <No_spamming@noWhere_7073.org>
First post2017-04-21 16:44 +0000
Last post2017-04-21 16:44 +0000
Articles 1 — 1 participant

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


Contents

  Rosetta: Pangram checker "Robert L." <No_spamming@noWhere_7073.org> - 2017-04-21 16:44 +0000

#57726 — Rosetta: Pangram checker

From"Robert L." <No_spamming@noWhere_7073.org>
Date2017-04-21 16:44 +0000
SubjectRosetta: Pangram checker
Message-ID<oddct4$1lso$1@gioia.aioe.org>
> A pangram is a sentence that contains all the letters of the
> English alphabet at least once.
> 
> For example:   The quick brown fox jumps over the lazy dog. 
> 
> Task
> 
> Write a function or method to check a sentence to see if it is
> a pangram (or not) and show its use.


> Forth[edit]
> 
> : pangram? ( addr len -- ? )
>   0 -rot bounds do
>     i c@ 32 or [char] a -
>     dup 0 26 within if
>       1 swap lshift or
>     else drop then
>   loop
>   1 26 lshift 1- = ;



def pangram? s
  ('A'..'Z').to_a - s.upcase.chars == []
end

pangram? "The five boxing wizards jump quickly."
    ==>true
pangram? "The five boxing wizards jump uickly."
    ==>false
pangram? 'How vexingly quick daft zebras jump!'
    ==>true
pangram? "ABC.D.E.FGHI*J/KL-M+NO*PQ R\nSTUVWXYZ"
    ==>true
pangram? "This sentence contains A-Z but not the whole alphabet."
    ==>false


-- 
It is the same instinct that made one [Swedish] female refugee aid worker and
her colleagues hush up her recent rape at the hands of some recent arrivals.
They feared that mentioning the rape might exacerbate anti-immigrant sentiment
in Europe.
theoccidentalobserver.net/2015/11/douglas-murrays-warning-to-the-jewish-community

[toc] | [standalone]


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


csiph-web