sumim #4429(2007/11/27 08:48 GMT) [ Smalltalk ] Rating0/0=0.00
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') "
Rating0/0=0.00-0+
[ reply ]
sumim
#4429()
[
Smalltalk
]
Rating0/0=0.00
| 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') "Rating0/0=0.00-0+
[ reply ]