[squeak-dev] Given an interval of numbers from 1 to 100 how to split them into 10 collections(?) of 1 to 10.
Levente Uzonyi
leves at caesar.elte.hu
Thu Jan 28 21:17:15 UTC 2021
Hi Tim,
On Thu, 28 Jan 2021, gettimothy via Squeak-dev wrote:
> Hi Folks,
>
>
> For a development tool and Unicode grok exercise, I am recreating the functionality of: https://jrgraphix.net/r/Unicode/
>
>
> For the Latin unicode characters, I would like to create a table 10 <td> things wide in a table row.
>
> There has got to be an elegant way rather than the kludge I am imagining...
>
> Here is my current code that has one TD for each row.
> render000020to00007F: html
> html table
> with:[
> html tableHead with: [html strong: ' Basic Latin'].
> html tableBody with:[
> (16r000020 asCharacter to: 16r00007F asCharacter)
> do:[:each|
> html tableRow with:[
> html tableHeading: (each asInteger).
> html tableData: each]]]]
If the size of the collection would be a multiple of 10, you could use
#groupsOf:atATimeDo:, but it's not, so I'd try something like this:
| start end step |
start := 16r000020.
end := 16r00007F.
step := 10.
start to: end by: step do: [ :groupStart |
| group |
group := groupStart to: (groupStart + step - 1 min: end).
html
tableRow: [
group do: [ :each |
html tableHead: each ] ];
tableRow: [
group do: [ :each |
html tableData: each asCharacter ] ] ]
Levente
>
>
> If I could "chunk" that (16r000020 asCharacter to: 16r00007F asCharacter) or the Interval (16r000020 to: 16r00007F) into subsets of 10, it would be easy to code this.
>
>
>
> thanks in advance.
>
>
>
More information about the Squeak-dev
mailing list
|