[plt-scheme] Re: Question result is not true or false: (void)

From: Benjamin L.Russell (DekuDekuplex at Yahoo.com)
Date: Mon Jan 4 17:42:41 EST 2010

On Tue, 29 Dec 2009 10:53:14 -0500 (EST), Gregory Marton
<gremio at acm.org> wrote:

>[...]
>
>You all are quite right, of course, that thinking about representation will 
>help him eventually, but it'll never get and to do begin's job, and whatever 
>other problems you may see with his code, he's not to be faulted
>for not knowing enough of PLT's vocabulary, or for presuming that and might do 
>the trick: in other Schemes, (e.g., Guile, Ikarus) it does!

This is not a question of "not knowing ... PLT's vocabulary"; it's a
much more fundamental one of knowing where to start in good program
design.

For this type of problem, there is no reason that the external and
internal representations of the data must coincide.

If I had to solve this type of problem, I would:

1) Decide on the internal data structures for representing the data.

2) Decide on an algorithm for solving the problem.

3) Solve the problem using the algorithm operating on those internal
data structures.

4) Decide how to represent those internal data structures as external
data.

5) Represent the external data.

Deciding how to represent the external data before deciding how to
represent the internal data structures and devising an algorithm is
going backwards.  There is nothing about this process that is peculiar
to PLT.

-- Benjamin L. Russell

>
>Grem
>
>
>> 
>> On Dec 27, 2009, at 12:51 PM, Jayto wrote:
>> 
>>> I am trying to design a sudokku game in dr scheme, but it is proving
>>> difficult.
>>> First what I did was draw out the game with this code:
>> 
>> There's your problem: you started thinking about I/O FIRST, rather than LAST.
>> 
>> What are the important questions to ask about a Sudoku board?  "What, if 
>> anything, is in this position?"  "Does this board violate any constraints?" 
>> "Could I put this value into this position without violating any 
>> constraints?"  Things like that.  Oh, and "draw the board" too -- but that's 
>> probably the least-interesting one.
>> 
>> Next, you need to choose an internal representation, from which it should be 
>> reasonably easy to answer all of the above questions.  Test your 
>> representation and the basic functions that operate on it.  Note that in 
>> Scheme, you CAN test these functions without worrying about I/O first, 
>> because whatever you choose as an internal representation, Scheme will 
>> probably have SOME readable representation for it -- not spiffy graphics, but 
>> enough that you can tell whether the answers are right.
>> 
>> Then figure out how to identify legal vs. illegal moves, fill in a number, 
>> and all that stuff.  Test these functions, again without worrying about 
>> visual formatting.
>> 
>> Once you have all this stuff working, THEN you can write a "draw" function 
>> that converts an internal representation into an attractive graphical 
>> representation.  And you can write functions to handle user input, and all 
>> that stuff.  But the user interface really should be separate from the rules 
>> of the game (go look up "model-view separation", which governs how almost all 
>> modern GUI-based programs are written).
>> 
>> 
>> 
>> Stephen Bloch
>> sbloch at adelphi.edu_________________________________________________
>>  For list-related administrative tasks:
>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>



Posted on the users mailing list.