20 minutes ago, Jon Rafkind wrote:
> Yet another option that I mentioned was: | (+ 1 { n = 8 | (sqr x) =
> (* x x) | (sqr n) })
>
>
> #lang honu
>
> (1 + { var n = 8;
>sqr(x){ x * x }
>sqr(n) })
>
> > 65
>
> Of course I sort of cheated and just (as in 5 seconds ago) changed
> {
Yet another option that I mentioned was: | (+ 1 { n = 8 | (sqr x) = (* x x) |
(sqr n) })
#lang honu
(1 + { var n = 8;
sqr(x){ x * x }
sqr(n) })
> 65
Of course I sort of cheated and just (as in 5 seconds ago) changed {} from
(begin ...) to (let () ...)
__
This subject came up a bit more than a year ago. One thing that I
mentioned at the time is that you can also imagine allowing definition
before any expression, and they'd get lumped with it, for example:
| (define counter-or-not
| (if zeros?
| (lambda () 0)
| (define n 0)
| (lambda
I know I use it all the time in my PLaneT packages.
On Wed, Sep 21, 2011 at 8:43 PM, Sam Tobin-Hochstadt wrote:
> On Wed, Sep 21, 2011 at 10:24 PM, Robby Findler
> wrote:
> >
> > Did anyone check and see if there are any uses of (define (let ()
> > ...)) in the tree or on planet?
>
> I know I'v
On Wed, Sep 21, 2011 at 10:24 PM, Robby Findler
wrote:
>
> Did anyone check and see if there are any uses of (define (let ()
> ...)) in the tree or on planet?
I know I've used this idiom, and even more:
(define-values (x y) (let () ...))
--
sam th
sa...@ccs.neu.edu
___
Yes, that is Racket style these days (as codified in the style guide).
Saving the level(s) of indention is great, as far as I'm concerned.
As to the original question, tho, it seems like you can usually just
put the nested defines next to the original define and unless you have
a very big function
Is this "let over lambda", instead as "define over lambda"?
Actually in general, is the intent that define should be an
alternative to let in all cases? Although you pay 2X typing the
symbol itself, you save parens and a level of indent? :)
On Wed, Sep 21, 2011 at 4:24 AM, David Van Horn wrote:
On Wed, Sep 21, 2011 at 4:24 AM, David Van Horn wrote:
> The grammar for define includes
>
> (define id expr)
>
> but I wonder if this couldn't be relaxed to
>
> (define id body)
>
> so that you could write things like
>
> (define count
> (define i 0)
> (λ () (begin0 i (set! i (add1
The grammar for define includes
(define id expr)
but I wonder if this couldn't be relaxed to
(define id body)
so that you could write things like
(define count
(define i 0)
(λ () (begin0 i (set! i (add1 i)
David
_
For li
9 matches
Mail list logo