On 19-07-10 02:46, Maciek Godek wrote:
> A while ago, I wrote a booklet which used almost the same problem to 
> introduce to, what you called nicely in the title of this thread, "thinking 
> in Scheme", so if you're interested, you may want to check out the first 
> chapter ("Introduction"):

Maciek,

Thank you for your reply.

I skimmed through your booklet some time ago.  (I too dislike the R
language, although some attempts have been made in recent years to make
it less awful).  I read through the introduction again this morning and
enjoyed it.

The reason I like racket (and scheme-like languages in general) is that
they encourage the style of programming you are advocating (I think)
where the program is expressive and can be read and appreciated by
humans.  In theory, my favourite style of programming is one that is
elegant and readable by humans.

My original email had to do with the problem of when this comes into
conflict with a prosaic computational task where my main aim is simply
to get the job done efficiently and my brain defaults to writing the
program in something like C.

For instance, another way of writing something like my original program
might be something like:

(define (f n) (- (expt 2 n) 3))
(define (good? n) (and (positive? n) (prime? n)))
(length (filter good? (map f (range 1 100))))

which is, I think, fairly expressive.  It is still, however, relatively
inefficient.  A python programmer might write something like

count = 0
for n in range(1, 1000):
    if 2 ** n - 3 >= 0 and isprime(2 ** n - 3):
      count += 1

print(count)

and happily report that her program ran quite a bit faster than mine.

I'm not sure how I'd advocate for Racket (or scheme) in a situation like this.

Regards,
Bob

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20190711013633.nm2jlznhzwibhsli%40bob-cit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to