Given an interval of numbers from 1 to 100 how to split them into 10 collections(?) of 1 to 10.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Given an interval of numbers from 1 to 100 how to split them into 10 collections(?) of 1 to 10.

Squeak - Dev mailing list
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 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.



Reply | Threaded
Open this post in threaded view
|

Re: Given an interval of numbers from 1 to 100 how to split them into 10 collections(?) of 1 to 10.

Levente Uzonyi
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.
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Given an interval of numbers from 1 to 100 how to split them into 10 collections(?) of 1 to 10.

Squeak - Dev mailing list
Levente

Thank you!

I will tussle with that tomorrow.

As an aside, fior he purposes of seaside I learned that  xml only supports a subset of available Unicode.

https://en.m.wikipedia.org/wiki/Valid_characters_in_XML

This may simplify my PEG filters.

The larger and intriguing issue of getting every  printable unicode character to display in squeak  is now on my want to do list!
.
A fun experiment will be seeing if out putting "delete the e" to the Transcript followed by the delete character (127?) results in "delete the "  (:


cheers!

t
---- On Thu, 28 Jan 2021 16:17:15 -0500 [hidden email] wrote ----

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.
>
>
>