[plt-scheme] Beginner question
On Sep 29, 2005, at 9:15 AM, Anders Persson wrote:
> Hi!
>
> I am trying to learn PLT and yesterday i try to write
> a program with 2 functions that asks for user namen
> och write Hello + user namen
>
> The code was
> -------------------------------------------------------------------
> (define ask-user-name
> (begin
> (display "Hi whats your name? ")
> (read-line)))
>
> (define say-hello-to-user
> (lambda (name)
> (display "Hello ")
> (display name)))
>
> (define name (string->symbol ask-user-name))
> (say-hello-to-user name)
> ---------------------------------------------------------------------
>
> My qestion is this a good program or is there
> some changes to make it a more professional look.
Take a look at htdp.org. It may help.
If someone put a gun to my head to write such a program I'd probably do
it like this:
(define (ask-and-respond)
(printf "Hi. What's your name? ~n")
(printf "Hello ~a." (read-line)))
> And som ting that puzzles me is the line
>
> (define name (ask-user-name))
ask-user-name isn't a function.
> don't work but
>
> (define name (string->symbol ask-user-name))
> Works this is a try-and-error and i would like
Yes it is. It is better to learn to program systematically. -- Matthias
> som explanation way i have to konvert my
> string to symbol, becurse i can write
> (define name "Hello Anders")
> but not
> (define name (ask-user-name))
>
> Best regards
> Anders Persson
>
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme