Comment detail

アルファベットの繰り上がり (Nested Flatten)

This comment is reply for 788 sumim: Squeak Smalltalk で。(アルファベットの繰り上がり). Go to thread root.

別のアプローチで。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
| excelColumnName |

excelColumnName := [:n |
   | rest digits |
   rest := n - 1.
   digits := OrderedCollection new.
   [  digits addFirst: (($A to: $Z) at: rest \\ 26 - digits size sign + 1).
      (rest := rest // 26) > 0
   ] whileTrue.
   digits as: String].

World findATranscript: nil.
Transcript cr.
(1 to: 100)
   do: [:i | Transcript show: (excelColumnName value: i)]
   separatedBy: [Transcript show: ', ']

Index

Feed

Other

Link

Pathtraq

loading...