Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

A short alias for lambda expression

10 views
Skip to first unread message

higepon

unread,
May 12, 2010, 10:21:12 PM5/12/10
to
I wrote (shorten) library which provides a short alias for lambda
expression.
http://github.com/higepon/Scheme-shorten

Examples:
(import (rnrs)
(shorten))
(map (^(x y) (+ x y)) '(1 2 3 4) '(1 2 3 4)) ;; (map (lambda (x y) (+
x y)) '(1 2 3 4) '(1 2 3 4))
(map (^a a) '(1 2 3 4)) ;; (map (lambda (a) a)
'(1 2 3 4))
(map (^a* a*) '(1 2 3 4)) ;; (map (lambda a* a*)
'(1 2 3 4))

The idea come from "Gauche Devlog - Shorter names
http://blog.practical-scheme.net/gauche/20100428-shorter-names" by
Shiro.

Feedback Welcome.

--
Taro Minowa(Higepon)

http://www.monaos.org/
http://code.google.com/p/mosh-scheme/
http://twitter.com/higepon

Pascal J. Bourguignon

unread,
May 13, 2010, 3:40:23 AM5/13/10
to
higepon <hig...@gmail.com> writes:

> I wrote (shorten) library which provides a short alias for lambda
> expression.
> http://github.com/higepon/Scheme-shorten
>
> Examples:
> (import (rnrs)
> (shorten))
> (map (^(x y) (+ x y)) '(1 2 3 4) '(1 2 3 4)) ;; (map (lambda (x y) (+
> x y)) '(1 2 3 4) '(1 2 3 4))
> (map (^a a) '(1 2 3 4)) ;; (map (lambda (a) a)
> '(1 2 3 4))
> (map (^a* a*) '(1 2 3 4)) ;; (map (lambda a* a*)
> '(1 2 3 4))
>
> The idea come from "Gauche Devlog - Shorter names
> http://blog.practical-scheme.net/gauche/20100428-shorter-names" by
> Shiro.
>
> Feedback Welcome.

Why not use Church's notation? λx λy (+ x y)

If you have reader macros, this can be implemented rather easily.
(Harder would be to implement currying, mixing it with the variable
arity of scheme).

--
__Pascal Bourguignon__

higepon

unread,
May 13, 2010, 4:12:23 AM5/13/10
to
Hi.

> Why not use Church's notation?  λx λy (+ x y)

^ is easier to type than non-ascii λ.


> If you have reader macros, this can be implemented rather easily.

Yes I agree. But we have not reader macro which is portable.

Grant Rettke

unread,
May 13, 2010, 9:32:18 AM5/13/10
to
On May 12, 9:21 pm, higepon <hige...@gmail.com> wrote:
> Feedback Welcome.

Nice thanks Higepon :).

George Neuner

unread,
May 13, 2010, 11:45:19 PM5/13/10
to
On Thu, 13 May 2010 01:12:23 -0700 (PDT), higepon <hig...@gmail.com>
wrote:

>> Why not use Church's notation? �?x ?y (+ x y)
>
>^ is easier to type than non-ascii ?.

The question mark is ASCII character 63.

On a QWERTY keyboard ? in the bottom row is easier to reach than ^ in
the number row. Can't speak for other keyboard layouts though.

George

higepon

unread,
May 14, 2010, 2:57:51 AM5/14/10
to
Hi

>>^ is easier to type than non-ascii ?.
>The question mark is ASCII character 63.

Pascal J. Bourguignon doesn't write ascii 63? but Greek char lambda.
I think that character corruption occurs on your browser.

Cheers.


On 5月14日, 午後12:45, George Neuner <gneun...@comcast.net> wrote:
> On Thu, 13 May 2010 01:12:23 -0700 (PDT), higepon <hige...@gmail.com>

Pascal J. Bourguignon

unread,
May 14, 2010, 5:42:50 AM5/14/10
to
George Neuner <gneu...@comcast.net> writes:

> On Thu, 13 May 2010 01:12:23 -0700 (PDT), higepon <hig...@gmail.com>
> wrote:
>
>>> Why not use Church's notation?  ?x ?y (+ x y)
>>
>>^ is easier to type than non-ascii ?.
>
> The question mark is ASCII character 63.

But originally, it was λ, GREEK_LAMBDA, with unicode code 955.

> On a QWERTY keyboard ? in the bottom row is easier to reach than ^ in
> the number row. Can't speak for other keyboard layouts though.

And if you use it a lot you can map it to a key, or an easy keychoard,
trivially either in emacs or X (~/.Xmodmap).

--
__Pascal Bourguignon__

George Neuner

unread,
May 14, 2010, 10:11:47 PM5/14/10
to
On Thu, 13 May 2010 23:57:51 -0700 (PDT), higepon <hig...@gmail.com>
wrote:

>>>^ is easier to type than non-ascii ?.


>>The question mark is ASCII character 63.
>
>Pascal J. Bourguignon doesn't write ascii 63? but Greek char lambda.
>I think that character corruption occurs on your browser.

Sorry for the confusion.

George

0 new messages