擬似lsの実装
Posted feedbacks - Smalltalk
Squeak Smalltalk で。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | | ls list |
ls := [:pathList :pathTo |
| start stream results path |
start := pathTo size + 1.
stream := pathList readStream.
results := OrderedCollection new.
[(path := stream next) notNil] whileTrue: [
(path beginsWith: pathTo) ifTrue: [
| end |
end := path indexOf: $/ startingAt: start.
end isZero ifTrue: [end := path size].
results add: (path copyFrom: start to: end)]].
results asArray].
list := #('aaa/bbb' 'aaa/ccc' 'aaa/ddd/eee' 'bbb/ddd/eee').
ls value: list value: 'aaa/'.
"=> #('bbb' 'ccc' 'ddd/') "
ls value: list value: 'aaa/ddd/'.
"=> #('eee') "
|


ところてん
#4212()
Rating1/3=0.33
[ reply ]