[BULK] [plt-scheme] Teaching Scheme
Dear Shriram,
Unfortunately, many "brain damaged" programmers throughout the world use this method of debugging. It may be an unfortunate reality we have to deal with and try to improve as best we can.
In this sense, the idea of this program is to produce an output that someone can look at. That is a design goal. It has to print out the result. We need to write this output to a file, or stdout, or something. The goal is to have the correct output on the screen.
Just like the email client you are using right now is rendering text to the screen, there must be some side effect! Well, the majority of useful programs have some side effects. Maybe I'm pressing keys on my keyboard just for the hell of it?
Thanks for your reply, you are welcome to not be polite as much as you want I won't take any personal offense... I think the key to having a good discussion is saying what you think! I think it is important to have a critical discussion to make real improvements.
Kind regards,
Samuel
On 4/05/2010, at 2:53 AM, Shriram Krishnamurthi wrote:
> Dear Samuel,
>
> It might also be considered a strength to compute rather than print,
> and teaching programming by showing printf's might be considered a
> weaknesses.
>
> [Note: I use "might be" in a strained effort to be polite. If I were
> being more honest, I'd say the alternatives you suggest are slightly
> brain-damaged.]
>
> Shriram
>
> On Mon, May 3, 2010 at 7:44 AM, Samuel Williams
> <space.ship.traveller at gmail.com> wrote:
>> Dear Shriram,
>>
>> In an effort to be equivalent to all the other implementations, it would be great to write the values to stdout in the same format.
>>
>> If this isn't possible with Scheme, thats fine, but it might be considered a weakness. Lots of people want to print something out, either for debugging purposes or simply to see intermediate results of processing. It is a very common way of teaching programming at present.
>>
>> This might not be the best way to debug Scheme (I'm not a Scheme programmer) but if this is the case then it will be important to discuss this on the page about Scheme, especially as a potential reason why someone would want to use Scheme.
>>
>> Kind regards,
>> Samuel
>>
>> On 4/05/2010, at 2:31 AM, Shriram Krishnamurthi wrote:
>>
>>> Functions compute values. They don't print output.
>>>
>>> On Mon, May 3, 2010 at 7:26 AM, Samuel Williams
>>> <space.ship.traveller at gmail.com> wrote:
>>>> Dear Stephen,
>>>> Can you let me know firstly which function is responsible for printing the
>>>> output?
>>>> Secondly, can you add comments explaining how it works? I can generally
>>>> appreciate what you are doing, but I'm not a Scheme programmer so I might
>>>> not understand the exact detail correctly.
>>>> Thanks
>>>> Samuel
>>>> On 4/05/2010, at 1:01 AM, Stephen Bloch wrote:
>>>>
>>>> Well, that particular algorithm relies very heavily on mutation, but here's
>>>> a functional version.
>>>> (define (door-open door)
>>>> (doh door 99))
>>>> (define (doh door pass)
>>>> (cond [(zero? pass) true]
>>>> [(= (remainder door (+ pass 1)) pass)
>>>> (not (doh door (- pass 1)))]
>>>> [else
>>>> (doh door (- pass 1))]))
>>>> (define doors (build-list 100 door-open))
>>>>
>>>>
>>>> Somewhat shorter but more cryptic:
>>>> (define (door-open door)
>>>> (doh door 99))
>>>> (define (doh door pass)
>>>> (or (zero? pass)
>>>> (not (boolean=? (= (remainder door (+ pass 1)) pass)
>>>> (doh door (- pass 1))))))
>>>> (define doors (build-list 100 door-open))
>>>>
>>>>
>>>> Even shorter, but takes some math (and illustrates how artificial this
>>>> problem is :-) :
>>>> (define (door-open door)
>>>> (integer? (sqrt (+ door 1))))
>>>> (define doors (build-list 100 door-open))
>>>>
>>>>
>>>> Stephen Bloch
>>>> sbloch at adelphi.edu
>>>>
>>>>
>>>>
>>>>
>>>> _________________________________________________
>>>> For list-related administrative tasks:
>>>> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>>>
>>>>
>>
>>