Paste: refactor this

Author: typemore
Mode: factor
Date: Wed, 18 Aug 2010 22:16:08
Plain Text |
:: process-keys ( g -- )
    read-keyboard keys>> :> keys

    key-w keys nth
      [ g 0 >>angle-diff drop ]
      [ ] if

    key-e keys nth
      [ g 1 >>angle-diff drop ]
      [ ] if

    key-h keys nth
      [ g [ 1 + ] change-horiz-angle drop ]
      [ ] if

    key-l keys nth
      [ g [ 1 - ] change-horiz-angle drop ]
      [ ] if
  ;

Annotation: how about this

Author: mrjbq7
Mode: factor
Date: Wed, 18 Aug 2010 22:30:20
Plain Text |
:: process-keys ( g -- )
    read-keyboard keys>> :> keys
    {
        { [ key-w ] [ g 0 >>angle-diff drop ] }
        { [ key-e ] [ g 1 >>angle-diff drop ] }
        { [ key-h ] [ g [ 1 + ] change-horiz-angle drop ] }
        { [ key-l ] [ g [ 1 - ] change-horiz-angle drop ] }
    } [ [ keys nth ] dip when ] assoc-each ;

Annotation: rather

Author: mrjbq7
Mode: factor
Date: Wed, 18 Aug 2010 22:31:11
Plain Text |
:: process-keys ( g -- )
    read-keyboard keys>> :> keys
    {
        { key-w [ g 0 >>angle-diff drop ] }
        { key-e [ g 1 >>angle-diff drop ] }
        { key-h [ g [ 1 + ] change-horiz-angle drop ] }
        { key-l [ g [ 1 - ] change-horiz-angle drop ] }
    } [ [ keys nth ] dip when ] assoc-each ;

New Annotation

Summary:
Author:
Mode:
Body: