Jump to page: 1 2
Thread overview
[your code here]
Feb 04, 2012
Jos van Uden
Feb 04, 2012
bearophile
Feb 04, 2012
Jos van Uden
Feb 04, 2012
Manfred Nowak
Feb 04, 2012
Tobias Pankrath
Feb 04, 2012
Manfred Nowak
Feb 04, 2012
Timon Gehr
Feb 04, 2012
bearophile
Feb 04, 2012
Timon Gehr
Feb 05, 2012
Manfred Nowak
Feb 06, 2012
Manfred Nowak
Feb 05, 2012
Jos van Uden
Feb 06, 2012
Era Scarecrow
Feb 06, 2012
Era Scarecrow
Feb 06, 2012
Marco Leise
February 04, 2012
import std.string, std.traits, std.uni;

enum Alphabet : dstring {
    DE = "abcdefghijklmnopqrstuvwxyzßäöü",
    EN = "abcdefghijklmnopqrstuvwxyz",
    SV = "abcdefghijklmnopqrstuvwxyzåäö"
}

bool isPangram(S)(S s, dstring alpha = Alphabet.EN) if (isSomeString!S) {
    foreach (c; alpha)
        if (indexOf(s, c) == -1 && indexOf(s, toUpper(c)) == -1)
            return false;
    return true;
}

---

A pangram is a sentence that contains every letter of a given alphabet
at least once. A classic example is "The quick brown fox jumps over the lazy dog".
February 04, 2012
Jos van Uden:

See:
http://rosettacode.org/wiki/Pangram_checker#D

Bye,
bearophile
February 04, 2012
On 4-2-2012 14:14, bearophile wrote:
> Jos van Uden:
>
> See:
> http://rosettacode.org/wiki/Pangram_checker#D


Yeah, it's mine. And I bet the other one is yours :-)

February 04, 2012
Jos van Uden wrote:

> A pangram is a sentence that contains every letter of a given alphabet at least once.

1)
Because such definitions do not contribute to D as a programming
language, I believe that such threads do not belong into the D-forum.

2)
Because solutions are presented, I believe that such threads do neither
belong into the D.learn-forum.

3)
Because no general usability is visible I doubt, that such threads
belong into the D.announce-forum.

4) Because all other forums are for specific themes a D.misc-forum should be the right place for such threads---but it is missing.

-manfred
February 04, 2012
Manfred Nowak wrote:

> Jos van Uden wrote:
> 
>> A pangram is a sentence that contains every letter of a given alphabet at least once.
> 
> 1)
> Because such definitions do not contribute to D as a programming
> language, I believe that such threads do not belong into the D-forum.
> 
> 2)
> Because solutions are presented, I believe that such threads do neither
> belong into the D.learn-forum.
> 
> 3)
> Because no general usability is visible I doubt, that such threads
> belong into the D.announce-forum.
> 
> 4) Because all other forums are for specific themes a D.misc-forum should be the right place for such threads---but it is missing.
> 
> -manfred

Quote from dlang.org

> Got a brief example illustrating D? Submit your code to the digitalmars.D
forum, specifying "[your code here]" in the title. Upon approval, it will be showcased on a random schedule on D‘s homepage.

February 04, 2012
Manfred Nowak:

> Because such definitions do not contribute to D as a programming language, I believe that such threads do not belong into the D-forum. etc.

Because we are gentle and tolerant people, we tolerate those posts, despite a better place for them is in D.learn.

Bye,
bearophile
February 04, 2012
On 02/04/2012 07:43 PM, bearophile wrote:
> Manfred Nowak:
>
>> Because such definitions do not contribute to D as a programming
>> language, I believe that such threads do not belong into the D-forum.
>> etc.
>
> Because we are gentle and tolerant people, we tolerate those posts, despite a better place for them is in D.learn.
>
> Bye,
> bearophile

'Got a brief example illustrating D? Submit your code to the ***digitalmars.D*** forum, specifying "[your code here]" in the title. Upon approval, it will be showcased on a random schedule on D‘s homepage.'

I completely agree with the rest of your post though.
February 04, 2012
Tobias Pankrath wrote:

> Quote from dlang.org
>> Got a brief example illustrating D? Submit your code to the digitalmars.D forum, specifying "[your code here]" in the title.

I doubt that the author of that text indeed wanted some hundred contributers and lurkers to see this title pop up some hundred times and stay amused.

digitalmars.D.misc or digitalmars.D.propaganda would be good places to not distract interested people from the language.

Furthermore I believe, that the costs for creating a new digitalmars.D.abc group are negligible. For example digitalmars.D.debugger has fewer than 500 messages and about 80 threads within a time span of five years.

-manfred


February 04, 2012
On 02/04/2012 09:38 PM, Manfred Nowak wrote:
> Tobias Pankrath wrote:
>
>> Quote from dlang.org
>>> Got a brief example illustrating D? Submit your code to the
>>> digitalmars.D forum, specifying "[your code here]" in the title.
>
> I doubt that the author of that text indeed wanted some hundred
> contributers and lurkers to see this title pop up some hundred times
> and stay amused.
>
> digitalmars.D.misc or digitalmars.D.propaganda would be good places to
> not distract interested people from the language.
>
> Furthermore I believe, that the costs for creating a new
> digitalmars.D.abc group are negligible. For example
> digitalmars.D.debugger has fewer than 500 messages and about 80 threads
> within a time span of five years.
>
> -manfred
>

This post is not making any sense. I kindly request the author to reconsider.
February 05, 2012
Jos van Uden wrote:

> bool isPangram

The presented code is not an acceptable example for the usage of the D programming language.

1)
`indexOf( s, c)' has a worst case running time of O( `s.length').
`indexOf' is called once for each `c' in the used member `alpha' of
`Alphabet'.
Therefore the runtime of the presented code is
  O( `s.length' * `alpha.length')
whereas
  O( `s.length' + `alpha.length')
is possible.

2)
The optional third parameter of `indexOf' can be called with
`CaseSensitive.no'. But that parameter is left untouched. Instead a
check with `toUpper( c)' is used, thereby risking a further visitation
of the whole string .

3)
The use of the literal value `-1' stands out of the code and hints to a
maldesign in phobos. This is because `-1' is not mnemonic.

-manfred
« First   ‹ Prev
1 2