[ENH] on:collect:
Lex Spoon
lex at cc.gatech.edu
Mon Jun 12 09:05:59 UTC 2000
Aside from the deep discussion in upgrading the collection library, some
people might be interested that Squeak actually has a string translation
facility in it. Look at how #asLowercase works to see it in action.
-Lex
"Francisco Garau" <fgarau at hotpop.com> wrote:
> | withAll:collect: be natural, because it would just be removing
> | parentheses from the following:
> |
> | String withAll: ( #( 97 101 105 111 117) collect: [:each | each
> asCharacter])
>
> If afterwards, you want to obtain an Array with all the ascii values from a
> string, just evaluate
> Array on: aString collect: [:e | e asInteger]
>
> or, as you suggest,
> Array withAll: 'aeiou' collect: [:e | e asInteger]
>
> |
> | Do you code this kind of thing a lot?
> |
>
> No. I just wanted to remove the accents of the vowels. But Windows makes
> some magic on the (extended) ascii values (from 128 to 255). Its is very
> common in our countries to know the ascii value of the accented 'a' (which
> is 160), and people are used to type Alt-160 to get it. But windows
> represents it with another integer (225 with my codepage). So, I have to
> make some conversions from array to string and then back to an array. Wich I
> did is available in VisualSmalltalk (http://vse.swiki.net), but I found very
> interesting (and possible useful) this small message.
>
> -- Pancho
More information about the Squeak-dev
mailing list
|