Paste: don't know how to simplify

Author: malu
Mode: factor
Date: Sun, 4 Jan 2009 12:04:12
Plain Text |
! empty, white-... etc are all inlined word which only push an integer on the stack
: (initialize-chess-board)
    64 empty <array>
    {
        ! white pieces
        [ 0 white-rook spin ]
        [ 1 white-knight spin ]
        [ 2 white-bishop spin ]
        [ 3 white-queen spin ]
        [ 4 white-king spin ]
        [ 5 white-bishop spin ]
        [ 6 white-knight spin ]
        [ 7 white-rook spin ]
        [ 8 white-pawn spin ]
        [ 9 white-pawn spin ]
        [ 10 white-pawn spin ]
        [ 11 white-pawn spin ]
        [ 12 white-pawn spin ]
        [ 13 white-pawn spin ]
        [ 14 white-pawn spin ]
        [ 15 white-pawn spin ]
        ! black pieces
        [ 48 black-pawn spin ]
        [ 49 black-pawn spin ]
        [ 50 black-pawn spin ]
        [ 51 black-pawn spin ]
        [ 52 black-pawn spin ]
        [ 53 black-pawn spin ]
        [ 54 black-pawn spin ]
        [ 55 black-pawn spin ]
        [ 56 black-rook spin ]
        [ 57 black-knight spin ]
        [ 58 black-bishop spin ]
        [ 59 black-queen spin ]
        [ 60 black-king spin ]
        [ 61 black-bishop spin ]
        [ 62 black-knight spin ]
        [ 63 black-rook spin ]
    } [ set-array-nth ] each
    ;

Annotation: suggestions

Author: slava
Mode: factor
Date: Sun, 4 Jan 2009 23:55:49
Plain Text |
Use set-nth instead of set-array-nth (look at \ set-array-nth help, it's not the right word for this). Or to make it even simpler use make:

[ white-pawn , black-pawn , ... ] { } make

New Annotation

Summary:
Author:
Mode:
Body: