[plt-scheme] Re: Text-contents to a function variable

From: Avi (n4alpaca at gmail.com)
Date: Fri Jan 15 13:58:14 EST 2010

Its not so much what goes into this, it is the fact that I don't know
how to run this. It gives me an error telling me that new is not a
function

On Jan 14, 6:56 pm, Stephen Bloch <bl... at adelphi.edu> wrote:
> On Jan 14, 2010, at 12:30 PM, Avi wrote:
>
> > Goal: To balance a chemical compound
> > I have GUI that when a user enters 2 elements in seperate text boxes,
> > the element charges are plugged into a function that processes every
> > combination of the charge multiplied by 1 2 and 3
>
> How about this: forget about the GUI and the text boxes for a while, and get the other parts of the program to work.  Write a function that takes an element name (as a string) and returns its charge (presumably by some kind of table lookup).  Write a function that takes in two element names and generates all these combinations (presumably by calling the first function), looking for combinations that will make the equation balance.  Once you have all these things tested and debugged, THEN start worrying about a GUI.
>
> Yet another case of starting a program by thinking about I/O first, rather than last....
>
> I guess I can understand this impulse in a development environment that doesn't come with an interactive REPL: you CAN'T test your functions until you have a way to input the arguments, and a way to print the results.  (Even this isn't technically true -- you can write test cases that call the function on known arguments and compare the results with known right answers, printing out "success" or "failure" for each test case.)  But if you have DrScheme (or, for Java, BlueJ), this is unnecessary: you can concentrate on solving the real problem first, and come back to the I/O details later.
>
> Stephen Bloch
> sbl... at adelphi.edu
>
> _________________________________________________
>   For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme


Posted on the users mailing list.