18/11/02 11:25:03.96 b7bQuZgR.net
>>204 Squeak Smalltalk
| fn |
fn := [:pg :tot :wd |
| start pages |
start := pg - (wd // 2) min: tot - wd + 1 max: 1.
pages := start to: start + wd - 1.
(pages collect: [:x | (x = pg ifTrue: ['[{1}]'] ifFalse: ['{1}']) format: {x}]) joinSeparatedBy: ' '
].
#((1 10 5) (5 10 5) (10 10 5)) collect: [:tri | fn valueWithArguments: tri]
"=> #('[1] 2 3 4 5' '3 4 [5] 6 7' '6 7 8 9 [10]') "