[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Shorter lambda expressions
From: |
Mateusz Kowalczyk |
Subject: |
Re: Shorter lambda expressions |
Date: |
Thu, 23 Jan 2014 07:17:05 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 |
On 23/01/14 04:51, Mark H Weaver wrote:
> Hello all,
>
> For a short time I liked 'cut' from SRFI-26, but I soon became
> frustrated by its limitations, most notably not being able to reference
> the arguments out of order or within nested expressions. I don't like
> the inconsistent style that results when I use 'cut' wherever possible
> and 'lambda' everywhere else. So I just stopped using it altogether.
>
> I prefer what Shiro Kawai did in Gauche: ^ is short for lambda, (^x ...)
> is short for (lambda (x) ...), and similarly for all the letters. ^_ is
> short for lambda with one ignored argument.
>
> http://blog.practical-scheme.net/gauche/20100428-shorter-names
>
> Here's a module that implements that idea, but takes it slightly
> further. It exports the unary lambda shorthands described above, and
> also a few non-unary ones: ^xy, ^xyz, ^ab, ^abc, ^uv. It also exports
> variants that use λ instead of ^, for a nicer look if you're willing to
> venture outside of ASCII.
>
> Finally, it exports the transformer procedure that's bound to all of the
> keywords above. It's called 'short-lambda'. Bind it to any keyword
> like this:
>
> (define-syntax ^kw short-lambda)
>
> and now (^kw ...) will expand to (lambda (k w) ...).
>
> 'short-lambda' splits the keyword into individual characters. The first
> character (usually ^ or λ) is ignored. The other characters become the
> variable names. Underscores are treated specially: they become gensyms.
>
> Thoughts?
>
> Mark
>
>
Hi,
Any chance for the curried version of these?
--
Mateusz K.