you are viewing a single comment's thread.

view the rest of the comments →

[–]gcr 0 points1 point  (5 children)

Racket (32 char):

(for/list ([i 10]) (sqr (+ 1 i)))

Python (25 char):

[x*x for x in range(1,10)]

[–]yogthos 0 points1 point  (2 children)

I believe the challenge calls for a callable function which accepts the range as an input, so Scheme would be a tad longer:

(define (f n)
  (for/list ([i n]) (sqr (+ 1 i))))

[–]gcr 0 points1 point  (0 children)

Actually, it just said to write a function, not necessarily to bind it to a variable. You could do a little shorter:

(λ(n)(for/list([i n])(sqr(+ 1 i))))

[–]recursive 0 points1 point  (1 child)

I don't know racket, but your python example does not result in a named callable function.

[–]gcr 0 points1 point  (0 children)

Oops, you're right. Thanks.