Paste: sudoku start - for learning

Author: randy7
Mode: factor
Date: Wed, 7 Jan 2009 17:56:59
Plain Text |
TUPLE: sudoku-cell { x integer } { y integer } { possible-values sequence initial: { 1 2 3 4 5 6 7 8 9 } } ;

: <sudoku-cell> ( x y -- tuple )
    sudoku-cell new swap >>y
                    swap >>x ;


: init-table ( from to -- cells )
    dup axb 
    [ [ first ] [ second ] bi  <sudoku-cell> ] map ; 

: init-table-1-9 ( -- cells )
    1 9 [a,b]  init-table ;

:: axb ( seq1 seq2 -- seq-of-seq )
SYMBOL: x   f x set
SYMBOL: y   f y set
SYMBOL: vector V{ } clone vector set
seq1 [ x set seq2 [ y set x get y get 2array . ! vector get swap suffix 
] each ] each ;

New Annotation

Summary:
Author:
Mode:
Body: