メソッド検索を賢く
昨日のgoruby
GoSTに訳すと「oOOR:d:」で「onOccurrencesOfRegex:do:」が呼べる感じ。
!Object methodsFor: 'golf'! doesNotUnderstand: m | a s k | a := m arguments size. s := (((k := m selector) inject: '' writeStream into: [:s :c| c <= $Z and: [ s << $* ]. s << c ]) << $*) contents. ^m selector: (GolfDic at: {k. self class} ifAbsentPut: [ self class allSelectors asSortedCollection detect: [:x| (x occurrencesOf: $:) = a and: [ s match: x ignoreCase: false ] ] ]); sendTo: self!
$ echo '#hoge dWI:[:c :i|{c.(i+48)aCh}di]'|gst gost.st -Q - ($h $1 )($o $2 )($g $3 )($e $4 )