GoST

gorubyに対抗してみる。

  • GoST.st
!Object methodsFor: 'golf'!
doesNotUnderstand: m
  | a s |
  a := m arguments size.
  s := m selector, '*' copyReplaceAll: ':' with: '*:'.
  ^m selector: (self class allSelectors asSortedCollection detect:
    [ :x | (x occurrencesOf:$:) = a and: [ s match: x ] ]); sendTo: self!
h
  ^'Hello, world!' displayNl!
h: args
  ^('%1ello, %2orld%3' bindWithArguments: args) displayNl!
!
  • hw.gst
0h!
  • echo.gst
stdin con di!
  • quine.gst
stdout<<thisContext me methodSourceS<<$!!

実行例:

$ echo hoge | gst GoST.st hw.gst echo.gst quine.gst
Hello, world!
hoge
stdout<<thisContext me methodSourceS<<$!!

こ,これは楽しいかも。(−−#)