First I've heard of an isogram. Wikipedia [1] is ambiguous.  Are you
considering only single occurrence of letters, or also equal
occurrence of letters.

I like Sven's answer best, but just as an exercise I thought of an alternative.

String>>#isIsogram
    | letters |
    letters := Dictionary new.
    self do: [ :x | letters at: x ifAbsent: [] ifPresent: [ ^false ].


On Fri, Nov 11, 2016 at 6:19 AM, Sven Van Caekenberghe <s...@stfx.eu> wrote:
> you're right, should probably be case insensitive.

Or maybe that is overly restrictive.  A case sensitive #isogram would
have the flexibility to used both ways...

   'Pharop' isogram
   'Pharop' asLowercase isogram


Now a philosophical question (not that its practical to change anything),
but intuitively I tried using #lowercase before searching and finding
#asLowercase,
so I am wondering...
I feel #asXXX methods are there to change the 'type' of an object,
while #asLowercase isn't changing the type, but returning a
transformation much like...

   'Pharop' sorted

We don't say 'Pharop' asSorted

cheers -ben

>
>> On 10 Nov 2016, at 23:14, Cyril Ferlicot D. <cyril.ferli...@gmail.com> wrote:
>>
>> Le 10/11/2016 à 23:09, Sven Van Caekenberghe a écrit :
>>> [ :string | string size = string asSet size ] value: 'Pharo'.
>>>
>>>>>> true
>>>
>>> [ :string | string size = string asSet size ] value: 'Pharoo'.
>>>
>>>>>> false
>>>
>>> String>>#isIsogram
>>>  ^ self size = self asSet size
>>>
>>> ?
>>>
>>
>> 'Pharop' size = 'Pharop' asSet size
>>
>>>>> true
>>
>> Does it count? If upper-case counts you will need to do `^ self size =
>> self asLowercase asSet size` :)

Reply via email to